aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
authorTacoTheDank <SkytkRSfan3895@gmail.com>2020-05-05 19:04:19 +0000
committerGitHub <noreply@github.com>2020-05-05 19:04:19 +0000
commitfc284a3dc01a99234785a0633630931f5abad648 (patch)
treedbf563a7fb6cf7b03dc18b83a57154624eaae566 /app/src/main
parentbac83aa1c7b368d0736fc4dc9bd167dbedb971e0 (diff)
parenteefc8e869d74721ffd41bd7295ae88228a7cca1e (diff)
downloadinfinity-for-reddit-fc284a3dc01a99234785a0633630931f5abad648.tar
infinity-for-reddit-fc284a3dc01a99234785a0633630931f5abad648.tar.gz
infinity-for-reddit-fc284a3dc01a99234785a0633630931f5abad648.tar.bz2
infinity-for-reddit-fc284a3dc01a99234785a0633630931f5abad648.tar.lz
infinity-for-reddit-fc284a3dc01a99234785a0633630931f5abad648.tar.xz
infinity-for-reddit-fc284a3dc01a99234785a0633630931f5abad648.tar.zst
infinity-for-reddit-fc284a3dc01a99234785a0633630931f5abad648.zip
Merge branch 'master' into master
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/AndroidManifest.xml12
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java10
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ReportActivity.java213
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/RulesActivity.java63
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ThemePreviewActivity.java10
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java19
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java32
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewUserDetailActivity.java39
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java543
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java1875
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/ReportReasonRecyclerViewAdapter.java130
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/AppModule.java19
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/BroadcastReceiver/NetworkWifiStatusReceiver.java22
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomTheme.java105
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeSettingsItem.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeWrapper.java16
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/CustomView/CustomToroContainer.java27
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Event/ChangeVideoAutoplayEvent.java9
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Event/ChangeWifiStatusEvent.java8
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/FetchRules.java101
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CommentMoreBottomSheetFragment.java12
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java78
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Infinity.java13
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/ParseSubredditData.java3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/ParseSubscribedThing.java3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/ParseUserData.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Post/FetchPost.java (renamed from app/src/main/java/ml/docilealligator/infinityforreddit/FetchPost.java)4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Post/HidePost.java (renamed from app/src/main/java/ml/docilealligator/infinityforreddit/HidePost.java)3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Post/ParsePost.java (renamed from app/src/main/java/ml/docilealligator/infinityforreddit/ParsePost.java)11
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Post/Post.java10
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Post/PostDataSource.java103
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Post/SubmitPost.java (renamed from app/src/main/java/ml/docilealligator/infinityforreddit/SubmitPost.java)4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/RedditAPI.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/RedditDataRoomDatabase.java25
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/ReportReason.java90
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/ReportThing.java54
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Service/SubmitPostService.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Settings/MainPreferenceFragment.java19
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/SubredditDatabase/SubredditData.java9
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/User/UserData.java36
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Utils/CustomThemeSharedPreferencesUtils.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Utils/RedditUtils.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java12
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Utils/Utils.java17
-rw-r--r--app/src/main/res/drawable/exo_player_autoplay_button_background.xml9
-rw-r--r--app/src/main/res/drawable/ic_fullscreen_white_rounded_18dp.xml9
-rw-r--r--app/src/main/res/drawable/ic_mute_white_rounded_18dp.xml9
-rw-r--r--app/src/main/res/drawable/ic_pause_white_rounded_18dp.xml9
-rw-r--r--app/src/main/res/drawable/ic_play_arrow_white_rounded_18dp.xml9
-rw-r--r--app/src/main/res/drawable/ic_report_black_24dp.xml15
-rw-r--r--app/src/main/res/drawable/ic_unmute_white_rounded_18dp.xml9
-rw-r--r--app/src/main/res/layout/activity_report.xml31
-rw-r--r--app/src/main/res/layout/activity_view_gif.xml3
-rw-r--r--app/src/main/res/layout/activity_view_subreddit_detail.xml47
-rw-r--r--app/src/main/res/layout/activity_view_user_detail.xml42
-rw-r--r--app/src/main/res/layout/activity_view_video.xml2
-rw-r--r--app/src/main/res/layout/exo_autoplay_playback_control_view.xml72
-rw-r--r--app/src/main/res/layout/fragment_comment_more_bottom_sheet.xml18
-rw-r--r--app/src/main/res/layout/fragment_post.xml2
-rw-r--r--app/src/main/res/layout/item_post_image_and_gif_autoplay_type.xml313
-rw-r--r--app/src/main/res/layout/item_post_link_type.xml324
-rw-r--r--app/src/main/res/layout/item_post_no_preview_link_type.xml293
-rw-r--r--app/src/main/res/layout/item_post_text_type.xml288
-rw-r--r--app/src/main/res/layout/item_post_video_and_gif_preview_type.xml328
-rw-r--r--app/src/main/res/layout/item_post_video_type_autoplay.xml291
-rw-r--r--app/src/main/res/layout/item_report_reason.xml29
-rw-r--r--app/src/main/res/menu/report_activity.xml10
-rw-r--r--app/src/main/res/menu/view_post_detail_activity.xml7
-rw-r--r--app/src/main/res/menu/view_subreddit_detail_activity.xml6
-rw-r--r--app/src/main/res/menu/view_user_detail_activity.xml6
-rw-r--r--app/src/main/res/values/arrays.xml12
-rw-r--r--app/src/main/res/values/strings.xml22
-rw-r--r--app/src/main/res/xml/main_preferences.xml8
74 files changed, 5005 insertions, 1002 deletions
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index b665b78b..08f83a69 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -21,14 +21,20 @@
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true"
tools:replace="android:label">
- <activity android:name=".Activity.SelectedSubredditsActivity"
+ <activity android:name=".Activity.ReportActivity"
+ android:label="@string/report_activity_label"
+ android:parentActivityName=".Activity.MainActivity"
+ android:theme="@style/AppTheme.NoActionBar"/>
+ <activity
+ android:name=".Activity.SelectedSubredditsActivity"
android:label="@string/selected_subeddits_activity_label"
android:parentActivityName=".Activity.MainActivity"
android:theme="@style/AppTheme.NoActionBar" />
- <activity android:name=".Activity.EditMultiRedditActivity"
+ <activity
+ android:name=".Activity.EditMultiRedditActivity"
android:label="@string/edit_multi_reddit_activity_label"
android:parentActivityName=".Activity.MainActivity"
- android:theme="@style/AppTheme.NoActionBar"/>
+ android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name=".Activity.ThemePreviewActivity"
android:label="@string/theme_preview_activity_label"
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java
index 434eaa87..ca7e42d2 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java
@@ -302,11 +302,11 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
int backgroundColor = mCustomThemeWrapper.getBackgroundColor();
drawer.setBackgroundColor(backgroundColor);
drawer.setStatusBarBackgroundColor(mCustomThemeWrapper.getColorPrimaryDark());
- int primaryIconColor = mCustomThemeWrapper.getPrimaryIconColor();
- subscriptionsBottomAppBar.setColorFilter(primaryIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
- multiRedditBottomAppBar.setColorFilter(primaryIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
- messageBottomAppBar.setColorFilter(primaryIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
- profileBottomAppBar.setColorFilter(primaryIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ int bottomAppBarIconColor = mCustomThemeWrapper.getBottomAppBarIconColor();
+ subscriptionsBottomAppBar.setColorFilter(bottomAppBarIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ multiRedditBottomAppBar.setColorFilter(bottomAppBarIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ messageBottomAppBar.setColorFilter(bottomAppBarIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ profileBottomAppBar.setColorFilter(bottomAppBarIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
navigationView.setBackgroundColor(backgroundColor);
applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
applyTabLayoutTheme(tabLayout);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ReportActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ReportActivity.java
new file mode 100644
index 00000000..4e3a0738
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ReportActivity.java
@@ -0,0 +1,213 @@
+package ml.docilealligator.infinityforreddit.Activity;
+
+import android.content.SharedPreferences;
+import android.os.Build;
+import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.widget.Toast;
+
+import androidx.annotation.NonNull;
+import androidx.appcompat.widget.Toolbar;
+import androidx.coordinatorlayout.widget.CoordinatorLayout;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+
+import com.google.android.material.appbar.AppBarLayout;
+import com.google.android.material.snackbar.Snackbar;
+
+import java.util.ArrayList;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import butterknife.BindView;
+import butterknife.ButterKnife;
+import ml.docilealligator.infinityforreddit.Adapter.ReportReasonRecyclerViewAdapter;
+import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
+import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
+import ml.docilealligator.infinityforreddit.FetchRules;
+import ml.docilealligator.infinityforreddit.Infinity;
+import ml.docilealligator.infinityforreddit.R;
+import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
+import ml.docilealligator.infinityforreddit.ReportReason;
+import ml.docilealligator.infinityforreddit.ReportThing;
+import ml.docilealligator.infinityforreddit.Rule;
+import retrofit2.Retrofit;
+
+public class ReportActivity extends BaseActivity {
+
+ public static final String EXTRA_SUBREDDIT_NAME = "ESN";
+ public static final String EXTRA_THING_FULLNAME = "ETF";
+ private static final String NULL_ACCESS_TOKEN_STATE = "NATS";
+ private static final String ACCESS_TOKEN_STATE = "ATS";
+ private static final String GENERAL_REASONS_STATE = "GRS";
+ private static final String RULES_REASON_STATE = "RRS";
+
+ @BindView(R.id.coordinator_layout_report_activity)
+ CoordinatorLayout coordinatorLayout;
+ @BindView(R.id.appbar_layout_report_activity)
+ AppBarLayout appBarLayout;
+ @BindView(R.id.toolbar_report_activity)
+ Toolbar toolbar;
+ @BindView(R.id.recycler_view_report_activity)
+ RecyclerView recyclerView;
+ @Inject
+ @Named("oauth")
+ Retrofit mOauthRetrofit;
+ @Inject
+ @Named("no_oauth")
+ Retrofit mRetrofit;
+ @Inject
+ @Named("default")
+ SharedPreferences mSharedPreferences;
+ @Inject
+ RedditDataRoomDatabase mRedditDataRoomDatabase;
+ @Inject
+ CustomThemeWrapper mCustomThemeWrapper;
+ private boolean mNullAccessToken = false;
+ private String mAccessToken;
+ private String mFullname;
+ private String mSubredditName;
+ private ArrayList<ReportReason> generalReasons;
+ private ArrayList<ReportReason> rulesReasons;
+ private ReportReasonRecyclerViewAdapter mAdapter;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ ((Infinity) getApplication()).getAppComponent().inject(this);
+
+ setImmersiveModeNotApplicable();
+
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_report);
+
+ ButterKnife.bind(this);
+
+ applyCustomTheme();
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && isChangeStatusBarIconColor()) {
+ addOnOffsetChangedListener(appBarLayout);
+ }
+
+ setSupportActionBar(toolbar);
+ getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+
+ mFullname = getIntent().getStringExtra(EXTRA_THING_FULLNAME);
+ mSubredditName = getIntent().getStringExtra(EXTRA_SUBREDDIT_NAME);
+
+ if (savedInstanceState != null) {
+ mNullAccessToken = savedInstanceState.getBoolean(NULL_ACCESS_TOKEN_STATE);
+ mAccessToken = savedInstanceState.getString(ACCESS_TOKEN_STATE);
+
+ if (!mNullAccessToken && mAccessToken == null) {
+ getCurrentAccount();
+ }
+
+ generalReasons = savedInstanceState.getParcelableArrayList(GENERAL_REASONS_STATE);
+ rulesReasons = savedInstanceState.getParcelableArrayList(RULES_REASON_STATE);
+ } else {
+ getCurrentAccount();
+ }
+
+ if (generalReasons != null) {
+ mAdapter = new ReportReasonRecyclerViewAdapter(mCustomThemeWrapper, generalReasons);
+ } else {
+ mAdapter = new ReportReasonRecyclerViewAdapter(mCustomThemeWrapper, ReportReason.getGeneralReasons(this));
+ }
+ recyclerView.setLayoutManager(new LinearLayoutManager(this));
+ recyclerView.setAdapter(mAdapter);
+
+ if (rulesReasons == null) {
+ FetchRules.fetchRules(mRetrofit, mSubredditName, new FetchRules.FetchRulesListener() {
+ @Override
+ public void success(ArrayList<Rule> rules) {
+ mAdapter.setRules(ReportReason.convertRulesToReasons(rules));
+ }
+
+ @Override
+ public void failed() {
+ Snackbar.make(coordinatorLayout, R.string.error_loading_rules_without_retry, Snackbar.LENGTH_SHORT).show();
+ }
+ });
+ } else {
+ mAdapter.setRules(rulesReasons);
+ }
+ }
+
+ private void getCurrentAccount() {
+ new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
+ if (account == null) {
+ mNullAccessToken = true;
+ } else {
+ mAccessToken = account.getAccessToken();
+ }
+ }).execute();
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.report_activity, menu);
+ applyMenuItemTheme(menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(@NonNull MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ finish();
+ return true;
+ case R.id.action_send_report_activity:
+ ReportReason reportReason = mAdapter.getSelectedReason();
+ if (reportReason != null) {
+ Toast.makeText(ReportActivity.this, R.string.reporting, Toast.LENGTH_SHORT).show();
+ ReportThing.reportThing(mOauthRetrofit, mAccessToken, mFullname, mSubredditName,
+ reportReason.getReasonType(), reportReason.getReportReason(), new ReportThing.ReportThingListener() {
+ @Override
+ public void success() {
+ Toast.makeText(ReportActivity.this, R.string.report_successful, Toast.LENGTH_SHORT).show();
+ finish();
+ }
+
+ @Override
+ public void failed() {
+ Toast.makeText(ReportActivity.this, R.string.report_failed, Toast.LENGTH_SHORT).show();
+ }
+ });
+ } else {
+ Toast.makeText(ReportActivity.this, R.string.report_reason_not_selected, Toast.LENGTH_SHORT).show();
+ }
+ return true;
+ }
+
+ return false;
+ }
+
+ @Override
+ protected void onSaveInstanceState(@NonNull Bundle outState) {
+ super.onSaveInstanceState(outState);
+ outState.putBoolean(NULL_ACCESS_TOKEN_STATE, mNullAccessToken);
+ outState.putString(ACCESS_TOKEN_STATE, mAccessToken);
+ if (mAdapter != null) {
+ outState.putParcelableArrayList(GENERAL_REASONS_STATE, mAdapter.getGeneralReasons());
+ outState.putParcelableArrayList(RULES_REASON_STATE, mAdapter.getRules());
+ }
+ }
+
+ @Override
+ protected SharedPreferences getSharedPreferences() {
+ return mSharedPreferences;
+ }
+
+ @Override
+ protected CustomThemeWrapper getCustomThemeWrapper() {
+ return mCustomThemeWrapper;
+ }
+
+ @Override
+ protected void applyCustomTheme() {
+ coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
+ applyAppBarLayoutAndToolbarTheme(appBarLayout, toolbar);
+ }
+}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/RulesActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/RulesActivity.java
index 925efd0e..2c5cb05c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/RulesActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/RulesActivity.java
@@ -2,7 +2,6 @@ package ml.docilealligator.infinityforreddit.Activity;
import android.content.SharedPreferences;
import android.content.res.ColorStateList;
-import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.view.MenuItem;
@@ -22,9 +21,6 @@ import com.google.android.material.appbar.AppBarLayout;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
import java.util.ArrayList;
@@ -36,15 +32,10 @@ import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.Adapter.RulesRecyclerViewAdapter;
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
+import ml.docilealligator.infinityforreddit.FetchRules;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
-import ml.docilealligator.infinityforreddit.RedditAPI;
import ml.docilealligator.infinityforreddit.Rule;
-import ml.docilealligator.infinityforreddit.Utils.JSONUtils;
-import ml.docilealligator.infinityforreddit.Utils.Utils;
-import retrofit2.Call;
-import retrofit2.Callback;
-import retrofit2.Response;
import retrofit2.Retrofit;
public class RulesActivity extends BaseActivity {
@@ -116,7 +107,26 @@ public class RulesActivity extends BaseActivity {
mAdapter = new RulesRecyclerViewAdapter(this, mCustomThemeWrapper);
recyclerView.setAdapter(mAdapter);
- fetchRules();
+ //fetchRules();
+
+ FetchRules.fetchRules(mRetrofit, mSubredditName, new FetchRules.FetchRulesListener() {
+ @Override
+ public void success(ArrayList<Rule> rules) {
+ progressBar.setVisibility(View.GONE);
+ if (rules == null || rules.size() == 0) {
+ errorTextView.setVisibility(View.VISIBLE);
+ errorTextView.setText(R.string.no_rule);
+ errorTextView.setOnClickListener(view -> {
+ });
+ }
+ mAdapter.changeDataset(rules);
+ }
+
+ @Override
+ public void failed() {
+ displayError();
+ }
+ });
}
@Override
@@ -137,7 +147,7 @@ public class RulesActivity extends BaseActivity {
errorTextView.setTextColor(mCustomThemeWrapper.getSecondaryTextColor());
}
- private void fetchRules() {
+ /*private void fetchRules() {
progressBar.setVisibility(View.VISIBLE);
errorTextView.setVisibility(View.GONE);
@@ -175,13 +185,34 @@ public class RulesActivity extends BaseActivity {
displayError();
}
});
- }
+ }*/
private void displayError() {
progressBar.setVisibility(View.GONE);
errorTextView.setVisibility(View.VISIBLE);
errorTextView.setText(R.string.error_loading_rules);
- errorTextView.setOnClickListener(view -> fetchRules());
+ errorTextView.setOnClickListener(view -> {
+ progressBar.setVisibility(View.VISIBLE);
+ errorTextView.setVisibility(View.GONE);
+ FetchRules.fetchRules(mRetrofit, mSubredditName, new FetchRules.FetchRulesListener() {
+ @Override
+ public void success(ArrayList<Rule> rules) {
+ progressBar.setVisibility(View.GONE);
+ if (rules == null || rules.size() == 0) {
+ errorTextView.setVisibility(View.VISIBLE);
+ errorTextView.setText(R.string.no_rule);
+ errorTextView.setOnClickListener(view -> {
+ });
+ }
+ mAdapter.changeDataset(rules);
+ }
+
+ @Override
+ public void failed() {
+ displayError();
+ }
+ });
+ });
}
@Override
@@ -205,7 +236,7 @@ public class RulesActivity extends BaseActivity {
finish();
}
- private static class ParseRulesAsyncTask extends AsyncTask<Void, ArrayList<Rule>, ArrayList<Rule>> {
+ /*private static class ParseRulesAsyncTask extends AsyncTask<Void, ArrayList<Rule>, ArrayList<Rule>> {
private String response;
private ParseRulesAsyncTaskListener parseRulesAsyncTaskListener;
@@ -248,5 +279,5 @@ public class RulesActivity extends BaseActivity {
void parseFailed();
}
- }
+ }*/
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ThemePreviewActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ThemePreviewActivity.java
index 83478a2f..f8275d66 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ThemePreviewActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ThemePreviewActivity.java
@@ -323,11 +323,11 @@ public class ThemePreviewActivity extends AppCompatActivity {
primaryTextView.setTextColor(customTheme.primaryTextColor);
secondaryTextView.setTextColor(customTheme.secondaryTextColor);
bottomNavigationView.setBackgroundTint(ColorStateList.valueOf(customTheme.bottomAppBarBackgroundColor));
- int primaryIconColor = customTheme.primaryIconColor;
- subscriptionsBottomAppBar.setColorFilter(primaryIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
- multiRedditBottomAppBar.setColorFilter(primaryIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
- messageBottomAppBar.setColorFilter(primaryIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
- profileBottomAppBar.setColorFilter(primaryIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ int bottomAppBarIconColor = customTheme.bottomAppBarIconColor;
+ subscriptionsBottomAppBar.setColorFilter(bottomAppBarIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ multiRedditBottomAppBar.setColorFilter(bottomAppBarIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ messageBottomAppBar.setColorFilter(bottomAppBarIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ profileBottomAppBar.setColorFilter(bottomAppBarIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
applyTabLayoutTheme(tabLayout);
applyFABTheme(fab);
unsubscribedColor = customTheme.unsubscribed;
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java
index 92d04927..f3e4d0aa 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java
@@ -64,14 +64,14 @@ import ml.docilealligator.infinityforreddit.Event.PostUpdateEventToDetailActivit
import ml.docilealligator.infinityforreddit.Event.PostUpdateEventToPostList;
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.FetchComment;
-import ml.docilealligator.infinityforreddit.FetchPost;
+import ml.docilealligator.infinityforreddit.Post.FetchPost;
import ml.docilealligator.infinityforreddit.Flair;
import ml.docilealligator.infinityforreddit.Fragment.FlairBottomSheetFragment;
import ml.docilealligator.infinityforreddit.Fragment.PostCommentSortTypeBottomSheetFragment;
-import ml.docilealligator.infinityforreddit.HidePost;
+import ml.docilealligator.infinityforreddit.Post.HidePost;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.ParseComment;
-import ml.docilealligator.infinityforreddit.ParsePost;
+import ml.docilealligator.infinityforreddit.Post.ParsePost;
import ml.docilealligator.infinityforreddit.Post.Post;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.ReadMessage;
@@ -473,6 +473,8 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
hideItem.setVisible(true);
hideItem.setTitle(R.string.action_hide_post);
}
+
+ mMenu.findItem(R.id.action_report_view_post_detail_activity).setVisible(true);
} else {
saveItem.setVisible(false);
hideItem.setVisible(false);
@@ -622,6 +624,8 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
hideItem.setVisible(true);
hideItem.setTitle(R.string.action_hide_post);
}
+
+ mMenu.findItem(R.id.action_report_view_post_detail_activity).setVisible(true);
} else {
saveItem.setVisible(false);
hideItem.setVisible(false);
@@ -931,6 +935,8 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
hideItem.setVisible(true);
hideItem.setTitle(R.string.action_hide_post);
}
+
+ mMenu.findItem(R.id.action_report_view_post_detail_activity).setVisible(true);
} else {
saveItem.setVisible(false);
hideItem.setVisible(false);
@@ -1264,6 +1270,8 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
hideItem.setVisible(true);
hideItem.setTitle(R.string.action_hide_post);
}
+
+ mMenu.findItem(R.id.action_report_view_post_detail_activity).setVisible(true);
} else {
saveItem.setVisible(false);
hideItem.setVisible(false);
@@ -1481,6 +1489,11 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
flairBottomSheetFragment.setArguments(bundle);
flairBottomSheetFragment.show(getSupportFragmentManager(), flairBottomSheetFragment.getTag());
return true;
+ case R.id.action_report_view_post_detail_activity:
+ Intent intent = new Intent(this, ReportActivity.class);
+ intent.putExtra(ReportActivity.EXTRA_SUBREDDIT_NAME, mPost.getSubredditName());
+ intent.putExtra(ReportActivity.EXTRA_THING_FULLNAME, mPost.getFullName());
+ startActivity(intent);
case android.R.id.home:
onBackPressed();
return true;
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java
index 419a5e08..f22b6361 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java
@@ -41,6 +41,9 @@ import com.google.android.material.tabs.TabLayout;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
+import java.text.SimpleDateFormat;
+import java.util.Locale;
+
import javax.inject.Inject;
import javax.inject.Named;
@@ -119,6 +122,10 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
TextView nSubscribersTextView;
@BindView(R.id.online_subscriber_count_text_view_view_subreddit_detail_activity)
TextView nOnlineSubscribersTextView;
+ @BindView(R.id.since_text_view_view_subreddit_detail_activity)
+ TextView sinceTextView;
+ @BindView(R.id.creation_time_text_view_view_subreddit_detail_activity)
+ TextView creationTimeTextView;
@BindView(R.id.description_text_view_view_subreddit_detail_activity)
TextView descriptionTextView;
@BindView(R.id.bottom_navigation_view_subreddit_detail_activity)
@@ -322,6 +329,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
setSupportActionBar(toolbar);
glide = Glide.with(this);
+ Locale locale = getResources().getConfiguration().locale;
mSubredditViewModel = new ViewModelProvider(this,
new SubredditViewModel.Factory(getApplication(), mRedditDataRoomDatabase, subredditName))
@@ -370,6 +378,8 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
subredditNameTextView.setText(subredditFullName);
String nSubscribers = getString(R.string.subscribers_number_detail, subredditData.getNSubscribers());
nSubscribersTextView.setText(nSubscribers);
+ creationTimeTextView.setText(new SimpleDateFormat("MMM d, yyyy",
+ locale).format(subredditData.getCreatedUTC()));
if (subredditData.getDescription().equals("")) {
descriptionTextView.setVisibility(View.GONE);
} else {
@@ -416,13 +426,15 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
int primaryTextColor = mCustomThemeWrapper.getPrimaryTextColor();
nSubscribersTextView.setTextColor(primaryTextColor);
nOnlineSubscribersTextView.setTextColor(primaryTextColor);
+ sinceTextView.setTextColor(primaryTextColor);
+ creationTimeTextView.setTextColor(primaryTextColor);
descriptionTextView.setTextColor(primaryTextColor);
bottomNavigationView.setBackgroundTint(ColorStateList.valueOf(mCustomThemeWrapper.getBottomAppBarBackgroundColor()));
- int primaryIconColor = mCustomThemeWrapper.getPrimaryIconColor();
- subscriptionsBottomAppBar.setColorFilter(primaryIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
- multiRedditBottomAppBar.setColorFilter(primaryIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
- messageBottomAppBar.setColorFilter(primaryIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
- profileBottomAppBar.setColorFilter(primaryIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ int bottomAppBarIconColor = mCustomThemeWrapper.getBottomAppBarIconColor();
+ subscriptionsBottomAppBar.setColorFilter(bottomAppBarIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ multiRedditBottomAppBar.setColorFilter(bottomAppBarIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ messageBottomAppBar.setColorFilter(bottomAppBarIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ profileBottomAppBar.setColorFilter(bottomAppBarIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
applyTabLayoutTheme(tabLayout);
applyFABTheme(fab);
unsubscribedColor = mCustomThemeWrapper.getUnsubscribed();
@@ -706,6 +718,16 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
sidebarIntent.putExtra(ViewSidebarActivity.EXTRA_SUBREDDIT_NAME, subredditName);
startActivity(sidebarIntent);
return true;
+ case R.id.action_share_view_subreddit_detail_activity:
+ Intent shareIntent = new Intent(Intent.ACTION_SEND);
+ shareIntent.setType("text/plain");
+ shareIntent.putExtra(Intent.EXTRA_TEXT, "https://www.reddit.com/r/" + subredditName);
+ if (shareIntent.resolveActivity(getPackageManager()) != null) {
+ startActivity(Intent.createChooser(shareIntent, getString(R.string.share)));
+ } else {
+ Toast.makeText(this, R.string.no_app, Toast.LENGTH_SHORT).show();
+ }
+ return true;
}
return false;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewUserDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewUserDetailActivity.java
index 8af8944c..c6bda8bd 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewUserDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewUserDetailActivity.java
@@ -40,6 +40,9 @@ import com.google.android.material.tabs.TabLayout;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
+import java.text.SimpleDateFormat;
+import java.util.Locale;
+
import javax.inject.Inject;
import javax.inject.Named;
@@ -116,6 +119,10 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
Chip subscribeUserChip;
@BindView(R.id.karma_text_view_view_user_detail_activity)
TextView karmaTextView;
+ @BindView(R.id.cakeday_text_view_view_user_detail_activity)
+ TextView cakedayTextView;
+ @BindView(R.id.description_text_view_view_user_detail_activity)
+ TextView descriptionTextView;
@Inject
@Named("no_oauth")
Retrofit mRetrofit;
@@ -274,15 +281,14 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
subscribedUserDao = mRedditDataRoomDatabase.subscribedUserDao();
glide = Glide.with(this);
+ Locale locale = getResources().getConfiguration().locale;
userViewModel = new ViewModelProvider(this, new UserViewModel.Factory(getApplication(), mRedditDataRoomDatabase, username))
.get(UserViewModel.class);
userViewModel.getUserLiveData().observe(this, userData -> {
if (userData != null) {
if (userData.getBanner().equals("")) {
- bannerImageView.setOnClickListener(view -> {
- //Do nothing since the user has no banner image
- });
+ bannerImageView.setOnClickListener(null);
} else {
glide.load(userData.getBanner()).into(bannerImageView);
bannerImageView.setOnClickListener(view -> {
@@ -297,9 +303,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
glide.load(getDrawable(R.drawable.subreddit_default_icon))
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(216, 0)))
.into(iconGifImageView);
- iconGifImageView.setOnClickListener(view -> {
- //Do nothing since the user has no icon image
- });
+ iconGifImageView.setOnClickListener(null);
} else {
glide.load(userData.getIconUrl())
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(216, 0)))
@@ -387,8 +391,17 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
if (!title.equals(userFullName)) {
getSupportActionBar().setTitle(userFullName);
}
- String karma = getString(R.string.karma_info, userData.getKarma());
+ String karma = getString(R.string.karma_info_user_detail, userData.getKarma(), userData.getLinkKarma(), userData.getCommentKarma());
karmaTextView.setText(karma);
+ cakedayTextView.setText(getString(R.string.cakeday_info, new SimpleDateFormat("MMM d, yyyy",
+ locale).format(userData.getCakeday())));
+
+ if (userData.getDescription() == null || userData.getDescription().equals("")) {
+ descriptionTextView.setVisibility(View.GONE);
+ } else {
+ descriptionTextView.setVisibility(View.VISIBLE);
+ descriptionTextView.setText(userData.getDescription());
+ }
}
});
@@ -432,6 +445,8 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
subscribedColor = mCustomThemeWrapper.getSubscribed();
userNameTextView.setTextColor(mCustomThemeWrapper.getUsername());
karmaTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
+ cakedayTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
+ descriptionTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
subscribeUserChip.setTextColor(mCustomThemeWrapper.getChipTextColor());
applyTabLayoutTheme(tabLayout);
}
@@ -621,6 +636,16 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
case R.id.action_change_post_layout_view_user_detail_activity:
postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag());
return true;
+ case R.id.action_share_view_user_detail_activity:
+ Intent shareIntent = new Intent(Intent.ACTION_SEND);
+ shareIntent.setType("text/plain");
+ shareIntent.putExtra(Intent.EXTRA_TEXT, "https://www.reddit.com/user/" + username);
+ if (shareIntent.resolveActivity(getPackageManager()) != null) {
+ startActivity(Intent.createChooser(shareIntent, getString(R.string.share)));
+ } else {
+ Toast.makeText(this, R.string.no_app, Toast.LENGTH_SHORT).show();
+ }
+ return true;
}
return false;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java
index c29f0940..eb2ba7ae 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java
@@ -834,7 +834,6 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
if (comment.getAuthorFlairHTML() != null && !comment.getAuthorFlairHTML().equals("")) {
((CommentViewHolder) holder).authorFlairTextView.setVisibility(View.VISIBLE);
Utils.setHTMLWithImageToTextView(((CommentViewHolder) holder).authorFlairTextView, comment.getAuthorFlairHTML());
- ((CommentViewHolder) holder).authorFlairTextView.setOnClickListener(view -> ((CommentViewHolder) holder).authorTextView.performClick());
} else if (comment.getAuthorFlair() != null && !comment.getAuthorFlair().equals("")) {
((CommentViewHolder) holder).authorFlairTextView.setVisibility(View.VISIBLE);
((CommentViewHolder) holder).authorFlairTextView.setText(comment.getAuthorFlair());
@@ -924,39 +923,6 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
((CommentViewHolder) holder).verticalBlock.setLayoutParams(params);
}
- if (mCommentToolbarHideOnClick) {
- View.OnClickListener hideToolbarOnClickListener = view -> {
- if (((CommentViewHolder) holder).bottomConstraintLayout.getLayoutParams().height == 0) {
- ((CommentViewHolder) holder).bottomConstraintLayout.getLayoutParams().height = LinearLayout.LayoutParams.WRAP_CONTENT;
- ((CommentViewHolder) holder).topScoreTextView.setVisibility(View.GONE);
- ((ViewPostDetailActivity) mActivity).delayTransition();
- } else {
- ((ViewPostDetailActivity) mActivity).delayTransition();
- ((CommentViewHolder) holder).bottomConstraintLayout.getLayoutParams().height = 0;
- ((CommentViewHolder) holder).topScoreTextView.setVisibility(View.VISIBLE);
- }
- };
- ((CommentViewHolder) holder).linearLayout.setOnClickListener(hideToolbarOnClickListener);
- ((CommentViewHolder) holder).commentMarkdownView.setOnClickListener(hideToolbarOnClickListener);
- ((CommentViewHolder) holder).commentTimeTextView.setOnClickListener(hideToolbarOnClickListener);
- }
-
- ((CommentViewHolder) holder).moreButton.setOnClickListener(view -> {
- Bundle bundle = new Bundle();
- if (!mPost.isArchived() && !mPost.isLocked() && comment.getAuthor().equals(mAccountName)) {
- bundle.putString(CommentMoreBottomSheetFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
- }
- bundle.putParcelable(CommentMoreBottomSheetFragment.EXTRA_COMMENT, comment);
- if (mIsSingleCommentThreadMode) {
- bundle.putInt(CommentMoreBottomSheetFragment.EXTRA_POSITION, holder.getAdapterPosition() - 2);
- } else {
- bundle.putInt(CommentMoreBottomSheetFragment.EXTRA_POSITION, holder.getAdapterPosition() - 1);
- }
- CommentMoreBottomSheetFragment commentMoreBottomSheetFragment = new CommentMoreBottomSheetFragment();
- commentMoreBottomSheetFragment.setArguments(bundle);
- commentMoreBottomSheetFragment.show(mActivity.getSupportFragmentManager(), commentMoreBottomSheetFragment.getTag());
- });
-
if (comment.hasReply()) {
if (comment.isExpanded()) {
((CommentViewHolder) holder).expandButton.setImageResource(R.drawable.ic_expand_less_grey_24dp);
@@ -997,239 +963,11 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
android.graphics.PorterDuff.Mode.SRC_IN);
}
- ((CommentViewHolder) holder).replyButton.setOnClickListener(view -> {
- if (mAccessToken == null) {
- Toast.makeText(mActivity, R.string.login_first, Toast.LENGTH_SHORT).show();
- return;
- }
-
- if (mPost.isArchived()) {
- Toast.makeText(mActivity, R.string.archived_post_reply_unavailable, Toast.LENGTH_SHORT).show();
- return;
- }
-
- if (mPost.isLocked()) {
- Toast.makeText(mActivity, R.string.locked_post_reply_unavailable, Toast.LENGTH_SHORT).show();
- return;
- }
-
- Intent intent = new Intent(mActivity, CommentActivity.class);
- intent.putExtra(CommentActivity.EXTRA_PARENT_DEPTH_KEY, comment.getDepth() + 1);
- intent.putExtra(CommentActivity.EXTRA_COMMENT_PARENT_TEXT_KEY, comment.getCommentMarkdown());
- intent.putExtra(CommentActivity.EXTRA_PARENT_FULLNAME_KEY, comment.getFullName());
- intent.putExtra(CommentActivity.EXTRA_IS_REPLYING_KEY, true);
-
- int parentPosition = mIsSingleCommentThreadMode ? holder.getAdapterPosition() - 2 : holder.getAdapterPosition() - 1;
- intent.putExtra(CommentActivity.EXTRA_PARENT_POSITION_KEY, parentPosition);
- mActivity.startActivityForResult(intent, CommentActivity.WRITE_COMMENT_REQUEST_CODE);
- });
-
- ((CommentViewHolder) holder).upvoteButton.setOnClickListener(view -> {
- if (mPost.isArchived()) {
- Toast.makeText(mActivity, R.string.archived_post_vote_unavailable, Toast.LENGTH_SHORT).show();
- return;
- }
-
- if (mAccessToken == null) {
- Toast.makeText(mActivity, R.string.login_first, Toast.LENGTH_SHORT).show();
- return;
- }
-
- int previousVoteType = comment.getVoteType();
- String newVoteType;
-
- ((CommentViewHolder) holder).downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
-
- if (previousVoteType != CommentData.VOTE_TYPE_UPVOTE) {
- //Not upvoted before
- comment.setVoteType(CommentData.VOTE_TYPE_UPVOTE);
- newVoteType = RedditUtils.DIR_UPVOTE;
- ((CommentViewHolder) holder).upvoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
- ((CommentViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor);
- } else {
- //Upvoted before
- comment.setVoteType(CommentData.VOTE_TYPE_NO_VOTE);
- newVoteType = RedditUtils.DIR_UNVOTE;
- ((CommentViewHolder) holder).upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
- ((CommentViewHolder) holder).scoreTextView.setTextColor(mCommentIconAndInfoColor);
- }
-
- ((CommentViewHolder) holder).scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
- comment.getScore() + comment.getVoteType()));
- ((CommentViewHolder) holder).topScoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
- comment.getScore() + comment.getVoteType()) + " pts");
-
- VoteThing.voteThing(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
- @Override
- public void onVoteThingSuccess(int position) {
- if (newVoteType.equals(RedditUtils.DIR_UPVOTE)) {
- comment.setVoteType(CommentData.VOTE_TYPE_UPVOTE);
- ((CommentViewHolder) holder).upvoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
- ((CommentViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor);
- } else {
- comment.setVoteType(CommentData.VOTE_TYPE_NO_VOTE);
- ((CommentViewHolder) holder).upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
- ((CommentViewHolder) holder).scoreTextView.setTextColor(mCommentIconAndInfoColor);
- }
-
- ((CommentViewHolder) holder).downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
- ((CommentViewHolder) holder).scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
- comment.getScore() + comment.getVoteType()));
- ((CommentViewHolder) holder).topScoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
- comment.getScore() + comment.getVoteType()) + " pts");
- }
-
- @Override
- public void onVoteThingFail(int position) {
- }
- }, comment.getFullName(), newVoteType, holder.getAdapterPosition());
- });
-
- ((CommentViewHolder) holder).downvoteButton.setOnClickListener(view -> {
- if (mPost.isArchived()) {
- Toast.makeText(mActivity, R.string.archived_post_vote_unavailable, Toast.LENGTH_SHORT).show();
- return;
- }
-
- if (mAccessToken == null) {
- Toast.makeText(mActivity, R.string.login_first, Toast.LENGTH_SHORT).show();
- return;
- }
-
- int previousVoteType = comment.getVoteType();
- String newVoteType;
-
- ((CommentViewHolder) holder).upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
-
- if (previousVoteType != CommentData.VOTE_TYPE_DOWNVOTE) {
- //Not downvoted before
- comment.setVoteType(CommentData.VOTE_TYPE_DOWNVOTE);
- newVoteType = RedditUtils.DIR_DOWNVOTE;
- ((CommentViewHolder) holder).downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
- ((CommentViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor);
- } else {
- //Downvoted before
- comment.setVoteType(CommentData.VOTE_TYPE_NO_VOTE);
- newVoteType = RedditUtils.DIR_UNVOTE;
- ((CommentViewHolder) holder).downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
- ((CommentViewHolder) holder).scoreTextView.setTextColor(mCommentIconAndInfoColor);
- }
-
- ((CommentViewHolder) holder).scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
- comment.getScore() + comment.getVoteType()));
- ((CommentViewHolder) holder).topScoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
- comment.getScore() + comment.getVoteType()) + " pts");
-
- VoteThing.voteThing(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
- @Override
- public void onVoteThingSuccess(int position1) {
- if (newVoteType.equals(RedditUtils.DIR_DOWNVOTE)) {
- comment.setVoteType(CommentData.VOTE_TYPE_DOWNVOTE);
- ((CommentViewHolder) holder).downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
- ((CommentViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor);
- } else {
- comment.setVoteType(CommentData.VOTE_TYPE_NO_VOTE);
- ((CommentViewHolder) holder).downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
- ((CommentViewHolder) holder).scoreTextView.setTextColor(mCommentIconAndInfoColor);
- }
-
- ((CommentViewHolder) holder).upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
- ((CommentViewHolder) holder).scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
- comment.getScore() + comment.getVoteType()));
- ((CommentViewHolder) holder).topScoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
- comment.getScore() + comment.getVoteType()) + " pts");
- }
-
- @Override
- public void onVoteThingFail(int position1) {
- }
- }, comment.getFullName(), newVoteType, holder.getAdapterPosition());
- });
-
if (comment.isSaved()) {
((CommentViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
} else {
((CommentViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
}
-
- ((CommentViewHolder) holder).saveButton.setOnClickListener(view -> {
- if (comment.isSaved()) {
- comment.setSaved(false);
- SaveThing.unsaveThing(mOauthRetrofit, mAccessToken, comment.getFullName(), new SaveThing.SaveThingListener() {
- @Override
- public void success() {
- comment.setSaved(false);
- ((CommentViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
- Toast.makeText(mActivity, R.string.comment_unsaved_success, Toast.LENGTH_SHORT).show();
- }
-
- @Override
- public void failed() {
- comment.setSaved(true);
- ((CommentViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
- Toast.makeText(mActivity, R.string.comment_unsaved_failed, Toast.LENGTH_SHORT).show();
- }
- });
- } else {
- comment.setSaved(true);
- SaveThing.saveThing(mOauthRetrofit, mAccessToken, comment.getFullName(), new SaveThing.SaveThingListener() {
- @Override
- public void success() {
- comment.setSaved(true);
- ((CommentViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
- Toast.makeText(mActivity, R.string.comment_saved_success, Toast.LENGTH_SHORT).show();
- }
-
- @Override
- public void failed() {
- comment.setSaved(false);
- ((CommentViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
- Toast.makeText(mActivity, R.string.comment_saved_failed, Toast.LENGTH_SHORT).show();
- }
- });
- }
- });
-
- ((CommentViewHolder) holder).authorTextView.setOnClickListener(view -> {
- Intent intent = new Intent(mActivity, ViewUserDetailActivity.class);
- intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, comment.getAuthor());
- mActivity.startActivity(intent);
- });
-
- ((CommentViewHolder) holder).expandButton.setOnClickListener(view -> {
- if (((CommentViewHolder) holder).expandButton.getVisibility() == View.VISIBLE) {
- int commentPosition = mIsSingleCommentThreadMode ? holder.getAdapterPosition() - 2 : holder.getAdapterPosition() - 1;
- if(commentPosition >= 0 && commentPosition < mVisibleComments.size()) {
- if (mVisibleComments.get(commentPosition).isExpanded()) {
- collapseChildren(commentPosition);
- ((CommentViewHolder) holder).expandButton.setImageResource(R.drawable.ic_expand_more_grey_24dp);
- } else {
- comment.setExpanded(true);
- ArrayList<CommentData> newList = new ArrayList<>();
- expandChildren(mVisibleComments.get(commentPosition).getChildren(), newList, 0);
- mVisibleComments.get(commentPosition).setExpanded(true);
- mVisibleComments.addAll(commentPosition + 1, newList);
-
- if (mIsSingleCommentThreadMode) {
- notifyItemRangeInserted(commentPosition + 3, newList.size());
- } else {
- notifyItemRangeInserted(commentPosition + 2, newList.size());
- }
- ((CommentViewHolder) holder).expandButton.setImageResource(R.drawable.ic_expand_less_grey_24dp);
- }
- }
- }
- });
-
- ((CommentViewHolder) holder).commentMarkdownView.setOnLongClickListener(view -> {
- ((CommentViewHolder) holder).expandButton.performClick();
- return true;
- });
-
- ((CommentViewHolder) holder).itemView.setOnLongClickListener(view -> {
- ((CommentViewHolder) holder).expandButton.performClick();
- return true;
- });
} else if (holder instanceof LoadMoreChildCommentsViewHolder) {
CommentData placeholder;
placeholder = mIsSingleCommentThreadMode ? mVisibleComments.get(holder.getAdapterPosition() - 2)
@@ -2208,6 +1946,287 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
expandButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
saveButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
replyButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+
+ authorFlairTextView.setOnClickListener(view -> authorTextView.performClick());
+
+ View.OnClickListener hideToolbarOnClickListener = view -> {
+ if (mCommentToolbarHideOnClick) {
+ if (bottomConstraintLayout.getLayoutParams().height == 0) {
+ bottomConstraintLayout.getLayoutParams().height = LinearLayout.LayoutParams.WRAP_CONTENT;
+ topScoreTextView.setVisibility(View.GONE);
+ ((ViewPostDetailActivity) mActivity).delayTransition();
+ } else {
+ ((ViewPostDetailActivity) mActivity).delayTransition();
+ bottomConstraintLayout.getLayoutParams().height = 0;
+ topScoreTextView.setVisibility(View.VISIBLE);
+ }
+ }
+ };
+ linearLayout.setOnClickListener(hideToolbarOnClickListener);
+ commentMarkdownView.setOnClickListener(hideToolbarOnClickListener);
+ commentTimeTextView.setOnClickListener(hideToolbarOnClickListener);
+
+ moreButton.setOnClickListener(view -> {
+ CommentData comment = getCurrentComment();
+ Bundle bundle = new Bundle();
+ if (!mPost.isArchived() && !mPost.isLocked() && comment.getAuthor().equals(mAccountName)) {
+ bundle.putString(CommentMoreBottomSheetFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
+ }
+ bundle.putParcelable(CommentMoreBottomSheetFragment.EXTRA_COMMENT, comment);
+ if (mIsSingleCommentThreadMode) {
+ bundle.putInt(CommentMoreBottomSheetFragment.EXTRA_POSITION, getAdapterPosition() - 2);
+ } else {
+ bundle.putInt(CommentMoreBottomSheetFragment.EXTRA_POSITION, getAdapterPosition() - 1);
+ }
+ CommentMoreBottomSheetFragment commentMoreBottomSheetFragment = new CommentMoreBottomSheetFragment();
+ commentMoreBottomSheetFragment.setArguments(bundle);
+ commentMoreBottomSheetFragment.show(mActivity.getSupportFragmentManager(), commentMoreBottomSheetFragment.getTag());
+ });
+
+ replyButton.setOnClickListener(view -> {
+ if (mAccessToken == null) {
+ Toast.makeText(mActivity, R.string.login_first, Toast.LENGTH_SHORT).show();
+ return;
+ }
+
+ if (mPost.isArchived()) {
+ Toast.makeText(mActivity, R.string.archived_post_reply_unavailable, Toast.LENGTH_SHORT).show();
+ return;
+ }
+
+ if (mPost.isLocked()) {
+ Toast.makeText(mActivity, R.string.locked_post_reply_unavailable, Toast.LENGTH_SHORT).show();
+ return;
+ }
+
+ CommentData comment = getCurrentComment();
+
+ Intent intent = new Intent(mActivity, CommentActivity.class);
+ intent.putExtra(CommentActivity.EXTRA_PARENT_DEPTH_KEY, comment.getDepth() + 1);
+ intent.putExtra(CommentActivity.EXTRA_COMMENT_PARENT_TEXT_KEY, comment.getCommentMarkdown());
+ intent.putExtra(CommentActivity.EXTRA_PARENT_FULLNAME_KEY, comment.getFullName());
+ intent.putExtra(CommentActivity.EXTRA_IS_REPLYING_KEY, true);
+
+ int parentPosition = mIsSingleCommentThreadMode ? getAdapterPosition() - 2 : getAdapterPosition() - 1;
+ intent.putExtra(CommentActivity.EXTRA_PARENT_POSITION_KEY, parentPosition);
+ mActivity.startActivityForResult(intent, CommentActivity.WRITE_COMMENT_REQUEST_CODE);
+ });
+
+ upvoteButton.setOnClickListener(view -> {
+ if (mPost.isArchived()) {
+ Toast.makeText(mActivity, R.string.archived_post_vote_unavailable, Toast.LENGTH_SHORT).show();
+ return;
+ }
+
+ if (mAccessToken == null) {
+ Toast.makeText(mActivity, R.string.login_first, Toast.LENGTH_SHORT).show();
+ return;
+ }
+
+ CommentData comment = getCurrentComment();
+ int previousVoteType = comment.getVoteType();
+ String newVoteType;
+
+ downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+
+ if (previousVoteType != CommentData.VOTE_TYPE_UPVOTE) {
+ //Not upvoted before
+ comment.setVoteType(CommentData.VOTE_TYPE_UPVOTE);
+ newVoteType = RedditUtils.DIR_UPVOTE;
+ upvoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ scoreTextView.setTextColor(mUpvotedColor);
+ } else {
+ //Upvoted before
+ comment.setVoteType(CommentData.VOTE_TYPE_NO_VOTE);
+ newVoteType = RedditUtils.DIR_UNVOTE;
+ upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ scoreTextView.setTextColor(mCommentIconAndInfoColor);
+ }
+
+ scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
+ comment.getScore() + comment.getVoteType()));
+ topScoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
+ comment.getScore() + comment.getVoteType()) + " pts");
+
+ VoteThing.voteThing(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
+ @Override
+ public void onVoteThingSuccess(int position) {
+ if (newVoteType.equals(RedditUtils.DIR_UPVOTE)) {
+ comment.setVoteType(CommentData.VOTE_TYPE_UPVOTE);
+ upvoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ scoreTextView.setTextColor(mUpvotedColor);
+ } else {
+ comment.setVoteType(CommentData.VOTE_TYPE_NO_VOTE);
+ upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ scoreTextView.setTextColor(mCommentIconAndInfoColor);
+ }
+
+ downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
+ comment.getScore() + comment.getVoteType()));
+ topScoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
+ comment.getScore() + comment.getVoteType()) + " pts");
+ }
+
+ @Override
+ public void onVoteThingFail(int position) {
+ }
+ }, comment.getFullName(), newVoteType, getAdapterPosition());
+ });
+
+ downvoteButton.setOnClickListener(view -> {
+ if (mPost.isArchived()) {
+ Toast.makeText(mActivity, R.string.archived_post_vote_unavailable, Toast.LENGTH_SHORT).show();
+ return;
+ }
+
+ if (mAccessToken == null) {
+ Toast.makeText(mActivity, R.string.login_first, Toast.LENGTH_SHORT).show();
+ return;
+ }
+
+ CommentData comment = getCurrentComment();
+ int previousVoteType = comment.getVoteType();
+ String newVoteType;
+
+ upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+
+ if (previousVoteType != CommentData.VOTE_TYPE_DOWNVOTE) {
+ //Not downvoted before
+ comment.setVoteType(CommentData.VOTE_TYPE_DOWNVOTE);
+ newVoteType = RedditUtils.DIR_DOWNVOTE;
+ downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ scoreTextView.setTextColor(mDownvotedColor);
+ } else {
+ //Downvoted before
+ comment.setVoteType(CommentData.VOTE_TYPE_NO_VOTE);
+ newVoteType = RedditUtils.DIR_UNVOTE;
+ downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ scoreTextView.setTextColor(mCommentIconAndInfoColor);
+ }
+
+ scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
+ comment.getScore() + comment.getVoteType()));
+ topScoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
+ comment.getScore() + comment.getVoteType()) + " pts");
+
+ VoteThing.voteThing(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
+ @Override
+ public void onVoteThingSuccess(int position1) {
+ if (newVoteType.equals(RedditUtils.DIR_DOWNVOTE)) {
+ comment.setVoteType(CommentData.VOTE_TYPE_DOWNVOTE);
+ downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ scoreTextView.setTextColor(mDownvotedColor);
+ } else {
+ comment.setVoteType(CommentData.VOTE_TYPE_NO_VOTE);
+ downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ scoreTextView.setTextColor(mCommentIconAndInfoColor);
+ }
+
+ upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
+ comment.getScore() + comment.getVoteType()));
+ topScoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
+ comment.getScore() + comment.getVoteType()) + " pts");
+ }
+
+ @Override
+ public void onVoteThingFail(int position1) {
+ }
+ }, comment.getFullName(), newVoteType, getAdapterPosition());
+ });
+
+ saveButton.setOnClickListener(view -> {
+ CommentData comment = getCurrentComment();
+ if (comment.isSaved()) {
+ comment.setSaved(false);
+ SaveThing.unsaveThing(mOauthRetrofit, mAccessToken, comment.getFullName(), new SaveThing.SaveThingListener() {
+ @Override
+ public void success() {
+ comment.setSaved(false);
+ saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
+ Toast.makeText(mActivity, R.string.comment_unsaved_success, Toast.LENGTH_SHORT).show();
+ }
+
+ @Override
+ public void failed() {
+ comment.setSaved(true);
+ saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
+ Toast.makeText(mActivity, R.string.comment_unsaved_failed, Toast.LENGTH_SHORT).show();
+ }
+ });
+ } else {
+ comment.setSaved(true);
+ SaveThing.saveThing(mOauthRetrofit, mAccessToken, comment.getFullName(), new SaveThing.SaveThingListener() {
+ @Override
+ public void success() {
+ comment.setSaved(true);
+ saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
+ Toast.makeText(mActivity, R.string.comment_saved_success, Toast.LENGTH_SHORT).show();
+ }
+
+ @Override
+ public void failed() {
+ comment.setSaved(false);
+ saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
+ Toast.makeText(mActivity, R.string.comment_saved_failed, Toast.LENGTH_SHORT).show();
+ }
+ });
+ }
+ });
+
+ authorTextView.setOnClickListener(view -> {
+ Intent intent = new Intent(mActivity, ViewUserDetailActivity.class);
+ intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, getCurrentComment().getAuthor());
+ mActivity.startActivity(intent);
+ });
+
+ expandButton.setOnClickListener(view -> {
+ if (expandButton.getVisibility() == View.VISIBLE) {
+ int commentPosition = mIsSingleCommentThreadMode ? getAdapterPosition() - 2 : getAdapterPosition() - 1;
+ if(commentPosition >= 0 && commentPosition < mVisibleComments.size()) {
+ CommentData comment = getCurrentComment();
+ if (mVisibleComments.get(commentPosition).isExpanded()) {
+ collapseChildren(commentPosition);
+ expandButton.setImageResource(R.drawable.ic_expand_more_grey_24dp);
+ } else {
+ comment.setExpanded(true);
+ ArrayList<CommentData> newList = new ArrayList<>();
+ expandChildren(mVisibleComments.get(commentPosition).getChildren(), newList, 0);
+ mVisibleComments.get(commentPosition).setExpanded(true);
+ mVisibleComments.addAll(commentPosition + 1, newList);
+
+ if (mIsSingleCommentThreadMode) {
+ notifyItemRangeInserted(commentPosition + 3, newList.size());
+ } else {
+ notifyItemRangeInserted(commentPosition + 2, newList.size());
+ }
+ expandButton.setImageResource(R.drawable.ic_expand_less_grey_24dp);
+ }
+ }
+ }
+ });
+
+ commentMarkdownView.setOnLongClickListener(view -> {
+ expandButton.performClick();
+ return true;
+ });
+
+ itemView.setOnLongClickListener(view -> {
+ expandButton.performClick();
+ return true;
+ });
+ }
+
+ private CommentData getCurrentComment() {
+ CommentData comment;
+ if (mIsSingleCommentThreadMode) {
+ comment = mVisibleComments.get(getAdapterPosition() - 2);
+ } else {
+ comment = mVisibleComments.get(getAdapterPosition() - 1);
+ }
+
+ return comment;
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java
index 38aa8b00..3623fb54 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java
@@ -1,14 +1,13 @@
package ml.docilealligator.infinityforreddit.Adapter;
import android.content.Intent;
+import android.content.SharedPreferences;
import android.content.res.ColorStateList;
import android.graphics.ColorFilter;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
-import android.text.Html;
-import android.text.Spannable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -38,13 +37,29 @@ 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.Target;
+import com.google.android.exoplayer2.metadata.Metadata;
+import com.google.android.exoplayer2.source.TrackGroupArray;
+import com.google.android.exoplayer2.text.Cue;
+import com.google.android.exoplayer2.trackselection.TrackSelectionArray;
+import com.google.android.exoplayer2.ui.AspectRatioFrameLayout;
+import com.google.android.exoplayer2.ui.PlayerView;
import com.google.android.material.card.MaterialCardView;
import com.libRG.CustomTextView;
import org.greenrobot.eventbus.EventBus;
+import java.util.List;
+
import butterknife.BindView;
import butterknife.ButterKnife;
+import im.ene.toro.CacheManager;
+import im.ene.toro.ToroPlayer;
+import im.ene.toro.ToroUtil;
+import im.ene.toro.exoplayer.ExoCreator;
+import im.ene.toro.exoplayer.ExoPlayerViewHelper;
+import im.ene.toro.exoplayer.Playable;
+import im.ene.toro.media.PlaybackInfo;
+import im.ene.toro.widget.Container;
import jp.wasabeef.glide.transformations.BlurTransformation;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import ml.docilealligator.infinityforreddit.Activity.FilteredThingActivity;
@@ -68,7 +83,6 @@ import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.SaveThing;
import ml.docilealligator.infinityforreddit.User.UserDao;
-import ml.docilealligator.infinityforreddit.Utils.GlideImageGetter;
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.Utils.Utils;
@@ -79,10 +93,16 @@ import retrofit2.Retrofit;
* Created by alex on 2/25/18.
*/
-public class PostRecyclerViewAdapter extends PagedListAdapter<Post, 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;
+public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHolder> implements CacheManager {
+ private static final int VIEW_TYPE_POST_CARD_VIDEO_TYPE_AUTOPLAY = 1;
+ private static final int VIEW_TYPE_POST_CARD_VIDEO_AND_GIF_PREVIEW_TYPE = 2;
+ private static final int VIEW_TYPE_POST_CARD_IMAGE_AND_GIF_AUTOPLAY_TYPE = 3;
+ private static final int VIEW_TYPE_POST_CARD_LINK_TYPE = 4;
+ private static final int VIEW_TYPE_POST_CARD_NO_PREVIEW_LINK_TYPE = 5;
+ private static final int VIEW_TYPE_POST_CARD_TEXT_TYPE = 6;
+ private static final int VIEW_TYPE_POST_COMPACT = 7;
+ private static final int VIEW_TYPE_ERROR = 8;
+ private static final int VIEW_TYPE_LOADING = 9;
private static final DiffUtil.ItemCallback<Post> DIFF_CALLBACK = new DiffUtil.ItemCallback<Post>() {
@Override
public boolean areItemsTheSame(@NonNull Post post, @NonNull Post t1) {
@@ -140,8 +160,10 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
private boolean mShowElapsedTime;
private boolean mShowDividerInCompactLayout;
private boolean mShowAbsoluteNumberOfVotes;
+ private boolean mAutoplay = false;
private Drawable mCommentIcon;
private NetworkState networkState;
+ private ExoCreator mExoCreator;
private Callback mCallback;
private ShareLinkBottomSheetFragment mShareLinkBottomSheetFragment;
@@ -149,9 +171,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
RedditDataRoomDatabase redditDataRoomDatabase,
CustomThemeWrapper customThemeWrapper, String accessToken,
int postType, int postLayout, boolean displaySubredditName,
- boolean needBlurNSFW, boolean needBlurSpoiler, boolean voteButtonsOnTheRight,
- boolean showElapsedTime, boolean showDividerInCompactLayout,
- boolean showAbsoluteNumberOfVotes, Callback callback) {
+ SharedPreferences sharedPreferences, ExoCreator exoCreator,
+ Callback callback) {
super(DIFF_CALLBACK);
if (activity != null) {
mActivity = activity;
@@ -160,12 +181,18 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
mAccessToken = accessToken;
mPostType = postType;
mDisplaySubredditName = displaySubredditName;
- mNeedBlurNSFW = needBlurNSFW;
- mNeedBlurSpoiler = needBlurSpoiler;
- mVoteButtonsOnTheRight = voteButtonsOnTheRight;
- mShowElapsedTime = showElapsedTime;
- mShowDividerInCompactLayout = showDividerInCompactLayout;
- mShowAbsoluteNumberOfVotes = showAbsoluteNumberOfVotes;
+ mNeedBlurNSFW = sharedPreferences.getBoolean(SharedPreferencesUtils.BLUR_NSFW_KEY, true);
+ mNeedBlurSpoiler = sharedPreferences.getBoolean(SharedPreferencesUtils.BLUR_SPOILER_KEY, false);
+ mVoteButtonsOnTheRight = sharedPreferences.getBoolean(SharedPreferencesUtils.VOTE_BUTTONS_ON_THE_RIGHT_KEY, false);
+ mShowElapsedTime = sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_ELAPSED_TIME_KEY, false);
+ mShowDividerInCompactLayout = sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_DIVIDER_IN_COMPACT_LAYOUT, true);
+ mShowAbsoluteNumberOfVotes = sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_ABSOLUTE_NUMBER_OF_VOTES, true);
+ String autoplayString = sharedPreferences.getString(SharedPreferencesUtils.VIDEO_AUTOPLAY, SharedPreferencesUtils.VIDEO_AUTOPLAY_VALUE_NEVER);
+ if (autoplayString.equals(SharedPreferencesUtils.VIDEO_AUTOPLAY_VALUE_ALWAYS_ON)) {
+ mAutoplay = true;
+ } else if (autoplayString.equals(SharedPreferencesUtils.VIDEO_AUTOPLAY_VALUE_ON_WIFI)) {
+ mAutoplay = Utils.isConnectedToWifi(activity);
+ }
mPostLayout = postLayout;
mColorPrimaryLightTheme = customThemeWrapper.getColorPrimaryLightTheme();
@@ -205,6 +232,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
mGlide = Glide.with(mActivity);
mRedditDataRoomDatabase = redditDataRoomDatabase;
mUserDao = redditDataRoomDatabase.userDao();
+ mExoCreator = exoCreator;
mCallback = callback;
mShareLinkBottomSheetFragment = new ShareLinkBottomSheetFragment();
}
@@ -214,15 +242,64 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
this.canStartActivity = canStartActivity;
}
- @NonNull
@Override
- public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
- if (viewType == VIEW_TYPE_DATA) {
+ public int getItemViewType(int position) {
+ // Reached at the end
+ if (hasExtraRow() && position == getItemCount() - 1) {
+ if (networkState.getStatus() == NetworkState.Status.LOADING) {
+ return VIEW_TYPE_LOADING;
+ } else {
+ return VIEW_TYPE_ERROR;
+ }
+ } else {
if (mPostLayout == SharedPreferencesUtils.POST_LAYOUT_CARD) {
- return new PostViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post, parent, false));
+ Post post = getItem(position);
+ if (post != null) {
+ switch (post.getPostType()) {
+ case Post.VIDEO_TYPE:
+ if (mAutoplay) {
+ return VIEW_TYPE_POST_CARD_VIDEO_TYPE_AUTOPLAY;
+ }
+ return VIEW_TYPE_POST_CARD_VIDEO_AND_GIF_PREVIEW_TYPE;
+ case Post.GIF_TYPE:
+ if (mAutoplay) {
+ return VIEW_TYPE_POST_CARD_IMAGE_AND_GIF_AUTOPLAY_TYPE;
+ }
+ return VIEW_TYPE_POST_CARD_VIDEO_AND_GIF_PREVIEW_TYPE;
+ case Post.IMAGE_TYPE:
+ return VIEW_TYPE_POST_CARD_IMAGE_AND_GIF_AUTOPLAY_TYPE;
+ case Post.LINK_TYPE:
+ return VIEW_TYPE_POST_CARD_LINK_TYPE;
+ case Post.NO_PREVIEW_LINK_TYPE:
+ return VIEW_TYPE_POST_CARD_NO_PREVIEW_LINK_TYPE;
+ default:
+ return VIEW_TYPE_POST_CARD_TEXT_TYPE;
+ }
+ }
+ return VIEW_TYPE_POST_CARD_TEXT_TYPE;
} else {
- return new PostCompactViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_compact, parent, false));
+ return VIEW_TYPE_POST_COMPACT;
}
+ }
+ }
+
+ @NonNull
+ @Override
+ public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
+ if (viewType == VIEW_TYPE_POST_CARD_VIDEO_TYPE_AUTOPLAY) {
+ return new PostVideoAutoplayViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_video_type_autoplay, parent, false));
+ } else if (viewType == VIEW_TYPE_POST_CARD_VIDEO_AND_GIF_PREVIEW_TYPE) {
+ return new PostGifAndVideoPreviewViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_video_and_gif_preview_type, parent, false));
+ } else if (viewType == VIEW_TYPE_POST_CARD_IMAGE_AND_GIF_AUTOPLAY_TYPE) {
+ return new PostImageAndGifAutoplayTypeViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_image_and_gif_autoplay_type, parent, false));
+ } else if (viewType == VIEW_TYPE_POST_CARD_LINK_TYPE) {
+ return new PostLinkTypeViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_link_type, parent, false));
+ } else if (viewType == VIEW_TYPE_POST_CARD_NO_PREVIEW_LINK_TYPE) {
+ return new PostNoPreviewLinkTypeViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_no_preview_link_type, parent, false));
+ } else if (viewType == VIEW_TYPE_POST_CARD_TEXT_TYPE) {
+ return new PostTextTypeViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_text_type, parent, false));
+ } else if (viewType == VIEW_TYPE_POST_COMPACT) {
+ return new PostCompactViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_compact, parent, false));
} else if (viewType == VIEW_TYPE_ERROR) {
return new ErrorViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_footer_error, parent, false));
} else {
@@ -232,44 +309,17 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
@Override
public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder holder, int position) {
- if (holder instanceof PostViewHolder) {
+ if (holder instanceof PostBaseViewHolder) {
Post post = getItem(position);
if (post != null) {
- final String fullName = post.getFullName();
- final String id = post.getId();
- final String subredditNamePrefixed = post.getSubredditNamePrefixed();
+ String subredditNamePrefixed = post.getSubredditNamePrefixed();
String subredditName = subredditNamePrefixed.substring(2);
String authorPrefixed = "u/" + post.getAuthor();
- final String postTime = post.getPostTime();
- final String title = post.getTitle();
- int voteType = post.getVoteType();
- boolean nsfw = post.isNSFW();
- boolean spoiler = post.isSpoiler();
String flair = post.getFlair();
int nAwards = post.getnAwards();
- boolean isArchived = post.isArchived();
-
- ((PostViewHolder) holder).cardView.setOnClickListener(view -> {
- if (canStartActivity) {
- canStartActivity = false;
- Intent intent = new Intent(mActivity, ViewPostDetailActivity.class);
- intent.putExtra(ViewPostDetailActivity.EXTRA_POST_DATA, post);
- intent.putExtra(ViewPostDetailActivity.EXTRA_POST_LIST_POSITION, position);
- mActivity.startActivity(intent);
- }
- });
-
- ((PostViewHolder) holder).subredditTextView.setText(subredditNamePrefixed);
- ((PostViewHolder) holder).userTextView.setText(authorPrefixed);
- ((PostViewHolder) holder).userTextView.setOnClickListener(view -> {
- if (canStartActivity) {
- canStartActivity = false;
- Intent intent = new Intent(mActivity, ViewUserDetailActivity.class);
- intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, post.getAuthor());
- mActivity.startActivity(intent);
- }
- });
+ ((PostBaseViewHolder) holder).subredditTextView.setText(subredditNamePrefixed);
+ ((PostBaseViewHolder) holder).userTextView.setText(authorPrefixed);
if (mDisplaySubredditName) {
if (authorPrefixed.equals(subredditNamePrefixed)) {
@@ -279,13 +329,13 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
if (iconImageUrl == null || iconImageUrl.equals("")) {
mGlide.load(R.drawable.subreddit_default_icon)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
- .into(((PostViewHolder) holder).iconGifImageView);
+ .into(((PostBaseViewHolder) holder).iconGifImageView);
} else {
mGlide.load(iconImageUrl)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
.error(mGlide.load(R.drawable.subreddit_default_icon)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
- .into(((PostViewHolder) holder).iconGifImageView);
+ .into(((PostBaseViewHolder) holder).iconGifImageView);
}
if (holder.getAdapterPosition() >= 0) {
@@ -298,11 +348,11 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
.error(mGlide.load(R.drawable.subreddit_default_icon)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
- .into(((PostViewHolder) holder).iconGifImageView);
+ .into(((PostBaseViewHolder) holder).iconGifImageView);
} else {
mGlide.load(R.drawable.subreddit_default_icon)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
- .into(((PostViewHolder) holder).iconGifImageView);
+ .into(((PostBaseViewHolder) holder).iconGifImageView);
}
} else {
if (post.getSubredditIconUrl() == null) {
@@ -312,13 +362,13 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
if (iconImageUrl == null || iconImageUrl.equals("")) {
mGlide.load(R.drawable.subreddit_default_icon)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
- .into(((PostViewHolder) holder).iconGifImageView);
+ .into(((PostBaseViewHolder) holder).iconGifImageView);
} else {
mGlide.load(iconImageUrl)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
.error(mGlide.load(R.drawable.subreddit_default_icon)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
- .into(((PostViewHolder) holder).iconGifImageView);
+ .into(((PostBaseViewHolder) holder).iconGifImageView);
}
if (holder.getAdapterPosition() >= 0) {
@@ -331,33 +381,13 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
.error(mGlide.load(R.drawable.subreddit_default_icon)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
- .into(((PostViewHolder) holder).iconGifImageView);
+ .into(((PostBaseViewHolder) holder).iconGifImageView);
} else {
mGlide.load(R.drawable.subreddit_default_icon)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
- .into(((PostViewHolder) holder).iconGifImageView);
+ .into(((PostBaseViewHolder) holder).iconGifImageView);
}
}
-
- ((PostViewHolder) holder).subredditTextView.setOnClickListener(view -> {
- if (canStartActivity) {
- canStartActivity = false;
- if (post.getSubredditNamePrefixed().startsWith("u/")) {
- Intent intent = new Intent(mActivity, ViewUserDetailActivity.class);
- intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY,
- post.getSubredditNamePrefixed().substring(2));
- mActivity.startActivity(intent);
- } else {
- Intent intent = new Intent(mActivity, ViewSubredditDetailActivity.class);
- intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY,
- post.getSubredditName());
- mActivity.startActivity(intent);
- }
- }
- });
-
- ((PostViewHolder) holder).iconGifImageView.setOnClickListener(view ->
- ((PostViewHolder) holder).subredditTextView.performClick());
} else {
if (post.getAuthorIconUrl() == null) {
String authorName = post.getAuthor().equals("[deleted]") ? post.getSubredditNamePrefixed().substring(2) : post.getAuthor();
@@ -366,13 +396,13 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
if (iconImageUrl == null || iconImageUrl.equals("")) {
mGlide.load(R.drawable.subreddit_default_icon)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
- .into(((PostViewHolder) holder).iconGifImageView);
+ .into(((PostBaseViewHolder) holder).iconGifImageView);
} else {
mGlide.load(iconImageUrl)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
.error(mGlide.load(R.drawable.subreddit_default_icon)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
- .into(((PostViewHolder) holder).iconGifImageView);
+ .into(((PostBaseViewHolder) holder).iconGifImageView);
}
if (holder.getAdapterPosition() >= 0) {
@@ -385,426 +415,141 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
.error(mGlide.load(R.drawable.subreddit_default_icon)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
- .into(((PostViewHolder) holder).iconGifImageView);
+ .into(((PostBaseViewHolder) holder).iconGifImageView);
} else {
mGlide.load(R.drawable.subreddit_default_icon)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
- .into(((PostViewHolder) holder).iconGifImageView);
+ .into(((PostBaseViewHolder) holder).iconGifImageView);
}
-
- ((PostViewHolder) holder).subredditTextView.setOnClickListener(view -> {
- if (canStartActivity) {
- canStartActivity = false;
- if (post.getSubredditNamePrefixed().startsWith("u/")) {
- Intent intent = new Intent(mActivity, ViewUserDetailActivity.class);
- intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, post.getAuthor());
- mActivity.startActivity(intent);
- } else {
- Intent intent = new Intent(mActivity, ViewSubredditDetailActivity.class);
- intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY,
- post.getSubredditName());
- mActivity.startActivity(intent);
- }
- }
- });
-
- ((PostViewHolder) holder).iconGifImageView.setOnClickListener(view ->
- ((PostViewHolder) holder).userTextView.performClick());
}
if (mShowElapsedTime) {
- ((PostViewHolder) holder).postTimeTextView.setText(
+ ((PostBaseViewHolder) holder).postTimeTextView.setText(
Utils.getElapsedTime(mActivity, post.getPostTimeMillis()));
} else {
- ((PostViewHolder) holder).postTimeTextView.setText(postTime);
+ ((PostBaseViewHolder) holder).postTimeTextView.setText(post.getPostTime());
}
- ((PostViewHolder) holder).titleTextView.setText(title);
- ((PostViewHolder) holder).scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType()));
+ ((PostBaseViewHolder) holder).titleTextView.setText(post.getTitle());
+ ((PostBaseViewHolder) holder).scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType()));
if (post.isLocked()) {
- ((PostViewHolder) holder).lockedImageView.setVisibility(View.VISIBLE);
+ ((PostBaseViewHolder) holder).lockedImageView.setVisibility(View.VISIBLE);
}
- if (nsfw) {
- if (!(mActivity instanceof FilteredThingActivity)) {
- ((PostViewHolder) holder).nsfwTextView.setOnClickListener(view -> {
- Intent intent = new Intent(mActivity, FilteredThingActivity.class);
- intent.putExtra(FilteredThingActivity.EXTRA_NAME, post.getSubredditNamePrefixed().substring(2));
- intent.putExtra(FilteredThingActivity.EXTRA_POST_TYPE, PostDataSource.TYPE_SUBREDDIT);
- intent.putExtra(FilteredThingActivity.EXTRA_FILTER, Post.NSFW_TYPE);
- mActivity.startActivity(intent);
- });
- }
- ((PostViewHolder) holder).nsfwTextView.setVisibility(View.VISIBLE);
+ if (post.isNSFW()) {
+ ((PostBaseViewHolder) holder).nsfwTextView.setVisibility(View.VISIBLE);
}
- if (spoiler) {
- ((PostViewHolder) holder).spoilerTextView.setVisibility(View.VISIBLE);
+ if (post.isSpoiler()) {
+ ((PostBaseViewHolder) holder).spoilerTextView.setVisibility(View.VISIBLE);
}
if (flair != null && !flair.equals("")) {
- ((PostViewHolder) holder).flairTextView.setVisibility(View.VISIBLE);
- Spannable flairHTML;
- GlideImageGetter glideImageGetter = new GlideImageGetter(((PostViewHolder) holder).flairTextView);
- if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
- flairHTML = (Spannable) Html.fromHtml(flair, Html.FROM_HTML_MODE_LEGACY, glideImageGetter, null);
- } else {
- flairHTML = (Spannable) Html.fromHtml(flair, glideImageGetter, null);
- }
- ((PostViewHolder) holder).flairTextView.setText(flairHTML);
+ Utils.setHTMLWithImageToTextView(((PostBaseViewHolder) holder).flairTextView, flair);
}
if (nAwards > 0) {
- ((PostViewHolder) holder).awardsTextView.setVisibility(View.VISIBLE);
+ ((PostBaseViewHolder) holder).awardsTextView.setVisibility(View.VISIBLE);
if (nAwards == 1) {
- ((PostViewHolder) holder).awardsTextView.setText(mActivity.getString(R.string.one_award));
+ ((PostBaseViewHolder) holder).awardsTextView.setText(mActivity.getString(R.string.one_award));
} else {
- ((PostViewHolder) holder).awardsTextView.setText(mActivity.getString(R.string.n_awards, nAwards));
+ ((PostBaseViewHolder) holder).awardsTextView.setText(mActivity.getString(R.string.n_awards, nAwards));
}
}
- switch (voteType) {
+ switch (post.getVoteType()) {
case 1:
//Upvoted
- ((PostViewHolder) holder).upvoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
- ((PostViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor);
+ ((PostBaseViewHolder) holder).upvoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ ((PostBaseViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor);
break;
case -1:
//Downvoted
- ((PostViewHolder) holder).downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
- ((PostViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor);
+ ((PostBaseViewHolder) holder).downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ ((PostBaseViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor);
break;
}
- if (post.getPostType() != Post.TEXT_TYPE && post.getPostType() != Post.NO_PREVIEW_LINK_TYPE) {
- ((PostViewHolder) holder).relativeLayout.setVisibility(View.VISIBLE);
- ((PostViewHolder) holder).progressBar.setVisibility(View.VISIBLE);
- ((PostViewHolder) holder).imageView.setVisibility(View.VISIBLE);
- ((PostViewHolder) holder).imageView
- .setRatio((float) post.getPreviewHeight() / post.getPreviewWidth());
- loadImage(holder, post);
- }
-
if (mPostType == PostDataSource.TYPE_SUBREDDIT && !mDisplaySubredditName && post.isStickied()) {
- ((PostViewHolder) holder).stickiedPostImageView.setVisibility(View.VISIBLE);
- mGlide.load(R.drawable.ic_thumbtack_24dp).into(((PostViewHolder) holder).stickiedPostImageView);
+ ((PostBaseViewHolder) holder).stickiedPostImageView.setVisibility(View.VISIBLE);
+ mGlide.load(R.drawable.ic_thumbtack_24dp).into(((PostBaseViewHolder) holder).stickiedPostImageView);
}
- if (isArchived) {
- ((PostViewHolder) holder).archivedImageView.setVisibility(View.VISIBLE);
+ if (post.isArchived()) {
+ ((PostBaseViewHolder) holder).archivedImageView.setVisibility(View.VISIBLE);
- ((PostViewHolder) holder).upvoteButton
+ ((PostBaseViewHolder) holder).upvoteButton
.setColorFilter(mVoteAndReplyUnavailableVoteButtonColor, android.graphics.PorterDuff.Mode.SRC_IN);
- ((PostViewHolder) holder).downvoteButton
+ ((PostBaseViewHolder) holder).downvoteButton
.setColorFilter(mVoteAndReplyUnavailableVoteButtonColor, android.graphics.PorterDuff.Mode.SRC_IN);
}
if (post.isCrosspost()) {
- ((PostViewHolder) holder).crosspostImageView.setVisibility(View.VISIBLE);
+ ((PostBaseViewHolder) holder).crosspostImageView.setVisibility(View.VISIBLE);
}
- if (!(mActivity instanceof FilteredThingActivity)) {
- ((PostViewHolder) holder).typeTextView.setOnClickListener(view -> mCallback.typeChipClicked(post.getPostType()));
- }
-
- switch (post.getPostType()) {
- case Post.IMAGE_TYPE:
- ((PostViewHolder) holder).typeTextView.setText(R.string.image);
-
- final String imageUrl = post.getUrl();
- ((PostViewHolder) holder).imageView.setOnClickListener(view -> {
- Intent intent = new Intent(mActivity, ViewImageActivity.class);
- intent.putExtra(ViewImageActivity.IMAGE_URL_KEY, imageUrl);
- intent.putExtra(ViewImageActivity.FILE_NAME_KEY, subredditName
- + "-" + id + ".jpg");
- intent.putExtra(ViewImageActivity.POST_TITLE_KEY, post.getTitle());
- mActivity.startActivity(intent);
- });
-
- if (post.getPreviewWidth() <= 0 || post.getPreviewHeight() <= 0) {
- ((PostViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
- ((PostViewHolder) holder).imageView.getLayoutParams().height = (int) (400 * mScale);
- }
- break;
- case Post.LINK_TYPE:
- ((PostViewHolder) holder).typeTextView.setText(R.string.link);
-
- ((PostViewHolder) holder).linkTextView.setVisibility(View.VISIBLE);
- String domain = Uri.parse(post.getUrl()).getHost();
- ((PostViewHolder) holder).linkTextView.setText(domain);
-
- ((PostViewHolder) holder).imageView.setOnClickListener(view -> {
- Intent intent = new Intent(mActivity, LinkResolverActivity.class);
- Uri uri = Uri.parse(post.getUrl());
- if (uri.getScheme() == null && uri.getHost() == null) {
- intent.setData(LinkResolverActivity.getRedditUriByPath(post.getUrl()));
- } else {
- intent.setData(uri);
- }
- mActivity.startActivity(intent);
- });
- break;
- case Post.GIF_TYPE:
- ((PostViewHolder) holder).typeTextView.setText(R.string.gif);
+ ((PostBaseViewHolder) holder).commentsCountTextView.setText(Integer.toString(post.getNComments()));
- final Uri gifVideoUri = Uri.parse(post.getVideoUrl());
- ((PostViewHolder) holder).imageView.setOnClickListener(view -> {
- Intent intent = new Intent(mActivity, ViewGIFActivity.class);
- intent.setData(gifVideoUri);
- intent.putExtra(ViewGIFActivity.FILE_NAME_KEY, subredditName
- + "-" + id + ".gif");
- intent.putExtra(ViewGIFActivity.GIF_URL_KEY, post.getVideoUrl());
- intent.putExtra(ViewGIFActivity.POST_TITLE_KEY, post.getTitle());
- mActivity.startActivity(intent);
- });
-
- ((PostViewHolder) holder).playButtonImageView.setVisibility(View.VISIBLE);
- break;
- case Post.VIDEO_TYPE:
- ((PostViewHolder) holder).typeTextView.setText(R.string.video);
-
- final Uri videoUri = Uri.parse(post.getVideoUrl());
- ((PostViewHolder) holder).imageView.setOnClickListener(view -> {
- Intent intent = new Intent(mActivity, ViewVideoActivity.class);
- intent.setData(videoUri);
- intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl());
- intent.putExtra(ViewVideoActivity.EXTRA_SUBREDDIT, subredditName);
- intent.putExtra(ViewVideoActivity.EXTRA_ID, fullName);
- intent.putExtra(ViewVideoActivity.EXTRA_POST_TITLE, post.getTitle());
- mActivity.startActivity(intent);
- });
-
- ((PostViewHolder) holder).playButtonImageView.setVisibility(View.VISIBLE);
- break;
- case Post.NO_PREVIEW_LINK_TYPE:
- ((PostViewHolder) holder).typeTextView.setText(R.string.link);
-
- String noPreviewLinkUrl = post.getUrl();
- ((PostViewHolder) holder).linkTextView.setVisibility(View.VISIBLE);
- String noPreviewLinkDomain = Uri.parse(noPreviewLinkUrl).getHost();
- ((PostViewHolder) holder).linkTextView.setText(noPreviewLinkDomain);
- ((PostViewHolder) holder).noPreviewLinkImageView.setVisibility(View.VISIBLE);
- ((PostViewHolder) holder).noPreviewLinkImageView.setOnClickListener(view -> {
- Intent intent = new Intent(mActivity, LinkResolverActivity.class);
- Uri uri = Uri.parse(post.getUrl());
- if (uri.getScheme() == null && uri.getHost() == null) {
- intent.setData(LinkResolverActivity.getRedditUriByPath(post.getUrl()));
- } else {
- intent.setData(uri);
- }
- mActivity.startActivity(intent);
- });
- break;
- case Post.TEXT_TYPE:
- ((PostViewHolder) holder).typeTextView.setText(R.string.text);
- if (post.getSelfTextPlainTrimmed() != null && !post.getSelfTextPlainTrimmed().equals("")) {
- ((PostViewHolder) holder).contentTextView.setVisibility(View.VISIBLE);
- ((PostViewHolder) holder).contentTextView.setText(post.getSelfTextPlainTrimmed());
- }
- break;
+ if (post.isSaved()) {
+ ((PostBaseViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
+ } else {
+ ((PostBaseViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
}
- ((PostViewHolder) holder).upvoteButton.setOnClickListener(view -> {
- if (mAccessToken == null) {
- Toast.makeText(mActivity, R.string.login_first, Toast.LENGTH_SHORT).show();
- return;
- }
-
- if (isArchived) {
- Toast.makeText(mActivity, R.string.archived_post_vote_unavailable, Toast.LENGTH_SHORT).show();
- return;
- }
-
- ColorFilter previousUpvoteButtonColorFilter = ((PostViewHolder) holder).upvoteButton.getColorFilter();
- ColorFilter previousDownvoteButtonColorFilter = ((PostViewHolder) holder).downvoteButton.getColorFilter();
- int previousScoreTextViewColor = ((PostViewHolder) holder).scoreTextView.getCurrentTextColor();
-
- int previousVoteType = post.getVoteType();
- String newVoteType;
-
- ((PostViewHolder) holder).downvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
-
- if (previousVoteType != 1) {
- //Not upvoted before
- post.setVoteType(1);
- newVoteType = RedditUtils.DIR_UPVOTE;
- ((PostViewHolder) holder).upvoteButton
- .setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
- ((PostViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor);
+ if (holder instanceof PostVideoAutoplayViewHolder) {
+ ((PostVideoAutoplayViewHolder) holder).aspectRatioFrameLayout.setAspectRatio((float) post.getPreviewWidth() / post.getPreviewHeight());
+ ((PostVideoAutoplayViewHolder) holder).bindVideoUri(Uri.parse(post.getVideoUrl()));
+ } else if (holder instanceof PostGifAndVideoPreviewViewHolder) {
+ if (post.getPostType() == Post.VIDEO_TYPE) {
+ ((PostGifAndVideoPreviewViewHolder) holder).typeTextView.setText(mActivity.getString(R.string.video));
} else {
- //Upvoted before
- post.setVoteType(0);
- newVoteType = RedditUtils.DIR_UNVOTE;
- ((PostViewHolder) holder).upvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
- ((PostViewHolder) holder).scoreTextView.setTextColor(mPostIconAndInfoColor);
- }
-
- ((PostViewHolder) holder).scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType()));
-
- VoteThing.voteThing(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
- @Override
- public void onVoteThingSuccess(int position1) {
- if (newVoteType.equals(RedditUtils.DIR_UPVOTE)) {
- post.setVoteType(1);
- ((PostViewHolder) holder).upvoteButton
- .setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
- ((PostViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor);
- } else {
- post.setVoteType(0);
- ((PostViewHolder) holder).upvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
- ((PostViewHolder) holder).scoreTextView.setTextColor(mPostIconAndInfoColor);
- }
-
- ((PostViewHolder) holder).downvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
- ((PostViewHolder) holder).scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType()));
-
- EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
- }
-
- @Override
- public void onVoteThingFail(int position1) {
- Toast.makeText(mActivity, R.string.vote_failed, Toast.LENGTH_SHORT).show();
- post.setVoteType(previousVoteType);
- ((PostViewHolder) holder).scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + previousVoteType));
- ((PostViewHolder) holder).upvoteButton.setColorFilter(previousUpvoteButtonColorFilter);
- ((PostViewHolder) holder).downvoteButton.setColorFilter(previousDownvoteButtonColorFilter);
- ((PostViewHolder) holder).scoreTextView.setTextColor(previousScoreTextViewColor);
-
- EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
- }
- }, fullName, newVoteType, holder.getAdapterPosition());
- });
-
- ((PostViewHolder) holder).downvoteButton.setOnClickListener(view -> {
- if (mAccessToken == null) {
- Toast.makeText(mActivity, R.string.login_first, Toast.LENGTH_SHORT).show();
- return;
+ ((PostGifAndVideoPreviewViewHolder) holder).typeTextView.setText(mActivity.getString(R.string.gif));
}
+ ((PostGifAndVideoPreviewViewHolder) holder).progressBar.setVisibility(View.VISIBLE);
+ ((PostGifAndVideoPreviewViewHolder) holder).imageView
+ .setRatio((float) post.getPreviewHeight() / post.getPreviewWidth());
+ loadImage(holder, post);
- if (isArchived) {
- Toast.makeText(mActivity, R.string.archived_post_vote_unavailable, Toast.LENGTH_SHORT).show();
- return;
+ if (post.getPreviewWidth() <= 0 || post.getPreviewHeight() <= 0) {
+ ((PostGifAndVideoPreviewViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
+ ((PostGifAndVideoPreviewViewHolder) holder).imageView.getLayoutParams().height = (int) (400 * mScale);
}
-
- ColorFilter previousUpvoteButtonColorFilter = ((PostViewHolder) holder).upvoteButton.getColorFilter();
- ColorFilter previousDownvoteButtonColorFilter = ((PostViewHolder) holder).downvoteButton.getColorFilter();
- int previousScoreTextViewColor = ((PostViewHolder) holder).scoreTextView.getCurrentTextColor();
-
- int previousVoteType = post.getVoteType();
- String newVoteType;
-
- ((PostViewHolder) holder).upvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
-
- if (previousVoteType != -1) {
- //Not downvoted before
- post.setVoteType(-1);
- newVoteType = RedditUtils.DIR_DOWNVOTE;
- ((PostViewHolder) holder).downvoteButton
- .setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
- ((PostViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor);
+ } else if (holder instanceof PostImageAndGifAutoplayTypeViewHolder) {
+ if (post.getPostType() == Post.GIF_TYPE) {
+ ((PostImageAndGifAutoplayTypeViewHolder) holder).typeTextView.setText(mActivity.getString(R.string.gif));
} else {
- //Downvoted before
- post.setVoteType(0);
- newVoteType = RedditUtils.DIR_UNVOTE;
- ((PostViewHolder) holder).downvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
- ((PostViewHolder) holder).scoreTextView.setTextColor(mPostIconAndInfoColor);
+ ((PostImageAndGifAutoplayTypeViewHolder) holder).typeTextView.setText(mActivity.getString(R.string.image));
}
+ ((PostImageAndGifAutoplayTypeViewHolder) holder).progressBar.setVisibility(View.VISIBLE);
+ ((PostImageAndGifAutoplayTypeViewHolder) holder).imageView
+ .setRatio((float) post.getPreviewHeight() / post.getPreviewWidth());
+ loadImage(holder, post);
- ((PostViewHolder) holder).scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType()));
-
- VoteThing.voteThing(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
- @Override
- public void onVoteThingSuccess(int position1) {
- if (newVoteType.equals(RedditUtils.DIR_DOWNVOTE)) {
- post.setVoteType(-1);
- ((PostViewHolder) holder).downvoteButton
- .setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
- ((PostViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor);
- } else {
- post.setVoteType(0);
- ((PostViewHolder) holder).downvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
- ((PostViewHolder) holder).scoreTextView.setTextColor(mPostIconAndInfoColor);
- }
-
- ((PostViewHolder) holder).upvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
- ((PostViewHolder) holder).scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType()));
-
- EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
- }
-
- @Override
- public void onVoteThingFail(int position1) {
- Toast.makeText(mActivity, R.string.vote_failed, Toast.LENGTH_SHORT).show();
- post.setVoteType(previousVoteType);
- ((PostViewHolder) holder).scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + previousVoteType));
- ((PostViewHolder) holder).upvoteButton.setColorFilter(previousUpvoteButtonColorFilter);
- ((PostViewHolder) holder).downvoteButton.setColorFilter(previousDownvoteButtonColorFilter);
- ((PostViewHolder) holder).scoreTextView.setTextColor(previousScoreTextViewColor);
-
- EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
- }
- }, fullName, newVoteType, holder.getAdapterPosition());
- });
-
- ((PostViewHolder) holder).commentsCountTextView.setText(Integer.toString(post.getNComments()));
-
- if (post.isSaved()) {
- ((PostViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
- } else {
- ((PostViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
- }
-
- ((PostViewHolder) holder).saveButton.setOnClickListener(view -> {
- if (mAccessToken == null) {
- Toast.makeText(mActivity, R.string.login_first, Toast.LENGTH_SHORT).show();
- return;
+ if (post.getPreviewWidth() <= 0 || post.getPreviewHeight() <= 0) {
+ ((PostImageAndGifAutoplayTypeViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
+ ((PostImageAndGifAutoplayTypeViewHolder) holder).imageView.getLayoutParams().height = (int) (400 * mScale);
}
+ } else if (holder instanceof PostLinkTypeViewHolder) {
+ ((PostLinkTypeViewHolder) holder).progressBar.setVisibility(View.VISIBLE);
+ ((PostLinkTypeViewHolder) holder).imageView
+ .setRatio((float) post.getPreviewHeight() / post.getPreviewWidth());
+ loadImage(holder, post);
- if (post.isSaved()) {
- ((PostViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
- SaveThing.unsaveThing(mOauthRetrofit, mAccessToken, post.getFullName(),
- new SaveThing.SaveThingListener() {
- @Override
- public void success() {
- post.setSaved(false);
- ((PostViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
- Toast.makeText(mActivity, R.string.post_unsaved_success, Toast.LENGTH_SHORT).show();
- EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
- }
-
- @Override
- public void failed() {
- post.setSaved(true);
- ((PostViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
- Toast.makeText(mActivity, R.string.post_unsaved_failed, Toast.LENGTH_SHORT).show();
- EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
- }
- });
- } else {
- ((PostViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
- SaveThing.saveThing(mOauthRetrofit, mAccessToken, post.getFullName(),
- new SaveThing.SaveThingListener() {
- @Override
- public void success() {
- post.setSaved(true);
- ((PostViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
- Toast.makeText(mActivity, R.string.post_saved_success, Toast.LENGTH_SHORT).show();
- EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
- }
-
- @Override
- public void failed() {
- post.setSaved(false);
- ((PostViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
- Toast.makeText(mActivity, R.string.post_saved_failed, Toast.LENGTH_SHORT).show();
- EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
- }
- });
+ ((PostLinkTypeViewHolder) holder).linkTextView.setVisibility(View.VISIBLE);
+ String domain = Uri.parse(post.getUrl()).getHost();
+ ((PostLinkTypeViewHolder) holder).linkTextView.setText(domain);
+ } else if (holder instanceof PostNoPreviewLinkTypeViewHolder) {
+ String noPreviewLinkUrl = post.getUrl();
+ ((PostNoPreviewLinkTypeViewHolder) holder).linkTextView.setVisibility(View.VISIBLE);
+ String noPreviewLinkDomain = Uri.parse(noPreviewLinkUrl).getHost();
+ ((PostNoPreviewLinkTypeViewHolder) holder).linkTextView.setText(noPreviewLinkDomain);
+ } else if (holder instanceof PostTextTypeViewHolder) {
+ if (post.getSelfTextPlainTrimmed() != null && !post.getSelfTextPlainTrimmed().equals("")) {
+ ((PostTextTypeViewHolder) holder).contentTextView.setVisibility(View.VISIBLE);
+ ((PostTextTypeViewHolder) holder).contentTextView.setText(post.getSelfTextPlainTrimmed());
}
- });
-
- ((PostViewHolder) holder).shareButton.setOnClickListener(view -> shareLink(post));
+ }
}
} else if (holder instanceof PostCompactViewHolder) {
Post post = getItem(position);
@@ -1359,15 +1104,72 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
}
private void loadImage(final RecyclerView.ViewHolder holder, final Post post) {
- if (holder instanceof PostViewHolder) {
+ if (holder instanceof PostImageAndGifAutoplayTypeViewHolder) {
+ String url = mAutoplay && post.getPostType() == Post.GIF_TYPE ? post.getUrl() : post.getPreviewUrl();
+ RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(url).listener(new RequestListener<Drawable>() {
+ @Override
+ public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
+ ((PostImageAndGifAutoplayTypeViewHolder) holder).progressBar.setVisibility(View.GONE);
+ ((PostImageAndGifAutoplayTypeViewHolder) holder).errorRelativeLayout.setVisibility(View.VISIBLE);
+ ((PostImageAndGifAutoplayTypeViewHolder) holder).errorRelativeLayout.setOnClickListener(view -> {
+ ((PostImageAndGifAutoplayTypeViewHolder) holder).progressBar.setVisibility(View.VISIBLE);
+ ((PostImageAndGifAutoplayTypeViewHolder) holder).errorRelativeLayout.setVisibility(View.GONE);
+ loadImage(holder, post);
+ });
+ return false;
+ }
+
+ @Override
+ public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
+ ((PostImageAndGifAutoplayTypeViewHolder) holder).errorRelativeLayout.setVisibility(View.GONE);
+ ((PostImageAndGifAutoplayTypeViewHolder) holder).progressBar.setVisibility(View.GONE);
+ return false;
+ }
+ });
+
+ if ((post.isNSFW() && mNeedBlurNSFW) || post.isSpoiler() && mNeedBlurSpoiler) {
+ imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
+ .into(((PostImageAndGifAutoplayTypeViewHolder) holder).imageView);
+ } else {
+ imageRequestBuilder.into(((PostImageAndGifAutoplayTypeViewHolder) holder).imageView);
+ }
+ } else if (holder instanceof PostGifAndVideoPreviewViewHolder) {
+ RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(post.getPreviewUrl()).listener(new RequestListener<Drawable>() {
+ @Override
+ public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
+ ((PostGifAndVideoPreviewViewHolder) holder).progressBar.setVisibility(View.GONE);
+ ((PostGifAndVideoPreviewViewHolder) holder).errorRelativeLayout.setVisibility(View.VISIBLE);
+ ((PostGifAndVideoPreviewViewHolder) holder).errorRelativeLayout.setOnClickListener(view -> {
+ ((PostGifAndVideoPreviewViewHolder) holder).progressBar.setVisibility(View.VISIBLE);
+ ((PostGifAndVideoPreviewViewHolder) holder).errorRelativeLayout.setVisibility(View.GONE);
+ loadImage(holder, post);
+ });
+ return false;
+ }
+
+ @Override
+ public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
+ ((PostGifAndVideoPreviewViewHolder) holder).errorRelativeLayout.setVisibility(View.GONE);
+ ((PostGifAndVideoPreviewViewHolder) holder).progressBar.setVisibility(View.GONE);
+ return false;
+ }
+ });
+
+ if ((post.isNSFW() && mNeedBlurNSFW) || post.isSpoiler() && mNeedBlurSpoiler) {
+ imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
+ .into(((PostGifAndVideoPreviewViewHolder) holder).imageView);
+ } else {
+ imageRequestBuilder.into(((PostGifAndVideoPreviewViewHolder) holder).imageView);
+ }
+ } else if (holder instanceof PostLinkTypeViewHolder) {
RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(post.getPreviewUrl()).listener(new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
- ((PostViewHolder) holder).progressBar.setVisibility(View.GONE);
- ((PostViewHolder) holder).errorRelativeLayout.setVisibility(View.VISIBLE);
- ((PostViewHolder) holder).errorRelativeLayout.setOnClickListener(view -> {
- ((PostViewHolder) holder).progressBar.setVisibility(View.VISIBLE);
- ((PostViewHolder) holder).errorRelativeLayout.setVisibility(View.GONE);
+ ((PostLinkTypeViewHolder) holder).progressBar.setVisibility(View.GONE);
+ ((PostLinkTypeViewHolder) holder).errorRelativeLayout.setVisibility(View.VISIBLE);
+ ((PostLinkTypeViewHolder) holder).errorRelativeLayout.setOnClickListener(view -> {
+ ((PostLinkTypeViewHolder) holder).progressBar.setVisibility(View.VISIBLE);
+ ((PostLinkTypeViewHolder) holder).errorRelativeLayout.setVisibility(View.GONE);
loadImage(holder, post);
});
return false;
@@ -1375,17 +1177,17 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
@Override
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
- ((PostViewHolder) holder).errorRelativeLayout.setVisibility(View.GONE);
- ((PostViewHolder) holder).progressBar.setVisibility(View.GONE);
+ ((PostLinkTypeViewHolder) holder).errorRelativeLayout.setVisibility(View.GONE);
+ ((PostLinkTypeViewHolder) holder).progressBar.setVisibility(View.GONE);
return false;
}
});
if ((post.isNSFW() && mNeedBlurNSFW) || post.isSpoiler() && mNeedBlurSpoiler) {
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
- .into(((PostViewHolder) holder).imageView);
+ .into(((PostLinkTypeViewHolder) holder).imageView);
} else {
- imageRequestBuilder.into(((PostViewHolder) holder).imageView);
+ imageRequestBuilder.into(((PostLinkTypeViewHolder) holder).imageView);
}
} else if (holder instanceof PostCompactViewHolder) {
String previewUrl = post.getThumbnailPreviewUrl().equals("") ? post.getPreviewUrl() : post.getThumbnailPreviewUrl();
@@ -1435,20 +1237,6 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
}
@Override
- public int getItemViewType(int position) {
- // Reached at the end
- if (hasExtraRow() && position == getItemCount() - 1) {
- if (networkState.getStatus() == NetworkState.Status.LOADING) {
- return VIEW_TYPE_LOADING;
- } else {
- return VIEW_TYPE_ERROR;
- }
- } else {
- return VIEW_TYPE_DATA;
- }
- }
-
- @Override
public int getItemCount() {
if (hasExtraRow()) {
return super.getItemCount() + 1;
@@ -1512,35 +1300,45 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
networkState = null;
}
+ public void setAutoplay(boolean autoplay) {
+ mAutoplay = autoplay;
+ }
+
@Override
public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
super.onViewRecycled(holder);
- if (holder instanceof PostViewHolder) {
- mGlide.clear(((PostViewHolder) holder).imageView);
- mGlide.clear(((PostViewHolder) holder).iconGifImageView);
- ((PostViewHolder) holder).stickiedPostImageView.setVisibility(View.GONE);
- ((PostViewHolder) holder).relativeLayout.setVisibility(View.GONE);
- ((PostViewHolder) holder).crosspostImageView.setVisibility(View.GONE);
- ((PostViewHolder) holder).archivedImageView.setVisibility(View.GONE);
- ((PostViewHolder) holder).lockedImageView.setVisibility(View.GONE);
- ((PostViewHolder) holder).nsfwTextView.setVisibility(View.GONE);
- ((PostViewHolder) holder).spoilerTextView.setVisibility(View.GONE);
- ((PostViewHolder) holder).flairTextView.setVisibility(View.GONE);
- ((PostViewHolder) holder).flairTextView.setText("");
- ((PostViewHolder) holder).awardsTextView.setVisibility(View.GONE);
- ((PostViewHolder) holder).awardsTextView.setText("");
- ((PostViewHolder) holder).linkTextView.setVisibility(View.GONE);
- ((PostViewHolder) holder).progressBar.setVisibility(View.GONE);
- ((PostViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.FIT_START);
- ((PostViewHolder) holder).imageView.getLayoutParams().height = FrameLayout.LayoutParams.WRAP_CONTENT;
- ((PostViewHolder) holder).imageView.setVisibility(View.GONE);
- ((PostViewHolder) holder).playButtonImageView.setVisibility(View.GONE);
- ((PostViewHolder) holder).errorRelativeLayout.setVisibility(View.GONE);
- ((PostViewHolder) holder).noPreviewLinkImageView.setVisibility(View.GONE);
- ((PostViewHolder) holder).contentTextView.setVisibility(View.GONE);
- ((PostViewHolder) holder).upvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
- ((PostViewHolder) holder).scoreTextView.setTextColor(mPostIconAndInfoColor);
- ((PostViewHolder) holder).downvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ if (holder instanceof PostBaseViewHolder) {
+ if (holder instanceof PostVideoAutoplayViewHolder) {
+ ((PostVideoAutoplayViewHolder) holder).muteButton.setImageDrawable(mActivity.getDrawable(R.drawable.ic_mute_24dp));
+ ((PostVideoAutoplayViewHolder) holder).muteButton.setVisibility(View.GONE);
+ } else if (holder instanceof PostImageAndGifAutoplayTypeViewHolder) {
+ mGlide.clear(((PostImageAndGifAutoplayTypeViewHolder) holder).imageView);
+ ((PostImageAndGifAutoplayTypeViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.FIT_START);
+ ((PostImageAndGifAutoplayTypeViewHolder) holder).imageView.getLayoutParams().height = FrameLayout.LayoutParams.WRAP_CONTENT;
+ ((PostImageAndGifAutoplayTypeViewHolder) holder).errorRelativeLayout.setVisibility(View.GONE);
+ } else if (holder instanceof PostLinkTypeViewHolder) {
+ mGlide.clear(((PostLinkTypeViewHolder) holder).imageView);
+ ((PostLinkTypeViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.FIT_START);
+ ((PostLinkTypeViewHolder) holder).imageView.getLayoutParams().height = FrameLayout.LayoutParams.WRAP_CONTENT;
+ ((PostLinkTypeViewHolder) holder).errorRelativeLayout.setVisibility(View.GONE);
+ } else if (holder instanceof PostTextTypeViewHolder) {
+ ((PostTextTypeViewHolder) holder).contentTextView.setVisibility(View.GONE);
+ }
+
+ mGlide.clear(((PostBaseViewHolder) holder).iconGifImageView);
+ ((PostBaseViewHolder) holder).stickiedPostImageView.setVisibility(View.GONE);
+ ((PostBaseViewHolder) holder).crosspostImageView.setVisibility(View.GONE);
+ ((PostBaseViewHolder) holder).archivedImageView.setVisibility(View.GONE);
+ ((PostBaseViewHolder) holder).lockedImageView.setVisibility(View.GONE);
+ ((PostBaseViewHolder) holder).nsfwTextView.setVisibility(View.GONE);
+ ((PostBaseViewHolder) holder).spoilerTextView.setVisibility(View.GONE);
+ ((PostBaseViewHolder) holder).flairTextView.setVisibility(View.GONE);
+ ((PostBaseViewHolder) holder).flairTextView.setText("");
+ ((PostBaseViewHolder) holder).awardsTextView.setVisibility(View.GONE);
+ ((PostBaseViewHolder) holder).awardsTextView.setText("");
+ ((PostBaseViewHolder) holder).upvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ ((PostBaseViewHolder) holder).scoreTextView.setTextColor(mPostIconAndInfoColor);
+ ((PostBaseViewHolder) holder).downvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
} else if (holder instanceof PostCompactViewHolder) {
mGlide.clear(((PostCompactViewHolder) holder).imageView);
mGlide.clear(((PostCompactViewHolder) holder).iconGifImageView);
@@ -1566,80 +1364,105 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
}
}
+ @Nullable
+ @Override
+ public Object getKeyForOrder(int order) {
+ if (super.getItemCount() <= 0 || order >= super.getItemCount()) {
+ return null;
+ }
+ return getItem(order);
+ }
+
+ @Nullable
+ @Override
+ public Integer getOrderForKey(@NonNull Object key) {
+ if (getCurrentList() != null && key instanceof Post) {
+ return getCurrentList().indexOf(key);
+ }
+
+ return null;
+ }
+
public interface Callback {
void retryLoadingMore();
void typeChipClicked(int filter);
}
- class PostViewHolder extends RecyclerView.ViewHolder {
- @BindView(R.id.card_view_item_post)
+ class PostBaseViewHolder extends RecyclerView.ViewHolder {
MaterialCardView cardView;
- @BindView(R.id.icon_gif_image_view_item_post)
AspectRatioGifImageView iconGifImageView;
- @BindView(R.id.subreddit_name_text_view_item_post)
TextView subredditTextView;
- @BindView(R.id.user_text_view_item_post)
TextView userTextView;
- @BindView(R.id.stickied_post_image_view_item_post)
ImageView stickiedPostImageView;
- @BindView(R.id.post_time_text_view_best_item_post)
TextView postTimeTextView;
- @BindView(R.id.title_text_view_best_item_post)
TextView titleTextView;
- @BindView(R.id.type_text_view_item_post)
CustomTextView typeTextView;
- @BindView(R.id.archived_image_view_item_post)
ImageView archivedImageView;
- @BindView(R.id.locked_image_view_item_post)
ImageView lockedImageView;
- @BindView(R.id.crosspost_image_view_item_post)
ImageView crosspostImageView;
- @BindView(R.id.nsfw_text_view_item_post)
CustomTextView nsfwTextView;
- @BindView(R.id.spoiler_custom_text_view_item_post)
CustomTextView spoilerTextView;
- @BindView(R.id.flair_custom_text_view_item_post)
CustomTextView flairTextView;
- @BindView(R.id.awards_text_view_item_post)
CustomTextView awardsTextView;
- @BindView(R.id.link_text_view_item_post)
- TextView linkTextView;
- @BindView(R.id.image_view_wrapper_item_post)
- RelativeLayout relativeLayout;
- @BindView(R.id.progress_bar_item_post)
- ProgressBar progressBar;
- @BindView(R.id.image_view_best_post_item)
- AspectRatioGifImageView imageView;
- @BindView(R.id.play_button_image_view_item_post)
- ImageView playButtonImageView;
- @BindView(R.id.load_image_error_relative_layout_item_post)
- RelativeLayout errorRelativeLayout;
- @BindView(R.id.image_view_no_preview_link_item_post)
- ImageView noPreviewLinkImageView;
- @BindView(R.id.content_text_view_item_post)
- TextView contentTextView;
- @BindView(R.id.bottom_constraint_layout_item_post)
ConstraintLayout bottomConstraintLayout;
- @BindView(R.id.plus_button_item_post)
ImageView upvoteButton;
- @BindView(R.id.score_text_view_item_post)
TextView scoreTextView;
- @BindView(R.id.minus_button_item_post)
ImageView downvoteButton;
- @BindView(R.id.comments_count_item_post)
TextView commentsCountTextView;
- @BindView(R.id.save_button_item_post)
ImageView saveButton;
- @BindView(R.id.share_button_item_post)
ImageView shareButton;
- PostViewHolder(View itemView) {
+ PostBaseViewHolder(@NonNull View itemView) {
super(itemView);
- ButterKnife.bind(this, itemView);
- scoreTextView.setOnClickListener(view -> {
- //Do nothing in order to prevent clicking this to start ViewPostDetailActivity
- });
+ }
+
+ void setBaseView(MaterialCardView cardView,
+ AspectRatioGifImageView iconGifImageView,
+ TextView subredditTextView,
+ TextView userTextView,
+ ImageView stickiedPostImageView,
+ TextView postTimeTextView,
+ TextView titleTextView,
+ CustomTextView typeTextView,
+ ImageView archivedImageView,
+ ImageView lockedImageView,
+ ImageView crosspostImageView,
+ CustomTextView nsfwTextView,
+ CustomTextView spoilerTextView,
+ CustomTextView flairTextView,
+ CustomTextView awardsTextView,
+ ConstraintLayout bottomConstraintLayout,
+ ImageView upvoteButton,
+ TextView scoreTextView,
+ ImageView downvoteButton,
+ TextView commentsCountTextView,
+ ImageView saveButton,
+ ImageView shareButton) {
+ this.cardView = cardView;
+ this.iconGifImageView = iconGifImageView;
+ this.subredditTextView = subredditTextView;
+ this.userTextView = userTextView;
+ this.stickiedPostImageView = stickiedPostImageView;
+ this.postTimeTextView = postTimeTextView;
+ this.titleTextView = titleTextView;
+ this.typeTextView = typeTextView;
+ this.archivedImageView = archivedImageView;
+ this.lockedImageView = lockedImageView;
+ this.crosspostImageView = crosspostImageView;
+ this.nsfwTextView = nsfwTextView;
+ this.spoilerTextView = spoilerTextView;
+ this.flairTextView = flairTextView;
+ this.awardsTextView = awardsTextView;
+ this.bottomConstraintLayout = bottomConstraintLayout;
+ this.upvoteButton = upvoteButton;
+ this.scoreTextView = scoreTextView;
+ this.downvoteButton = downvoteButton;
+ this.commentsCountTextView = commentsCountTextView;
+ this.saveButton = saveButton;
+ this.shareButton = shareButton;
+
+ scoreTextView.setOnClickListener(null);
if (mVoteButtonsOnTheRight) {
ConstraintSet constraintSet = new ConstraintSet();
@@ -1665,7 +1488,6 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
userTextView.setTextColor(mUsernameColor);
postTimeTextView.setTextColor(mSecondaryTextColor);
titleTextView.setTextColor(mPostTitleColor);
- contentTextView.setTextColor(mPostContentColor);
stickiedPostImageView.setColorFilter(mStickiedPostIconTint, PorterDuff.Mode.SRC_IN);
typeTextView.setBackgroundColor(mPostTypeBackgroundColor);
typeTextView.setBorderColor(mPostTypeBackgroundColor);
@@ -1685,9 +1507,6 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
archivedImageView.setColorFilter(mArchivedIconTint, PorterDuff.Mode.SRC_IN);
lockedImageView.setColorFilter(mLockedIconTint, PorterDuff.Mode.SRC_IN);
crosspostImageView.setColorFilter(mCrosspostIconTint, PorterDuff.Mode.SRC_IN);
- linkTextView.setTextColor(mSecondaryTextColor);
- progressBar.setIndeterminateTintList(ColorStateList.valueOf(mColorAccent));
- noPreviewLinkImageView.setBackgroundColor(mNoPreviewLinkBackgroundColor);
upvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
scoreTextView.setTextColor(mPostIconAndInfoColor);
downvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
@@ -1695,6 +1514,982 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
commentsCountTextView.setCompoundDrawablesWithIntrinsicBounds(mCommentIcon, null, null, null);
saveButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
shareButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+
+ cardView.setOnClickListener(view -> {
+ if (canStartActivity) {
+ canStartActivity = false;
+
+ Intent intent = new Intent(mActivity, ViewPostDetailActivity.class);
+ intent.putExtra(ViewPostDetailActivity.EXTRA_POST_DATA, getItem(getAdapterPosition()));
+ intent.putExtra(ViewPostDetailActivity.EXTRA_POST_LIST_POSITION, getAdapterPosition());
+ mActivity.startActivity(intent);
+ }
+ });
+
+ userTextView.setOnClickListener(view -> {
+ if (canStartActivity) {
+ Post post = getItem(getAdapterPosition());
+ if (post != null) {
+ canStartActivity = false;
+ Intent intent = new Intent(mActivity, ViewUserDetailActivity.class);
+ intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, post.getAuthor());
+ mActivity.startActivity(intent);
+ }
+ }
+ });
+
+ if (mDisplaySubredditName) {
+ subredditTextView.setOnClickListener(view -> {
+ Post post = getItem(getAdapterPosition());
+ if (post != null) {
+ if (canStartActivity) {
+ canStartActivity = false;
+ if (post.getSubredditNamePrefixed().startsWith("u/")) {
+ Intent intent = new Intent(mActivity, ViewUserDetailActivity.class);
+ intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY,
+ post.getSubredditNamePrefixed().substring(2));
+ mActivity.startActivity(intent);
+ } else {
+ Intent intent = new Intent(mActivity, ViewSubredditDetailActivity.class);
+ intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY,
+ post.getSubredditName());
+ mActivity.startActivity(intent);
+ }
+ }
+ }
+ });
+
+ iconGifImageView.setOnClickListener(view -> subredditTextView.performClick());
+ } else {
+ subredditTextView.setOnClickListener(view -> {
+ Post post = getItem(getAdapterPosition());
+ if (post != null) {
+ if (canStartActivity) {
+ canStartActivity = false;
+ if (post.getSubredditNamePrefixed().startsWith("u/")) {
+ Intent intent = new Intent(mActivity, ViewUserDetailActivity.class);
+ intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, post.getAuthor());
+ mActivity.startActivity(intent);
+ } else {
+ Intent intent = new Intent(mActivity, ViewSubredditDetailActivity.class);
+ intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY,
+ post.getSubredditName());
+ mActivity.startActivity(intent);
+ }
+ }
+ }
+ });
+
+ iconGifImageView.setOnClickListener(view -> userTextView.performClick());
+ }
+
+ if (!(mActivity instanceof FilteredThingActivity)) {
+ nsfwTextView.setOnClickListener(view -> {
+ Post post = getItem(getAdapterPosition());
+ if (post != null) {
+ Intent intent = new Intent(mActivity, FilteredThingActivity.class);
+ intent.putExtra(FilteredThingActivity.EXTRA_NAME, post.getSubredditNamePrefixed().substring(2));
+ intent.putExtra(FilteredThingActivity.EXTRA_POST_TYPE, PostDataSource.TYPE_SUBREDDIT);
+ intent.putExtra(FilteredThingActivity.EXTRA_FILTER, Post.NSFW_TYPE);
+ mActivity.startActivity(intent);
+ }
+ });
+ typeTextView.setOnClickListener(view -> {
+ Post post = getItem(getAdapterPosition());
+ if (post != null) {
+ mCallback.typeChipClicked(post.getPostType());
+ }
+ });
+ }
+
+ upvoteButton.setOnClickListener(view -> {
+ Post post = getItem(getAdapterPosition());
+ if (post != null) {
+ if (mAccessToken == null) {
+ Toast.makeText(mActivity, R.string.login_first, Toast.LENGTH_SHORT).show();
+ return;
+ }
+
+ if (post.isArchived()) {
+ Toast.makeText(mActivity, R.string.archived_post_vote_unavailable, Toast.LENGTH_SHORT).show();
+ return;
+ }
+
+ ColorFilter previousUpvoteButtonColorFilter = upvoteButton.getColorFilter();
+ ColorFilter previousDownvoteButtonColorFilter = downvoteButton.getColorFilter();
+ int previousScoreTextViewColor = scoreTextView.getCurrentTextColor();
+
+ int previousVoteType = post.getVoteType();
+ String newVoteType;
+
+ downvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+
+ if (previousVoteType != 1) {
+ //Not upvoted before
+ post.setVoteType(1);
+ newVoteType = RedditUtils.DIR_UPVOTE;
+ upvoteButton
+ .setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ scoreTextView.setTextColor(mUpvotedColor);
+ } else {
+ //Upvoted before
+ post.setVoteType(0);
+ newVoteType = RedditUtils.DIR_UNVOTE;
+ upvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ scoreTextView.setTextColor(mPostIconAndInfoColor);
+ }
+
+ scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType()));
+
+ VoteThing.voteThing(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
+ @Override
+ public void onVoteThingSuccess(int position1) {
+ if (newVoteType.equals(RedditUtils.DIR_UPVOTE)) {
+ post.setVoteType(1);
+ upvoteButton
+ .setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ scoreTextView.setTextColor(mUpvotedColor);
+ } else {
+ post.setVoteType(0);
+ upvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ scoreTextView.setTextColor(mPostIconAndInfoColor);
+ }
+
+ downvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType()));
+
+ EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
+ }
+
+ @Override
+ public void onVoteThingFail(int position1) {
+ Toast.makeText(mActivity, R.string.vote_failed, Toast.LENGTH_SHORT).show();
+ post.setVoteType(previousVoteType);
+ scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + previousVoteType));
+ upvoteButton.setColorFilter(previousUpvoteButtonColorFilter);
+ downvoteButton.setColorFilter(previousDownvoteButtonColorFilter);
+ scoreTextView.setTextColor(previousScoreTextViewColor);
+
+ EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
+ }
+ }, post.getFullName(), newVoteType, getAdapterPosition());
+ }
+ });
+
+ downvoteButton.setOnClickListener(view -> {
+ Post post = getItem(getAdapterPosition());
+ if (post != null) {
+ if (mAccessToken == null) {
+ Toast.makeText(mActivity, R.string.login_first, Toast.LENGTH_SHORT).show();
+ return;
+ }
+
+ if (post.isArchived()) {
+ Toast.makeText(mActivity, R.string.archived_post_vote_unavailable, Toast.LENGTH_SHORT).show();
+ return;
+ }
+
+ ColorFilter previousUpvoteButtonColorFilter = upvoteButton.getColorFilter();
+ ColorFilter previousDownvoteButtonColorFilter = downvoteButton.getColorFilter();
+ int previousScoreTextViewColor = scoreTextView.getCurrentTextColor();
+
+ int previousVoteType = post.getVoteType();
+ String newVoteType;
+
+ upvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+
+ if (previousVoteType != -1) {
+ //Not downvoted before
+ post.setVoteType(-1);
+ newVoteType = RedditUtils.DIR_DOWNVOTE;
+ downvoteButton
+ .setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ scoreTextView.setTextColor(mDownvotedColor);
+ } else {
+ //Downvoted before
+ post.setVoteType(0);
+ newVoteType = RedditUtils.DIR_UNVOTE;
+ downvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ scoreTextView.setTextColor(mPostIconAndInfoColor);
+ }
+
+ scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType()));
+
+ VoteThing.voteThing(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
+ @Override
+ public void onVoteThingSuccess(int position1) {
+ if (newVoteType.equals(RedditUtils.DIR_DOWNVOTE)) {
+ post.setVoteType(-1);
+ downvoteButton
+ .setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ scoreTextView.setTextColor(mDownvotedColor);
+ } else {
+ post.setVoteType(0);
+ downvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ scoreTextView.setTextColor(mPostIconAndInfoColor);
+ }
+
+ upvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
+ scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType()));
+
+ EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
+ }
+
+ @Override
+ public void onVoteThingFail(int position1) {
+ Toast.makeText(mActivity, R.string.vote_failed, Toast.LENGTH_SHORT).show();
+ post.setVoteType(previousVoteType);
+ scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + previousVoteType));
+ upvoteButton.setColorFilter(previousUpvoteButtonColorFilter);
+ downvoteButton.setColorFilter(previousDownvoteButtonColorFilter);
+ scoreTextView.setTextColor(previousScoreTextViewColor);
+
+ EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
+ }
+ }, post.getFullName(), newVoteType, getAdapterPosition());
+ }
+ });
+
+ saveButton.setOnClickListener(view -> {
+ Post post = getItem(getAdapterPosition());
+ if (post != null) {
+ if (mAccessToken == null) {
+ Toast.makeText(mActivity, R.string.login_first, Toast.LENGTH_SHORT).show();
+ return;
+ }
+
+ if (post.isSaved()) {
+ saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
+ SaveThing.unsaveThing(mOauthRetrofit, mAccessToken, post.getFullName(),
+ new SaveThing.SaveThingListener() {
+ @Override
+ public void success() {
+ post.setSaved(false);
+ saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
+ Toast.makeText(mActivity, R.string.post_unsaved_success, Toast.LENGTH_SHORT).show();
+ EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
+ }
+
+ @Override
+ public void failed() {
+ post.setSaved(true);
+ saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
+ Toast.makeText(mActivity, R.string.post_unsaved_failed, Toast.LENGTH_SHORT).show();
+ EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
+ }
+ });
+ } else {
+ saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
+ SaveThing.saveThing(mOauthRetrofit, mAccessToken, post.getFullName(),
+ new SaveThing.SaveThingListener() {
+ @Override
+ public void success() {
+ post.setSaved(true);
+ saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
+ Toast.makeText(mActivity, R.string.post_saved_success, Toast.LENGTH_SHORT).show();
+ EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
+ }
+
+ @Override
+ public void failed() {
+ post.setSaved(false);
+ saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
+ Toast.makeText(mActivity, R.string.post_saved_failed, Toast.LENGTH_SHORT).show();
+ EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
+ }
+ });
+ }
+ }
+ });
+
+ shareButton.setOnClickListener(view -> {
+ Post post = getItem(getAdapterPosition());
+ if (post != null) {
+ shareLink(post);
+ }
+ });
+ }
+ }
+
+ class PostVideoAutoplayViewHolder extends PostBaseViewHolder implements ToroPlayer {
+ @BindView(R.id.card_view_item_post_video_type_autoplay)
+ MaterialCardView cardView;
+ @BindView(R.id.icon_gif_image_view_item_post_video_type_autoplay)
+ AspectRatioGifImageView iconGifImageView;
+ @BindView(R.id.subreddit_name_text_view_item_post_video_type_autoplay)
+ TextView subredditTextView;
+ @BindView(R.id.user_text_view_item_post_video_type_autoplay)
+ TextView userTextView;
+ @BindView(R.id.stickied_post_image_view_item_post_video_type_autoplay)
+ ImageView stickiedPostImageView;
+ @BindView(R.id.post_time_text_view_best_item_post_video_type_autoplay)
+ TextView postTimeTextView;
+ @BindView(R.id.title_text_view_best_item_post_video_type_autoplay)
+ TextView titleTextView;
+ @BindView(R.id.type_text_view_item_post_video_type_autoplay)
+ CustomTextView typeTextView;
+ @BindView(R.id.archived_image_view_item_post_video_type_autoplay)
+ ImageView archivedImageView;
+ @BindView(R.id.locked_image_view_item_post_video_type_autoplay)
+ ImageView lockedImageView;
+ @BindView(R.id.crosspost_image_view_item_post_video_type_autoplay)
+ ImageView crosspostImageView;
+ @BindView(R.id.nsfw_text_view_item_post_video_type_autoplay)
+ CustomTextView nsfwTextView;
+ @BindView(R.id.spoiler_custom_text_view_item_post_video_type_autoplay)
+ CustomTextView spoilerTextView;
+ @BindView(R.id.flair_custom_text_view_item_post_video_type_autoplay)
+ CustomTextView flairTextView;
+ @BindView(R.id.awards_text_view_item_post_video_type_autoplay)
+ CustomTextView awardsTextView;
+ @BindView(R.id.aspect)
+ AspectRatioFrameLayout aspectRatioFrameLayout;
+ @BindView(R.id.player_view_item_post_video_type_autoplay)
+ PlayerView videoPlayer;
+ @BindView(R.id.mute_exo_playback_control_view)
+ ImageView muteButton;
+ @BindView(R.id.fullscreen_exo_playback_control_view)
+ ImageView fullscreenButton;
+ @BindView(R.id.bottom_constraint_layout_item_post_video_type_autoplay)
+ ConstraintLayout bottomConstraintLayout;
+ @BindView(R.id.plus_button_item_post_video_type_autoplay)
+ ImageView upvoteButton;
+ @BindView(R.id.score_text_view_item_post_video_type_autoplay)
+ TextView scoreTextView;
+ @BindView(R.id.minus_button_item_post_video_type_autoplay)
+ ImageView downvoteButton;
+ @BindView(R.id.comments_count_item_post_video_type_autoplay)
+ TextView commentsCountTextView;
+ @BindView(R.id.save_button_item_post_video_type_autoplay)
+ ImageView saveButton;
+ @BindView(R.id.share_button_item_post_video_type_autoplay)
+ ImageView shareButton;
+
+ @Nullable
+ ExoPlayerViewHelper helper;
+ private Uri mediaUri;
+ private float volume = 0f;
+
+ PostVideoAutoplayViewHolder(View itemView) {
+ super(itemView);
+ ButterKnife.bind(this, itemView);
+ setBaseView(cardView,
+ iconGifImageView,
+ subredditTextView,
+ userTextView,
+ stickiedPostImageView,
+ postTimeTextView,
+ titleTextView,
+ typeTextView,
+ archivedImageView,
+ lockedImageView,
+ crosspostImageView,
+ nsfwTextView,
+ spoilerTextView,
+ flairTextView,
+ awardsTextView,
+ bottomConstraintLayout,
+ upvoteButton,
+ scoreTextView,
+ downvoteButton,
+ commentsCountTextView,
+ saveButton,
+ shareButton);
+
+ aspectRatioFrameLayout.setOnClickListener(null);
+
+ muteButton.setOnClickListener(view -> {
+ if (helper != null) {
+ if (helper.getVolume() != 0) {
+ muteButton.setImageDrawable(mActivity.getDrawable(R.drawable.ic_mute_white_rounded_18dp));
+ helper.setVolume(0f);
+ volume = 0f;
+ } else {
+ muteButton.setImageDrawable(mActivity.getDrawable(R.drawable.ic_unmute_white_rounded_18dp));
+ helper.setVolume(1f);
+ volume = 1f;
+ }
+ }
+ });
+
+ fullscreenButton.setOnClickListener(view -> {
+ Post post = getItem(getAdapterPosition());
+ if (post != null) {
+ Intent intent = new Intent(mActivity, ViewVideoActivity.class);
+ intent.setData(Uri.parse(post.getVideoUrl()));
+ intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl());
+ intent.putExtra(ViewVideoActivity.EXTRA_SUBREDDIT, post.getSubredditName());
+ intent.putExtra(ViewVideoActivity.EXTRA_ID, post.getId());
+ intent.putExtra(ViewVideoActivity.EXTRA_POST_TITLE, post.getTitle());
+ mActivity.startActivity(intent);
+ }
+ });
+ }
+
+ void bindVideoUri(Uri videoUri) {
+ mediaUri = videoUri;
+ }
+
+ @NonNull
+ @Override
+ public View getPlayerView() {
+ return videoPlayer;
+ }
+
+ @NonNull
+ @Override
+ public PlaybackInfo getCurrentPlaybackInfo() {
+ return helper != null ? helper.getLatestPlaybackInfo() : new PlaybackInfo();
+ }
+
+ @Override
+ public void initialize(@NonNull Container container, @NonNull PlaybackInfo playbackInfo) {
+ if (helper == null) {
+ helper = new ExoPlayerViewHelper(this, mediaUri, null, mExoCreator);
+ helper.addEventListener(new Playable.EventListener() {
+ @Override
+ public void onTracksChanged(TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {
+ if (!trackGroups.isEmpty()) {
+ for (int i = 0; i < trackGroups.length; i++) {
+ String mimeType = trackGroups.get(i).getFormat(0).sampleMimeType;
+ if (mimeType != null && mimeType.contains("audio")) {
+ helper.setVolume(volume);
+ muteButton.setVisibility(View.VISIBLE);
+ if (volume != 0f) {
+ muteButton.setImageDrawable(mActivity.getDrawable(R.drawable.ic_unmute_white_rounded_18dp));
+ } else {
+ muteButton.setImageDrawable(mActivity.getDrawable(R.drawable.ic_mute_white_rounded_18dp));
+ }
+ break;
+ }
+ }
+ } else {
+ muteButton.setVisibility(View.GONE);
+ }
+ }
+
+ @Override
+ public void onMetadata(Metadata metadata) {
+
+ }
+
+ @Override
+ public void onCues(List<Cue> cues) {
+
+ }
+ });
+ }
+ helper.initialize(container, playbackInfo);
+ }
+
+ @Override
+ public void play() {
+ if (helper != null) helper.play();
+ }
+
+ @Override
+ public void pause() {
+ if (helper != null) helper.pause();
+ }
+
+ @Override
+ public boolean isPlaying() {
+ return helper != null && helper.isPlaying();
+ }
+
+ @Override
+ public void release() {
+ if (helper != null) {
+ helper.release();
+ helper = null;
+ }
+ }
+
+ @Override
+ public boolean wantsToPlay() {
+ return ToroUtil.visibleAreaOffset(this, itemView.getParent()) >= 0.85;
+ }
+
+ @Override
+ public int getPlayerOrder() {
+ return getAdapterPosition();
+ }
+ }
+
+ class PostGifAndVideoPreviewViewHolder extends PostBaseViewHolder {
+ @BindView(R.id.card_view_item_post_gif_type_autoplay)
+ MaterialCardView cardView;
+ @BindView(R.id.icon_gif_image_view_item_post_gif_type_autoplay)
+ AspectRatioGifImageView iconGifImageView;
+ @BindView(R.id.subreddit_name_text_view_item_post_gif_type_autoplay)
+ TextView subredditTextView;
+ @BindView(R.id.user_text_view_item_post_gif_type_autoplay)
+ TextView userTextView;
+ @BindView(R.id.stickied_post_image_view_item_post_gif_type_autoplay)
+ ImageView stickiedPostImageView;
+ @BindView(R.id.post_time_text_view_best_item_post_gif_type_autoplay)
+ TextView postTimeTextView;
+ @BindView(R.id.title_text_view_best_item_post_gif_type_autoplay)
+ TextView titleTextView;
+ @BindView(R.id.type_text_view_item_post_gif_type_autoplay)
+ CustomTextView typeTextView;
+ @BindView(R.id.archived_image_view_item_post_gif_type_autoplay)
+ ImageView archivedImageView;
+ @BindView(R.id.locked_image_view_item_post_gif_type_autoplay)
+ ImageView lockedImageView;
+ @BindView(R.id.crosspost_image_view_item_post_gif_type_autoplay)
+ ImageView crosspostImageView;
+ @BindView(R.id.nsfw_text_view_item_post_gif_type_autoplay)
+ CustomTextView nsfwTextView;
+ @BindView(R.id.spoiler_custom_text_view_item_post_gif_type_autoplay)
+ CustomTextView spoilerTextView;
+ @BindView(R.id.flair_custom_text_view_item_post_gif_type_autoplay)
+ CustomTextView flairTextView;
+ @BindView(R.id.awards_text_view_item_post_gif_type_autoplay)
+ CustomTextView awardsTextView;
+ @BindView(R.id.image_view_wrapper_item_post_gif_type_autoplay)
+ RelativeLayout relativeLayout;
+ @BindView(R.id.progress_bar_item_post_gif_type_autoplay)
+ ProgressBar progressBar;
+ @BindView(R.id.image_view_item_post_gif_type_autoplay)
+ AspectRatioGifImageView imageView;
+ @BindView(R.id.load_image_error_relative_layout_item_post_gif_type_autoplay)
+ RelativeLayout errorRelativeLayout;
+ @BindView(R.id.bottom_constraint_layout_item_post_gif_type_autoplay)
+ ConstraintLayout bottomConstraintLayout;
+ @BindView(R.id.plus_button_item_post_gif_type_autoplay)
+ ImageView upvoteButton;
+ @BindView(R.id.score_text_view_item_post_gif_type_autoplay)
+ TextView scoreTextView;
+ @BindView(R.id.minus_button_item_post_gif_type_autoplay)
+ ImageView downvoteButton;
+ @BindView(R.id.comments_count_item_post_gif_type_autoplay)
+ TextView commentsCountTextView;
+ @BindView(R.id.save_button_item_post_gif_type_autoplay)
+ ImageView saveButton;
+ @BindView(R.id.share_button_item_post_gif_type_autoplay)
+ ImageView shareButton;
+
+ PostGifAndVideoPreviewViewHolder(View itemView) {
+ super(itemView);
+ ButterKnife.bind(this, itemView);
+ setBaseView(cardView,
+ iconGifImageView,
+ subredditTextView,
+ userTextView,
+ stickiedPostImageView,
+ postTimeTextView,
+ titleTextView,
+ typeTextView,
+ archivedImageView,
+ lockedImageView,
+ crosspostImageView,
+ nsfwTextView,
+ spoilerTextView,
+ flairTextView,
+ awardsTextView,
+ bottomConstraintLayout,
+ upvoteButton,
+ scoreTextView,
+ downvoteButton,
+ commentsCountTextView,
+ saveButton,
+ shareButton);
+
+ progressBar.setIndeterminateTintList(ColorStateList.valueOf(mColorAccent));
+
+ imageView.setOnClickListener(view -> {
+ Post post = getItem(getAdapterPosition());
+ if (post != null) {
+ if (post.getPostType() == Post.VIDEO_TYPE) {
+ Intent intent = new Intent(mActivity, ViewVideoActivity.class);
+ intent.setData(Uri.parse(post.getVideoUrl()));
+ intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl());
+ intent.putExtra(ViewVideoActivity.EXTRA_SUBREDDIT, post.getSubredditName());
+ intent.putExtra(ViewVideoActivity.EXTRA_ID, post.getFullName());
+ intent.putExtra(ViewVideoActivity.EXTRA_POST_TITLE, post.getTitle());
+ mActivity.startActivity(intent);
+ } else if (post.getPostType() == Post.GIF_TYPE) {
+ Intent intent = new Intent(mActivity, ViewGIFActivity.class);
+ intent.setData(Uri.parse(post.getVideoUrl()));
+ intent.putExtra(ViewGIFActivity.FILE_NAME_KEY, post.getSubredditName()
+ + "-" + post.getId() + ".gif");
+ intent.putExtra(ViewGIFActivity.GIF_URL_KEY, post.getVideoUrl());
+ intent.putExtra(ViewGIFActivity.POST_TITLE_KEY, post.getTitle());
+ mActivity.startActivity(intent);
+ }
+ }
+ });
+ }
+ }
+
+ class PostImageAndGifAutoplayTypeViewHolder extends PostBaseViewHolder {
+ @BindView(R.id.card_view_item_post_image_type)
+ MaterialCardView cardView;
+ @BindView(R.id.icon_gif_image_view_item_post_image_type)
+ AspectRatioGifImageView iconGifImageView;
+ @BindView(R.id.subreddit_name_text_view_item_post_image_type)
+ TextView subredditTextView;
+ @BindView(R.id.user_text_view_item_post_image_type)
+ TextView userTextView;
+ @BindView(R.id.stickied_post_image_view_item_post_image_type)
+ ImageView stickiedPostImageView;
+ @BindView(R.id.post_time_text_view_best_item_post_image_type)
+ TextView postTimeTextView;
+ @BindView(R.id.title_text_view_best_item_post_image_type)
+ TextView titleTextView;
+ @BindView(R.id.type_text_view_item_post_image_type)
+ CustomTextView typeTextView;
+ @BindView(R.id.archived_image_view_item_post_image_type)
+ ImageView archivedImageView;
+ @BindView(R.id.locked_image_view_item_post_image_type)
+ ImageView lockedImageView;
+ @BindView(R.id.crosspost_image_view_item_post_image_type)
+ ImageView crosspostImageView;
+ @BindView(R.id.nsfw_text_view_item_post_image_type)
+ CustomTextView nsfwTextView;
+ @BindView(R.id.spoiler_custom_text_view_item_post_image_type)
+ CustomTextView spoilerTextView;
+ @BindView(R.id.flair_custom_text_view_item_post_image_type)
+ CustomTextView flairTextView;
+ @BindView(R.id.awards_text_view_item_post_image_type)
+ CustomTextView awardsTextView;
+ @BindView(R.id.image_view_wrapper_item_post_image_type)
+ RelativeLayout relativeLayout;
+ @BindView(R.id.progress_bar_item_post_image_type)
+ ProgressBar progressBar;
+ @BindView(R.id.image_view_best_post_item)
+ AspectRatioGifImageView imageView;
+ @BindView(R.id.load_image_error_relative_layout_item_post_image_type)
+ RelativeLayout errorRelativeLayout;
+ @BindView(R.id.bottom_constraint_layout_item_post_image_type)
+ ConstraintLayout bottomConstraintLayout;
+ @BindView(R.id.plus_button_item_post_image_type)
+ ImageView upvoteButton;
+ @BindView(R.id.score_text_view_item_post_image_type)
+ TextView scoreTextView;
+ @BindView(R.id.minus_button_item_post_image_type)
+ ImageView downvoteButton;
+ @BindView(R.id.comments_count_item_post_image_type)
+ TextView commentsCountTextView;
+ @BindView(R.id.save_button_item_post_image_type)
+ ImageView saveButton;
+ @BindView(R.id.share_button_item_post_image_type)
+ ImageView shareButton;
+
+ PostImageAndGifAutoplayTypeViewHolder(View itemView) {
+ super(itemView);
+ ButterKnife.bind(this, itemView);
+ setBaseView(cardView,
+ iconGifImageView,
+ subredditTextView,
+ userTextView,
+ stickiedPostImageView,
+ postTimeTextView,
+ titleTextView,
+ typeTextView,
+ archivedImageView,
+ lockedImageView,
+ crosspostImageView,
+ nsfwTextView,
+ spoilerTextView,
+ flairTextView,
+ awardsTextView,
+ bottomConstraintLayout,
+ upvoteButton,
+ scoreTextView,
+ downvoteButton,
+ commentsCountTextView,
+ saveButton,
+ shareButton);
+
+ progressBar.setIndeterminateTintList(ColorStateList.valueOf(mColorAccent));
+
+ imageView.setOnClickListener(view -> {
+ Post post = getItem(getAdapterPosition());
+ if (post != null) {
+ Intent intent = new Intent(mActivity, ViewImageActivity.class);
+ intent.putExtra(ViewImageActivity.IMAGE_URL_KEY, post.getUrl());
+ intent.putExtra(ViewImageActivity.FILE_NAME_KEY, post.getSubredditName()
+ + "-" + post.getId() + ".jpg");
+ intent.putExtra(ViewImageActivity.POST_TITLE_KEY, post.getTitle());
+ mActivity.startActivity(intent);
+ }
+ });
+ }
+ }
+
+ class PostLinkTypeViewHolder extends PostBaseViewHolder {
+ @BindView(R.id.card_view_item_post_link_type)
+ MaterialCardView cardView;
+ @BindView(R.id.icon_gif_image_view_item_post_link_type)
+ AspectRatioGifImageView iconGifImageView;
+ @BindView(R.id.subreddit_name_text_view_item_post_link_type)
+ TextView subredditTextView;
+ @BindView(R.id.user_text_view_item_post_link_type)
+ TextView userTextView;
+ @BindView(R.id.stickied_post_image_view_item_post_link_type)
+ ImageView stickiedPostImageView;
+ @BindView(R.id.post_time_text_view_best_item_post_link_type)
+ TextView postTimeTextView;
+ @BindView(R.id.title_text_view_best_item_post_link_type)
+ TextView titleTextView;
+ @BindView(R.id.type_text_view_item_post_link_type)
+ CustomTextView typeTextView;
+ @BindView(R.id.archived_image_view_item_post_link_type)
+ ImageView archivedImageView;
+ @BindView(R.id.locked_image_view_item_post_link_type)
+ ImageView lockedImageView;
+ @BindView(R.id.crosspost_image_view_item_post_link_type)
+ ImageView crosspostImageView;
+ @BindView(R.id.nsfw_text_view_item_post_link_type)
+ CustomTextView nsfwTextView;
+ @BindView(R.id.spoiler_custom_text_view_item_post_link_type)
+ CustomTextView spoilerTextView;
+ @BindView(R.id.flair_custom_text_view_item_post_link_type)
+ CustomTextView flairTextView;
+ @BindView(R.id.awards_text_view_item_post_link_type)
+ CustomTextView awardsTextView;
+ @BindView(R.id.link_text_view_item_post_link_type)
+ TextView linkTextView;
+ @BindView(R.id.image_view_wrapper_item_post_link_type)
+ RelativeLayout relativeLayout;
+ @BindView(R.id.progress_bar_item_post_link_type)
+ ProgressBar progressBar;
+ @BindView(R.id.image_view_best_post_item)
+ AspectRatioGifImageView imageView;
+ @BindView(R.id.load_image_error_relative_layout_item_post_link_type)
+ RelativeLayout errorRelativeLayout;
+ @BindView(R.id.bottom_constraint_layout_item_post_link_type)
+ ConstraintLayout bottomConstraintLayout;
+ @BindView(R.id.plus_button_item_post_link_type)
+ ImageView upvoteButton;
+ @BindView(R.id.score_text_view_item_post_link_type)
+ TextView scoreTextView;
+ @BindView(R.id.minus_button_item_post_link_type)
+ ImageView downvoteButton;
+ @BindView(R.id.comments_count_item_post_link_type)
+ TextView commentsCountTextView;
+ @BindView(R.id.save_button_item_post_link_type)
+ ImageView saveButton;
+ @BindView(R.id.share_button_item_post_link_type)
+ ImageView shareButton;
+
+ PostLinkTypeViewHolder(View itemView) {
+ super(itemView);
+ ButterKnife.bind(this, itemView);
+ setBaseView(cardView,
+ iconGifImageView,
+ subredditTextView,
+ userTextView,
+ stickiedPostImageView,
+ postTimeTextView,
+ titleTextView,
+ typeTextView,
+ archivedImageView,
+ lockedImageView,
+ crosspostImageView,
+ nsfwTextView,
+ spoilerTextView,
+ flairTextView,
+ awardsTextView,
+ bottomConstraintLayout,
+ upvoteButton,
+ scoreTextView,
+ downvoteButton,
+ commentsCountTextView,
+ saveButton,
+ shareButton);
+
+ linkTextView.setTextColor(mSecondaryTextColor);
+ progressBar.setIndeterminateTintList(ColorStateList.valueOf(mColorAccent));
+
+ imageView.setOnClickListener(view -> {
+ Post post = getItem(getAdapterPosition());
+ if (post != null) {
+ Intent intent = new Intent(mActivity, LinkResolverActivity.class);
+ Uri uri = Uri.parse(post.getUrl());
+ if (uri.getScheme() == null && uri.getHost() == null) {
+ intent.setData(LinkResolverActivity.getRedditUriByPath(post.getUrl()));
+ } else {
+ intent.setData(uri);
+ }
+ mActivity.startActivity(intent);
+ }
+ });
+ }
+ }
+
+ class PostNoPreviewLinkTypeViewHolder extends PostBaseViewHolder {
+ @BindView(R.id.card_view_item_post_no_preview_link_type)
+ MaterialCardView cardView;
+ @BindView(R.id.icon_gif_image_view_item_post_no_preview_link_type)
+ AspectRatioGifImageView iconGifImageView;
+ @BindView(R.id.subreddit_name_text_view_item_post_no_preview_link_type)
+ TextView subredditTextView;
+ @BindView(R.id.user_text_view_item_post_no_preview_link_type)
+ TextView userTextView;
+ @BindView(R.id.stickied_post_image_view_item_post_no_preview_link_type)
+ ImageView stickiedPostImageView;
+ @BindView(R.id.post_time_text_view_best_item_post_no_preview_link_type)
+ TextView postTimeTextView;
+ @BindView(R.id.title_text_view_best_item_post_no_preview_link_type)
+ TextView titleTextView;
+ @BindView(R.id.type_text_view_item_post_no_preview_link_type)
+ CustomTextView typeTextView;
+ @BindView(R.id.archived_image_view_item_post_no_preview_link_type)
+ ImageView archivedImageView;
+ @BindView(R.id.locked_image_view_item_post_no_preview_link_type)
+ ImageView lockedImageView;
+ @BindView(R.id.crosspost_image_view_item_post_no_preview_link_type)
+ ImageView crosspostImageView;
+ @BindView(R.id.nsfw_text_view_item_post_no_preview_link_type)
+ CustomTextView nsfwTextView;
+ @BindView(R.id.spoiler_custom_text_view_item_post_no_preview_link_type)
+ CustomTextView spoilerTextView;
+ @BindView(R.id.flair_custom_text_view_item_post_no_preview_link_type)
+ CustomTextView flairTextView;
+ @BindView(R.id.awards_text_view_item_post_no_preview_link_type)
+ CustomTextView awardsTextView;
+ @BindView(R.id.link_text_view_item_post_no_preview_link_type)
+ TextView linkTextView;
+ @BindView(R.id.image_view_no_preview_link_item_post_no_preview_link_type)
+ ImageView noPreviewLinkImageView;
+ @BindView(R.id.bottom_constraint_layout_item_post_no_preview_link_type)
+ ConstraintLayout bottomConstraintLayout;
+ @BindView(R.id.plus_button_item_post_no_preview_link_type)
+ ImageView upvoteButton;
+ @BindView(R.id.score_text_view_item_post_no_preview_link_type)
+ TextView scoreTextView;
+ @BindView(R.id.minus_button_item_post_no_preview_link_type)
+ ImageView downvoteButton;
+ @BindView(R.id.comments_count_item_post_no_preview_link_type)
+ TextView commentsCountTextView;
+ @BindView(R.id.save_button_item_post_no_preview_link_type)
+ ImageView saveButton;
+ @BindView(R.id.share_button_item_post_no_preview_link_type)
+ ImageView shareButton;
+
+ PostNoPreviewLinkTypeViewHolder(View itemView) {
+ super(itemView);
+ ButterKnife.bind(this, itemView);
+ setBaseView(cardView,
+ iconGifImageView,
+ subredditTextView,
+ userTextView,
+ stickiedPostImageView,
+ postTimeTextView,
+ titleTextView,
+ typeTextView,
+ archivedImageView,
+ lockedImageView,
+ crosspostImageView,
+ nsfwTextView,
+ spoilerTextView,
+ flairTextView,
+ awardsTextView,
+ bottomConstraintLayout,
+ upvoteButton,
+ scoreTextView,
+ downvoteButton,
+ commentsCountTextView,
+ saveButton,
+ shareButton);
+
+ linkTextView.setTextColor(mSecondaryTextColor);
+ noPreviewLinkImageView.setBackgroundColor(mNoPreviewLinkBackgroundColor);
+
+ noPreviewLinkImageView.setOnClickListener(view -> {
+ Post post = getItem(getAdapterPosition());
+ if (post != null) {
+ Intent intent = new Intent(mActivity, LinkResolverActivity.class);
+ Uri uri = Uri.parse(post.getUrl());
+ if (uri.getScheme() == null && uri.getHost() == null) {
+ intent.setData(LinkResolverActivity.getRedditUriByPath(post.getUrl()));
+ } else {
+ intent.setData(uri);
+ }
+ mActivity.startActivity(intent);
+ }
+ });
+ }
+ }
+
+ class PostTextTypeViewHolder extends PostBaseViewHolder {
+ @BindView(R.id.card_view_item_post_text_type)
+ MaterialCardView cardView;
+ @BindView(R.id.icon_gif_image_view_item_post_text_type)
+ AspectRatioGifImageView iconGifImageView;
+ @BindView(R.id.subreddit_name_text_view_item_post_text_type)
+ TextView subredditTextView;
+ @BindView(R.id.user_text_view_item_post_text_type)
+ TextView userTextView;
+ @BindView(R.id.stickied_post_image_view_item_post_text_type)
+ ImageView stickiedPostImageView;
+ @BindView(R.id.post_time_text_view_best_item_post_text_type)
+ TextView postTimeTextView;
+ @BindView(R.id.title_text_view_best_item_post_text_type)
+ TextView titleTextView;
+ @BindView(R.id.type_text_view_item_post_text_type)
+ CustomTextView typeTextView;
+ @BindView(R.id.archived_image_view_item_post_text_type)
+ ImageView archivedImageView;
+ @BindView(R.id.locked_image_view_item_post_text_type)
+ ImageView lockedImageView;
+ @BindView(R.id.crosspost_image_view_item_post_text_type)
+ ImageView crosspostImageView;
+ @BindView(R.id.nsfw_text_view_item_post_text_type)
+ CustomTextView nsfwTextView;
+ @BindView(R.id.spoiler_custom_text_view_item_post_text_type)
+ CustomTextView spoilerTextView;
+ @BindView(R.id.flair_custom_text_view_item_post_text_type)
+ CustomTextView flairTextView;
+ @BindView(R.id.awards_text_view_item_post_text_type)
+ CustomTextView awardsTextView;
+ @BindView(R.id.content_text_view_item_post_text_type)
+ TextView contentTextView;
+ @BindView(R.id.bottom_constraint_layout_item_post_text_type)
+ ConstraintLayout bottomConstraintLayout;
+ @BindView(R.id.plus_button_item_post_text_type)
+ ImageView upvoteButton;
+ @BindView(R.id.score_text_view_item_post_text_type)
+ TextView scoreTextView;
+ @BindView(R.id.minus_button_item_post_text_type)
+ ImageView downvoteButton;
+ @BindView(R.id.comments_count_item_post_text_type)
+ TextView commentsCountTextView;
+ @BindView(R.id.save_button_item_post_text_type)
+ ImageView saveButton;
+ @BindView(R.id.share_button_item_post_text_type)
+ ImageView shareButton;
+
+ PostTextTypeViewHolder (View itemView) {
+ super(itemView);
+ ButterKnife.bind(this, itemView);
+ setBaseView(cardView,
+ iconGifImageView,
+ subredditTextView,
+ userTextView,
+ stickiedPostImageView,
+ postTimeTextView,
+ titleTextView,
+ typeTextView,
+ archivedImageView,
+ lockedImageView,
+ crosspostImageView,
+ nsfwTextView,
+ spoilerTextView,
+ flairTextView,
+ awardsTextView,
+ bottomConstraintLayout,
+ upvoteButton,
+ scoreTextView,
+ downvoteButton,
+ commentsCountTextView,
+ saveButton,
+ shareButton);
+
+ contentTextView.setTextColor(mPostContentColor);
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/ReportReasonRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/ReportReasonRecyclerViewAdapter.java
new file mode 100644
index 00000000..8bbc3991
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/ReportReasonRecyclerViewAdapter.java
@@ -0,0 +1,130 @@
+package ml.docilealligator.infinityforreddit.Adapter;
+
+import android.content.res.ColorStateList;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.CheckBox;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+
+import java.util.ArrayList;
+
+import butterknife.BindView;
+import butterknife.ButterKnife;
+import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
+import ml.docilealligator.infinityforreddit.R;
+import ml.docilealligator.infinityforreddit.ReportReason;
+
+public class ReportReasonRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
+
+ private ArrayList<ReportReason> generalReasons;
+ private ArrayList<ReportReason> rules;
+ private int primaryTextColor;
+ private int colorAccent;
+
+ public ReportReasonRecyclerViewAdapter(CustomThemeWrapper customThemeWrapper, ArrayList<ReportReason> generalReasons) {
+ this.generalReasons = generalReasons;
+ primaryTextColor = customThemeWrapper.getPrimaryTextColor();
+ colorAccent = customThemeWrapper.getColorAccent();
+ }
+
+ @NonNull
+ @Override
+ public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
+ return new ReasonViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_report_reason, parent, false));
+ }
+
+ @Override
+ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
+ if (holder instanceof ReasonViewHolder) {
+ ReportReason reportReason;
+ if (position >= generalReasons.size()) {
+ reportReason = rules.get(holder.getAdapterPosition() - generalReasons.size());
+ } else {
+ reportReason = generalReasons.get(holder.getAdapterPosition());
+ }
+ ((ReasonViewHolder) holder).reasonTextView.setText(reportReason.getReportReason());
+ ((ReasonViewHolder) holder).checkBox.setChecked(reportReason.isSelected());
+ }
+ }
+
+ @Override
+ public int getItemCount() {
+ return rules == null ? generalReasons.size() : rules.size() + generalReasons.size();
+ }
+
+ public void setRules(ArrayList<ReportReason> reportReasons) {
+ this.rules = reportReasons;
+ notifyDataSetChanged();
+ }
+
+ public ReportReason getSelectedReason() {
+ for (ReportReason reportReason : rules) {
+ if (reportReason.isSelected()) {
+ return reportReason;
+ }
+ }
+
+ for (ReportReason reportReason : generalReasons) {
+ if (reportReason.isSelected()) {
+ return reportReason;
+ }
+ }
+
+ return null;
+ }
+
+ public ArrayList<ReportReason> getGeneralReasons() {
+ return generalReasons;
+ }
+
+ public ArrayList<ReportReason> getRules() {
+ return rules;
+ }
+
+ class ReasonViewHolder extends RecyclerView.ViewHolder {
+
+ @BindView(R.id.reason_text_view_item_report_reason)
+ TextView reasonTextView;
+ @BindView(R.id.check_box_item_report_reason)
+ CheckBox checkBox;
+
+ ReasonViewHolder(@NonNull View itemView) {
+ super(itemView);
+ ButterKnife.bind(this, itemView);
+
+ reasonTextView.setTextColor(primaryTextColor);
+ checkBox.setButtonTintList(ColorStateList.valueOf(colorAccent));
+
+ checkBox.setOnClickListener(view -> {
+ for (int i = 0; i < generalReasons.size(); i++) {
+ if (generalReasons.get(i).isSelected()) {
+ generalReasons.get(i).setSelected(false);
+ notifyItemChanged(i);
+
+ }
+ }
+
+ if (rules != null) {
+ for (int i = 0; i < rules.size(); i++) {
+ if (rules.get(i).isSelected()) {
+ rules.get(i).setSelected(false);
+ notifyItemChanged(i + generalReasons.size());
+ }
+ }
+ }
+
+ if (getAdapterPosition() >= generalReasons.size()) {
+ rules.get(getAdapterPosition() - generalReasons.size()).setSelected(checkBox.isChecked());
+ } else {
+ generalReasons.get(getAdapterPosition()).setSelected(checkBox.isChecked());
+ }
+ });
+
+ itemView.setOnClickListener(view -> checkBox.performClick());
+ }
+ }
+}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java b/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java
index d8dcc56e..351ab8f8 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java
@@ -21,6 +21,7 @@ import ml.docilealligator.infinityforreddit.Activity.PostImageActivity;
import ml.docilealligator.infinityforreddit.Activity.PostLinkActivity;
import ml.docilealligator.infinityforreddit.Activity.PostTextActivity;
import ml.docilealligator.infinityforreddit.Activity.PostVideoActivity;
+import ml.docilealligator.infinityforreddit.Activity.ReportActivity;
import ml.docilealligator.infinityforreddit.Activity.RulesActivity;
import ml.docilealligator.infinityforreddit.Activity.SearchActivity;
import ml.docilealligator.infinityforreddit.Activity.SearchResultActivity;
@@ -161,4 +162,6 @@ public interface AppComponent {
void inject(EditMultiRedditActivity editMultiRedditActivity);
void inject(SelectedSubredditsActivity selectedSubredditsActivity);
+
+ void inject(ReportActivity reportActivity);
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/AppModule.java b/app/src/main/java/ml/docilealligator/infinityforreddit/AppModule.java
index fe483c3c..a15c01ab 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/AppModule.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/AppModule.java
@@ -6,6 +6,11 @@ import android.content.SharedPreferences;
import androidx.preference.PreferenceManager;
+import com.google.android.exoplayer2.database.ExoDatabaseProvider;
+import com.google.android.exoplayer2.upstream.cache.LeastRecentlyUsedCacheEvictor;
+import com.google.android.exoplayer2.upstream.cache.SimpleCache;
+
+import java.io.File;
import java.util.concurrent.TimeUnit;
import javax.inject.Named;
@@ -13,6 +18,10 @@ import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
+import im.ene.toro.exoplayer.Config;
+import im.ene.toro.exoplayer.ExoCreator;
+import im.ene.toro.exoplayer.MediaSourceBuilder;
+import im.ene.toro.exoplayer.ToroExo;
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.Utils.CustomThemeSharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
@@ -147,4 +156,14 @@ class AppModule {
@Named("amoled_theme") SharedPreferences amoledThemeSharedPreferences) {
return new CustomThemeWrapper(lightThemeSharedPreferences, darkThemeSharedPreferences, amoledThemeSharedPreferences);
}
+
+ @Provides
+ @Singleton
+ ExoCreator provideExoCreator() {
+ SimpleCache cache = new SimpleCache(new File(mApplication.getCacheDir(), "/toro_cache"),
+ new LeastRecentlyUsedCacheEvictor(200 * 1024 * 1024), new ExoDatabaseProvider(mApplication));
+ Config config = new Config.Builder(mApplication).setMediaSourceBuilder(MediaSourceBuilder.LOOPING).setCache(cache)
+ .build();
+ return ToroExo.with(mApplication).getCreator(config);
+ }
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/BroadcastReceiver/NetworkWifiStatusReceiver.java b/app/src/main/java/ml/docilealligator/infinityforreddit/BroadcastReceiver/NetworkWifiStatusReceiver.java
new file mode 100644
index 00000000..fb8d3ae4
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/BroadcastReceiver/NetworkWifiStatusReceiver.java
@@ -0,0 +1,22 @@
+package ml.docilealligator.infinityforreddit.BroadcastReceiver;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+
+public class NetworkWifiStatusReceiver extends BroadcastReceiver {
+ private NetworkWifiStatusReceiverListener networkWifiStatusReceiverListener;
+
+ public interface NetworkWifiStatusReceiverListener {
+ void networkStatusChange();
+ }
+
+ public NetworkWifiStatusReceiver(NetworkWifiStatusReceiverListener listener) {
+ networkWifiStatusReceiverListener = listener;
+ }
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ networkWifiStatusReceiverListener.networkStatusChange();
+ }
+}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomTheme.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomTheme.java
index 1c105ad3..7fbd3359 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomTheme.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomTheme.java
@@ -51,6 +51,8 @@ public class CustomTheme {
public int bottomAppBarBackgroundColor;
@ColumnInfo(name = "primary_icon_color")
public int primaryIconColor;
+ @ColumnInfo(name = "bottom_app_bar_icon_color")
+ public int bottomAppBarIconColor;
@ColumnInfo(name = "post_icon_and_info_color")
public int postIconAndInfoColor;
@ColumnInfo(name = "comment_icon_and_info_color")
@@ -193,57 +195,58 @@ public class CustomTheme {
customTheme.commentBackgroundColor = customThemeSettingsItems.get(16).colorValue;
customTheme.bottomAppBarBackgroundColor = customThemeSettingsItems.get(17).colorValue;
customTheme.primaryIconColor = customThemeSettingsItems.get(18).colorValue;
- customTheme.postIconAndInfoColor = customThemeSettingsItems.get(19).colorValue;
- customTheme.commentIconAndInfoColor = customThemeSettingsItems.get(20).colorValue;
- customTheme.fabIconColor = customThemeSettingsItems.get(21).colorValue;
- customTheme.toolbarPrimaryTextAndIconColor = customThemeSettingsItems.get(22).colorValue;
- customTheme.toolbarSecondaryTextColor = customThemeSettingsItems.get(23).colorValue;
- customTheme.circularProgressBarBackground = customThemeSettingsItems.get(24).colorValue;
- customTheme.tabLayoutWithExpandedCollapsingToolbarTabBackground = customThemeSettingsItems.get(25).colorValue;
- customTheme.tabLayoutWithExpandedCollapsingToolbarTextColor = customThemeSettingsItems.get(26).colorValue;
- customTheme.tabLayoutWithExpandedCollapsingToolbarTabIndicator = customThemeSettingsItems.get(27).colorValue;
- customTheme.tabLayoutWithCollapsedCollapsingToolbarTabBackground = customThemeSettingsItems.get(28).colorValue;
- customTheme.tabLayoutWithCollapsedCollapsingToolbarTextColor = customThemeSettingsItems.get(29).colorValue;
- customTheme.tabLayoutWithCollapsedCollapsingToolbarTabIndicator = customThemeSettingsItems.get(30).colorValue;
- customTheme.upvoted = customThemeSettingsItems.get(31).colorValue;
- customTheme.downvoted = customThemeSettingsItems.get(32).colorValue;
- customTheme.postTypeBackgroundColor = customThemeSettingsItems.get(33).colorValue;
- customTheme.postTypeTextColor = customThemeSettingsItems.get(34).colorValue;
- customTheme.spoilerBackgroundColor = customThemeSettingsItems.get(35).colorValue;
- customTheme.spoilerTextColor = customThemeSettingsItems.get(36).colorValue;
- customTheme.nsfwBackgroundColor = customThemeSettingsItems.get(37).colorValue;
- customTheme.nsfwTextColor = customThemeSettingsItems.get(38).colorValue;
- customTheme.flairBackgroundColor = customThemeSettingsItems.get(39).colorValue;
- customTheme.flairTextColor = customThemeSettingsItems.get(40).colorValue;
- customTheme.awardsBackgroundColor = customThemeSettingsItems.get(41).colorValue;
- customTheme.awardsTextColor = customThemeSettingsItems.get(42).colorValue;
- customTheme.archivedTint = customThemeSettingsItems.get(43).colorValue;
- customTheme.lockedIconTint = customThemeSettingsItems.get(44).colorValue;
- customTheme.crosspostIconTint = customThemeSettingsItems.get(45).colorValue;
- customTheme.stickiedPostIconTint = customThemeSettingsItems.get(46).colorValue;
- customTheme.subscribed = customThemeSettingsItems.get(47).colorValue;
- customTheme.unsubscribed = customThemeSettingsItems.get(48).colorValue;
- customTheme.username = customThemeSettingsItems.get(49).colorValue;
- customTheme.subreddit = customThemeSettingsItems.get(50).colorValue;
- customTheme.authorFlairTextColor = customThemeSettingsItems.get(51).colorValue;
- customTheme.submitter = customThemeSettingsItems.get(52).colorValue;
- customTheme.moderator = customThemeSettingsItems.get(53).colorValue;
- customTheme.singleCommentThreadBackgroundColor = customThemeSettingsItems.get(54).colorValue;
- customTheme.unreadMessageBackgroundColor = customThemeSettingsItems.get(55).colorValue;
- customTheme.dividerColor = customThemeSettingsItems.get(56).colorValue;
- customTheme.noPreviewLinkBackgroundColor = customThemeSettingsItems.get(57).colorValue;
- customTheme.voteAndReplyUnavailableButtonColor = customThemeSettingsItems.get(58).colorValue;
- customTheme.commentVerticalBarColor1 = customThemeSettingsItems.get(59).colorValue;
- customTheme.commentVerticalBarColor2 = customThemeSettingsItems.get(60).colorValue;
- customTheme.commentVerticalBarColor3 = customThemeSettingsItems.get(61).colorValue;
- customTheme.commentVerticalBarColor4 = customThemeSettingsItems.get(62).colorValue;
- customTheme.commentVerticalBarColor5 = customThemeSettingsItems.get(63).colorValue;
- customTheme.commentVerticalBarColor6 = customThemeSettingsItems.get(64).colorValue;
- customTheme.commentVerticalBarColor7 = customThemeSettingsItems.get(65).colorValue;
- customTheme.navBarColor = customThemeSettingsItems.get(66).colorValue;
- customTheme.isLightStatusBar = customThemeSettingsItems.get(67).isEnabled;
- customTheme.isLightNavBar = customThemeSettingsItems.get(68).isEnabled;
- customTheme.isChangeStatusBarIconColorAfterToolbarCollapsedInImmersiveInterface = customThemeSettingsItems.get(69).isEnabled;
+ customTheme.bottomAppBarIconColor = customThemeSettingsItems.get(19).colorValue;
+ customTheme.postIconAndInfoColor = customThemeSettingsItems.get(20).colorValue;
+ customTheme.commentIconAndInfoColor = customThemeSettingsItems.get(21).colorValue;
+ customTheme.fabIconColor = customThemeSettingsItems.get(22).colorValue;
+ customTheme.toolbarPrimaryTextAndIconColor = customThemeSettingsItems.get(23).colorValue;
+ customTheme.toolbarSecondaryTextColor = customThemeSettingsItems.get(24).colorValue;
+ customTheme.circularProgressBarBackground = customThemeSettingsItems.get(25).colorValue;
+ customTheme.tabLayoutWithExpandedCollapsingToolbarTabBackground = customThemeSettingsItems.get(26).colorValue;
+ customTheme.tabLayoutWithExpandedCollapsingToolbarTextColor = customThemeSettingsItems.get(27).colorValue;
+ customTheme.tabLayoutWithExpandedCollapsingToolbarTabIndicator = customThemeSettingsItems.get(28).colorValue;
+ customTheme.tabLayoutWithCollapsedCollapsingToolbarTabBackground = customThemeSettingsItems.get(29).colorValue;
+ customTheme.tabLayoutWithCollapsedCollapsingToolbarTextColor = customThemeSettingsItems.get(30).colorValue;
+ customTheme.tabLayoutWithCollapsedCollapsingToolbarTabIndicator = customThemeSettingsItems.get(31).colorValue;
+ customTheme.upvoted = customThemeSettingsItems.get(32).colorValue;
+ customTheme.downvoted = customThemeSettingsItems.get(33).colorValue;
+ customTheme.postTypeBackgroundColor = customThemeSettingsItems.get(34).colorValue;
+ customTheme.postTypeTextColor = customThemeSettingsItems.get(35).colorValue;
+ customTheme.spoilerBackgroundColor = customThemeSettingsItems.get(36).colorValue;
+ customTheme.spoilerTextColor = customThemeSettingsItems.get(37).colorValue;
+ customTheme.nsfwBackgroundColor = customThemeSettingsItems.get(38).colorValue;
+ customTheme.nsfwTextColor = customThemeSettingsItems.get(39).colorValue;
+ customTheme.flairBackgroundColor = customThemeSettingsItems.get(40).colorValue;
+ customTheme.flairTextColor = customThemeSettingsItems.get(41).colorValue;
+ customTheme.awardsBackgroundColor = customThemeSettingsItems.get(42).colorValue;
+ customTheme.awardsTextColor = customThemeSettingsItems.get(43).colorValue;
+ customTheme.archivedTint = customThemeSettingsItems.get(44).colorValue;
+ customTheme.lockedIconTint = customThemeSettingsItems.get(45).colorValue;
+ customTheme.crosspostIconTint = customThemeSettingsItems.get(46).colorValue;
+ customTheme.stickiedPostIconTint = customThemeSettingsItems.get(47).colorValue;
+ customTheme.subscribed = customThemeSettingsItems.get(48).colorValue;
+ customTheme.unsubscribed = customThemeSettingsItems.get(49).colorValue;
+ customTheme.username = customThemeSettingsItems.get(50).colorValue;
+ customTheme.subreddit = customThemeSettingsItems.get(51).colorValue;
+ customTheme.authorFlairTextColor = customThemeSettingsItems.get(52).colorValue;
+ customTheme.submitter = customThemeSettingsItems.get(53).colorValue;
+ customTheme.moderator = customThemeSettingsItems.get(54).colorValue;
+ customTheme.singleCommentThreadBackgroundColor = customThemeSettingsItems.get(55).colorValue;
+ customTheme.unreadMessageBackgroundColor = customThemeSettingsItems.get(56).colorValue;
+ customTheme.dividerColor = customThemeSettingsItems.get(57).colorValue;
+ customTheme.noPreviewLinkBackgroundColor = customThemeSettingsItems.get(58).colorValue;
+ customTheme.voteAndReplyUnavailableButtonColor = customThemeSettingsItems.get(59).colorValue;
+ customTheme.commentVerticalBarColor1 = customThemeSettingsItems.get(60).colorValue;
+ customTheme.commentVerticalBarColor2 = customThemeSettingsItems.get(61).colorValue;
+ customTheme.commentVerticalBarColor3 = customThemeSettingsItems.get(62).colorValue;
+ customTheme.commentVerticalBarColor4 = customThemeSettingsItems.get(63).colorValue;
+ customTheme.commentVerticalBarColor5 = customThemeSettingsItems.get(64).colorValue;
+ customTheme.commentVerticalBarColor6 = customThemeSettingsItems.get(65).colorValue;
+ customTheme.commentVerticalBarColor7 = customThemeSettingsItems.get(66).colorValue;
+ customTheme.navBarColor = customThemeSettingsItems.get(67).colorValue;
+ customTheme.isLightStatusBar = customThemeSettingsItems.get(68).isEnabled;
+ customTheme.isLightNavBar = customThemeSettingsItems.get(69).isEnabled;
+ customTheme.isChangeStatusBarIconColorAfterToolbarCollapsedInImmersiveInterface = customThemeSettingsItems.get(70).isEnabled;
return customTheme;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeSettingsItem.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeSettingsItem.java
index 531f6e8d..b32fcf1a 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeSettingsItem.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeSettingsItem.java
@@ -131,6 +131,10 @@ public class CustomThemeSettingsItem implements Parcelable {
context.getString(R.string.theme_item_primary_icon_color_detail),
customTheme.primaryIconColor));
customThemeSettingsItems.add(new CustomThemeSettingsItem(
+ context.getString(R.string.theme_item_bottom_app_bar_icon_color),
+ context.getString(R.string.theme_item_bottom_app_bar_icon_color_detail),
+ customTheme.bottomAppBarIconColor));
+ customThemeSettingsItems.add(new CustomThemeSettingsItem(
context.getString(R.string.theme_item_post_icon_and_info_color),
context.getString(R.string.theme_item_post_icon_and_info_color_detail),
customTheme.postIconAndInfoColor));
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeWrapper.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeWrapper.java
index ff30966d..aef072c9 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeWrapper.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeWrapper.java
@@ -127,6 +127,11 @@ public class CustomThemeWrapper {
getDefaultColor("#000000", "#FFFFFF", "#FFFFFF"));
}
+ public int getBottomAppBarIconColor() {
+ return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.BOTTOM_APP_BAR_ICON_COLOR,
+ getDefaultColor("#000000", "#FFFFFF", "#FFFFFF"));
+ }
+
public int getPostIconAndInfoColor() {
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.POST_ICON_AND_INFO_COLOR,
getDefaultColor("#8A000000", "#B3FFFFFF", "#B3FFFFFF"));
@@ -449,6 +454,7 @@ public class CustomThemeWrapper {
customTheme.commentBackgroundColor = Color.parseColor("#FFFFFF");
customTheme.bottomAppBarBackgroundColor = Color.parseColor("#FFFFFF");
customTheme.primaryIconColor = Color.parseColor("#000000");
+ customTheme.bottomAppBarIconColor = Color.parseColor("#000000");
customTheme.postIconAndInfoColor = Color.parseColor("#8A000000");
customTheme.commentIconAndInfoColor = Color.parseColor("#8A000000");
customTheme.toolbarPrimaryTextAndIconColor = Color.parseColor("#FFFFFF");
@@ -525,6 +531,7 @@ public class CustomThemeWrapper {
customTheme.commentBackgroundColor = Color.parseColor("#242424");
customTheme.bottomAppBarBackgroundColor = Color.parseColor("#121212");
customTheme.primaryIconColor = Color.parseColor("#FFFFFF");
+ customTheme.bottomAppBarIconColor = Color.parseColor("#FFFFFF");
customTheme.postIconAndInfoColor = Color.parseColor("#B3FFFFFF");
customTheme.commentIconAndInfoColor = Color.parseColor("#B3FFFFFF");
customTheme.toolbarPrimaryTextAndIconColor = Color.parseColor("#FFFFFF");
@@ -601,6 +608,7 @@ public class CustomThemeWrapper {
customTheme.commentBackgroundColor = Color.parseColor("#000000");
customTheme.bottomAppBarBackgroundColor = Color.parseColor("#000000");
customTheme.primaryIconColor = Color.parseColor("#FFFFFF");
+ customTheme.bottomAppBarIconColor = Color.parseColor("#FFFFFF");
customTheme.postIconAndInfoColor = Color.parseColor("#B3FFFFFF");
customTheme.commentIconAndInfoColor = Color.parseColor("#B3FFFFFF");
customTheme.toolbarPrimaryTextAndIconColor = Color.parseColor("#FFFFFF");
@@ -677,6 +685,7 @@ public class CustomThemeWrapper {
customTheme.commentBackgroundColor = Color.parseColor("#FFFFFF");
customTheme.bottomAppBarBackgroundColor = Color.parseColor("#FFFFFF");
customTheme.primaryIconColor = Color.parseColor("#000000");
+ customTheme.bottomAppBarIconColor = Color.parseColor("#000000");
customTheme.postIconAndInfoColor = Color.parseColor("#3C4043");
customTheme.commentIconAndInfoColor = Color.parseColor("#3C4043");
customTheme.toolbarPrimaryTextAndIconColor = Color.parseColor("#3C4043");
@@ -753,6 +762,7 @@ public class CustomThemeWrapper {
customTheme.commentBackgroundColor = Color.parseColor("#242424");
customTheme.bottomAppBarBackgroundColor = Color.parseColor("#121212");
customTheme.primaryIconColor = Color.parseColor("#FFFFFF");
+ customTheme.bottomAppBarIconColor = Color.parseColor("#FFFFFF");
customTheme.postIconAndInfoColor = Color.parseColor("#B3FFFFFF");
customTheme.commentIconAndInfoColor = Color.parseColor("#B3FFFFFF");
customTheme.toolbarPrimaryTextAndIconColor = Color.parseColor("#FFFFFF");
@@ -829,6 +839,7 @@ public class CustomThemeWrapper {
customTheme.commentBackgroundColor = Color.parseColor("#000000");
customTheme.bottomAppBarBackgroundColor = Color.parseColor("#000000");
customTheme.primaryIconColor = Color.parseColor("#FFFFFF");
+ customTheme.bottomAppBarIconColor = Color.parseColor("#FFFFFF");
customTheme.postIconAndInfoColor = Color.parseColor("#B3FFFFFF");
customTheme.commentIconAndInfoColor = Color.parseColor("#B3FFFFFF");
customTheme.toolbarPrimaryTextAndIconColor = Color.parseColor("#FFFFFF");
@@ -905,6 +916,7 @@ public class CustomThemeWrapper {
customTheme.commentBackgroundColor = Color.parseColor("#FFFFFF");
customTheme.bottomAppBarBackgroundColor = Color.parseColor("#FFFFFF");
customTheme.primaryIconColor = Color.parseColor("#000000");
+ customTheme.bottomAppBarIconColor = Color.parseColor("#000000");
customTheme.postIconAndInfoColor = Color.parseColor("#8A000000");
customTheme.commentIconAndInfoColor = Color.parseColor("#8A000000");
customTheme.toolbarPrimaryTextAndIconColor = Color.parseColor("#FFFFFF");
@@ -981,6 +993,7 @@ public class CustomThemeWrapper {
customTheme.commentBackgroundColor = Color.parseColor("#242424");
customTheme.bottomAppBarBackgroundColor = Color.parseColor("#121212");
customTheme.primaryIconColor = Color.parseColor("#FFFFFF");
+ customTheme.bottomAppBarIconColor = Color.parseColor("#FFFFFF");
customTheme.postIconAndInfoColor = Color.parseColor("#B3FFFFFF");
customTheme.commentIconAndInfoColor = Color.parseColor("#B3FFFFFF");
customTheme.toolbarPrimaryTextAndIconColor = Color.parseColor("#FFFFFF");
@@ -1057,6 +1070,7 @@ public class CustomThemeWrapper {
customTheme.commentBackgroundColor = Color.parseColor("#000000");
customTheme.bottomAppBarBackgroundColor = Color.parseColor("#000000");
customTheme.primaryIconColor = Color.parseColor("#FFFFFF");
+ customTheme.bottomAppBarIconColor = Color.parseColor("#FFFFFF");
customTheme.postIconAndInfoColor = Color.parseColor("#B3FFFFFF");
customTheme.commentIconAndInfoColor = Color.parseColor("#B3FFFFFF");
customTheme.toolbarPrimaryTextAndIconColor = Color.parseColor("#FFFFFF");
@@ -1133,6 +1147,7 @@ public class CustomThemeWrapper {
customTheme.commentBackgroundColor = Color.parseColor("#393A59");
customTheme.bottomAppBarBackgroundColor = Color.parseColor("#393A59");
customTheme.primaryIconColor = Color.parseColor("#FFFFFF");
+ customTheme.bottomAppBarIconColor = Color.parseColor("#FFFFFF");
customTheme.postIconAndInfoColor = Color.parseColor("#FFFFFF");
customTheme.commentIconAndInfoColor = Color.parseColor("#FFFFFF");
customTheme.toolbarPrimaryTextAndIconColor = Color.parseColor("#FFFFFF");
@@ -1209,6 +1224,7 @@ public class CustomThemeWrapper {
customTheme.commentBackgroundColor = Color.parseColor("#C0F0F4");
customTheme.bottomAppBarBackgroundColor = Color.parseColor("#D48AE0");
customTheme.primaryIconColor = Color.parseColor("#000000");
+ customTheme.bottomAppBarIconColor = Color.parseColor("#000000");
customTheme.postIconAndInfoColor = Color.parseColor("#000000");
customTheme.commentIconAndInfoColor = Color.parseColor("#000000");
customTheme.toolbarPrimaryTextAndIconColor = Color.parseColor("#3C4043");
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CustomView/CustomToroContainer.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CustomView/CustomToroContainer.java
new file mode 100644
index 00000000..40e3fe3e
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CustomView/CustomToroContainer.java
@@ -0,0 +1,27 @@
+package ml.docilealligator.infinityforreddit.CustomView;
+
+import android.content.Context;
+import android.util.AttributeSet;
+
+import androidx.annotation.Nullable;
+
+import im.ene.toro.widget.Container;
+
+public class CustomToroContainer extends Container {
+ public CustomToroContainer(Context context) {
+ super(context);
+ }
+
+ public CustomToroContainer(Context context, @Nullable AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public CustomToroContainer(Context context, @Nullable AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ }
+
+ @Override
+ public void onWindowVisibilityChanged(int visibility) {
+ super.onWindowVisibilityChanged(visibility);
+ }
+}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Event/ChangeVideoAutoplayEvent.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Event/ChangeVideoAutoplayEvent.java
new file mode 100644
index 00000000..76e7a589
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Event/ChangeVideoAutoplayEvent.java
@@ -0,0 +1,9 @@
+package ml.docilealligator.infinityforreddit.Event;
+
+public class ChangeVideoAutoplayEvent {
+ public String autoplay;
+
+ public ChangeVideoAutoplayEvent(String autoplay) {
+ this.autoplay = autoplay;
+ }
+}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Event/ChangeWifiStatusEvent.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Event/ChangeWifiStatusEvent.java
new file mode 100644
index 00000000..2c25b8c9
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Event/ChangeWifiStatusEvent.java
@@ -0,0 +1,8 @@
+package ml.docilealligator.infinityforreddit.Event;
+
+public class ChangeWifiStatusEvent {
+ public boolean isConnectedToWifi;
+ public ChangeWifiStatusEvent(boolean isConnectedToWifi) {
+ this.isConnectedToWifi = isConnectedToWifi;
+ }
+}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchRules.java b/app/src/main/java/ml/docilealligator/infinityforreddit/FetchRules.java
new file mode 100644
index 00000000..604fe82f
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/FetchRules.java
@@ -0,0 +1,101 @@
+package ml.docilealligator.infinityforreddit;
+
+import android.os.AsyncTask;
+
+import androidx.annotation.NonNull;
+
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.ArrayList;
+
+import ml.docilealligator.infinityforreddit.Utils.JSONUtils;
+import ml.docilealligator.infinityforreddit.Utils.Utils;
+import retrofit2.Call;
+import retrofit2.Callback;
+import retrofit2.Response;
+import retrofit2.Retrofit;
+
+public class FetchRules {
+ public interface FetchRulesListener {
+ void success(ArrayList<Rule> rules);
+ void failed();
+ }
+
+ public static void fetchRules(Retrofit retrofit, String subredditName, FetchRulesListener fetchRulesListener) {
+
+ RedditAPI api = retrofit.create(RedditAPI.class);
+ Call<String> rulesCall = api.getRules(subredditName);
+ rulesCall.enqueue(new Callback<String>() {
+ @Override
+ public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
+ if (response.isSuccessful()) {
+ new ParseRulesAsyncTask(response.body(), new ParseRulesAsyncTask.ParseRulesAsyncTaskListener() {
+ @Override
+ public void parseSuccessful(ArrayList<Rule> rules) {
+ fetchRulesListener.success(rules);
+ }
+
+ @Override
+ public void parseFailed() {
+ fetchRulesListener.failed();
+ }
+ }).execute();
+ } else {
+ fetchRulesListener.failed();
+ }
+ }
+
+ @Override
+ public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
+ fetchRulesListener.failed();
+ }
+ });
+ }
+
+ private static class ParseRulesAsyncTask extends AsyncTask<Void, ArrayList<Rule>, ArrayList<Rule>> {
+ private String response;
+ private ParseRulesAsyncTask.ParseRulesAsyncTaskListener parseRulesAsyncTaskListener;
+
+ ParseRulesAsyncTask(String response, ParseRulesAsyncTask.ParseRulesAsyncTaskListener parseRulesAsyncTaskListener) {
+ this.response = response;
+ this.parseRulesAsyncTaskListener = parseRulesAsyncTaskListener;
+ }
+
+ @Override
+ protected ArrayList<Rule> doInBackground(Void... voids) {
+ try {
+ JSONArray rulesArray = new JSONObject(response).getJSONArray(JSONUtils.RULES_KEY);
+ ArrayList<Rule> rules = new ArrayList<>();
+ for (int i = 0; i < rulesArray.length(); i++) {
+ String shortName = rulesArray.getJSONObject(i).getString(JSONUtils.SHORT_NAME_KEY);
+ String description = null;
+ if (rulesArray.getJSONObject(i).has(JSONUtils.DESCRIPTION_KEY)) {
+ description = Utils.modifyMarkdown(rulesArray.getJSONObject(i).getString(JSONUtils.DESCRIPTION_KEY));
+ }
+ rules.add(new Rule(shortName, description));
+ }
+ return rules;
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ @Override
+ protected void onPostExecute(ArrayList<Rule> rules) {
+ if (rules != null) {
+ parseRulesAsyncTaskListener.parseSuccessful(rules);
+ } else {
+ parseRulesAsyncTaskListener.parseFailed();
+ }
+ }
+
+ interface ParseRulesAsyncTaskListener {
+ void parseSuccessful(ArrayList<Rule> rules);
+
+ void parseFailed();
+ }
+ }
+}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CommentMoreBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CommentMoreBottomSheetFragment.java
index d339b5f6..fd97f1d4 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CommentMoreBottomSheetFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CommentMoreBottomSheetFragment.java
@@ -22,6 +22,7 @@ import com.deishelon.roundedbottomsheet.RoundedBottomSheetDialogFragment;
import butterknife.BindView;
import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.Activity.EditCommentActivity;
+import ml.docilealligator.infinityforreddit.Activity.ReportActivity;
import ml.docilealligator.infinityforreddit.Activity.ViewPostDetailActivity;
import ml.docilealligator.infinityforreddit.Activity.ViewUserDetailActivity;
import ml.docilealligator.infinityforreddit.CommentData;
@@ -44,6 +45,8 @@ public class CommentMoreBottomSheetFragment extends RoundedBottomSheetDialogFrag
TextView shareTextView;
@BindView(R.id.copy_text_view_comment_more_bottom_sheet_fragment)
TextView copyTextView;
+ @BindView(R.id.report_view_comment_more_bottom_sheet_fragment)
+ TextView reportTextView;
private AppCompatActivity activity;
public CommentMoreBottomSheetFragment() {
// Required empty public constructor
@@ -119,6 +122,15 @@ public class CommentMoreBottomSheetFragment extends RoundedBottomSheetDialogFrag
copyTextBottomSheetFragment.show(activity.getSupportFragmentManager(), copyTextBottomSheetFragment.getTag());
});
+ reportTextView.setOnClickListener(view -> {
+ Intent intent = new Intent(activity, ReportActivity.class);
+ intent.putExtra(ReportActivity.EXTRA_SUBREDDIT_NAME, commentData.getSubredditName());
+ intent.putExtra(ReportActivity.EXTRA_THING_FULLNAME, commentData.getFullName());
+ activity.startActivity(intent);
+
+ dismiss();
+ });
+
return rootView;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java
index 07ef965a..9d058e3b 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java
@@ -46,19 +46,26 @@ import javax.inject.Named;
import butterknife.BindView;
import butterknife.ButterKnife;
+import im.ene.toro.exoplayer.ExoCreator;
+import im.ene.toro.media.PlaybackInfo;
+import im.ene.toro.media.VolumeInfo;
+import im.ene.toro.widget.Container;
import ml.docilealligator.infinityforreddit.Activity.BaseActivity;
import ml.docilealligator.infinityforreddit.Activity.FilteredThingActivity;
import ml.docilealligator.infinityforreddit.Activity.MainActivity;
import ml.docilealligator.infinityforreddit.Activity.ViewSubredditDetailActivity;
import ml.docilealligator.infinityforreddit.Adapter.PostRecyclerViewAdapter;
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
+import ml.docilealligator.infinityforreddit.CustomView.CustomToroContainer;
import ml.docilealligator.infinityforreddit.Event.ChangeDefaultPostLayoutEvent;
import ml.docilealligator.infinityforreddit.Event.ChangeNSFWBlurEvent;
import ml.docilealligator.infinityforreddit.Event.ChangePostLayoutEvent;
import ml.docilealligator.infinityforreddit.Event.ChangeShowAbsoluteNumberOfVotesEvent;
import ml.docilealligator.infinityforreddit.Event.ChangeShowElapsedTimeEvent;
import ml.docilealligator.infinityforreddit.Event.ChangeSpoilerBlurEvent;
+import ml.docilealligator.infinityforreddit.Event.ChangeVideoAutoplayEvent;
import ml.docilealligator.infinityforreddit.Event.ChangeVoteButtonsPositionEvent;
+import ml.docilealligator.infinityforreddit.Event.ChangeWifiStatusEvent;
import ml.docilealligator.infinityforreddit.Event.PostUpdateEventToPostList;
import ml.docilealligator.infinityforreddit.Event.ShowDividerInCompactLayoutPreferenceEvent;
import ml.docilealligator.infinityforreddit.FragmentCommunicator;
@@ -71,8 +78,12 @@ import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.SortType;
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
+import ml.docilealligator.infinityforreddit.Utils.Utils;
import retrofit2.Retrofit;
+import static im.ene.toro.media.PlaybackInfo.INDEX_UNSET;
+import static im.ene.toro.media.PlaybackInfo.TIME_UNSET;
+
/**
* A simple {@link Fragment} subclass.
@@ -94,7 +105,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
@BindView(R.id.swipe_refresh_layout_post_fragment)
SwipeRefreshLayout mSwipeRefreshLayout;
@BindView(R.id.recycler_view_post_fragment)
- RecyclerView mPostRecyclerView;
+ CustomToroContainer mPostRecyclerView;
@BindView(R.id.fetch_post_info_linear_layout_post_fragment)
LinearLayout mFetchPostInfoLinearLayout;
@BindView(R.id.fetch_post_info_image_view_post_fragment)
@@ -121,6 +132,8 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
SharedPreferences mPostLayoutSharedPreferences;
@Inject
CustomThemeWrapper customThemeWrapper;
+ @Inject
+ ExoCreator exoCreator;
private RequestManager mGlide;
private AppCompatActivity activity;
private LinearLayoutManager mLinearLayoutManager;
@@ -151,6 +164,9 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
if (isInLazyMode && isLazyModePaused) {
resumeLazyMode(false);
}
+ if (mAdapter != null && mPostRecyclerView != null) {
+ mPostRecyclerView.onWindowVisibilityChanged(View.VISIBLE);
+ }
}
private boolean scrollPostsByCount(int count) {
@@ -323,12 +339,6 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
int filter = getArguments().getInt(EXTRA_FILTER);
String accessToken = getArguments().getString(EXTRA_ACCESS_TOKEN);
boolean nsfw = mSharedPreferences.getBoolean(SharedPreferencesUtils.NSFW_KEY, false);
- boolean needBlurNsfw = mSharedPreferences.getBoolean(SharedPreferencesUtils.BLUR_NSFW_KEY, true);
- boolean needBlurSpoiler = mSharedPreferences.getBoolean(SharedPreferencesUtils.BLUR_SPOILER_KEY, false);
- boolean voteButtonsOnTheRight = mSharedPreferences.getBoolean(SharedPreferencesUtils.VOTE_BUTTONS_ON_THE_RIGHT_KEY, false);
- boolean showElapsedTime = mSharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_ELAPSED_TIME_KEY, false);
- boolean showDividerInCompactLayout = mSharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_DIVIDER_IN_COMPACT_LAYOUT, true);
- boolean showAbsoluteNumberOfVotes = mSharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_ABSOLUTE_NUMBER_OF_VOTES, true);
int defaultPostLayout = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.DEFAULT_POST_LAYOUT_KEY, "0"));
if (postType == PostDataSource.TYPE_SEARCH) {
@@ -342,9 +352,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mRedditDataRoomDatabase,
customThemeWrapper, accessToken, postType, postLayout, true,
- needBlurNsfw, needBlurSpoiler, voteButtonsOnTheRight, showElapsedTime,
- showDividerInCompactLayout, showAbsoluteNumberOfVotes,
- new PostRecyclerViewAdapter.Callback() {
+ mSharedPreferences, exoCreator, new PostRecyclerViewAdapter.Callback() {
@Override
public void retryLoadingMore() {
mPostViewModel.retryLoadingMore();
@@ -407,9 +415,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mRedditDataRoomDatabase,
customThemeWrapper, accessToken, postType, postLayout, displaySubredditName,
- needBlurNsfw, needBlurSpoiler, voteButtonsOnTheRight, showElapsedTime,
- showDividerInCompactLayout, showAbsoluteNumberOfVotes,
- new PostRecyclerViewAdapter.Callback() {
+ mSharedPreferences, exoCreator, new PostRecyclerViewAdapter.Callback() {
@Override
public void retryLoadingMore() {
mPostViewModel.retryLoadingMore();
@@ -457,9 +463,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mRedditDataRoomDatabase,
customThemeWrapper, accessToken, postType, postLayout, true,
- needBlurNsfw, needBlurSpoiler, voteButtonsOnTheRight, showElapsedTime,
- showDividerInCompactLayout, showAbsoluteNumberOfVotes,
- new PostRecyclerViewAdapter.Callback() {
+ mSharedPreferences, exoCreator, new PostRecyclerViewAdapter.Callback() {
@Override
public void retryLoadingMore() {
mPostViewModel.retryLoadingMore();
@@ -505,9 +509,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mRedditDataRoomDatabase,
customThemeWrapper, accessToken, postType, postLayout, true,
- needBlurNsfw, needBlurSpoiler, voteButtonsOnTheRight, showElapsedTime,
- showDividerInCompactLayout, showAbsoluteNumberOfVotes,
- new PostRecyclerViewAdapter.Callback() {
+ mSharedPreferences, exoCreator, new PostRecyclerViewAdapter.Callback() {
@Override
public void retryLoadingMore() {
mPostViewModel.retryLoadingMore();
@@ -546,9 +548,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mRedditDataRoomDatabase,
customThemeWrapper, accessToken, postType, postLayout, true,
- needBlurNsfw, needBlurSpoiler, voteButtonsOnTheRight, showElapsedTime,
- showDividerInCompactLayout, showAbsoluteNumberOfVotes,
- new PostRecyclerViewAdapter.Callback() {
+ mSharedPreferences, exoCreator, new PostRecyclerViewAdapter.Callback() {
@Override
public void retryLoadingMore() {
mPostViewModel.retryLoadingMore();
@@ -569,6 +569,12 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
}
mPostRecyclerView.setAdapter(mAdapter);
+ mPostRecyclerView.setCacheManager(mAdapter);
+ mPostRecyclerView.setPlayerInitializer(order -> {
+ VolumeInfo volumeInfo = new VolumeInfo(true, 0f);
+ return new PlaybackInfo(INDEX_UNSET, TIME_UNSET, volumeInfo);
+ });
+
mPostViewModel.getPosts().observe(this, posts -> mAdapter.submitList(posts));
mPostViewModel.hasPost().observe(this, hasPost -> {
@@ -846,6 +852,31 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
}
}
+ @Subscribe
+ public void onChangeVideoAutoplayEvent(ChangeVideoAutoplayEvent changeVideoAutoplayEvent) {
+ if (mAdapter != null) {
+ boolean autoplay = false;
+ if (changeVideoAutoplayEvent.autoplay.equals(SharedPreferencesUtils.VIDEO_AUTOPLAY_VALUE_ALWAYS_ON)) {
+ autoplay = true;
+ } else if (changeVideoAutoplayEvent.autoplay.equals(SharedPreferencesUtils.VIDEO_AUTOPLAY_VALUE_ON_WIFI)) {
+ autoplay = Utils.isConnectedToWifi(activity);
+ }
+ mAdapter.setAutoplay(autoplay);
+ refreshAdapter();
+ }
+ }
+
+ @Subscribe
+ public void onChangeWifiStatusEvent(ChangeWifiStatusEvent changeWifiStatusEvent) {
+ if (mAdapter != null) {
+ String autoplay = mSharedPreferences.getString(SharedPreferencesUtils.VIDEO_AUTOPLAY, SharedPreferencesUtils.VIDEO_AUTOPLAY_VALUE_NEVER);
+ if (autoplay.equals(SharedPreferencesUtils.VIDEO_AUTOPLAY_VALUE_ON_WIFI)) {
+ mAdapter.setAutoplay(changeWifiStatusEvent.isConnectedToWifi);
+ refreshAdapter();
+ }
+ }
+ }
+
private void refreshAdapter() {
int previousPosition = -1;
if (mLinearLayoutManager != null) {
@@ -872,6 +903,9 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
if (isInLazyMode) {
pauseLazyMode(false);
}
+ if (mAdapter != null && mPostRecyclerView != null) {
+ mPostRecyclerView.onWindowVisibilityChanged(View.GONE);
+ }
}
@Override
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Infinity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Infinity.java
index df5a1100..90478a08 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Infinity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Infinity.java
@@ -1,6 +1,8 @@
package ml.docilealligator.infinityforreddit;
import android.app.Application;
+import android.content.IntentFilter;
+import android.net.ConnectivityManager;
import android.os.Bundle;
import androidx.annotation.NonNull;
@@ -10,8 +12,15 @@ import com.evernote.android.state.StateSaver;
import com.livefront.bridge.Bridge;
import com.livefront.bridge.SavedStateHandler;
+import org.greenrobot.eventbus.EventBus;
+
+import ml.docilealligator.infinityforreddit.BroadcastReceiver.NetworkWifiStatusReceiver;
+import ml.docilealligator.infinityforreddit.Event.ChangeWifiStatusEvent;
+import ml.docilealligator.infinityforreddit.Utils.Utils;
+
public class Infinity extends Application {
private AppComponent mAppComponent;
+ private NetworkWifiStatusReceiver mNetworkWifiStatusReceiver;
@Override
public void onCreate() {
@@ -32,6 +41,10 @@ public class Infinity extends Application {
StateSaver.restoreInstanceState(target, state);
}
});
+
+ mNetworkWifiStatusReceiver =
+ new NetworkWifiStatusReceiver(() -> EventBus.getDefault().post(new ChangeWifiStatusEvent(Utils.isConnectedToWifi(getApplicationContext()))));
+ registerReceiver(mNetworkWifiStatusReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
}
public AppComponent getAppComponent() {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ParseSubredditData.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ParseSubredditData.java
index bb64d7df..73854808 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/ParseSubredditData.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ParseSubredditData.java
@@ -25,6 +25,7 @@ class ParseSubredditData {
String subredditFullName = subredditDataJsonObject.getString(JSONUtils.DISPLAY_NAME_KEY);
String description = subredditDataJsonObject.getString(JSONUtils.PUBLIC_DESCRIPTION_KEY).trim();
String sidebarDescription = subredditDataJsonObject.getString(JSONUtils.DESCRIPTION_KEY).trim();
+ long createdUTC = subredditDataJsonObject.getLong(JSONUtils.CREATED_UTC_KEY) * 1000;
String bannerImageUrl;
if (subredditDataJsonObject.isNull(JSONUtils.BANNER_BACKGROUND_IMAGE_KEY)) {
@@ -52,7 +53,7 @@ class ParseSubredditData {
}
return new SubredditData(id, subredditFullName, iconUrl, bannerImageUrl, description,
- sidebarDescription, nSubscribers);
+ sidebarDescription, nSubscribers, createdUTC);
}
interface ParseSubredditDataListener {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ParseSubscribedThing.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ParseSubscribedThing.java
index 97827fc2..97da7db6 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/ParseSubscribedThing.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ParseSubscribedThing.java
@@ -99,9 +99,10 @@ class ParseSubscribedThing {
String description = data.getString(JSONUtils.PUBLIC_DESCRIPTION_KEY).trim();
String sidebarDescription = data.getString(JSONUtils.DESCRIPTION_KEY);
int nSubscribers = data.getInt(JSONUtils.SUBSCRIBERS_KEY);
+ long createdUTC = data.getLong(JSONUtils.CREATED_UTC_KEY);
newSubscribedSubredditData.add(new SubscribedSubredditData(id, name, iconUrl, accountName, isFavorite));
newSubredditData.add(new SubredditData(id, subredditFullName, iconUrl,
- bannerImageUrl, description, sidebarDescription, nSubscribers));
+ bannerImageUrl, description, sidebarDescription, nSubscribers, createdUTC));
}
}
lastItem = jsonResponse.getJSONObject(JSONUtils.DATA_KEY).getString(JSONUtils.AFTER_KEY);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ParseUserData.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ParseUserData.java
index 73932c34..f3766d05 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/ParseUserData.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ParseUserData.java
@@ -38,11 +38,13 @@ public class ParseUserData {
}
int linkKarma = userDataJson.getInt(JSONUtils.LINK_KARMA_KEY);
int commentKarma = userDataJson.getInt(JSONUtils.COMMENT_KARMA_KEY);
- int karma = linkKarma + commentKarma;
+ long cakeday = userDataJson.getLong(JSONUtils.CREATED_UTC_KEY) * 1000;
boolean isGold = userDataJson.getBoolean(JSONUtils.IS_GOLD_KEY);
boolean isFriend = userDataJson.getBoolean(JSONUtils.IS_FRIEND_KEY);
+ String description = userDataJson.getJSONObject(JSONUtils.SUBREDDIT_KEY).getString(JSONUtils.PUBLIC_DESCRIPTION_KEY);
- return new UserData(userName, iconImageUrl, bannerImageUrl, karma, isGold, isFriend, canBeFollowed);
+ return new UserData(userName, iconImageUrl, bannerImageUrl, linkKarma, commentKarma, cakeday,
+ isGold, isFriend, canBeFollowed, description);
}
interface ParseUserDataListener {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchPost.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Post/FetchPost.java
index 9f0c93ba..ccbec648 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchPost.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Post/FetchPost.java
@@ -1,10 +1,10 @@
-package ml.docilealligator.infinityforreddit;
+package ml.docilealligator.infinityforreddit.Post;
import androidx.annotation.NonNull;
import java.util.Locale;
-import ml.docilealligator.infinityforreddit.Post.Post;
+import ml.docilealligator.infinityforreddit.RedditAPI;
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
import retrofit2.Call;
import retrofit2.Callback;
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/HidePost.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Post/HidePost.java
index 39f6a2fb..ab031fa5 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/HidePost.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Post/HidePost.java
@@ -1,10 +1,11 @@
-package ml.docilealligator.infinityforreddit;
+package ml.docilealligator.infinityforreddit.Post;
import androidx.annotation.NonNull;
import java.util.HashMap;
import java.util.Map;
+import ml.docilealligator.infinityforreddit.RedditAPI;
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
import retrofit2.Call;
import retrofit2.Callback;
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ParsePost.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Post/ParsePost.java
index 3a4845e1..ba59f855 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/ParsePost.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Post/ParsePost.java
@@ -1,4 +1,4 @@
-package ml.docilealligator.infinityforreddit;
+package ml.docilealligator.infinityforreddit.Post;
import android.os.AsyncTask;
import android.text.Html;
@@ -8,12 +8,11 @@ import org.json.JSONException;
import org.json.JSONObject;
import java.text.SimpleDateFormat;
-import java.util.ArrayList;
import java.util.Calendar;
+import java.util.LinkedHashSet;
import java.util.Locale;
import ml.docilealligator.infinityforreddit.Fragment.PostFragment;
-import ml.docilealligator.infinityforreddit.Post.Post;
import ml.docilealligator.infinityforreddit.Utils.JSONUtils;
import ml.docilealligator.infinityforreddit.Utils.Utils;
@@ -357,7 +356,7 @@ public class ParsePost {
}
public interface ParsePostsListingListener {
- void onParsePostsListingSuccess(ArrayList<Post> newPostData, String lastItem);
+ void onParsePostsListingSuccess(LinkedHashSet<Post> newPostData, String lastItem);
void onParsePostsListingFail();
}
@@ -376,7 +375,7 @@ public class ParsePost {
private boolean nsfw;
private ParsePostsListingListener parsePostsListingListener;
private ParsePostListener parsePostListener;
- private ArrayList<Post> newPosts;
+ private LinkedHashSet<Post> newPosts;
private Post post;
private String lastItem;
private boolean parseFailed;
@@ -392,7 +391,7 @@ public class ParsePost {
this.nPosts = nPosts;
this.filter = filter;
this.nsfw = nsfw;
- newPosts = new ArrayList<>();
+ newPosts = new LinkedHashSet<>();
parseFailed = false;
} catch (JSONException e) {
e.printStackTrace();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Post/Post.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Post/Post.java
index d8b98ad8..b5aa1f1c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Post/Post.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Post/Post.java
@@ -3,6 +3,8 @@ package ml.docilealligator.infinityforreddit.Post;
import android.os.Parcel;
import android.os.Parcelable;
+import androidx.annotation.Nullable;
+
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
/**
@@ -506,4 +508,12 @@ public class Post implements Parcelable {
parcel.writeByte((byte) (isCrosspost ? 1 : 0));
parcel.writeString(crosspostParentId);
}
+
+ @Override
+ public boolean equals(@Nullable Object obj) {
+ if (!(obj instanceof Post)) {
+ return false;
+ }
+ return ((Post) obj).id.equals(id);
+ }
} \ No newline at end of file
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Post/PostDataSource.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Post/PostDataSource.java
index 19536c47..b26eef79 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Post/PostDataSource.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Post/PostDataSource.java
@@ -5,10 +5,11 @@ import androidx.lifecycle.MutableLiveData;
import androidx.paging.PageKeyedDataSource;
import java.util.ArrayList;
+import java.util.LinkedHashSet;
+import java.util.List;
import java.util.Locale;
import ml.docilealligator.infinityforreddit.NetworkState;
-import ml.docilealligator.infinityforreddit.ParsePost;
import ml.docilealligator.infinityforreddit.RedditAPI;
import ml.docilealligator.infinityforreddit.SortType;
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
@@ -42,6 +43,7 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
private int filter;
private String userWhere;
private String multiRedditPath;
+ private LinkedHashSet<Post> postLinkedHashSet;
private MutableLiveData<NetworkState> paginationNetworkStateLiveData;
private MutableLiveData<NetworkState> initialLoadStateLiveData;
@@ -62,6 +64,7 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
this.sortType = sortType == null ? new SortType(SortType.Type.BEST) : sortType;
this.filter = filter;
this.nsfw = nsfw;
+ postLinkedHashSet = new LinkedHashSet<>();
}
PostDataSource(Retrofit retrofit, String accessToken, Locale locale, String path, int postType,
@@ -97,6 +100,7 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
}
this.filter = filter;
this.nsfw = nsfw;
+ postLinkedHashSet = new LinkedHashSet<>();
}
PostDataSource(Retrofit retrofit, String accessToken, Locale locale, String subredditOrUserName, int postType,
@@ -113,6 +117,7 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
userWhere = where;
this.filter = filter;
this.nsfw = nsfw;
+ postLinkedHashSet = new LinkedHashSet<>();
}
PostDataSource(Retrofit retrofit, String accessToken, Locale locale, String subredditOrUserName, String query,
@@ -129,6 +134,7 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
this.sortType = sortType == null ? new SortType(SortType.Type.RELEVANCE) : sortType;
this.filter = filter;
this.nsfw = nsfw;
+ postLinkedHashSet = new LinkedHashSet<>();
}
MutableLiveData<NetworkState> getPaginationNetworkStateLiveData() {
@@ -234,7 +240,7 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
ParsePost.parsePosts(response.body(), locale, -1, filter, nsfw,
new ParsePost.ParsePostsListingListener() {
@Override
- public void onParsePostsListingSuccess(ArrayList<Post> newPosts, String lastItem) {
+ public void onParsePostsListingSuccess(LinkedHashSet<Post> newPosts, String lastItem) {
String nextPageKey;
if (lastItem == null || lastItem.equals("") || lastItem.equals("null")) {
nextPageKey = null;
@@ -243,13 +249,15 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
}
if (newPosts.size() != 0) {
- callback.onResult(newPosts, null, nextPageKey);
+ postLinkedHashSet.addAll(newPosts);
+ callback.onResult(new ArrayList<>(newPosts), null, nextPageKey);
hasPostLiveData.postValue(true);
} else if (nextPageKey != null) {
loadBestPostsInitial(callback, nextPageKey);
return;
} else {
- callback.onResult(newPosts, null, nextPageKey);
+ postLinkedHashSet.addAll(newPosts);
+ callback.onResult(new ArrayList<>(newPosts), null, nextPageKey);
hasPostLiveData.postValue(false);
}
@@ -296,11 +304,18 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
ParsePost.parsePosts(response.body(), locale, -1, filter, nsfw,
new ParsePost.ParsePostsListingListener() {
@Override
- public void onParsePostsListingSuccess(ArrayList<Post> newPosts, String lastItem) {
+ public void onParsePostsListingSuccess(LinkedHashSet<Post> newPosts, String lastItem) {
if (newPosts.size() == 0 && lastItem != null && !lastItem.equals("") && !lastItem.equals("null")) {
loadBestPostsAfter(params, callback, lastItem);
} else {
- callback.onResult(newPosts, lastItem);
+ int currentPostsSize = postLinkedHashSet.size();
+ postLinkedHashSet.addAll(newPosts);
+ if (currentPostsSize == postLinkedHashSet.size()) {
+ callback.onResult(new ArrayList<>(), lastItem);
+ } else {
+ List<Post> newPostsList = new ArrayList<>(postLinkedHashSet).subList(currentPostsSize, postLinkedHashSet.size());
+ callback.onResult(newPostsList, lastItem);
+ }
paginationNetworkStateLiveData.postValue(NetworkState.LOADED);
}
}
@@ -366,7 +381,7 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
ParsePost.parsePosts(response.body(), locale, -1, filter, nsfw,
new ParsePost.ParsePostsListingListener() {
@Override
- public void onParsePostsListingSuccess(ArrayList<Post> newPosts, String lastItem) {
+ public void onParsePostsListingSuccess(LinkedHashSet<Post> newPosts, String lastItem) {
String nextPageKey;
if (lastItem == null || lastItem.equals("") || lastItem.equals("null")) {
nextPageKey = null;
@@ -375,13 +390,15 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
}
if (newPosts.size() != 0) {
- callback.onResult(newPosts, null, nextPageKey);
+ postLinkedHashSet.addAll(newPosts);
+ callback.onResult(new ArrayList<>(newPosts), null, nextPageKey);
hasPostLiveData.postValue(true);
} else if (nextPageKey != null) {
loadSubredditPostsInitial(callback, nextPageKey);
return;
} else {
- callback.onResult(newPosts, null, nextPageKey);
+ postLinkedHashSet.addAll(newPosts);
+ callback.onResult(new ArrayList<>(newPosts), null, nextPageKey);
hasPostLiveData.postValue(false);
}
@@ -439,11 +456,18 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
ParsePost.parsePosts(response.body(), locale, -1, filter, nsfw,
new ParsePost.ParsePostsListingListener() {
@Override
- public void onParsePostsListingSuccess(ArrayList<Post> newPosts, String lastItem) {
+ public void onParsePostsListingSuccess(LinkedHashSet<Post> newPosts, String lastItem) {
if (newPosts.size() == 0 && lastItem != null && !lastItem.equals("") && !lastItem.equals("null")) {
loadSubredditPostsAfter(params, callback, lastItem);
} else {
- callback.onResult(newPosts, lastItem);
+ int currentPostsSize = postLinkedHashSet.size();
+ postLinkedHashSet.addAll(newPosts);
+ if (currentPostsSize == postLinkedHashSet.size()) {
+ callback.onResult(new ArrayList<>(), lastItem);
+ } else {
+ List<Post> newPostsList = new ArrayList<>(postLinkedHashSet).subList(currentPostsSize, postLinkedHashSet.size());
+ callback.onResult(newPostsList, lastItem);
+ }
paginationNetworkStateLiveData.postValue(NetworkState.LOADED);
}
}
@@ -493,7 +517,7 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
ParsePost.parsePosts(response.body(), locale, -1, filter, nsfw,
new ParsePost.ParsePostsListingListener() {
@Override
- public void onParsePostsListingSuccess(ArrayList<Post> newPosts, String lastItem) {
+ public void onParsePostsListingSuccess(LinkedHashSet<Post> newPosts, String lastItem) {
String nextPageKey;
if (lastItem == null || lastItem.equals("") || lastItem.equals("null")) {
nextPageKey = null;
@@ -502,13 +526,15 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
}
if (newPosts.size() != 0) {
- callback.onResult(newPosts, null, nextPageKey);
+ postLinkedHashSet.addAll(newPosts);
+ callback.onResult(new ArrayList<>(newPosts), null, nextPageKey);
hasPostLiveData.postValue(true);
} else if (nextPageKey != null) {
loadUserPostsInitial(callback, nextPageKey);
return;
} else {
- callback.onResult(newPosts, null, nextPageKey);
+ postLinkedHashSet.addAll(newPosts);
+ callback.onResult(new ArrayList<>(newPosts), null, nextPageKey);
hasPostLiveData.postValue(false);
}
@@ -562,11 +588,18 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
ParsePost.parsePosts(response.body(), locale, -1, filter, nsfw,
new ParsePost.ParsePostsListingListener() {
@Override
- public void onParsePostsListingSuccess(ArrayList<Post> newPosts, String lastItem) {
+ public void onParsePostsListingSuccess(LinkedHashSet<Post> newPosts, String lastItem) {
if (newPosts.size() == 0 && lastItem != null && !lastItem.equals("") && !lastItem.equals("null")) {
loadUserPostsAfter(params, callback, lastItem);
} else {
- callback.onResult(newPosts, lastItem);
+ int currentPostsSize = postLinkedHashSet.size();
+ postLinkedHashSet.addAll(newPosts);
+ if (currentPostsSize == postLinkedHashSet.size()) {
+ callback.onResult(new ArrayList<>(), lastItem);
+ } else {
+ List<Post> newPostsList = new ArrayList<>(postLinkedHashSet).subList(currentPostsSize, postLinkedHashSet.size());
+ callback.onResult(newPostsList, lastItem);
+ }
paginationNetworkStateLiveData.postValue(NetworkState.LOADED);
}
}
@@ -638,7 +671,7 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
ParsePost.parsePosts(response.body(), locale, -1, filter, nsfw,
new ParsePost.ParsePostsListingListener() {
@Override
- public void onParsePostsListingSuccess(ArrayList<Post> newPosts, String lastItem) {
+ public void onParsePostsListingSuccess(LinkedHashSet<Post> newPosts, String lastItem) {
String nextPageKey;
if (lastItem == null || lastItem.equals("") || lastItem.equals("null")) {
nextPageKey = null;
@@ -647,13 +680,15 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
}
if (newPosts.size() != 0) {
- callback.onResult(newPosts, null, nextPageKey);
+ postLinkedHashSet.addAll(newPosts);
+ callback.onResult(new ArrayList<>(newPosts), null, nextPageKey);
hasPostLiveData.postValue(true);
} else if (nextPageKey != null) {
loadSearchPostsInitial(callback, nextPageKey);
return;
} else {
- callback.onResult(newPosts, null, nextPageKey);
+ postLinkedHashSet.addAll(newPosts);
+ callback.onResult(new ArrayList<>(newPosts), null, nextPageKey);
hasPostLiveData.postValue(false);
}
@@ -727,11 +762,18 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
ParsePost.parsePosts(response.body(), locale, -1, filter, nsfw,
new ParsePost.ParsePostsListingListener() {
@Override
- public void onParsePostsListingSuccess(ArrayList<Post> newPosts, String lastItem) {
+ public void onParsePostsListingSuccess(LinkedHashSet<Post> newPosts, String lastItem) {
if (newPosts.size() == 0 && lastItem != null && !lastItem.equals("") && !lastItem.equals("null")) {
loadSearchPostsAfter(params, callback, lastItem);
} else {
- callback.onResult(newPosts, lastItem);
+ int currentPostsSize = postLinkedHashSet.size();
+ postLinkedHashSet.addAll(newPosts);
+ if (currentPostsSize == postLinkedHashSet.size()) {
+ callback.onResult(new ArrayList<>(), lastItem);
+ } else {
+ List<Post> newPostsList = new ArrayList<>(postLinkedHashSet).subList(currentPostsSize, postLinkedHashSet.size());
+ callback.onResult(newPostsList, lastItem);
+ }
paginationNetworkStateLiveData.postValue(NetworkState.LOADED);
}
}
@@ -780,7 +822,7 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
ParsePost.parsePosts(response.body(), locale, -1, filter, nsfw,
new ParsePost.ParsePostsListingListener() {
@Override
- public void onParsePostsListingSuccess(ArrayList<Post> newPosts, String lastItem) {
+ public void onParsePostsListingSuccess(LinkedHashSet<Post> newPosts, String lastItem) {
String nextPageKey;
if (lastItem == null || lastItem.equals("") || lastItem.equals("null")) {
nextPageKey = null;
@@ -789,13 +831,15 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
}
if (newPosts.size() != 0) {
- callback.onResult(newPosts, null, nextPageKey);
+ postLinkedHashSet.addAll(newPosts);
+ callback.onResult(new ArrayList<>(newPosts), null, nextPageKey);
hasPostLiveData.postValue(true);
} else if (nextPageKey != null) {
loadMultiRedditPostsInitial(callback, nextPageKey);
return;
} else {
- callback.onResult(newPosts, null, nextPageKey);
+ postLinkedHashSet.addAll(newPosts);
+ callback.onResult(new ArrayList<>(newPosts), null, nextPageKey);
hasPostLiveData.postValue(false);
}
@@ -849,11 +893,18 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
ParsePost.parsePosts(response.body(), locale, -1, filter, nsfw,
new ParsePost.ParsePostsListingListener() {
@Override
- public void onParsePostsListingSuccess(ArrayList<Post> newPosts, String lastItem) {
+ public void onParsePostsListingSuccess(LinkedHashSet<Post> newPosts, String lastItem) {
if (newPosts.size() == 0 && lastItem != null && !lastItem.equals("") && !lastItem.equals("null")) {
loadMultiRedditPostsAfter(params, callback, lastItem);
} else {
- callback.onResult(newPosts, lastItem);
+ int currentPostsSize = postLinkedHashSet.size();
+ postLinkedHashSet.addAll(newPosts);
+ if (currentPostsSize == postLinkedHashSet.size()) {
+ callback.onResult(new ArrayList<>(), lastItem);
+ } else {
+ List<Post> newPostsList = new ArrayList<>(postLinkedHashSet).subList(currentPostsSize, postLinkedHashSet.size());
+ callback.onResult(newPostsList, lastItem);
+ }
paginationNetworkStateLiveData.postValue(NetworkState.LOADED);
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SubmitPost.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Post/SubmitPost.java
index 6a93edf1..e7479e36 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/SubmitPost.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Post/SubmitPost.java
@@ -1,4 +1,4 @@
-package ml.docilealligator.infinityforreddit;
+package ml.docilealligator.infinityforreddit.Post;
import android.graphics.Bitmap;
import android.os.AsyncTask;
@@ -20,7 +20,7 @@ import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
-import ml.docilealligator.infinityforreddit.Post.Post;
+import ml.docilealligator.infinityforreddit.RedditAPI;
import ml.docilealligator.infinityforreddit.Utils.JSONUtils;
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
import okhttp3.MediaType;
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/RedditAPI.java b/app/src/main/java/ml/docilealligator/infinityforreddit/RedditAPI.java
index 371e31e9..113e1604 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/RedditAPI.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/RedditAPI.java
@@ -304,4 +304,8 @@ public interface RedditAPI {
@GET("/api/multi/multipath/")
Call<String> getMultiRedditInfo(@HeaderMap Map<String, String> headers, @Query("multipath") String multipath);
+
+ @FormUrlEncoded
+ @POST("/api/report")
+ Call<String> report(@HeaderMap Map<String, String> headers, @FieldMap Map<String, String> params);
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/RedditDataRoomDatabase.java b/app/src/main/java/ml/docilealligator/infinityforreddit/RedditDataRoomDatabase.java
index 539bd20e..8743c4c9 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/RedditDataRoomDatabase.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/RedditDataRoomDatabase.java
@@ -26,7 +26,7 @@ import ml.docilealligator.infinityforreddit.User.UserDao;
import ml.docilealligator.infinityforreddit.User.UserData;
@Database(entities = {Account.class, SubredditData.class, SubscribedSubredditData.class, UserData.class,
- SubscribedUserData.class, MultiReddit.class, CustomTheme.class}, version = 7)
+ SubscribedUserData.class, MultiReddit.class, CustomTheme.class}, version = 8)
public abstract class RedditDataRoomDatabase extends RoomDatabase {
private static RedditDataRoomDatabase INSTANCE;
@@ -37,7 +37,7 @@ public abstract class RedditDataRoomDatabase extends RoomDatabase {
INSTANCE = Room.databaseBuilder(context.getApplicationContext(),
RedditDataRoomDatabase.class, "reddit_data")
.addMigrations(MIGRATION_1_2, MIGRATION_2_3, MIGRATION_3_4, MIGRATION_4_5,
- MIGRATION_5_6, MIGRATION_6_7)
+ MIGRATION_5_6, MIGRATION_6_7, MIGRATION_7_8)
.build();
}
}
@@ -165,4 +165,25 @@ public abstract class RedditDataRoomDatabase extends RoomDatabase {
database.execSQL("ALTER TABLE custom_themes ADD COLUMN awards_text_color INTEGER DEFAULT " + Color.parseColor("#FFFFFF") + " NOT NULL");
}
};
+
+ private static final Migration MIGRATION_7_8 = new Migration(7, 8) {
+ @Override
+ public void migrate(@NonNull SupportSQLiteDatabase database) {
+ database.execSQL("CREATE TABLE users_temp " +
+ "(name TEXT NOT NULL PRIMARY KEY, icon TEXT, banner TEXT, " +
+ "link_karma INTEGER NOT NULL, comment_karma INTEGER DEFAULT 0 NOT NULL, created_utc INTEGER DEFAULT 0 NOT NULL," +
+ "is_gold INTEGER NOT NULL, is_friend INTEGER NOT NULL, can_be_followed INTEGER NOT NULL," +
+ "description TEXT)");
+ database.execSQL(
+ "INSERT INTO users_temp(name, icon, banner, link_karma, is_gold, is_friend, can_be_followed) SELECT * FROM users");
+ database.execSQL("DROP TABLE users");
+ database.execSQL("ALTER TABLE users_temp RENAME TO users");
+
+ database.execSQL("ALTER TABLE subreddits"
+ + " ADD COLUMN created_utc INTEGER DEFAULT 0 NOT NULL");
+
+ database.execSQL("ALTER TABLE custom_themes"
+ + " ADD COLUMN bottom_app_bar_icon_color INTEGER DEFAULT " + Color.parseColor("#000000") + " NOT NULL");
+ }
+ };
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ReportReason.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ReportReason.java
new file mode 100644
index 00000000..cedda1d8
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ReportReason.java
@@ -0,0 +1,90 @@
+package ml.docilealligator.infinityforreddit;
+
+import android.content.Context;
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import java.util.ArrayList;
+
+public class ReportReason implements Parcelable {
+ public static final String REASON_TYPE_SITE_REASON = "site_reason";
+ public static final String REASON_TYPE_RULE_REASON = "rule_reason";
+ public static final String REASON_TYPE_OTHER_REASON = "other_reason";
+ public static final String REASON_SITE_REASON_SELECTED = "site_reason_selected";
+ public static final String REASON_RULE_REASON_SELECTED = "rule_reason_selected";
+ public static final String REASON_OTHER = "other";
+
+ private String reportReason;
+ private String reasonType;
+ private boolean isSelected;
+
+ public ReportReason(String reportReason, String reasonType) {
+ this.reportReason = reportReason;
+ this.reasonType = reasonType;
+ this.isSelected = false;
+ }
+
+ protected ReportReason(Parcel in) {
+ reportReason = in.readString();
+ reasonType = in.readString();
+ isSelected = in.readByte() != 0;
+ }
+
+ public static final Creator<ReportReason> CREATOR = new Creator<ReportReason>() {
+ @Override
+ public ReportReason createFromParcel(Parcel in) {
+ return new ReportReason(in);
+ }
+
+ @Override
+ public ReportReason[] newArray(int size) {
+ return new ReportReason[size];
+ }
+ };
+
+ public String getReportReason() {
+ return reportReason;
+ }
+
+ public String getReasonType() {
+ return reasonType;
+ }
+
+ public boolean isSelected() {
+ return isSelected;
+ }
+
+ public void setSelected(boolean selected) {
+ isSelected = selected;
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel parcel, int i) {
+ parcel.writeString(reportReason);
+ parcel.writeString(reasonType);
+ parcel.writeByte((byte) (isSelected ? 1 : 0));
+ }
+
+ public static ArrayList<ReportReason> getGeneralReasons(Context context) {
+ ArrayList<ReportReason> reportReasons = new ArrayList<>();
+ reportReasons.add(new ReportReason(context.getString(R.string.report_reason_general_spam), REASON_TYPE_SITE_REASON));
+ reportReasons.add(new ReportReason(context.getString(R.string.report_reason_general_copyright_issue), REASON_TYPE_SITE_REASON));
+ reportReasons.add(new ReportReason(context.getString(R.string.report_reason_general_child_pornography), REASON_TYPE_SITE_REASON));
+ reportReasons.add(new ReportReason(context.getString(R.string.report_reason_general_abusive_content), REASON_TYPE_SITE_REASON));
+ return reportReasons;
+ }
+
+ public static ArrayList<ReportReason> convertRulesToReasons(ArrayList<Rule> rules) {
+ ArrayList<ReportReason> reportReasons = new ArrayList<>();
+ for (Rule r : rules) {
+ reportReasons.add(new ReportReason(r.getShortName(), REASON_TYPE_RULE_REASON));
+ }
+
+ return reportReasons;
+ }
+}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ReportThing.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ReportThing.java
new file mode 100644
index 00000000..8a617179
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ReportThing.java
@@ -0,0 +1,54 @@
+package ml.docilealligator.infinityforreddit;
+
+import androidx.annotation.NonNull;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
+import retrofit2.Call;
+import retrofit2.Callback;
+import retrofit2.Response;
+import retrofit2.Retrofit;
+
+public class ReportThing {
+
+ public interface ReportThingListener {
+ void success();
+ void failed();
+ }
+
+ public static void reportThing(Retrofit oauthRetrofit, String accessToken, String thingFullname,
+ String subredditName, String reasonType, String reason,
+ ReportThingListener reportThingListener) {
+ Map<String, String> header = RedditUtils.getOAuthHeader(accessToken);
+ Map<String, String> params = new HashMap<>();
+ params.put(RedditUtils.THING_ID_KEY, thingFullname);
+ params.put(RedditUtils.SR_NAME_KEY, subredditName);
+ params.put(reasonType, reason);
+ if (reasonType.equals(ReportReason.REASON_TYPE_SITE_REASON)) {
+ params.put(RedditUtils.REASON_KEY, ReportReason.REASON_SITE_REASON_SELECTED);
+ } else if (reasonType.equals(ReportReason.REASON_TYPE_RULE_REASON)) {
+ params.put(RedditUtils.REASON_KEY, ReportReason.REASON_RULE_REASON_SELECTED);
+ } else {
+ params.put(RedditUtils.REASON_KEY, ReportReason.REASON_OTHER);
+ }
+ params.put(RedditUtils.API_TYPE_KEY, RedditUtils.API_TYPE_JSON);
+
+ oauthRetrofit.create(RedditAPI.class).report(header, params).enqueue(new Callback<String>() {
+ @Override
+ public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
+ if (response.isSuccessful()) {
+ reportThingListener.success();
+ } else {
+ reportThingListener.failed();
+ }
+ }
+
+ @Override
+ public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
+ reportThingListener.failed();
+ }
+ });
+ }
+} \ No newline at end of file
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Service/SubmitPostService.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Service/SubmitPostService.java
index cfce40c8..cedf9730 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Service/SubmitPostService.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Service/SubmitPostService.java
@@ -39,7 +39,7 @@ import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.NotificationUtils;
import ml.docilealligator.infinityforreddit.Post.Post;
import ml.docilealligator.infinityforreddit.R;
-import ml.docilealligator.infinityforreddit.SubmitPost;
+import ml.docilealligator.infinityforreddit.Post.SubmitPost;
import retrofit2.Retrofit;
public class SubmitPostService extends Service {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/MainPreferenceFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/MainPreferenceFragment.java
index 1aea7212..f0b61023 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/MainPreferenceFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/MainPreferenceFragment.java
@@ -7,7 +7,7 @@ import android.content.SharedPreferences;
import android.os.Bundle;
import androidx.annotation.NonNull;
-import androidx.preference.Preference;
+import androidx.preference.ListPreference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.SwitchPreference;
@@ -19,6 +19,7 @@ import javax.inject.Named;
import ml.docilealligator.infinityforreddit.Event.ChangeNSFWBlurEvent;
import ml.docilealligator.infinityforreddit.Event.ChangeNSFWEvent;
import ml.docilealligator.infinityforreddit.Event.ChangeSpoilerBlurEvent;
+import ml.docilealligator.infinityforreddit.Event.ChangeVideoAutoplayEvent;
import ml.docilealligator.infinityforreddit.Event.RecreateActivityEvent;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
@@ -39,18 +40,22 @@ public class MainPreferenceFragment extends PreferenceFragmentCompat {
setPreferencesFromResource(R.xml.main_preferences, rootKey);
((Infinity) activity.getApplication()).getAppComponent().inject(this);
+ ListPreference videoAutoplaySwitch = findPreference(SharedPreferencesUtils.VIDEO_AUTOPLAY);
SwitchPreference confirmToExitSwitch = findPreference(SharedPreferencesUtils.CONFIRM_TO_EXIT);
SwitchPreference nsfwSwitch = findPreference(SharedPreferencesUtils.NSFW_KEY);
SwitchPreference blurNSFWSwitch = findPreference(SharedPreferencesUtils.BLUR_NSFW_KEY);
SwitchPreference blurSpoilerSwitch = findPreference(SharedPreferencesUtils.BLUR_SPOILER_KEY);
+ if (videoAutoplaySwitch != null) {
+ videoAutoplaySwitch.setOnPreferenceChangeListener((preference, newValue) -> {
+ EventBus.getDefault().post(new ChangeVideoAutoplayEvent((String) newValue));
+ return true;
+ });
+ }
if (confirmToExitSwitch != null) {
- confirmToExitSwitch.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
- @Override
- public boolean onPreferenceChange(Preference preference, Object newValue) {
- EventBus.getDefault().post(new RecreateActivityEvent());
- return true;
- }
+ confirmToExitSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
+ EventBus.getDefault().post(new RecreateActivityEvent());
+ return true;
});
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditDatabase/SubredditData.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditDatabase/SubredditData.java
index 486bd0a7..6c73f459 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditDatabase/SubredditData.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditDatabase/SubredditData.java
@@ -23,9 +23,11 @@ public class SubredditData {
private String sidebarDescription;
@ColumnInfo(name = "subscribers_count")
private int nSubscribers;
+ @ColumnInfo(name = "created_utc")
+ private long createdUTC;
public SubredditData(@NonNull String id, String name, String iconUrl, String bannerUrl,
- String description, String sidebarDescription, int nSubscribers) {
+ String description, String sidebarDescription, int nSubscribers, long createdUTC) {
this.id = id;
this.name = name;
this.iconUrl = iconUrl;
@@ -33,6 +35,7 @@ public class SubredditData {
this.description = description;
this.sidebarDescription = sidebarDescription;
this.nSubscribers = nSubscribers;
+ this.createdUTC = createdUTC;
}
@NonNull
@@ -63,4 +66,8 @@ public class SubredditData {
public int getNSubscribers() {
return nSubscribers;
}
+
+ public long getCreatedUTC() {
+ return createdUTC;
+ }
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/User/UserData.java b/app/src/main/java/ml/docilealligator/infinityforreddit/User/UserData.java
index f207685e..8ad00b49 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/User/UserData.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/User/UserData.java
@@ -15,23 +15,33 @@ public class UserData {
private String iconUrl;
@ColumnInfo(name = "banner")
private String banner;
- @ColumnInfo(name = "karma")
- private int karma;
+ @ColumnInfo(name = "link_karma")
+ private int linkKarma;
+ @ColumnInfo(name = "comment_karma")
+ private int commentKarma;
+ @ColumnInfo(name = "created_utc")
+ private long cakeday;
@ColumnInfo(name = "is_gold")
private boolean isGold;
@ColumnInfo(name = "is_friend")
private boolean isFriend;
@ColumnInfo(name = "can_be_followed")
private boolean canBeFollowed;
+ @ColumnInfo(name = "description")
+ private String description;
- public UserData(@NonNull String name, String iconUrl, String banner, int karma, boolean isGold, boolean isFriend, boolean canBeFollowed) {
+ public UserData(@NonNull String name, String iconUrl, String banner, int linkKarma, int commentKarma,
+ long cakeday, boolean isGold, boolean isFriend, boolean canBeFollowed, String description) {
this.name = name;
this.iconUrl = iconUrl;
this.banner = banner;
- this.karma = karma;
+ this.commentKarma = commentKarma;
+ this.linkKarma = linkKarma;
+ this.cakeday = cakeday;
this.isGold = isGold;
this.isFriend = isFriend;
this.canBeFollowed = canBeFollowed;
+ this.description = description;
}
@NonNull
@@ -47,8 +57,20 @@ public class UserData {
return banner;
}
+ public int getLinkKarma() {
+ return linkKarma;
+ }
+
+ public int getCommentKarma() {
+ return commentKarma;
+ }
+
public int getKarma() {
- return karma;
+ return linkKarma + commentKarma;
+ }
+
+ public long getCakeday() {
+ return cakeday;
}
public boolean isGold() {
@@ -62,4 +84,8 @@ public class UserData {
public boolean isCanBeFollowed() {
return canBeFollowed;
}
+
+ public String getDescription() {
+ return description;
+ }
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/CustomThemeSharedPreferencesUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/CustomThemeSharedPreferencesUtils.java
index 6e08559b..295013f1 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/CustomThemeSharedPreferencesUtils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/CustomThemeSharedPreferencesUtils.java
@@ -29,6 +29,7 @@ public class CustomThemeSharedPreferencesUtils {
public static final String COMMENT_BACKGROUND_COLOR = "commentBackgroundColor";
public static final String BOTTOM_APP_BAR_BACKGROUND_COLOR = "bottomAppBarBackgroundColor";
public static final String PRIMARY_ICON_COLOR = "primaryIconColor";
+ public static final String BOTTOM_APP_BAR_ICON_COLOR = "bottomAppBarIconColor";
public static final String POST_ICON_AND_INFO_COLOR = "postIconAndInfoColor";
public static final String COMMENT_ICON_AND_INFO_COLOR = "commentIconAndInfoColor";
public static final String TOOLBAR_PRIMARY_TEXT_AND_ICON_COLOR = "toolbarPrimaryTextAndIconColor";
@@ -96,6 +97,7 @@ public class CustomThemeSharedPreferencesUtils {
editor.putInt(COMMENT_BACKGROUND_COLOR, customTheme.commentBackgroundColor);
editor.putInt(BOTTOM_APP_BAR_BACKGROUND_COLOR, customTheme.bottomAppBarBackgroundColor);
editor.putInt(PRIMARY_ICON_COLOR, customTheme.primaryIconColor);
+ editor.putInt(BOTTOM_APP_BAR_ICON_COLOR, customTheme.bottomAppBarIconColor);
editor.putInt(POST_ICON_AND_INFO_COLOR, customTheme.postIconAndInfoColor);
editor.putInt(COMMENT_ICON_AND_INFO_COLOR, customTheme.commentIconAndInfoColor);
editor.putInt(TOOLBAR_PRIMARY_TEXT_AND_ICON_COLOR, customTheme.toolbarPrimaryTextAndIconColor);
@@ -118,6 +120,8 @@ public class CustomThemeSharedPreferencesUtils {
editor.putInt(NSFW_TEXT_COLOR, customTheme.nsfwTextColor);
editor.putInt(FLAIR_BACKGROUND_COLOR, customTheme.flairBackgroundColor);
editor.putInt(FLAIR_TEXT_COLOR, customTheme.flairTextColor);
+ editor.putInt(AWARDS_BACKGROUND_COLOR, customTheme.awardsBackgroundColor);
+ editor.putInt(AWARDS_TEXT_COLOR, customTheme.awardsTextColor);
editor.putInt(ARCHIVED_ICON_TINT, customTheme.archivedTint);
editor.putInt(LOCKED_ICON_TINT, customTheme.lockedIconTint);
editor.putInt(CROSSPOST_ICON_TINT, customTheme.crosspostIconTint);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/RedditUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/RedditUtils.java
index 2e7c93c8..b42cbff1 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/RedditUtils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/RedditUtils.java
@@ -84,6 +84,8 @@ public class RedditUtils {
public static final String MULTIPATH_KEY = "multipath";
public static final String MODEL_KEY = "model";
+ public static final String REASON_KEY = "reason";
+
public static Map<String, String> getHttpBasicAuthHeader() {
Map<String, String> params = new HashMap<>();
String credentials = String.format("%s:%s", RedditUtils.CLIENT_ID, "");
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java
index ec523487..63ab550e 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java
@@ -76,6 +76,10 @@ public class SharedPreferencesUtils {
public static final String VOLUME_KEYS_NAVIGATE_POSTS = "volume_keys_navigate_posts";
public static final String MUTE_VIDEO = "mute_video";
public static final String OPEN_LINK_IN_APP = "open_link_in_app";
+ public static final String VIDEO_AUTOPLAY = "video_autoplay";
+ public static final String VIDEO_AUTOPLAY_VALUE_ALWAYS_ON = "2";
+ public static final String VIDEO_AUTOPLAY_VALUE_ON_WIFI = "1";
+ public static final String VIDEO_AUTOPLAY_VALUE_NEVER = "0";
public static final String LOCK_JUMP_TO_NEXT_TOP_LEVEL_COMMENT_BUTTON = "lock_jump_to_next_top_level_comment_button";
public static final String SWIPE_UP_TO_HIDE_JUMP_TO_NEXT_TOP_LEVEL_COMMENT_BUTTON = "swipe_up_to_hide_jump_to_next_top_level_comments_button";
public static final String SHOW_TOP_LEVEL_COMMENTS_FIRST = "show_top_level_comments_first";
@@ -89,10 +93,10 @@ public class SharedPreferencesUtils {
public static final String CUSTOMIZE_DARK_THEME = "customize_dark_theme";
public static final String CUSTOMIZE_AMOLED_THEME = "customize_amoled_theme";
public static final String MANAGE_THEMES = "manage_themes";
- public static final String DELETE_ALL_SUBREDDITS_DATA_IN_DATABASE= "delete_all_subreddits_data_in_database";
- public static final String DELETE_ALL_USERS_DATA_IN_DATABASE= "delete_all_users_data_in_database";
- public static final String DELETE_ALL_SORT_TYPE_DATA_IN_DATABASE= "delete_all_sort_type_data_in_database";
- public static final String DELETE_ALL_POST_LAYOUT_DATA_IN_DATABASE= "delete_all_post_layout_data_in_database";
+ public static final String DELETE_ALL_SUBREDDITS_DATA_IN_DATABASE = "delete_all_subreddits_data_in_database";
+ public static final String DELETE_ALL_USERS_DATA_IN_DATABASE = "delete_all_users_data_in_database";
+ public static final String DELETE_ALL_SORT_TYPE_DATA_IN_DATABASE = "delete_all_sort_type_data_in_database";
+ public static final String DELETE_ALL_POST_LAYOUT_DATA_IN_DATABASE = "delete_all_post_layout_data_in_database";
public static final String DELETE_ALL_THEMES_IN_DATABASE = "delete_all_themes_in_database";
public static final String RESET_ALL_SETTINGS = "reset_all_settings";
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/Utils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/Utils.java
index f3788ff8..e6726cbb 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/Utils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/Utils.java
@@ -1,6 +1,9 @@
package ml.docilealligator.infinityforreddit.Utils;
import android.content.Context;
+import android.net.ConnectivityManager;
+import android.net.Network;
+import android.net.NetworkInfo;
import android.text.Html;
import android.text.Spannable;
import android.widget.TextView;
@@ -87,4 +90,18 @@ public class Utils {
}
textView.setText(html);
}
+
+ public static boolean isConnectedToWifi(Context context) {
+ ConnectivityManager connMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
+ if (connMgr != null) {
+ for (Network network : connMgr.getAllNetworks()) {
+ NetworkInfo networkInfo = connMgr.getNetworkInfo(network);
+ if (networkInfo != null && networkInfo.getType() == ConnectivityManager.TYPE_WIFI) {
+ return networkInfo.isConnected();
+ }
+ }
+ }
+
+ return false;
+ }
}
diff --git a/app/src/main/res/drawable/exo_player_autoplay_button_background.xml b/app/src/main/res/drawable/exo_player_autoplay_button_background.xml
new file mode 100644
index 00000000..0ad9af8e
--- /dev/null
+++ b/app/src/main/res/drawable/exo_player_autoplay_button_background.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
+ <item>
+ <shape android:shape="oval">
+ <solid android:color="#02EEE6" />
+ </shape>
+ </item>
+
+</layer-list> \ No newline at end of file
diff --git a/app/src/main/res/drawable/ic_fullscreen_white_rounded_18dp.xml b/app/src/main/res/drawable/ic_fullscreen_white_rounded_18dp.xml
new file mode 100644
index 00000000..9977b60f
--- /dev/null
+++ b/app/src/main/res/drawable/ic_fullscreen_white_rounded_18dp.xml
@@ -0,0 +1,9 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="18dp"
+ android:height="18dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+ <path
+ android:pathData="M6,14c-0.55,0 -1,0.45 -1,1v3c0,0.55 0.45,1 1,1h3c0.55,0 1,-0.45 1,-1s-0.45,-1 -1,-1L7,17v-2c0,-0.55 -0.45,-1 -1,-1zM6,10c0.55,0 1,-0.45 1,-1L7,7h2c0.55,0 1,-0.45 1,-1s-0.45,-1 -1,-1L6,5c-0.55,0 -1,0.45 -1,1v3c0,0.55 0.45,1 1,1zM17,17h-2c-0.55,0 -1,0.45 -1,1s0.45,1 1,1h3c0.55,0 1,-0.45 1,-1v-3c0,-0.55 -0.45,-1 -1,-1s-1,0.45 -1,1v2zM14,6c0,0.55 0.45,1 1,1h2v2c0,0.55 0.45,1 1,1s1,-0.45 1,-1L19,6c0,-0.55 -0.45,-1 -1,-1h-3c-0.55,0 -1,0.45 -1,1z"
+ android:fillColor="#FFFFFF"/>
+</vector>
diff --git a/app/src/main/res/drawable/ic_mute_white_rounded_18dp.xml b/app/src/main/res/drawable/ic_mute_white_rounded_18dp.xml
new file mode 100644
index 00000000..b4f8f660
--- /dev/null
+++ b/app/src/main/res/drawable/ic_mute_white_rounded_18dp.xml
@@ -0,0 +1,9 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="18dp"
+ android:height="18dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+ <path
+ android:pathData="M3.63,3.63c-0.39,0.39 -0.39,1.02 0,1.41L7.29,8.7 7,9L4,9c-0.55,0 -1,0.45 -1,1v4c0,0.55 0.45,1 1,1h3l3.29,3.29c0.63,0.63 1.71,0.18 1.71,-0.71v-4.17l4.18,4.18c-0.49,0.37 -1.02,0.68 -1.6,0.91 -0.36,0.15 -0.58,0.53 -0.58,0.92 0,0.72 0.73,1.18 1.39,0.91 0.8,-0.33 1.55,-0.77 2.22,-1.31l1.34,1.34c0.39,0.39 1.02,0.39 1.41,0 0.39,-0.39 0.39,-1.02 0,-1.41L5.05,3.63c-0.39,-0.39 -1.02,-0.39 -1.42,0zM19,12c0,0.82 -0.15,1.61 -0.41,2.34l1.53,1.53c0.56,-1.17 0.88,-2.48 0.88,-3.87 0,-3.83 -2.4,-7.11 -5.78,-8.4 -0.59,-0.23 -1.22,0.23 -1.22,0.86v0.19c0,0.38 0.25,0.71 0.61,0.85C17.18,6.54 19,9.06 19,12zM10.29,5.71l-0.17,0.17L12,7.76L12,6.41c0,-0.89 -1.08,-1.33 -1.71,-0.7zM16.5,12c0,-1.77 -1.02,-3.29 -2.5,-4.03v1.79l2.48,2.48c0.01,-0.08 0.02,-0.16 0.02,-0.24z"
+ android:fillColor="#ffffff"/>
+</vector>
diff --git a/app/src/main/res/drawable/ic_pause_white_rounded_18dp.xml b/app/src/main/res/drawable/ic_pause_white_rounded_18dp.xml
new file mode 100644
index 00000000..479c57b0
--- /dev/null
+++ b/app/src/main/res/drawable/ic_pause_white_rounded_18dp.xml
@@ -0,0 +1,9 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="18dp"
+ android:height="18dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+ <path
+ android:pathData="M8,19c1.1,0 2,-0.9 2,-2L10,7c0,-1.1 -0.9,-2 -2,-2s-2,0.9 -2,2v10c0,1.1 0.9,2 2,2zM14,7v10c0,1.1 0.9,2 2,2s2,-0.9 2,-2L18,7c0,-1.1 -0.9,-2 -2,-2s-2,0.9 -2,2z"
+ android:fillColor="#ffffff"/>
+</vector>
diff --git a/app/src/main/res/drawable/ic_play_arrow_white_rounded_18dp.xml b/app/src/main/res/drawable/ic_play_arrow_white_rounded_18dp.xml
new file mode 100644
index 00000000..3400b3ac
--- /dev/null
+++ b/app/src/main/res/drawable/ic_play_arrow_white_rounded_18dp.xml
@@ -0,0 +1,9 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="18dp"
+ android:height="18dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+ <path
+ android:pathData="M8,6.82v10.36c0,0.79 0.87,1.27 1.54,0.84l8.14,-5.18c0.62,-0.39 0.62,-1.29 0,-1.69L9.54,5.98C8.87,5.55 8,6.03 8,6.82z"
+ android:fillColor="#ffffff"/>
+</vector>
diff --git a/app/src/main/res/drawable/ic_report_black_24dp.xml b/app/src/main/res/drawable/ic_report_black_24dp.xml
new file mode 100644
index 00000000..6e07b06d
--- /dev/null
+++ b/app/src/main/res/drawable/ic_report_black_24dp.xml
@@ -0,0 +1,15 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+ <path
+ android:pathData="M15.73,3H8.27L3,8.27v7.46L8.27,21h7.46L21,15.73V8.27L15.73,3zM19,14.9L14.9,19H9.1L5,14.9V9.1L9.1,5h5.8L19,9.1v5.8z"
+ android:fillColor="#000000"/>
+ <path
+ android:pathData="M12,16m-1,0a1,1 0,1 1,2 0a1,1 0,1 1,-2 0"
+ android:fillColor="#000000"/>
+ <path
+ android:pathData="M11,7h2v7h-2z"
+ android:fillColor="#000000"/>
+</vector>
diff --git a/app/src/main/res/drawable/ic_unmute_white_rounded_18dp.xml b/app/src/main/res/drawable/ic_unmute_white_rounded_18dp.xml
new file mode 100644
index 00000000..90b8f85d
--- /dev/null
+++ b/app/src/main/res/drawable/ic_unmute_white_rounded_18dp.xml
@@ -0,0 +1,9 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="18dp"
+ android:height="18dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+ <path
+ android:pathData="M3,10v4c0,0.55 0.45,1 1,1h3l3.29,3.29c0.63,0.63 1.71,0.18 1.71,-0.71L12,6.41c0,-0.89 -1.08,-1.34 -1.71,-0.71L7,9L4,9c-0.55,0 -1,0.45 -1,1zM16.5,12c0,-1.77 -1.02,-3.29 -2.5,-4.03v8.05c1.48,-0.73 2.5,-2.25 2.5,-4.02zM14,4.45v0.2c0,0.38 0.25,0.71 0.6,0.85C17.18,6.53 19,9.06 19,12s-1.82,5.47 -4.4,6.5c-0.36,0.14 -0.6,0.47 -0.6,0.85v0.2c0,0.63 0.63,1.07 1.21,0.85C18.6,19.11 21,15.84 21,12s-2.4,-7.11 -5.79,-8.4c-0.58,-0.23 -1.21,0.22 -1.21,0.85z"
+ android:fillColor="#ffffff"/>
+</vector>
diff --git a/app/src/main/res/layout/activity_report.xml b/app/src/main/res/layout/activity_report.xml
new file mode 100644
index 00000000..845c9ecc
--- /dev/null
+++ b/app/src/main/res/layout/activity_report.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:id="@+id/coordinator_layout_report_activity"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ tools:application=".PostImageActivity">
+
+ <com.google.android.material.appbar.AppBarLayout
+ android:id="@+id/appbar_layout_report_activity"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:theme="@style/AppTheme.AppBarOverlay">
+
+ <androidx.appcompat.widget.Toolbar
+ android:id="@+id/toolbar_report_activity"
+ android:layout_width="match_parent"
+ android:layout_height="?attr/actionBarSize"
+ app:navigationIcon="?attr/homeAsUpIndicator"
+ app:popupTheme="@style/AppTheme.PopupOverlay" />
+
+ </com.google.android.material.appbar.AppBarLayout>
+
+ <androidx.recyclerview.widget.RecyclerView
+ android:id="@+id/recycler_view_report_activity"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ app:layout_behavior="@string/appbar_scrolling_view_behavior" />
+
+</androidx.coordinatorlayout.widget.CoordinatorLayout> \ No newline at end of file
diff --git a/app/src/main/res/layout/activity_view_gif.xml b/app/src/main/res/layout/activity_view_gif.xml
index 8740679c..cce51370 100644
--- a/app/src/main/res/layout/activity_view_gif.xml
+++ b/app/src/main/res/layout/activity_view_gif.xml
@@ -5,7 +5,8 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/parent_relative_layout_view_gif_activity"
- android:background="@android:color/black"
+ android:background="#000000"
+ android:keepScreenOn="true"
tools:application="ml.docilealligator.infinityforreddit.Activity.ViewGIFActivity">
<ProgressBar
diff --git a/app/src/main/res/layout/activity_view_subreddit_detail.xml b/app/src/main/res/layout/activity_view_subreddit_detail.xml
index da17e978..ee3f0357 100644
--- a/app/src/main/res/layout/activity_view_subreddit_detail.xml
+++ b/app/src/main/res/layout/activity_view_subreddit_detail.xml
@@ -74,7 +74,7 @@
android:textColor="@android:color/white"
android:layout_gravity="center_horizontal"/>
- <RelativeLayout
+ <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
@@ -84,20 +84,51 @@
android:id="@+id/subscriber_count_text_view_view_subreddit_detail_activity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:textColor="?attr/primaryTextColor"
android:textSize="?attr/font_default"
- android:layout_alignParentStart="true"
- android:layout_toStartOf="@id/online_subscriber_count_text_view_view_subreddit_detail_activity" />
+ app:layout_constraintBottom_toTopOf="@id/online_subscriber_count_text_view_view_subreddit_detail_activity"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintEnd_toStartOf="@id/barrier"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintHorizontal_bias="0" />
<TextView
android:id="@+id/online_subscriber_count_text_view_view_subreddit_detail_activity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_alignParentEnd="true"
- android:textColor="?attr/primaryTextColor"
- android:textSize="?attr/font_default" />
+ android:textSize="?attr/font_default"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintEnd_toStartOf="@id/barrier"
+ app:layout_constraintTop_toBottomOf="@id/subscriber_count_text_view_view_subreddit_detail_activity"
+ app:layout_constraintHorizontal_bias="0" />
+
+ <TextView
+ android:id="@+id/since_text_view_view_subreddit_detail_activity"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/since"
+ app:layout_constraintBottom_toTopOf="@id/creation_time_text_view_view_subreddit_detail_activity"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintTop_toTopOf="parent" />
+
+ <TextView
+ android:id="@+id/creation_time_text_view_view_subreddit_detail_activity"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:gravity="end"
+ android:textSize="?attr/font_default"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintTop_toBottomOf="@id/since_text_view_view_subreddit_detail_activity" />
+
+ <androidx.constraintlayout.widget.Barrier
+ android:id="@+id/barrier"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ app:barrierDirection="start"
+ app:constraint_referenced_ids="creation_time_text_view_view_subreddit_detail_activity, since_text_view_view_subreddit_detail_activity" />
- </RelativeLayout>
+ </androidx.constraintlayout.widget.ConstraintLayout>
<TextView
android:id="@+id/description_text_view_view_subreddit_detail_activity"
diff --git a/app/src/main/res/layout/activity_view_user_detail.xml b/app/src/main/res/layout/activity_view_user_detail.xml
index 4539f50a..3499823e 100644
--- a/app/src/main/res/layout/activity_view_user_detail.xml
+++ b/app/src/main/res/layout/activity_view_user_detail.xml
@@ -62,16 +62,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
- android:textSize="?attr/font_18"
- android:layout_gravity="center_horizontal"/>
-
- <TextView
- android:id="@+id/karma_text_view_view_user_detail_activity"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
- android:textSize="?attr/font_default"
+ android:textSize="?attr/font_18"
android:layout_gravity="center_horizontal"/>
<com.google.android.material.chip.Chip
@@ -79,10 +71,40 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
- android:textColor="@android:color/white"
android:layout_gravity="center_horizontal"
android:visibility="gone"/>
+ <RelativeLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="16dp">
+
+ <TextView
+ android:id="@+id/karma_text_view_view_user_detail_activity"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentStart="true"
+ android:layout_toStartOf="@id/cakeday_text_view_view_user_detail_activity"
+ android:textSize="?attr/font_default" />
+
+ <TextView
+ android:id="@+id/cakeday_text_view_view_user_detail_activity"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:gravity="end"
+ android:layout_alignParentEnd="true"
+ android:textSize="?attr/font_default" />
+
+ </RelativeLayout>
+
+ <TextView
+ android:id="@+id/description_text_view_view_user_detail_activity"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="16dp"
+ android:textSize="?attr/font_default"
+ android:visibility="gone" />
+
</LinearLayout>
</RelativeLayout>
diff --git a/app/src/main/res/layout/activity_view_video.xml b/app/src/main/res/layout/activity_view_video.xml
index 906770fe..8f23ea26 100644
--- a/app/src/main/res/layout/activity_view_video.xml
+++ b/app/src/main/res/layout/activity_view_video.xml
@@ -4,7 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:background="@android:color/black"
+ android:background="#000000"
android:id="@+id/relative_layout_view_video_activity"
android:keepScreenOn="true"
tools:application="ml.docilealligator.infinityforreddit.Activity.ViewVideoActivity">
diff --git a/app/src/main/res/layout/exo_autoplay_playback_control_view.xml b/app/src/main/res/layout/exo_autoplay_playback_control_view.xml
new file mode 100644
index 00000000..7280717b
--- /dev/null
+++ b/app/src/main/res/layout/exo_autoplay_playback_control_view.xml
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/linear_layout_exo_playback_control_view"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingStart="16dp"
+ android:paddingEnd="8dp"
+ android:layout_gravity="bottom">
+
+ <TextView android:id="@id/exo_position"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentStart="true"
+ android:layout_centerVertical="true"
+ android:includeFontPadding="false"
+ android:textColor="#FFFFFF"
+ android:textSize="12sp"
+ android:textStyle="bold" />
+
+ <TextView
+ android:id="@+id/slash"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_toEndOf="@id/exo_position"
+ android:layout_centerVertical="true"
+ android:text="/"
+ android:textColor="#FFFFFF"
+ android:textSize="12sp"
+ android:textStyle="bold" />
+
+ <TextView android:id="@id/exo_duration"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_toEndOf="@id/slash"
+ android:layout_centerVertical="true"
+ android:includeFontPadding="false"
+ android:textColor="#FFFFFF"
+ android:textSize="12sp"
+ android:textStyle="bold" />
+
+ <ImageView android:id="@id/exo_play"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="8dp"
+ android:layout_centerInParent="true"
+ android:src="@drawable/ic_play_arrow_white_rounded_18dp" />
+
+ <ImageView android:id="@id/exo_pause"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="8dp"
+ android:layout_centerInParent="true"
+ android:src="@drawable/ic_pause_white_rounded_18dp" />
+
+ <ImageView
+ android:id="@+id/mute_exo_playback_control_view"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="8dp"
+ android:layout_toStartOf="@id/fullscreen_exo_playback_control_view"
+ android:src="@drawable/ic_mute_white_rounded_18dp"
+ android:visibility="gone" />
+
+ <ImageView
+ android:id="@+id/fullscreen_exo_playback_control_view"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="8dp"
+ android:layout_alignParentEnd="true"
+ android:src="@drawable/ic_fullscreen_white_rounded_18dp" />
+
+</RelativeLayout> \ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_comment_more_bottom_sheet.xml b/app/src/main/res/layout/fragment_comment_more_bottom_sheet.xml
index d60fe273..ddd3e572 100644
--- a/app/src/main/res/layout/fragment_comment_more_bottom_sheet.xml
+++ b/app/src/main/res/layout/fragment_comment_more_bottom_sheet.xml
@@ -81,6 +81,24 @@
android:textColor="?attr/primaryTextColor"
android:textSize="?attr/font_default" />
+ <TextView
+ android:id="@+id/report_view_comment_more_bottom_sheet_fragment"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:background="?attr/selectableItemBackground"
+ android:clickable="true"
+ android:drawableStart="@drawable/ic_report_black_24dp"
+ android:drawablePadding="48dp"
+ android:focusable="true"
+ android:gravity="center_vertical"
+ android:paddingStart="32dp"
+ android:paddingTop="16dp"
+ android:paddingEnd="32dp"
+ android:paddingBottom="16dp"
+ android:text="@string/report"
+ android:textColor="?attr/primaryTextColor"
+ android:textSize="?attr/font_default" />
+
</LinearLayout>
</androidx.core.widget.NestedScrollView> \ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_post.xml b/app/src/main/res/layout/fragment_post.xml
index 7862ba25..94d2f551 100644
--- a/app/src/main/res/layout/fragment_post.xml
+++ b/app/src/main/res/layout/fragment_post.xml
@@ -10,7 +10,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
- <androidx.recyclerview.widget.RecyclerView
+ <ml.docilealligator.infinityforreddit.CustomView.CustomToroContainer
android:id="@+id/recycler_view_post_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
diff --git a/app/src/main/res/layout/item_post_image_and_gif_autoplay_type.xml b/app/src/main/res/layout/item_post_image_and_gif_autoplay_type.xml
new file mode 100644
index 00000000..b2fdf016
--- /dev/null
+++ b/app/src/main/res/layout/item_post_image_and_gif_autoplay_type.xml
@@ -0,0 +1,313 @@
+<?xml version="1.0" encoding="utf-8"?>
+<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="8dp"
+ android:layout_marginBottom="8dp"
+ android:id="@+id/card_view_item_post_image_type"
+ app:cardBackgroundColor="?attr/cardViewBackgroundColor"
+ app:cardElevation="2dp"
+ app:cardCornerRadius="16dp">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
+
+ <androidx.constraintlayout.widget.ConstraintLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:padding="16dp">
+
+ <ml.docilealligator.infinityforreddit.CustomView.AspectRatioGifImageView
+ android:id="@+id/icon_gif_image_view_item_post_image_type"
+ android:layout_width="24dp"
+ android:layout_height="24dp"
+ android:layout_gravity="center"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent"/>
+
+ <TextView
+ android:id="@+id/subreddit_name_text_view_item_post_image_type"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:layout_marginStart="16dp"
+ android:layout_marginEnd="8dp"
+ android:textSize="?attr/font_default"
+ app:layout_constraintBottom_toTopOf="@id/user_text_view_item_post_image_type"
+ app:layout_constraintStart_toEndOf="@id/icon_gif_image_view_item_post_image_type"
+ app:layout_constraintEnd_toStartOf="@id/stickied_post_image_view_item_post_image_type"
+ app:layout_constraintTop_toTopOf="parent"/>
+
+ <TextView
+ android:id="@+id/user_text_view_item_post_image_type"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="16dp"
+ android:layout_marginEnd="8dp"
+ android:textSize="?attr/font_default"
+ android:maxLines="2"
+ android:ellipsize="end"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toEndOf="@+id/icon_gif_image_view_item_post_image_type"
+ app:layout_constraintEnd_toStartOf="@id/stickied_post_image_view_item_post_image_type"
+ app:layout_constraintTop_toBottomOf="@+id/subreddit_name_text_view_item_post_image_type"
+ app:layout_constraintHorizontal_bias="0" />
+
+ <ImageView
+ android:id="@+id/stickied_post_image_view_item_post_image_type"
+ android:layout_width="24dp"
+ android:layout_height="24dp"
+ android:layout_marginEnd="8dp"
+ android:visibility="gone"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toEndOf="@id/subreddit_name_text_view_item_post_image_type"
+ app:layout_constraintEnd_toStartOf="@+id/guideline2"
+ app:layout_constraintTop_toTopOf="parent"/>
+
+ <TextView
+ android:id="@+id/post_time_text_view_best_item_post_image_type"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:gravity="end"
+ android:textSize="?attr/font_default"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toEndOf="@id/guideline2"
+ app:layout_constraintTop_toTopOf="parent" />
+
+ <androidx.constraintlayout.widget.Guideline
+ android:id="@+id/guideline2"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ app:layout_constraintGuide_percent="0.6" />
+
+ </androidx.constraintlayout.widget.ConstraintLayout>
+
+ <TextView
+ android:id="@+id/title_text_view_best_item_post_image_type"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingStart="16dp"
+ android:paddingEnd="16dp"
+ android:textSize="?attr/title_font_18" />
+
+ <com.nex3z.flowlayout.FlowLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:padding="16dp"
+ app:flChildSpacing="16dp"
+ app:flChildSpacingForLastRow="align"
+ app:flRowSpacing="8dp">
+
+ <com.libRG.CustomTextView
+ android:id="@+id/type_text_view_item_post_image_type"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="4dp"
+ android:textSize="?attr/font_12"
+ app:lib_setRadius="3dp"
+ app:lib_setRoundedView="true"
+ app:lib_setShape="rectangle" />
+
+ <com.libRG.CustomTextView
+ android:id="@+id/spoiler_custom_text_view_item_post_image_type"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:text="@string/spoiler"
+ android:textSize="?attr/font_12"
+ android:padding="4dp"
+ android:visibility="gone"
+ app:lib_setRadius="3dp"
+ app:lib_setRoundedView="true"
+ app:lib_setShape="rectangle" />
+
+ <com.libRG.CustomTextView
+ android:id="@+id/nsfw_text_view_item_post_image_type"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="4dp"
+ android:text="@string/nsfw"
+ android:textSize="?attr/font_12"
+ android:visibility="gone"
+ app:lib_setRadius="3dp"
+ app:lib_setRoundedView="true"
+ app:lib_setShape="rectangle" />
+
+ <com.libRG.CustomTextView
+ android:id="@+id/flair_custom_text_view_item_post_image_type"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:textSize="?attr/font_12"
+ android:padding="4dp"
+ android:visibility="gone"
+ app:lib_setRadius="3dp"
+ app:lib_setRoundedView="true"
+ app:lib_setShape="rectangle" />
+
+ <com.libRG.CustomTextView
+ android:id="@+id/awards_text_view_item_post_image_type"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="4dp"
+ android:textSize="?attr/font_12"
+ android:visibility="gone"
+ app:lib_setRadius="3dp"
+ app:lib_setRoundedView="true"
+ app:lib_setShape="rectangle" />
+
+ <ImageView
+ android:id="@+id/archived_image_view_item_post_image_type"
+ android:layout_width="24dp"
+ android:layout_height="24dp"
+ android:src="@drawable/ic_archive_outline"
+ android:visibility="gone" />
+
+ <ImageView
+ android:id="@+id/locked_image_view_item_post_image_type"
+ android:layout_width="24dp"
+ android:layout_height="24dp"
+ android:src="@drawable/ic_outline_lock_24dp"
+ android:visibility="gone" />
+
+ <ImageView
+ android:id="@+id/crosspost_image_view_item_post_image_type"
+ android:layout_width="24dp"
+ android:layout_height="24dp"
+ android:src="@drawable/crosspost"
+ android:visibility="gone" />
+
+ </com.nex3z.flowlayout.FlowLayout>
+
+ <RelativeLayout
+ android:id="@+id/image_view_wrapper_item_post_image_type"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+
+ <ml.docilealligator.infinityforreddit.CustomView.AspectRatioGifImageView
+ android:id="@+id/image_view_best_post_item"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:adjustViewBounds="true"
+ android:scaleType="fitStart" />
+
+ <ProgressBar
+ android:id="@+id/progress_bar_item_post_image_type"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_centerInParent="true" />
+
+ <RelativeLayout
+ android:id="@+id/load_image_error_relative_layout_item_post_image_type"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_centerInParent="true"
+ android:visibility="gone">
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:drawableTop="@drawable/ic_error_outline_black_24dp"
+ android:layout_gravity="center"
+ android:gravity="center"
+ android:text="@string/error_loading_image_tap_to_retry"
+ android:textSize="?attr/font_default" />
+
+ </RelativeLayout>
+
+ </RelativeLayout>
+
+ <androidx.constraintlayout.widget.ConstraintLayout
+ android:id="@+id/bottom_constraint_layout_item_post_image_type"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+
+ <ImageView
+ android:id="@+id/plus_button_item_post_image_type"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="12dp"
+ android:src="@drawable/ic_arrow_upward_grey_24dp"
+ android:background="?actionBarItemBackground"
+ android:clickable="true"
+ android:focusable="true"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toStartOf="parent" />
+
+ <TextView
+ android:id="@+id/score_text_view_item_post_image_type"
+ android:layout_width="64dp"
+ android:layout_height="wrap_content"
+ android:gravity="center"
+ android:textSize="?attr/font_12"
+ android:textStyle="bold"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toEndOf="@id/plus_button_item_post_image_type" />
+
+ <ImageView
+ android:id="@+id/minus_button_item_post_image_type"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="12dp"
+ android:src="@drawable/ic_arrow_downward_grey_24dp"
+ android:background="?actionBarItemBackground"
+ android:clickable="true"
+ android:focusable="true"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toEndOf="@id/score_text_view_item_post_image_type" />
+
+ <TextView
+ android:id="@+id/comments_count_item_post_image_type"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="12dp"
+ android:gravity="center_vertical"
+ android:textSize="?attr/font_12"
+ android:textStyle="bold"
+ android:drawableStart="@drawable/ic_comment_grey_24dp"
+ android:drawablePadding="12dp"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toEndOf="@id/minus_button_item_post_image_type" />
+
+ <ImageView
+ android:id="@+id/save_button_item_post_image_type"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="12dp"
+ android:background="?actionBarItemBackground"
+ android:clickable="true"
+ android:focusable="true"
+ app:layout_constraintHorizontal_bias="1"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toEndOf="@id/comments_count_item_post_image_type"
+ app:layout_constraintEnd_toStartOf="@id/share_button_item_post_image_type" />
+
+ <ImageView
+ android:id="@+id/share_button_item_post_image_type"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="12dp"
+ android:src="@drawable/ic_share_grey_24dp"
+ android:background="?actionBarItemBackground"
+ android:clickable="true"
+ android:focusable="true"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent" />
+
+ </androidx.constraintlayout.widget.ConstraintLayout>
+
+ </LinearLayout>
+
+</com.google.android.material.card.MaterialCardView> \ No newline at end of file
diff --git a/app/src/main/res/layout/item_post_link_type.xml b/app/src/main/res/layout/item_post_link_type.xml
new file mode 100644
index 00000000..43f51b10
--- /dev/null
+++ b/app/src/main/res/layout/item_post_link_type.xml
@@ -0,0 +1,324 @@
+<?xml version="1.0" encoding="utf-8"?>
+<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="8dp"
+ android:layout_marginBottom="8dp"
+ android:id="@+id/card_view_item_post_link_type"
+ app:cardBackgroundColor="?attr/cardViewBackgroundColor"
+ app:cardElevation="2dp"
+ app:cardCornerRadius="16dp">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
+
+ <androidx.constraintlayout.widget.ConstraintLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:padding="16dp">
+
+ <ml.docilealligator.infinityforreddit.CustomView.AspectRatioGifImageView
+ android:id="@+id/icon_gif_image_view_item_post_link_type"
+ android:layout_width="24dp"
+ android:layout_height="24dp"
+ android:layout_gravity="center"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent"/>
+
+ <TextView
+ android:id="@+id/subreddit_name_text_view_item_post_link_type"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:layout_marginStart="16dp"
+ android:layout_marginEnd="8dp"
+ android:textSize="?attr/font_default"
+ app:layout_constraintBottom_toTopOf="@id/user_text_view_item_post_link_type"
+ app:layout_constraintStart_toEndOf="@id/icon_gif_image_view_item_post_link_type"
+ app:layout_constraintEnd_toStartOf="@id/stickied_post_image_view_item_post_link_type"
+ app:layout_constraintTop_toTopOf="parent"/>
+
+ <TextView
+ android:id="@+id/user_text_view_item_post_link_type"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="16dp"
+ android:layout_marginEnd="8dp"
+ android:textSize="?attr/font_default"
+ android:maxLines="2"
+ android:ellipsize="end"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toEndOf="@+id/icon_gif_image_view_item_post_link_type"
+ app:layout_constraintEnd_toStartOf="@id/stickied_post_image_view_item_post_link_type"
+ app:layout_constraintTop_toBottomOf="@+id/subreddit_name_text_view_item_post_link_type"
+ app:layout_constraintHorizontal_bias="0" />
+
+ <ImageView
+ android:id="@+id/stickied_post_image_view_item_post_link_type"
+ android:layout_width="24dp"
+ android:layout_height="24dp"
+ android:layout_marginEnd="8dp"
+ android:visibility="gone"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toEndOf="@id/subreddit_name_text_view_item_post_link_type"
+ app:layout_constraintEnd_toStartOf="@+id/guideline2"
+ app:layout_constraintTop_toTopOf="parent"/>
+
+ <TextView
+ android:id="@+id/post_time_text_view_best_item_post_link_type"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:gravity="end"
+ android:textSize="?attr/font_default"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toEndOf="@id/guideline2"
+ app:layout_constraintTop_toTopOf="parent" />
+
+ <androidx.constraintlayout.widget.Guideline
+ android:id="@+id/guideline2"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ app:layout_constraintGuide_percent="0.6" />
+
+ </androidx.constraintlayout.widget.ConstraintLayout>
+
+ <TextView
+ android:id="@+id/title_text_view_best_item_post_link_type"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingStart="16dp"
+ android:paddingEnd="16dp"
+ android:textSize="?attr/title_font_18" />
+
+ <com.nex3z.flowlayout.FlowLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:padding="16dp"
+ app:flChildSpacing="16dp"
+ app:flChildSpacingForLastRow="align"
+ app:flRowSpacing="8dp">
+
+ <com.libRG.CustomTextView
+ android:id="@+id/type_text_view_item_post_link_type"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="4dp"
+ android:text="@string/link"
+ android:textSize="?attr/font_12"
+ app:lib_setRadius="3dp"
+ app:lib_setRoundedView="true"
+ app:lib_setShape="rectangle" />
+
+ <com.libRG.CustomTextView
+ android:id="@+id/spoiler_custom_text_view_item_post_link_type"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:text="@string/spoiler"
+ android:textSize="?attr/font_12"
+ android:padding="4dp"
+ android:visibility="gone"
+ app:lib_setRadius="3dp"
+ app:lib_setRoundedView="true"
+ app:lib_setShape="rectangle" />
+
+ <com.libRG.CustomTextView
+ android:id="@+id/nsfw_text_view_item_post_link_type"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="4dp"
+ android:text="@string/nsfw"
+ android:textSize="?attr/font_12"
+ android:visibility="gone"
+ app:lib_setRadius="3dp"
+ app:lib_setRoundedView="true"
+ app:lib_setShape="rectangle" />
+
+ <com.libRG.CustomTextView
+ android:id="@+id/flair_custom_text_view_item_post_link_type"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:textSize="?attr/font_12"
+ android:padding="4dp"
+ android:visibility="gone"
+ app:lib_setRadius="3dp"
+ app:lib_setRoundedView="true"
+ app:lib_setShape="rectangle" />
+
+ <com.libRG.CustomTextView
+ android:id="@+id/awards_text_view_item_post_link_type"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="4dp"
+ android:textSize="?attr/font_12"
+ android:visibility="gone"
+ app:lib_setRadius="3dp"
+ app:lib_setRoundedView="true"
+ app:lib_setShape="rectangle" />
+
+ <ImageView
+ android:id="@+id/archived_image_view_item_post_link_type"
+ android:layout_width="24dp"
+ android:layout_height="24dp"
+ android:src="@drawable/ic_archive_outline"
+ android:visibility="gone" />
+
+ <ImageView
+ android:id="@+id/locked_image_view_item_post_link_type"
+ android:layout_width="24dp"
+ android:layout_height="24dp"
+ android:src="@drawable/ic_outline_lock_24dp"
+ android:visibility="gone" />
+
+ <ImageView
+ android:id="@+id/crosspost_image_view_item_post_link_type"
+ android:layout_width="24dp"
+ android:layout_height="24dp"
+ android:src="@drawable/crosspost"
+ android:visibility="gone" />
+
+ </com.nex3z.flowlayout.FlowLayout>
+
+ <TextView
+ android:id="@+id/link_text_view_item_post_link_type"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="16dp"
+ android:paddingStart="16dp"
+ android:paddingEnd="16dp"
+ android:textSize="?attr/font_12"
+ android:visibility="gone" />
+
+ <RelativeLayout
+ android:id="@+id/image_view_wrapper_item_post_link_type"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+
+ <ml.docilealligator.infinityforreddit.CustomView.AspectRatioGifImageView
+ android:id="@+id/image_view_best_post_item"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:adjustViewBounds="true"
+ android:scaleType="fitStart" />
+
+ <ProgressBar
+ android:id="@+id/progress_bar_item_post_link_type"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_centerInParent="true" />
+
+ <RelativeLayout
+ android:id="@+id/load_image_error_relative_layout_item_post_link_type"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_centerInParent="true"
+ android:visibility="gone">
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:drawableTop="@drawable/ic_error_outline_black_24dp"
+ android:layout_gravity="center"
+ android:gravity="center"
+ android:text="@string/error_loading_image_tap_to_retry"
+ android:textSize="?attr/font_default" />
+
+ </RelativeLayout>
+
+ </RelativeLayout>
+
+ <androidx.constraintlayout.widget.ConstraintLayout
+ android:id="@+id/bottom_constraint_layout_item_post_link_type"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+
+ <ImageView
+ android:id="@+id/plus_button_item_post_link_type"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="12dp"
+ android:src="@drawable/ic_arrow_upward_grey_24dp"
+ android:background="?actionBarItemBackground"
+ android:clickable="true"
+ android:focusable="true"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toStartOf="parent" />
+
+ <TextView
+ android:id="@+id/score_text_view_item_post_link_type"
+ android:layout_width="64dp"
+ android:layout_height="wrap_content"
+ android:gravity="center"
+ android:textSize="?attr/font_12"
+ android:textStyle="bold"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toEndOf="@id/plus_button_item_post_link_type" />
+
+ <ImageView
+ android:id="@+id/minus_button_item_post_link_type"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="12dp"
+ android:src="@drawable/ic_arrow_downward_grey_24dp"
+ android:background="?actionBarItemBackground"
+ android:clickable="true"
+ android:focusable="true"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toEndOf="@id/score_text_view_item_post_link_type" />
+
+ <TextView
+ android:id="@+id/comments_count_item_post_link_type"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="12dp"
+ android:gravity="center_vertical"
+ android:textSize="?attr/font_12"
+ android:textStyle="bold"
+ android:drawableStart="@drawable/ic_comment_grey_24dp"
+ android:drawablePadding="12dp"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toEndOf="@id/minus_button_item_post_link_type" />
+
+ <ImageView
+ android:id="@+id/save_button_item_post_link_type"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="12dp"
+ android:background="?actionBarItemBackground"
+ android:clickable="true"
+ android:focusable="true"
+ app:layout_constraintHorizontal_bias="1"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toEndOf="@id/comments_count_item_post_link_type"
+ app:layout_constraintEnd_toStartOf="@id/share_button_item_post_link_type" />
+
+ <ImageView
+ android:id="@+id/share_button_item_post_link_type"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="12dp"
+ android:src="@drawable/ic_share_grey_24dp"
+ android:background="?actionBarItemBackground"
+ android:clickable="true"
+ android:focusable="true"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent" />
+
+ </androidx.constraintlayout.widget.ConstraintLayout>
+
+ </LinearLayout>
+
+</com.google.android.material.card.MaterialCardView> \ No newline at end of file
diff --git a/app/src/main/res/layout/item_post_no_preview_link_type.xml b/app/src/main/res/layout/item_post_no_preview_link_type.xml
new file mode 100644
index 00000000..a6ef9eeb
--- /dev/null
+++ b/app/src/main/res/layout/item_post_no_preview_link_type.xml
@@ -0,0 +1,293 @@
+<?xml version="1.0" encoding="utf-8"?>
+<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="8dp"
+ android:layout_marginBottom="8dp"
+ android:id="@+id/card_view_item_post_no_preview_link_type"
+ app:cardBackgroundColor="?attr/cardViewBackgroundColor"
+ app:cardElevation="2dp"
+ app:cardCornerRadius="16dp">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
+
+ <androidx.constraintlayout.widget.ConstraintLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:padding="16dp">
+
+ <ml.docilealligator.infinityforreddit.CustomView.AspectRatioGifImageView
+ android:id="@+id/icon_gif_image_view_item_post_no_preview_link_type"
+ android:layout_width="24dp"
+ android:layout_height="24dp"
+ android:layout_gravity="center"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent"/>
+
+ <TextView
+ android:id="@+id/subreddit_name_text_view_item_post_no_preview_link_type"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:layout_marginStart="16dp"
+ android:layout_marginEnd="8dp"
+ android:textSize="?attr/font_default"
+ app:layout_constraintBottom_toTopOf="@id/user_text_view_item_post_no_preview_link_type"
+ app:layout_constraintStart_toEndOf="@id/icon_gif_image_view_item_post_no_preview_link_type"
+ app:layout_constraintEnd_toStartOf="@id/stickied_post_image_view_item_post_no_preview_link_type"
+ app:layout_constraintTop_toTopOf="parent"/>
+
+ <TextView
+ android:id="@+id/user_text_view_item_post_no_preview_link_type"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="16dp"
+ android:layout_marginEnd="8dp"
+ android:textSize="?attr/font_default"
+ android:maxLines="2"
+ android:ellipsize="end"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toEndOf="@+id/icon_gif_image_view_item_post_no_preview_link_type"
+ app:layout_constraintEnd_toStartOf="@id/stickied_post_image_view_item_post_no_preview_link_type"
+ app:layout_constraintTop_toBottomOf="@+id/subreddit_name_text_view_item_post_no_preview_link_type"
+ app:layout_constraintHorizontal_bias="0" />
+
+ <ImageView
+ android:id="@+id/stickied_post_image_view_item_post_no_preview_link_type"
+ android:layout_width="24dp"
+ android:layout_height="24dp"
+ android:layout_marginEnd="8dp"
+ android:visibility="gone"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toEndOf="@id/subreddit_name_text_view_item_post_no_preview_link_type"
+ app:layout_constraintEnd_toStartOf="@+id/guideline2"
+ app:layout_constraintTop_toTopOf="parent"/>
+
+ <TextView
+ android:id="@+id/post_time_text_view_best_item_post_no_preview_link_type"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:gravity="end"
+ android:textSize="?attr/font_default"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toEndOf="@id/guideline2"
+ app:layout_constraintTop_toTopOf="parent" />
+
+ <androidx.constraintlayout.widget.Guideline
+ android:id="@+id/guideline2"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ app:layout_constraintGuide_percent="0.6" />
+
+ </androidx.constraintlayout.widget.ConstraintLayout>
+
+ <TextView
+ android:id="@+id/title_text_view_best_item_post_no_preview_link_type"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingStart="16dp"
+ android:paddingEnd="16dp"
+ android:textSize="?attr/title_font_18" />
+
+ <com.nex3z.flowlayout.FlowLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:padding="16dp"
+ app:flChildSpacing="16dp"
+ app:flChildSpacingForLastRow="align"
+ app:flRowSpacing="8dp">
+
+ <com.libRG.CustomTextView
+ android:id="@+id/type_text_view_item_post_no_preview_link_type"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="4dp"
+ android:text="@string/link"
+ android:textSize="?attr/font_12"
+ app:lib_setRadius="3dp"
+ app:lib_setRoundedView="true"
+ app:lib_setShape="rectangle" />
+
+ <com.libRG.CustomTextView
+ android:id="@+id/spoiler_custom_text_view_item_post_no_preview_link_type"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:text="@string/spoiler"
+ android:textSize="?attr/font_12"
+ android:padding="4dp"
+ android:visibility="gone"
+ app:lib_setRadius="3dp"
+ app:lib_setRoundedView="true"
+ app:lib_setShape="rectangle" />
+
+ <com.libRG.CustomTextView
+ android:id="@+id/nsfw_text_view_item_post_no_preview_link_type"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="4dp"
+ android:text="@string/nsfw"
+ android:textSize="?attr/font_12"
+ android:visibility="gone"
+ app:lib_setRadius="3dp"
+ app:lib_setRoundedView="true"
+ app:lib_setShape="rectangle" />
+
+ <com.libRG.CustomTextView
+ android:id="@+id/flair_custom_text_view_item_post_no_preview_link_type"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:textSize="?attr/font_12"
+ android:padding="4dp"
+ android:visibility="gone"
+ app:lib_setRadius="3dp"
+ app:lib_setRoundedView="true"
+ app:lib_setShape="rectangle" />
+
+ <com.libRG.CustomTextView
+ android:id="@+id/awards_text_view_item_post_no_preview_link_type"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="4dp"
+ android:textSize="?attr/font_12"
+ android:visibility="gone"
+ app:lib_setRadius="3dp"
+ app:lib_setRoundedView="true"
+ app:lib_setShape="rectangle" />
+
+ <ImageView
+ android:id="@+id/archived_image_view_item_post_no_preview_link_type"
+ android:layout_width="24dp"
+ android:layout_height="24dp"
+ android:src="@drawable/ic_archive_outline"
+ android:visibility="gone" />
+
+ <ImageView
+ android:id="@+id/locked_image_view_item_post_no_preview_link_type"
+ android:layout_width="24dp"
+ android:layout_height="24dp"
+ android:src="@drawable/ic_outline_lock_24dp"
+ android:visibility="gone" />
+
+ <ImageView
+ android:id="@+id/crosspost_image_view_item_post_no_preview_link_type"
+ android:layout_width="24dp"
+ android:layout_height="24dp"
+ android:src="@drawable/crosspost"
+ android:visibility="gone" />
+
+ </com.nex3z.flowlayout.FlowLayout>
+
+ <TextView
+ android:id="@+id/link_text_view_item_post_no_preview_link_type"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="16dp"
+ android:paddingStart="16dp"
+ android:paddingEnd="16dp"
+ android:textSize="?attr/font_12" />
+
+ <ImageView
+ android:id="@+id/image_view_no_preview_link_item_post_no_preview_link_type"
+ android:layout_width="match_parent"
+ android:layout_height="150dp"
+ android:scaleType="center"
+ android:src="@drawable/ic_link"
+ android:tint="@android:color/tab_indicator_text" />
+
+ <androidx.constraintlayout.widget.ConstraintLayout
+ android:id="@+id/bottom_constraint_layout_item_post_no_preview_link_type"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+
+ <ImageView
+ android:id="@+id/plus_button_item_post_no_preview_link_type"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="12dp"
+ android:src="@drawable/ic_arrow_upward_grey_24dp"
+ android:background="?actionBarItemBackground"
+ android:clickable="true"
+ android:focusable="true"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toStartOf="parent" />
+
+ <TextView
+ android:id="@+id/score_text_view_item_post_no_preview_link_type"
+ android:layout_width="64dp"
+ android:layout_height="wrap_content"
+ android:gravity="center"
+ android:textSize="?attr/font_12"
+ android:textStyle="bold"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toEndOf="@id/plus_button_item_post_no_preview_link_type" />
+
+ <ImageView
+ android:id="@+id/minus_button_item_post_no_preview_link_type"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="12dp"
+ android:src="@drawable/ic_arrow_downward_grey_24dp"
+ android:background="?actionBarItemBackground"
+ android:clickable="true"
+ android:focusable="true"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toEndOf="@id/score_text_view_item_post_no_preview_link_type" />
+
+ <TextView
+ android:id="@+id/comments_count_item_post_no_preview_link_type"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="12dp"
+ android:gravity="center_vertical"
+ android:textSize="?attr/font_12"
+ android:textStyle="bold"
+ android:drawableStart="@drawable/ic_comment_grey_24dp"
+ android:drawablePadding="12dp"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toEndOf="@id/minus_button_item_post_no_preview_link_type" />
+
+ <ImageView
+ android:id="@+id/save_button_item_post_no_preview_link_type"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="12dp"
+ android:background="?actionBarItemBackground"
+ android:clickable="true"
+ android:focusable="true"
+ app:layout_constraintHorizontal_bias="1"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toEndOf="@id/comments_count_item_post_no_preview_link_type"
+ app:layout_constraintEnd_toStartOf="@id/share_button_item_post_no_preview_link_type" />
+
+ <ImageView
+ android:id="@+id/share_button_item_post_no_preview_link_type"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="12dp"
+ android:src="@drawable/ic_share_grey_24dp"
+ android:background="?actionBarItemBackground"
+ android:clickable="true"
+ android:focusable="true"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent" />
+
+ </androidx.constraintlayout.widget.ConstraintLayout>
+
+ </LinearLayout>
+
+</com.google.android.material.card.MaterialCardView> \ No newline at end of file
diff --git a/app/src/main/res/layout/item_post_text_type.xml b/app/src/main/res/layout/item_post_text_type.xml
new file mode 100644
index 00000000..cc7a3bb9
--- /dev/null
+++ b/app/src/main/res/layout/item_post_text_type.xml
@@ -0,0 +1,288 @@
+<?xml version="1.0" encoding="utf-8"?>
+<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="8dp"
+ android:layout_marginBottom="8dp"
+ android:id="@+id/card_view_item_post_text_type"
+ app:cardBackgroundColor="?attr/cardViewBackgroundColor"
+ app:cardElevation="2dp"
+ app:cardCornerRadius="16dp">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
+
+ <androidx.constraintlayout.widget.ConstraintLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:padding="16dp">
+
+ <ml.docilealligator.infinityforreddit.CustomView.AspectRatioGifImageView
+ android:id="@+id/icon_gif_image_view_item_post_text_type"
+ android:layout_width="24dp"
+ android:layout_height="24dp"
+ android:layout_gravity="center"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent"/>
+
+ <TextView
+ android:id="@+id/subreddit_name_text_view_item_post_text_type"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:layout_marginStart="16dp"
+ android:layout_marginEnd="8dp"
+ android:textSize="?attr/font_default"
+ app:layout_constraintBottom_toTopOf="@id/user_text_view_item_post_text_type"
+ app:layout_constraintStart_toEndOf="@id/icon_gif_image_view_item_post_text_type"
+ app:layout_constraintEnd_toStartOf="@id/stickied_post_image_view_item_post_text_type"
+ app:layout_constraintTop_toTopOf="parent"/>
+
+ <TextView
+ android:id="@+id/user_text_view_item_post_text_type"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="16dp"
+ android:layout_marginEnd="8dp"
+ android:textSize="?attr/font_default"
+ android:maxLines="2"
+ android:ellipsize="end"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toEndOf="@+id/icon_gif_image_view_item_post_text_type"
+ app:layout_constraintEnd_toStartOf="@id/stickied_post_image_view_item_post_text_type"
+ app:layout_constraintTop_toBottomOf="@+id/subreddit_name_text_view_item_post_text_type"
+ app:layout_constraintHorizontal_bias="0" />
+
+ <ImageView
+ android:id="@+id/stickied_post_image_view_item_post_text_type"
+ android:layout_width="24dp"
+ android:layout_height="24dp"
+ android:layout_marginEnd="8dp"
+ android:visibility="gone"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toEndOf="@id/subreddit_name_text_view_item_post_text_type"
+ app:layout_constraintEnd_toStartOf="@+id/guideline2"
+ app:layout_constraintTop_toTopOf="parent"/>
+
+ <TextView
+ android:id="@+id/post_time_text_view_best_item_post_text_type"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:gravity="end"
+ android:textSize="?attr/font_default"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toEndOf="@id/guideline2"
+ app:layout_constraintTop_toTopOf="parent" />
+
+ <androidx.constraintlayout.widget.Guideline
+ android:id="@+id/guideline2"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ app:layout_constraintGuide_percent="0.6" />
+
+ </androidx.constraintlayout.widget.ConstraintLayout>
+
+ <TextView
+ android:id="@+id/title_text_view_best_item_post_text_type"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingStart="16dp"
+ android:paddingEnd="16dp"
+ android:textSize="?attr/title_font_18" />
+
+ <TextView
+ android:id="@+id/content_text_view_item_post_text_type"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="16dp"
+ android:paddingStart="16dp"
+ android:paddingEnd="16dp"
+ android:maxLines="4"
+ android:visibility="gone"
+ android:textSize="?attr/content_font_default"
+ android:ellipsize="end" />
+
+ <com.nex3z.flowlayout.FlowLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:padding="16dp"
+ app:flChildSpacing="16dp"
+ app:flChildSpacingForLastRow="align"
+ app:flRowSpacing="8dp">
+
+ <com.libRG.CustomTextView
+ android:id="@+id/type_text_view_item_post_text_type"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="4dp"
+ android:text="@string/text"
+ android:textSize="?attr/font_12"
+ app:lib_setRadius="3dp"
+ app:lib_setRoundedView="true"
+ app:lib_setShape="rectangle" />
+
+ <com.libRG.CustomTextView
+ android:id="@+id/spoiler_custom_text_view_item_post_text_type"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:text="@string/spoiler"
+ android:textSize="?attr/font_12"
+ android:padding="4dp"
+ android:visibility="gone"
+ app:lib_setRadius="3dp"
+ app:lib_setRoundedView="true"
+ app:lib_setShape="rectangle" />
+
+ <com.libRG.CustomTextView
+ android:id="@+id/nsfw_text_view_item_post_text_type"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="4dp"
+ android:text="@string/nsfw"
+ android:textSize="?attr/font_12"
+ android:visibility="gone"
+ app:lib_setRadius="3dp"
+ app:lib_setRoundedView="true"
+ app:lib_setShape="rectangle" />
+
+ <com.libRG.CustomTextView
+ android:id="@+id/flair_custom_text_view_item_post_text_type"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:textSize="?attr/font_12"
+ android:padding="4dp"
+ android:visibility="gone"
+ app:lib_setRadius="3dp"
+ app:lib_setRoundedView="true"
+ app:lib_setShape="rectangle" />
+
+ <com.libRG.CustomTextView
+ android:id="@+id/awards_text_view_item_post_text_type"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="4dp"
+ android:textSize="?attr/font_12"
+ android:visibility="gone"
+ app:lib_setRadius="3dp"
+ app:lib_setRoundedView="true"
+ app:lib_setShape="rectangle" />
+
+ <ImageView
+ android:id="@+id/archived_image_view_item_post_text_type"
+ android:layout_width="24dp"
+ android:layout_height="24dp"
+ android:src="@drawable/ic_archive_outline"
+ android:visibility="gone" />
+
+ <ImageView
+ android:id="@+id/locked_image_view_item_post_text_type"
+ android:layout_width="24dp"
+ android:layout_height="24dp"
+ android:src="@drawable/ic_outline_lock_24dp"
+ android:visibility="gone" />
+
+ <ImageView
+ android:id="@+id/crosspost_image_view_item_post_text_type"
+ android:layout_width="24dp"
+ android:layout_height="24dp"
+ android:src="@drawable/crosspost"
+ android:visibility="gone" />
+
+ </com.nex3z.flowlayout.FlowLayout>
+
+ <androidx.constraintlayout.widget.ConstraintLayout
+ android:id="@+id/bottom_constraint_layout_item_post_text_type"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+
+ <ImageView
+ android:id="@+id/plus_button_item_post_text_type"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="12dp"
+ android:src="@drawable/ic_arrow_upward_grey_24dp"
+ android:background="?actionBarItemBackground"
+ android:clickable="true"
+ android:focusable="true"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toStartOf="parent" />
+
+ <TextView
+ android:id="@+id/score_text_view_item_post_text_type"
+ android:layout_width="64dp"
+ android:layout_height="wrap_content"
+ android:gravity="center"
+ android:textSize="?attr/font_12"
+ android:textStyle="bold"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toEndOf="@id/plus_button_item_post_text_type" />
+
+ <ImageView
+ android:id="@+id/minus_button_item_post_text_type"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="12dp"
+ android:src="@drawable/ic_arrow_downward_grey_24dp"
+ android:background="?actionBarItemBackground"
+ android:clickable="true"
+ android:focusable="true"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toEndOf="@id/score_text_view_item_post_text_type" />
+
+ <TextView
+ android:id="@+id/comments_count_item_post_text_type"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="12dp"
+ android:gravity="center_vertical"
+ android:textSize="?attr/font_12"
+ android:textStyle="bold"
+ android:drawableStart="@drawable/ic_comment_grey_24dp"
+ android:drawablePadding="12dp"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toEndOf="@id/minus_button_item_post_text_type" />
+
+ <ImageView
+ android:id="@+id/save_button_item_post_text_type"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="12dp"
+ android:background="?actionBarItemBackground"
+ android:clickable="true"
+ android:focusable="true"
+ app:layout_constraintHorizontal_bias="1"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toEndOf="@id/comments_count_item_post_text_type"
+ app:layout_constraintEnd_toStartOf="@id/share_button_item_post_text_type" />
+
+ <ImageView
+ android:id="@+id/share_button_item_post_text_type"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="12dp"
+ android:src="@drawable/ic_share_grey_24dp"
+ android:background="?actionBarItemBackground"
+ android:clickable="true"
+ android:focusable="true"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent" />
+
+ </androidx.constraintlayout.widget.ConstraintLayout>
+
+ </LinearLayout>
+
+</com.google.android.material.card.MaterialCardView> \ No newline at end of file
diff --git a/app/src/main/res/layout/item_post_video_and_gif_preview_type.xml b/app/src/main/res/layout/item_post_video_and_gif_preview_type.xml
new file mode 100644
index 00000000..c3549df4
--- /dev/null
+++ b/app/src/main/res/layout/item_post_video_and_gif_preview_type.xml
@@ -0,0 +1,328 @@
+<?xml version="1.0" encoding="utf-8"?>
+<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="8dp"
+ android:layout_marginBottom="8dp"
+ android:id="@+id/card_view_item_post_gif_type_autoplay"
+ app:cardBackgroundColor="?attr/cardViewBackgroundColor"
+ app:cardElevation="2dp"
+ app:cardCornerRadius="16dp">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
+
+ <androidx.constraintlayout.widget.ConstraintLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:padding="16dp">
+
+ <ml.docilealligator.infinityforreddit.CustomView.AspectRatioGifImageView
+ android:id="@+id/icon_gif_image_view_item_post_gif_type_autoplay"
+ android:layout_width="24dp"
+ android:layout_height="24dp"
+ android:layout_gravity="center"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent"/>
+
+ <TextView
+ android:id="@+id/subreddit_name_text_view_item_post_gif_type_autoplay"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:layout_marginStart="16dp"
+ android:layout_marginEnd="8dp"
+ android:textSize="?attr/font_default"
+ app:layout_constraintBottom_toTopOf="@id/user_text_view_item_post_gif_type_autoplay"
+ app:layout_constraintStart_toEndOf="@id/icon_gif_image_view_item_post_gif_type_autoplay"
+ app:layout_constraintEnd_toStartOf="@id/stickied_post_image_view_item_post_gif_type_autoplay"
+ app:layout_constraintTop_toTopOf="parent"/>
+
+ <TextView
+ android:id="@+id/user_text_view_item_post_gif_type_autoplay"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="16dp"
+ android:layout_marginEnd="8dp"
+ android:textSize="?attr/font_default"
+ android:maxLines="2"
+ android:ellipsize="end"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toEndOf="@+id/icon_gif_image_view_item_post_gif_type_autoplay"
+ app:layout_constraintEnd_toStartOf="@id/stickied_post_image_view_item_post_gif_type_autoplay"
+ app:layout_constraintTop_toBottomOf="@+id/subreddit_name_text_view_item_post_gif_type_autoplay"
+ app:layout_constraintHorizontal_bias="0" />
+
+ <ImageView
+ android:id="@+id/stickied_post_image_view_item_post_gif_type_autoplay"
+ android:layout_width="24dp"
+ android:layout_height="24dp"
+ android:layout_marginEnd="8dp"
+ android:visibility="gone"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toEndOf="@id/subreddit_name_text_view_item_post_gif_type_autoplay"
+ app:layout_constraintEnd_toStartOf="@+id/guideline2"
+ app:layout_constraintTop_toTopOf="parent"/>
+
+ <TextView
+ android:id="@+id/post_time_text_view_best_item_post_gif_type_autoplay"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:gravity="end"
+ android:textSize="?attr/font_default"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toEndOf="@id/guideline2"
+ app:layout_constraintTop_toTopOf="parent" />
+
+ <androidx.constraintlayout.widget.Guideline
+ android:id="@+id/guideline2"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ app:layout_constraintGuide_percent="0.6" />
+
+ </androidx.constraintlayout.widget.ConstraintLayout>
+
+ <TextView
+ android:id="@+id/title_text_view_best_item_post_gif_type_autoplay"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingStart="16dp"
+ android:paddingEnd="16dp"
+ android:textSize="?attr/title_font_18" />
+
+ <com.nex3z.flowlayout.FlowLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:padding="16dp"
+ app:flChildSpacing="16dp"
+ app:flChildSpacingForLastRow="align"
+ app:flRowSpacing="8dp">
+
+ <com.libRG.CustomTextView
+ android:id="@+id/type_text_view_item_post_gif_type_autoplay"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="4dp"
+ android:text="@string/gif"
+ android:textSize="?attr/font_12"
+ app:lib_setRadius="3dp"
+ app:lib_setRoundedView="true"
+ app:lib_setShape="rectangle" />
+
+ <com.libRG.CustomTextView
+ android:id="@+id/spoiler_custom_text_view_item_post_gif_type_autoplay"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:text="@string/spoiler"
+ android:textSize="?attr/font_12"
+ android:padding="4dp"
+ android:visibility="gone"
+ app:lib_setRadius="3dp"
+ app:lib_setRoundedView="true"
+ app:lib_setShape="rectangle" />
+
+ <com.libRG.CustomTextView
+ android:id="@+id/nsfw_text_view_item_post_gif_type_autoplay"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="4dp"
+ android:text="@string/nsfw"
+ android:textSize="?attr/font_12"
+ android:visibility="gone"
+ app:lib_setRadius="3dp"
+ app:lib_setRoundedView="true"
+ app:lib_setShape="rectangle" />
+
+ <com.libRG.CustomTextView
+ android:id="@+id/flair_custom_text_view_item_post_gif_type_autoplay"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:textSize="?attr/font_12"
+ android:padding="4dp"
+ android:visibility="gone"
+ app:lib_setRadius="3dp"
+ app:lib_setRoundedView="true"
+ app:lib_setShape="rectangle" />
+
+ <com.libRG.CustomTextView
+ android:id="@+id/awards_text_view_item_post_gif_type_autoplay"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="4dp"
+ android:textSize="?attr/font_12"
+ android:visibility="gone"
+ app:lib_setRadius="3dp"
+ app:lib_setRoundedView="true"
+ app:lib_setShape="rectangle" />
+
+ <ImageView
+ android:id="@+id/archived_image_view_item_post_gif_type_autoplay"
+ android:layout_width="24dp"
+ android:layout_height="24dp"
+ android:src="@drawable/ic_archive_outline"
+ android:visibility="gone" />
+
+ <ImageView
+ android:id="@+id/locked_image_view_item_post_gif_type_autoplay"
+ android:layout_width="24dp"
+ android:layout_height="24dp"
+ android:src="@drawable/ic_outline_lock_24dp"
+ android:visibility="gone" />
+
+ <ImageView
+ android:id="@+id/crosspost_image_view_item_post_gif_type_autoplay"
+ android:layout_width="24dp"
+ android:layout_height="24dp"
+ android:src="@drawable/crosspost"
+ android:visibility="gone" />
+
+ </com.nex3z.flowlayout.FlowLayout>
+
+ <RelativeLayout
+ android:id="@+id/image_view_wrapper_item_post_gif_type_autoplay"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+
+ <ml.docilealligator.infinityforreddit.CustomView.AspectRatioGifImageView
+ android:id="@+id/image_view_item_post_gif_type_autoplay"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:adjustViewBounds="true"
+ android:scaleType="fitStart" />
+
+ <ImageView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_margin="16dp"
+ android:layout_gravity="start"
+ android:background="@drawable/play_button_round_background"
+ android:src="@drawable/ic_play_circle_36dp" />
+
+ </FrameLayout>
+
+ <ProgressBar
+ android:id="@+id/progress_bar_item_post_gif_type_autoplay"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_centerInParent="true" />
+
+ <RelativeLayout
+ android:id="@+id/load_image_error_relative_layout_item_post_gif_type_autoplay"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_centerInParent="true"
+ android:visibility="gone">
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:drawableTop="@drawable/ic_error_outline_black_24dp"
+ android:layout_gravity="center"
+ android:gravity="center"
+ android:text="@string/error_loading_image_tap_to_retry"
+ android:textSize="?attr/font_default" />
+
+ </RelativeLayout>
+
+ </RelativeLayout>
+
+ <androidx.constraintlayout.widget.ConstraintLayout
+ android:id="@+id/bottom_constraint_layout_item_post_gif_type_autoplay"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+
+ <ImageView
+ android:id="@+id/plus_button_item_post_gif_type_autoplay"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="12dp"
+ android:src="@drawable/ic_arrow_upward_grey_24dp"
+ android:background="?actionBarItemBackground"
+ android:clickable="true"
+ android:focusable="true"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toStartOf="parent" />
+
+ <TextView
+ android:id="@+id/score_text_view_item_post_gif_type_autoplay"
+ android:layout_width="64dp"
+ android:layout_height="wrap_content"
+ android:gravity="center"
+ android:textSize="?attr/font_12"
+ android:textStyle="bold"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toEndOf="@id/plus_button_item_post_gif_type_autoplay" />
+
+ <ImageView
+ android:id="@+id/minus_button_item_post_gif_type_autoplay"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="12dp"
+ android:src="@drawable/ic_arrow_downward_grey_24dp"
+ android:background="?actionBarItemBackground"
+ android:clickable="true"
+ android:focusable="true"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toEndOf="@id/score_text_view_item_post_gif_type_autoplay" />
+
+ <TextView
+ android:id="@+id/comments_count_item_post_gif_type_autoplay"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="12dp"
+ android:gravity="center_vertical"
+ android:textSize="?attr/font_12"
+ android:textStyle="bold"
+ android:drawableStart="@drawable/ic_comment_grey_24dp"
+ android:drawablePadding="12dp"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toEndOf="@id/minus_button_item_post_gif_type_autoplay" />
+
+ <ImageView
+ android:id="@+id/save_button_item_post_gif_type_autoplay"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="12dp"
+ android:background="?actionBarItemBackground"
+ android:clickable="true"
+ android:focusable="true"
+ app:layout_constraintHorizontal_bias="1"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toEndOf="@id/comments_count_item_post_gif_type_autoplay"
+ app:layout_constraintEnd_toStartOf="@id/share_button_item_post_gif_type_autoplay" />
+
+ <ImageView
+ android:id="@+id/share_button_item_post_gif_type_autoplay"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="12dp"
+ android:src="@drawable/ic_share_grey_24dp"
+ android:background="?actionBarItemBackground"
+ android:clickable="true"
+ android:focusable="true"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent" />
+
+ </androidx.constraintlayout.widget.ConstraintLayout>
+
+ </LinearLayout>
+
+</com.google.android.material.card.MaterialCardView> \ No newline at end of file
diff --git a/app/src/main/res/layout/item_post_video_type_autoplay.xml b/app/src/main/res/layout/item_post_video_type_autoplay.xml
new file mode 100644
index 00000000..138090d8
--- /dev/null
+++ b/app/src/main/res/layout/item_post_video_type_autoplay.xml
@@ -0,0 +1,291 @@
+<?xml version="1.0" encoding="utf-8"?>
+<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="8dp"
+ android:layout_marginBottom="8dp"
+ android:id="@+id/card_view_item_post_video_type_autoplay"
+ app:cardBackgroundColor="?attr/cardViewBackgroundColor"
+ app:cardElevation="2dp"
+ app:cardCornerRadius="16dp">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
+
+ <androidx.constraintlayout.widget.ConstraintLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:padding="16dp">
+
+ <ml.docilealligator.infinityforreddit.CustomView.AspectRatioGifImageView
+ android:id="@+id/icon_gif_image_view_item_post_video_type_autoplay"
+ android:layout_width="24dp"
+ android:layout_height="24dp"
+ android:layout_gravity="center"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent"/>
+
+ <TextView
+ android:id="@+id/subreddit_name_text_view_item_post_video_type_autoplay"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:layout_marginStart="16dp"
+ android:layout_marginEnd="8dp"
+ android:textSize="?attr/font_default"
+ app:layout_constraintBottom_toTopOf="@id/user_text_view_item_post_video_type_autoplay"
+ app:layout_constraintStart_toEndOf="@id/icon_gif_image_view_item_post_video_type_autoplay"
+ app:layout_constraintEnd_toStartOf="@id/stickied_post_image_view_item_post_video_type_autoplay"
+ app:layout_constraintTop_toTopOf="parent"/>
+
+ <TextView
+ android:id="@+id/user_text_view_item_post_video_type_autoplay"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="16dp"
+ android:layout_marginEnd="8dp"
+ android:textSize="?attr/font_default"
+ android:maxLines="2"
+ android:ellipsize="end"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toEndOf="@+id/icon_gif_image_view_item_post_video_type_autoplay"
+ app:layout_constraintEnd_toStartOf="@id/stickied_post_image_view_item_post_video_type_autoplay"
+ app:layout_constraintTop_toBottomOf="@+id/subreddit_name_text_view_item_post_video_type_autoplay"
+ app:layout_constraintHorizontal_bias="0" />
+
+ <ImageView
+ android:id="@+id/stickied_post_image_view_item_post_video_type_autoplay"
+ android:layout_width="24dp"
+ android:layout_height="24dp"
+ android:layout_marginEnd="8dp"
+ android:visibility="gone"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toEndOf="@id/subreddit_name_text_view_item_post_video_type_autoplay"
+ app:layout_constraintEnd_toStartOf="@+id/guideline2"
+ app:layout_constraintTop_toTopOf="parent"/>
+
+ <TextView
+ android:id="@+id/post_time_text_view_best_item_post_video_type_autoplay"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:gravity="end"
+ android:textSize="?attr/font_default"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toEndOf="@id/guideline2"
+ app:layout_constraintTop_toTopOf="parent" />
+
+ <androidx.constraintlayout.widget.Guideline
+ android:id="@+id/guideline2"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ app:layout_constraintGuide_percent="0.6" />
+
+ </androidx.constraintlayout.widget.ConstraintLayout>
+
+ <TextView
+ android:id="@+id/title_text_view_best_item_post_video_type_autoplay"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingStart="16dp"
+ android:paddingEnd="16dp"
+ android:textSize="?attr/title_font_18" />
+
+ <com.nex3z.flowlayout.FlowLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:padding="16dp"
+ app:flChildSpacing="16dp"
+ app:flChildSpacingForLastRow="align"
+ app:flRowSpacing="8dp">
+
+ <com.libRG.CustomTextView
+ android:id="@+id/type_text_view_item_post_video_type_autoplay"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="4dp"
+ android:text="@string/video"
+ android:textSize="?attr/font_12"
+ app:lib_setRadius="3dp"
+ app:lib_setRoundedView="true"
+ app:lib_setShape="rectangle" />
+
+ <com.libRG.CustomTextView
+ android:id="@+id/spoiler_custom_text_view_item_post_video_type_autoplay"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:text="@string/spoiler"
+ android:textSize="?attr/font_12"
+ android:padding="4dp"
+ android:visibility="gone"
+ app:lib_setRadius="3dp"
+ app:lib_setRoundedView="true"
+ app:lib_setShape="rectangle" />
+
+ <com.libRG.CustomTextView
+ android:id="@+id/nsfw_text_view_item_post_video_type_autoplay"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="4dp"
+ android:text="@string/nsfw"
+ android:textSize="?attr/font_12"
+ android:visibility="gone"
+ app:lib_setRadius="3dp"
+ app:lib_setRoundedView="true"
+ app:lib_setShape="rectangle" />
+
+ <com.libRG.CustomTextView
+ android:id="@+id/flair_custom_text_view_item_post_video_type_autoplay"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:textSize="?attr/font_12"
+ android:padding="4dp"
+ android:visibility="gone"
+ app:lib_setRadius="3dp"
+ app:lib_setRoundedView="true"
+ app:lib_setShape="rectangle" />
+
+ <com.libRG.CustomTextView
+ android:id="@+id/awards_text_view_item_post_video_type_autoplay"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="4dp"
+ android:textSize="?attr/font_12"
+ android:visibility="gone"
+ app:lib_setRadius="3dp"
+ app:lib_setRoundedView="true"
+ app:lib_setShape="rectangle" />
+
+ <ImageView
+ android:id="@+id/archived_image_view_item_post_video_type_autoplay"
+ android:layout_width="24dp"
+ android:layout_height="24dp"
+ android:src="@drawable/ic_archive_outline"
+ android:visibility="gone" />
+
+ <ImageView
+ android:id="@+id/locked_image_view_item_post_video_type_autoplay"
+ android:layout_width="24dp"
+ android:layout_height="24dp"
+ android:src="@drawable/ic_outline_lock_24dp"
+ android:visibility="gone" />
+
+ <ImageView
+ android:id="@+id/crosspost_image_view_item_post_video_type_autoplay"
+ android:layout_width="24dp"
+ android:layout_height="24dp"
+ android:src="@drawable/crosspost"
+ android:visibility="gone" />
+
+ </com.nex3z.flowlayout.FlowLayout>
+
+ <com.google.android.exoplayer2.ui.AspectRatioFrameLayout
+ android:id="@+id/aspect"
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:background="#000000"
+ app:resize_mode="fixed_width">
+
+ <com.google.android.exoplayer2.ui.PlayerView
+ android:id="@+id/player_view_item_post_video_type_autoplay"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ app:controller_layout_id="@layout/exo_autoplay_playback_control_view"/>
+
+ </com.google.android.exoplayer2.ui.AspectRatioFrameLayout>
+
+ <androidx.constraintlayout.widget.ConstraintLayout
+ android:id="@+id/bottom_constraint_layout_item_post_video_type_autoplay"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+
+ <ImageView
+ android:id="@+id/plus_button_item_post_video_type_autoplay"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="12dp"
+ android:src="@drawable/ic_arrow_upward_grey_24dp"
+ android:background="?actionBarItemBackground"
+ android:clickable="true"
+ android:focusable="true"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toStartOf="parent" />
+
+ <TextView
+ android:id="@+id/score_text_view_item_post_video_type_autoplay"
+ android:layout_width="64dp"
+ android:layout_height="wrap_content"
+ android:gravity="center"
+ android:textSize="?attr/font_12"
+ android:textStyle="bold"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toEndOf="@id/plus_button_item_post_video_type_autoplay" />
+
+ <ImageView
+ android:id="@+id/minus_button_item_post_video_type_autoplay"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="12dp"
+ android:src="@drawable/ic_arrow_downward_grey_24dp"
+ android:background="?actionBarItemBackground"
+ android:clickable="true"
+ android:focusable="true"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toEndOf="@id/score_text_view_item_post_video_type_autoplay" />
+
+ <TextView
+ android:id="@+id/comments_count_item_post_video_type_autoplay"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="12dp"
+ android:gravity="center_vertical"
+ android:textSize="?attr/font_12"
+ android:textStyle="bold"
+ android:drawableStart="@drawable/ic_comment_grey_24dp"
+ android:drawablePadding="12dp"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toEndOf="@id/minus_button_item_post_video_type_autoplay" />
+
+ <ImageView
+ android:id="@+id/save_button_item_post_video_type_autoplay"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="12dp"
+ android:background="?actionBarItemBackground"
+ android:clickable="true"
+ android:focusable="true"
+ app:layout_constraintHorizontal_bias="1"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintStart_toEndOf="@id/comments_count_item_post_video_type_autoplay"
+ app:layout_constraintEnd_toStartOf="@id/share_button_item_post_video_type_autoplay" />
+
+ <ImageView
+ android:id="@+id/share_button_item_post_video_type_autoplay"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="12dp"
+ android:src="@drawable/ic_share_grey_24dp"
+ android:background="?actionBarItemBackground"
+ android:clickable="true"
+ android:focusable="true"
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent" />
+
+ </androidx.constraintlayout.widget.ConstraintLayout>
+
+ </LinearLayout>
+
+</com.google.android.material.card.MaterialCardView> \ No newline at end of file
diff --git a/app/src/main/res/layout/item_report_reason.xml b/app/src/main/res/layout/item_report_reason.xml
new file mode 100644
index 00000000..08d6900b
--- /dev/null
+++ b/app/src/main/res/layout/item_report_reason.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingStart="16dp"
+ android:paddingEnd="16dp"
+ android:paddingTop="8dp"
+ android:paddingBottom="8dp"
+ android:clickable="true"
+ android:focusable="true"
+ android:background="?attr/selectableItemBackground">
+
+ <TextView
+ android:id="@+id/reason_text_view_item_report_reason"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:layout_gravity="center_vertical"
+ android:layout_marginEnd="32dp"
+ android:textColor="?attr/primaryTextColor"
+ android:textSize="?attr/font_default" />
+
+ <CheckBox
+ android:id="@+id/check_box_item_report_reason"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical" />
+
+</LinearLayout> \ No newline at end of file
diff --git a/app/src/main/res/menu/report_activity.xml b/app/src/main/res/menu/report_activity.xml
new file mode 100644
index 00000000..8445d412
--- /dev/null
+++ b/app/src/main/res/menu/report_activity.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto">
+ <item
+ android:id="@+id/action_send_report_activity"
+ android:orderInCategory="1"
+ android:title="@string/action_send"
+ android:icon="@drawable/ic_send_toolbar_24dp"
+ app:showAsAction="ifRoom" />
+</menu> \ No newline at end of file
diff --git a/app/src/main/res/menu/view_post_detail_activity.xml b/app/src/main/res/menu/view_post_detail_activity.xml
index a9871051..32f83c41 100644
--- a/app/src/main/res/menu/view_post_detail_activity.xml
+++ b/app/src/main/res/menu/view_post_detail_activity.xml
@@ -74,4 +74,11 @@
android:title="@string/action_edit_flair"
app:showAsAction="never"
android:visible="false" />
+
+ <item
+ android:id="@+id/action_report_view_post_detail_activity"
+ android:orderInCategory="12"
+ android:title="@string/action_report"
+ app:showAsAction="never"
+ android:visible="false" />
</menu> \ No newline at end of file
diff --git a/app/src/main/res/menu/view_subreddit_detail_activity.xml b/app/src/main/res/menu/view_subreddit_detail_activity.xml
index eeef2439..9365ed2e 100644
--- a/app/src/main/res/menu/view_subreddit_detail_activity.xml
+++ b/app/src/main/res/menu/view_subreddit_detail_activity.xml
@@ -39,4 +39,10 @@
android:orderInCategory="6"
android:title="@string/action_view_side_bar"
app:showAsAction="never" />
+
+ <item
+ android:id="@+id/action_share_view_subreddit_detail_activity"
+ android:orderInCategory="7"
+ android:title="@string/action_share"
+ app:showAsAction="never" />
</menu> \ No newline at end of file
diff --git a/app/src/main/res/menu/view_user_detail_activity.xml b/app/src/main/res/menu/view_user_detail_activity.xml
index fe991f16..18c3ef16 100644
--- a/app/src/main/res/menu/view_user_detail_activity.xml
+++ b/app/src/main/res/menu/view_user_detail_activity.xml
@@ -31,4 +31,10 @@
android:orderInCategory="5"
android:title="@string/action_change_post_layout"
app:showAsAction="never" />
+
+ <item
+ android:id="@+id/action_share_view_user_detail_activity"
+ android:orderInCategory="6"
+ android:title="@string/action_share"
+ app:showAsAction="never" />
</menu>
diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml
index 4adfdff9..b415b0f5 100644
--- a/app/src/main/res/values/arrays.xml
+++ b/app/src/main/res/values/arrays.xml
@@ -47,6 +47,18 @@
<item>1</item>
</string-array>
+ <string-array name="settings_video_autoplay">
+ <item>Always On</item>
+ <item>Only on Wifi</item>
+ <item>Never</item>
+ </string-array>
+
+ <string-array name="settings_video_autoplay_values">
+ <item>2</item>
+ <item>1</item>
+ <item>0</item>
+ </string-array>
+
<string-array name="settings_lazy_mode_interval">
<item>1s</item>
<item>2s</item>
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index fb7082dd..c12d7105 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -25,6 +25,7 @@
<string name="theme_preview_activity_label">Theme Preview</string>
<string name="edit_multi_reddit_activity_label">Edit Multireddit</string>
<string name="selected_subeddits_activity_label">Selected Subreddits</string>
+ <string name="report_activity_label">Report</string>
<string name="navigation_drawer_open">Open navigation drawer</string>
<string name="navigation_drawer_close">Close navigation drawer</string>
@@ -57,6 +58,7 @@
<string name="action_delete_multi_reddit">Delete Multireddit</string>
<string name="action_share">Share</string>
<string name="action_preview">Preview</string>
+ <string name="action_report">Report</string>
<string name="parse_json_response_error">Error occurred when parsing the JSON response</string>
<string name="retrieve_token_error">Error Retrieving the token</string>
@@ -90,6 +92,9 @@
<string name="nsfw">NSFW</string>
<string name="karma_info">Karma: %1$d</string>
+ <string name="karma_info_user_detail">Karma:\n%1$d (%2$d + %3$d)</string>
+ <string name="cakeday_info">Cakeday:\n%1$s</string>
+ <string name="since">Since:</string>
<string name="profile">Profile</string>
<string name="following">Following</string>
@@ -193,6 +198,7 @@
<string name="no_rule">No rule</string>
<string name="error_loading_rules">Error loading rules.\nTap to retry.</string>
+ <string name="error_loading_rules_without_retry">Error Loading Rules</string>
<string name="search_in">Search in</string>
<string name="all_subreddits">All subreddits</string>
@@ -311,6 +317,7 @@
<string name="settings_interface_title">Interface</string>
<string name="settings_gestures_and_buttons_title">Gestures &amp; Buttons</string>
<string name="settings_open_link_in_app_title">Open Link In App</string>
+ <string name="settings_video_autoplay_title">Video Autoplay</string>
<string name="settings_immersive_interface_title">Immersive Interface</string>
<string name="settings_immersive_interface_ignore_nav_bar_title">Ignore Navigation Bar in Immersive Interface</string>
<string name="settings_immersive_interface_ignore_nav_bar_summary">Prevent the Bottom Navigation Bar Having Extra Padding</string>
@@ -524,7 +531,9 @@
<string name="theme_item_bottom_app_bar_background_color">Bottom Navigation Bar Color</string>
<string name="theme_item_bottom_app_bar_background_color_detail">Applied to: Bottom navigation bar</string>
<string name="theme_item_primary_icon_color">Primary Icon Color</string>
- <string name="theme_item_primary_icon_color_detail">Applied to: Icons in the bottom navigation bar and the navigation drawer.</string>
+ <string name="theme_item_primary_icon_color_detail">Applied to: Icons in the navigation drawer.</string>
+ <string name="theme_item_bottom_app_bar_icon_color">Bottom Navigation Bar Icon Color</string>
+ <string name="theme_item_bottom_app_bar_icon_color_detail">Applied to: Icons in the bottom navigation bar</string>
<string name="theme_item_post_icon_and_info_color">Post Icon and Info Color</string>
<string name="theme_item_post_icon_and_info_color_detail">Applied to: Icons, score and the number of comments in posts</string>
<string name="theme_item_comment_icon_and_info_color">Comment Icon and Info Color</string>
@@ -696,4 +705,15 @@
<string name="n_awards">%1$d Awards</string>
<string name="one_award">1 Award</string>
+ <string name="report">Report</string>
+ <string name="reporting">Reporting</string>
+ <string name="report_successful">Reported</string>
+ <string name="report_failed">Report failed</string>
+ <string name="report_reason_not_selected">You haven\'t selected a reason</string>
+
+ <string name="report_reason_general_spam">It Is Spam</string>
+ <string name="report_reason_general_copyright_issue">It Contains Copyright Issue</string>
+ <string name="report_reason_general_child_pornography">It Contains Child Pornography</string>
+ <string name="report_reason_general_abusive_content">It Contains Abusive Content</string>
+
</resources>
diff --git a/app/src/main/res/xml/main_preferences.xml b/app/src/main/res/xml/main_preferences.xml
index 8622a87f..1074a90e 100644
--- a/app/src/main/res/xml/main_preferences.xml
+++ b/app/src/main/res/xml/main_preferences.xml
@@ -28,6 +28,14 @@
app:key="open_link_in_app"
app:title="@string/settings_open_link_in_app_title" />
+ <ListPreference
+ app:defaultValue="0"
+ android:entries="@array/settings_video_autoplay"
+ app:entryValues="@array/settings_video_autoplay_values"
+ app:key="video_autoplay"
+ app:title="@string/settings_video_autoplay_title"
+ app:useSimpleSummaryProvider="true" />
+
<SwitchPreference
app:defaultValue="false"
app:key="mute_video"