Prepare to add different themes. Try fixing timeout issue in okhttp3.

This commit is contained in:
Alex Ning 2020-02-26 22:40:15 +08:00
parent 6433014679
commit 0f36ad4e1d
36 changed files with 456 additions and 245 deletions

5
.idea/gradle.xml generated
View File

@ -1,11 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings"> <component name="GradleSettings">
<option name="linkedExternalProjectsSettings"> <option name="linkedExternalProjectsSettings">
<GradleProjectSettings> <GradleProjectSettings>
<compositeConfiguration> <option name="testRunner" value="PLATFORM" />
<compositeBuild compositeDefinitionSource="SCRIPT" />
</compositeConfiguration>
<option name="distributionType" value="DEFAULT_WRAPPED" /> <option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" /> <option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules"> <option name="modules">

View File

@ -72,7 +72,7 @@ dependencies {
implementation "io.noties.markwon:simple-ext:4.2.0" implementation "io.noties.markwon:simple-ext:4.2.0"
implementation "io.noties.markwon:recycler-table:4.2.0" implementation "io.noties.markwon:recycler-table:4.2.0"
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.19' implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.19'
implementation 'com.github.Ferfalk:SimpleSearchView:0.1.3' implementation 'com.github.Ferfalk:SimpleSearchView:0.1.4'
implementation 'org.greenrobot:eventbus:3.1.1' implementation 'org.greenrobot:eventbus:3.1.1'
implementation 'com.libRG:customtextview:2.2' implementation 'com.libRG:customtextview:2.2'
implementation 'com.github.Deishelon:RoundedBottomSheet:1.0.1' implementation 'com.github.Deishelon:RoundedBottomSheet:1.0.1'

View File

@ -19,13 +19,17 @@ import okhttp3.Response;
import okhttp3.Route; import okhttp3.Route;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Retrofit; import retrofit2.Retrofit;
import retrofit2.converter.scalars.ScalarsConverterFactory;
class AccessTokenAuthenticator implements Authenticator { class AccessTokenAuthenticator implements Authenticator {
private Retrofit mRetrofit; private Retrofit mRetrofit;
private RedditDataRoomDatabase mRedditDataRoomDatabase; private RedditDataRoomDatabase mRedditDataRoomDatabase;
AccessTokenAuthenticator(Retrofit retrofit, RedditDataRoomDatabase accountRoomDatabase) { AccessTokenAuthenticator(RedditDataRoomDatabase accountRoomDatabase) {
mRetrofit = retrofit; mRetrofit = new Retrofit.Builder()
.baseUrl(RedditUtils.API_BASE_URI)
.addConverterFactory(ScalarsConverterFactory.create())
.build();
mRedditDataRoomDatabase = accountRoomDatabase; mRedditDataRoomDatabase = accountRoomDatabase;
} }

View File

@ -2,6 +2,7 @@ package ml.docilealligator.infinityforreddit.Activity;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.res.Resources;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
@ -52,6 +53,7 @@ import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.Service.SubmitPostService; import ml.docilealligator.infinityforreddit.Service.SubmitPostService;
import ml.docilealligator.infinityforreddit.Utils.Utils;
import pl.droidsonroids.gif.GifImageView; import pl.droidsonroids.gif.GifImageView;
import retrofit2.Retrofit; import retrofit2.Retrofit;
@ -128,9 +130,13 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
private boolean loadSubredditIconSuccessful = true; private boolean loadSubredditIconSuccessful = true;
private boolean isPosting; private boolean isPosting;
private Uri imageUri; private Uri imageUri;
private int flairColor;
private int spoilerColor;
private int nsfwColor;
private Flair flair; private Flair flair;
private boolean isSpoiler = false; private boolean isSpoiler = false;
private boolean isNSFW = false; private boolean isNSFW = false;
private Resources resources;
private Menu mMemu; private Menu mMemu;
private RequestManager mGlide; private RequestManager mGlide;
private FlairBottomSheetFragment flairSelectionBottomSheetFragment; private FlairBottomSheetFragment flairSelectionBottomSheetFragment;
@ -155,6 +161,12 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
mPostingSnackbar = Snackbar.make(coordinatorLayout, R.string.posting, Snackbar.LENGTH_INDEFINITE); mPostingSnackbar = Snackbar.make(coordinatorLayout, R.string.posting, Snackbar.LENGTH_INDEFINITE);
flairColor = Utils.getAttributeColor(this, R.attr.flairColor);
spoilerColor = Utils.getAttributeColor(this, R.attr.spoilerColor);
nsfwColor = Utils.getAttributeColor(this, R.attr.nsfwColor);
resources = getResources();
if (savedInstanceState != null) { if (savedInstanceState != null) {
mNullAccessToken = savedInstanceState.getBoolean(NULL_ACCESS_TOKEN_STATE); mNullAccessToken = savedInstanceState.getBoolean(NULL_ACCESS_TOKEN_STATE);
mAccessToken = savedInstanceState.getString(ACCESS_TOKEN_STATE); mAccessToken = savedInstanceState.getString(ACCESS_TOKEN_STATE);
@ -180,7 +192,7 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
} }
if (subredditName != null) { if (subredditName != null) {
subredditNameTextView.setTextColor(getResources().getColor(R.color.primaryTextColor)); subredditNameTextView.setTextColor(resources.getColor(R.color.primaryTextColor));
subredditNameTextView.setText(subredditName); subredditNameTextView.setText(subredditName);
flairTextView.setVisibility(View.VISIBLE); flairTextView.setVisibility(View.VISIBLE);
if (!loadSubredditIconSuccessful) { if (!loadSubredditIconSuccessful) {
@ -195,13 +207,13 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
if (flair != null) { if (flair != null) {
flairTextView.setText(flair.getText()); flairTextView.setText(flair.getText());
flairTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark)); flairTextView.setBackgroundColor(flairColor);
} }
if (isSpoiler) { if (isSpoiler) {
spoilerTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark)); spoilerTextView.setBackgroundColor(spoilerColor);
} }
if (isNSFW) { if (isNSFW) {
nsfwTextView.setBackgroundColor(getResources().getColor(R.color.colorAccent)); nsfwTextView.setBackgroundColor(nsfwColor);
} }
} else { } else {
getCurrentAccount(); getCurrentAccount();
@ -212,7 +224,7 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
loadSubredditIconSuccessful = false; loadSubredditIconSuccessful = false;
subredditName = getIntent().getStringExtra(EXTRA_SUBREDDIT_NAME); subredditName = getIntent().getStringExtra(EXTRA_SUBREDDIT_NAME);
subredditSelected = true; subredditSelected = true;
subredditNameTextView.setTextColor(getResources().getColor(R.color.primaryTextColor)); subredditNameTextView.setTextColor(resources.getColor(R.color.primaryTextColor));
subredditNameTextView.setText(subredditName); subredditNameTextView.setText(subredditName);
loadSubredditIcon(); loadSubredditIcon();
} else { } else {
@ -260,7 +272,7 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
flairSelectionBottomSheetFragment.setArguments(bundle); flairSelectionBottomSheetFragment.setArguments(bundle);
flairSelectionBottomSheetFragment.show(getSupportFragmentManager(), flairSelectionBottomSheetFragment.getTag()); flairSelectionBottomSheetFragment.show(getSupportFragmentManager(), flairSelectionBottomSheetFragment.getTag());
} else { } else {
flairTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent)); flairTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
flairTextView.setText(getString(R.string.flair)); flairTextView.setText(getString(R.string.flair));
flair = null; flair = null;
} }
@ -268,20 +280,20 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
spoilerTextView.setOnClickListener(view -> { spoilerTextView.setOnClickListener(view -> {
if (!isSpoiler) { if (!isSpoiler) {
spoilerTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark)); spoilerTextView.setBackgroundColor(spoilerColor);
isSpoiler = true; isSpoiler = true;
} else { } else {
spoilerTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent)); spoilerTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
isSpoiler = false; isSpoiler = false;
} }
}); });
nsfwTextView.setOnClickListener(view -> { nsfwTextView.setOnClickListener(view -> {
if (!isNSFW) { if (!isNSFW) {
nsfwTextView.setBackgroundColor(getResources().getColor(R.color.colorAccent)); nsfwTextView.setBackgroundColor(nsfwColor);
isNSFW = true; isNSFW = true;
} else { } else {
nsfwTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent)); nsfwTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
isNSFW = false; isNSFW = false;
} }
}); });
@ -306,7 +318,7 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
Intent intent = new Intent(); Intent intent = new Intent();
intent.setType("image/*"); intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT); intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, getResources().getString(R.string.select_from_gallery)), PICK_IMAGE_REQUEST_CODE); startActivityForResult(Intent.createChooser(intent, resources.getString(R.string.select_from_gallery)), PICK_IMAGE_REQUEST_CODE);
}); });
selectAgainTextView.setOnClickListener(view -> { selectAgainTextView.setOnClickListener(view -> {
@ -495,12 +507,12 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
subredditSelected = true; subredditSelected = true;
subredditIsUser = data.getExtras().getBoolean(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_IS_USER); subredditIsUser = data.getExtras().getBoolean(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_IS_USER);
subredditNameTextView.setTextColor(getResources().getColor(R.color.primaryTextColor)); subredditNameTextView.setTextColor(resources.getColor(R.color.primaryTextColor));
subredditNameTextView.setText(subredditName); subredditNameTextView.setText(subredditName);
displaySubredditIcon(); displaySubredditIcon();
flairTextView.setVisibility(View.VISIBLE); flairTextView.setVisibility(View.VISIBLE);
flairTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent)); flairTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
flairTextView.setText(getString(R.string.flair)); flairTextView.setText(getString(R.string.flair));
flair = null; flair = null;
} }
@ -531,7 +543,7 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
public void flairSelected(Flair flair) { public void flairSelected(Flair flair) {
this.flair = flair; this.flair = flair;
flairTextView.setText(flair.getText()); flairTextView.setText(flair.getText());
flairTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark)); flairTextView.setBackgroundColor(flairColor);
} }
@Subscribe @Subscribe

View File

@ -2,6 +2,7 @@ package ml.docilealligator.infinityforreddit.Activity;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.res.Resources;
import android.os.Bundle; import android.os.Bundle;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
@ -42,6 +43,7 @@ import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.Service.SubmitPostService; import ml.docilealligator.infinityforreddit.Service.SubmitPostService;
import ml.docilealligator.infinityforreddit.Utils.RedditUtils; import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
import ml.docilealligator.infinityforreddit.Utils.Utils;
import pl.droidsonroids.gif.GifImageView; import pl.droidsonroids.gif.GifImageView;
import retrofit2.Retrofit; import retrofit2.Retrofit;
@ -102,9 +104,13 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
private boolean subredditIsUser; private boolean subredditIsUser;
private boolean loadSubredditIconSuccessful = true; private boolean loadSubredditIconSuccessful = true;
private boolean isPosting; private boolean isPosting;
private int flairColor;
private int spoilerColor;
private int nsfwColor;
private Flair flair; private Flair flair;
private boolean isSpoiler = false; private boolean isSpoiler = false;
private boolean isNSFW = false; private boolean isNSFW = false;
private Resources resources;
private Menu mMemu; private Menu mMemu;
private RequestManager mGlide; private RequestManager mGlide;
private FlairBottomSheetFragment flairSelectionBottomSheetFragment; private FlairBottomSheetFragment flairSelectionBottomSheetFragment;
@ -129,6 +135,12 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
mPostingSnackbar = Snackbar.make(coordinatorLayout, R.string.posting, Snackbar.LENGTH_INDEFINITE); mPostingSnackbar = Snackbar.make(coordinatorLayout, R.string.posting, Snackbar.LENGTH_INDEFINITE);
flairColor = Utils.getAttributeColor(this, R.attr.flairColor);
spoilerColor = Utils.getAttributeColor(this, R.attr.spoilerColor);
nsfwColor = Utils.getAttributeColor(this, R.attr.nsfwColor);
resources = getResources();
if (savedInstanceState != null) { if (savedInstanceState != null) {
mNullAccessToken = savedInstanceState.getBoolean(NULL_ACCESS_TOKEN_STATE); mNullAccessToken = savedInstanceState.getBoolean(NULL_ACCESS_TOKEN_STATE);
mAccessToken = savedInstanceState.getString(ACCESS_TOKEN_STATE); mAccessToken = savedInstanceState.getString(ACCESS_TOKEN_STATE);
@ -148,7 +160,7 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
isNSFW = savedInstanceState.getBoolean(IS_NSFW_STATE); isNSFW = savedInstanceState.getBoolean(IS_NSFW_STATE);
if (subredditName != null) { if (subredditName != null) {
subredditNameTextView.setTextColor(getResources().getColor(R.color.primaryTextColor)); subredditNameTextView.setTextColor(resources.getColor(R.color.primaryTextColor));
subredditNameTextView.setText(subredditName); subredditNameTextView.setText(subredditName);
flairTextView.setVisibility(View.VISIBLE); flairTextView.setVisibility(View.VISIBLE);
if (!loadSubredditIconSuccessful) { if (!loadSubredditIconSuccessful) {
@ -163,13 +175,13 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
if (flair != null) { if (flair != null) {
flairTextView.setText(flair.getText()); flairTextView.setText(flair.getText());
flairTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark)); flairTextView.setBackgroundColor(flairColor);
} }
if (isSpoiler) { if (isSpoiler) {
spoilerTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark)); spoilerTextView.setBackgroundColor(spoilerColor);
} }
if (isNSFW) { if (isNSFW) {
nsfwTextView.setBackgroundColor(getResources().getColor(R.color.colorAccent)); nsfwTextView.setBackgroundColor(nsfwColor);
} }
} else { } else {
getCurrentAccount(); getCurrentAccount();
@ -180,7 +192,7 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
loadSubredditIconSuccessful = false; loadSubredditIconSuccessful = false;
subredditName = getIntent().getStringExtra(EXTRA_SUBREDDIT_NAME); subredditName = getIntent().getStringExtra(EXTRA_SUBREDDIT_NAME);
subredditSelected = true; subredditSelected = true;
subredditNameTextView.setTextColor(getResources().getColor(R.color.primaryTextColor)); subredditNameTextView.setTextColor(resources.getColor(R.color.primaryTextColor));
subredditNameTextView.setText(subredditName); subredditNameTextView.setText(subredditName);
flairTextView.setVisibility(View.VISIBLE); flairTextView.setVisibility(View.VISIBLE);
loadSubredditIcon(); loadSubredditIcon();
@ -229,7 +241,7 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
flairSelectionBottomSheetFragment.setArguments(bundle); flairSelectionBottomSheetFragment.setArguments(bundle);
flairSelectionBottomSheetFragment.show(getSupportFragmentManager(), flairSelectionBottomSheetFragment.getTag()); flairSelectionBottomSheetFragment.show(getSupportFragmentManager(), flairSelectionBottomSheetFragment.getTag());
} else { } else {
flairTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent)); flairTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
flairTextView.setText(getString(R.string.flair)); flairTextView.setText(getString(R.string.flair));
flair = null; flair = null;
} }
@ -237,20 +249,20 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
spoilerTextView.setOnClickListener(view -> { spoilerTextView.setOnClickListener(view -> {
if (!isSpoiler) { if (!isSpoiler) {
spoilerTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark)); spoilerTextView.setBackgroundColor(spoilerColor);
isSpoiler = true; isSpoiler = true;
} else { } else {
spoilerTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent)); spoilerTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
isSpoiler = false; isSpoiler = false;
} }
}); });
nsfwTextView.setOnClickListener(view -> { nsfwTextView.setOnClickListener(view -> {
if (!isNSFW) { if (!isNSFW) {
nsfwTextView.setBackgroundColor(getResources().getColor(R.color.colorAccent)); nsfwTextView.setBackgroundColor(nsfwColor);
isNSFW = true; isNSFW = true;
} else { } else {
nsfwTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent)); nsfwTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
isNSFW = false; isNSFW = false;
} }
}); });
@ -415,12 +427,12 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
subredditSelected = true; subredditSelected = true;
subredditIsUser = data.getExtras().getBoolean(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_IS_USER); subredditIsUser = data.getExtras().getBoolean(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_IS_USER);
subredditNameTextView.setTextColor(getResources().getColor(R.color.primaryTextColor)); subredditNameTextView.setTextColor(resources.getColor(R.color.primaryTextColor));
subredditNameTextView.setText(subredditName); subredditNameTextView.setText(subredditName);
displaySubredditIcon(); displaySubredditIcon();
flairTextView.setVisibility(View.VISIBLE); flairTextView.setVisibility(View.VISIBLE);
flairTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent)); flairTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
flairTextView.setText(getString(R.string.flair)); flairTextView.setText(getString(R.string.flair));
flair = null; flair = null;
} }
@ -437,7 +449,7 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
public void flairSelected(Flair flair) { public void flairSelected(Flair flair) {
this.flair = flair; this.flair = flair;
flairTextView.setText(flair.getText()); flairTextView.setText(flair.getText());
flairTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark)); flairTextView.setBackgroundColor(flairColor);
} }
@Subscribe @Subscribe

View File

@ -2,6 +2,7 @@ package ml.docilealligator.infinityforreddit.Activity;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.res.Resources;
import android.os.Bundle; import android.os.Bundle;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
@ -42,6 +43,7 @@ import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.Service.SubmitPostService; import ml.docilealligator.infinityforreddit.Service.SubmitPostService;
import ml.docilealligator.infinityforreddit.Utils.RedditUtils; import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
import ml.docilealligator.infinityforreddit.Utils.Utils;
import pl.droidsonroids.gif.GifImageView; import pl.droidsonroids.gif.GifImageView;
import retrofit2.Retrofit; import retrofit2.Retrofit;
@ -102,9 +104,13 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
private boolean subredditIsUser; private boolean subredditIsUser;
private boolean loadSubredditIconSuccessful = true; private boolean loadSubredditIconSuccessful = true;
private boolean isPosting; private boolean isPosting;
private int flairColor;
private int spoilerColor;
private int nsfwColor;
private Flair flair; private Flair flair;
private boolean isSpoiler = false; private boolean isSpoiler = false;
private boolean isNSFW = false; private boolean isNSFW = false;
private Resources resources;
private Menu mMemu; private Menu mMemu;
private RequestManager mGlide; private RequestManager mGlide;
private FlairBottomSheetFragment flairSelectionBottomSheetFragment; private FlairBottomSheetFragment flairSelectionBottomSheetFragment;
@ -129,6 +135,12 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
mPostingSnackbar = Snackbar.make(coordinatorLayout, R.string.posting, Snackbar.LENGTH_INDEFINITE); mPostingSnackbar = Snackbar.make(coordinatorLayout, R.string.posting, Snackbar.LENGTH_INDEFINITE);
flairColor = Utils.getAttributeColor(this, R.attr.flairColor);
spoilerColor = Utils.getAttributeColor(this, R.attr.spoilerColor);
nsfwColor = Utils.getAttributeColor(this, R.attr.nsfwColor);
resources = getResources();
if (savedInstanceState != null) { if (savedInstanceState != null) {
mNullAccessToken = savedInstanceState.getBoolean(NULL_ACCESS_TOKEN_STATE); mNullAccessToken = savedInstanceState.getBoolean(NULL_ACCESS_TOKEN_STATE);
mAccessToken = savedInstanceState.getString(ACCESS_TOKEN_STATE); mAccessToken = savedInstanceState.getString(ACCESS_TOKEN_STATE);
@ -148,7 +160,7 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
isNSFW = savedInstanceState.getBoolean(IS_NSFW_STATE); isNSFW = savedInstanceState.getBoolean(IS_NSFW_STATE);
if (subredditName != null) { if (subredditName != null) {
subredditNameTextView.setTextColor(getResources().getColor(R.color.primaryTextColor)); subredditNameTextView.setTextColor(resources.getColor(R.color.primaryTextColor));
subredditNameTextView.setText(subredditName); subredditNameTextView.setText(subredditName);
flairTextView.setVisibility(View.VISIBLE); flairTextView.setVisibility(View.VISIBLE);
if (!loadSubredditIconSuccessful) { if (!loadSubredditIconSuccessful) {
@ -163,13 +175,13 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
if (flair != null) { if (flair != null) {
flairTextView.setText(flair.getText()); flairTextView.setText(flair.getText());
flairTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark)); flairTextView.setBackgroundColor(flairColor);
} }
if (isSpoiler) { if (isSpoiler) {
spoilerTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark)); spoilerTextView.setBackgroundColor(spoilerColor);
} }
if (isNSFW) { if (isNSFW) {
nsfwTextView.setBackgroundColor(getResources().getColor(R.color.colorAccent)); nsfwTextView.setBackgroundColor(nsfwColor);
} }
} else { } else {
getCurrentAccount(); getCurrentAccount();
@ -180,7 +192,7 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
loadSubredditIconSuccessful = false; loadSubredditIconSuccessful = false;
subredditName = getIntent().getStringExtra(EXTRA_SUBREDDIT_NAME); subredditName = getIntent().getStringExtra(EXTRA_SUBREDDIT_NAME);
subredditSelected = true; subredditSelected = true;
subredditNameTextView.setTextColor(getResources().getColor(R.color.primaryTextColor)); subredditNameTextView.setTextColor(resources.getColor(R.color.primaryTextColor));
subredditNameTextView.setText(subredditName); subredditNameTextView.setText(subredditName);
flairTextView.setVisibility(View.VISIBLE); flairTextView.setVisibility(View.VISIBLE);
loadSubredditIcon(); loadSubredditIcon();
@ -233,7 +245,7 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
flairSelectionBottomSheetFragment.setArguments(bundle); flairSelectionBottomSheetFragment.setArguments(bundle);
flairSelectionBottomSheetFragment.show(getSupportFragmentManager(), flairSelectionBottomSheetFragment.getTag()); flairSelectionBottomSheetFragment.show(getSupportFragmentManager(), flairSelectionBottomSheetFragment.getTag());
} else { } else {
flairTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent)); flairTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
flairTextView.setText(getString(R.string.flair)); flairTextView.setText(getString(R.string.flair));
flair = null; flair = null;
} }
@ -241,20 +253,20 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
spoilerTextView.setOnClickListener(view -> { spoilerTextView.setOnClickListener(view -> {
if (!isSpoiler) { if (!isSpoiler) {
spoilerTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark)); spoilerTextView.setBackgroundColor(spoilerColor);
isSpoiler = true; isSpoiler = true;
} else { } else {
spoilerTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent)); spoilerTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
isSpoiler = false; isSpoiler = false;
} }
}); });
nsfwTextView.setOnClickListener(view -> { nsfwTextView.setOnClickListener(view -> {
if (!isNSFW) { if (!isNSFW) {
nsfwTextView.setBackgroundColor(getResources().getColor(R.color.colorAccent)); nsfwTextView.setBackgroundColor(nsfwColor);
isNSFW = true; isNSFW = true;
} else { } else {
nsfwTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent)); nsfwTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
isNSFW = false; isNSFW = false;
} }
}); });
@ -415,12 +427,12 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
subredditSelected = true; subredditSelected = true;
subredditIsUser = data.getExtras().getBoolean(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_IS_USER); subredditIsUser = data.getExtras().getBoolean(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_IS_USER);
subredditNameTextView.setTextColor(getResources().getColor(R.color.primaryTextColor)); subredditNameTextView.setTextColor(resources.getColor(R.color.primaryTextColor));
subredditNameTextView.setText(subredditName); subredditNameTextView.setText(subredditName);
displaySubredditIcon(); displaySubredditIcon();
flairTextView.setVisibility(View.VISIBLE); flairTextView.setVisibility(View.VISIBLE);
flairTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent)); flairTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
flairTextView.setText(getString(R.string.flair)); flairTextView.setText(getString(R.string.flair));
flair = null; flair = null;
} }
@ -437,7 +449,7 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
public void flairSelected(Flair flair) { public void flairSelected(Flair flair) {
this.flair = flair; this.flair = flair;
flairTextView.setText(flair.getText()); flairTextView.setText(flair.getText());
flairTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark)); flairTextView.setBackgroundColor(flairColor);
} }
@Subscribe @Subscribe

View File

@ -2,6 +2,7 @@ package ml.docilealligator.infinityforreddit.Activity;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.res.Resources;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
@ -54,6 +55,7 @@ import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.Service.SubmitPostService; import ml.docilealligator.infinityforreddit.Service.SubmitPostService;
import ml.docilealligator.infinityforreddit.Utils.Utils;
import pl.droidsonroids.gif.GifImageView; import pl.droidsonroids.gif.GifImageView;
import retrofit2.Retrofit; import retrofit2.Retrofit;
@ -134,9 +136,13 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
private boolean loadSubredditIconSuccessful = true; private boolean loadSubredditIconSuccessful = true;
private boolean isPosting; private boolean isPosting;
private boolean wasPlaying; private boolean wasPlaying;
private int flairColor;
private int spoilerColor;
private int nsfwColor;
private Flair flair; private Flair flair;
private boolean isSpoiler = false; private boolean isSpoiler = false;
private boolean isNSFW = false; private boolean isNSFW = false;
private Resources resources;
private Menu mMemu; private Menu mMemu;
private RequestManager mGlide; private RequestManager mGlide;
private FlairBottomSheetFragment mFlairSelectionBottomSheetFragment; private FlairBottomSheetFragment mFlairSelectionBottomSheetFragment;
@ -169,6 +175,12 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
mPostingSnackbar = Snackbar.make(coordinatorLayout, R.string.posting, Snackbar.LENGTH_INDEFINITE); mPostingSnackbar = Snackbar.make(coordinatorLayout, R.string.posting, Snackbar.LENGTH_INDEFINITE);
flairColor = Utils.getAttributeColor(this, R.attr.flairColor);
spoilerColor = Utils.getAttributeColor(this, R.attr.spoilerColor);
nsfwColor = Utils.getAttributeColor(this, R.attr.nsfwColor);
resources = getResources();
if (savedInstanceState != null) { if (savedInstanceState != null) {
subredditName = savedInstanceState.getString(SUBREDDIT_NAME_STATE); subredditName = savedInstanceState.getString(SUBREDDIT_NAME_STATE);
iconUrl = savedInstanceState.getString(SUBREDDIT_ICON_STATE); iconUrl = savedInstanceState.getString(SUBREDDIT_ICON_STATE);
@ -193,7 +205,7 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
} }
if (subredditName != null) { if (subredditName != null) {
subredditNameTextView.setTextColor(getResources().getColor(R.color.primaryTextColor)); subredditNameTextView.setTextColor(resources.getColor(R.color.primaryTextColor));
subredditNameTextView.setText(subredditName); subredditNameTextView.setText(subredditName);
flairTextView.setVisibility(View.VISIBLE); flairTextView.setVisibility(View.VISIBLE);
if (!loadSubredditIconSuccessful) { if (!loadSubredditIconSuccessful) {
@ -208,13 +220,13 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
if (flair != null) { if (flair != null) {
flairTextView.setText(flair.getText()); flairTextView.setText(flair.getText());
flairTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark)); flairTextView.setBackgroundColor(flairColor);
} }
if (isSpoiler) { if (isSpoiler) {
spoilerTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark)); spoilerTextView.setBackgroundColor(spoilerColor);
} }
if (isNSFW) { if (isNSFW) {
nsfwTextView.setBackgroundColor(getResources().getColor(R.color.colorAccent)); nsfwTextView.setBackgroundColor(nsfwColor);
} }
} else { } else {
getCurrentAccount(); getCurrentAccount();
@ -225,7 +237,7 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
loadSubredditIconSuccessful = false; loadSubredditIconSuccessful = false;
subredditName = getIntent().getStringExtra(EXTRA_SUBREDDIT_NAME); subredditName = getIntent().getStringExtra(EXTRA_SUBREDDIT_NAME);
subredditSelected = true; subredditSelected = true;
subredditNameTextView.setTextColor(getResources().getColor(R.color.primaryTextColor)); subredditNameTextView.setTextColor(resources.getColor(R.color.primaryTextColor));
subredditNameTextView.setText(subredditName); subredditNameTextView.setText(subredditName);
loadSubredditIcon(); loadSubredditIcon();
} else { } else {
@ -273,7 +285,7 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
mFlairSelectionBottomSheetFragment.setArguments(bundle); mFlairSelectionBottomSheetFragment.setArguments(bundle);
mFlairSelectionBottomSheetFragment.show(getSupportFragmentManager(), mFlairSelectionBottomSheetFragment.getTag()); mFlairSelectionBottomSheetFragment.show(getSupportFragmentManager(), mFlairSelectionBottomSheetFragment.getTag());
} else { } else {
flairTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent)); flairTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
flairTextView.setText(getString(R.string.flair)); flairTextView.setText(getString(R.string.flair));
flair = null; flair = null;
} }
@ -281,20 +293,20 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
spoilerTextView.setOnClickListener(view -> { spoilerTextView.setOnClickListener(view -> {
if (!isSpoiler) { if (!isSpoiler) {
spoilerTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark)); spoilerTextView.setBackgroundColor(spoilerColor);
isSpoiler = true; isSpoiler = true;
} else { } else {
spoilerTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent)); spoilerTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
isSpoiler = false; isSpoiler = false;
} }
}); });
nsfwTextView.setOnClickListener(view -> { nsfwTextView.setOnClickListener(view -> {
if (!isNSFW) { if (!isNSFW) {
nsfwTextView.setBackgroundColor(getResources().getColor(R.color.colorAccent)); nsfwTextView.setBackgroundColor(nsfwColor);
isNSFW = true; isNSFW = true;
} else { } else {
nsfwTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent)); nsfwTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
isNSFW = false; isNSFW = false;
} }
}); });
@ -310,7 +322,7 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
Intent intent = new Intent(); Intent intent = new Intent();
intent.setType("video/*"); intent.setType("video/*");
intent.setAction(Intent.ACTION_GET_CONTENT); intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, getResources().getString(R.string.select_from_gallery)), PICK_VIDEO_REQUEST_CODE); startActivityForResult(Intent.createChooser(intent, resources.getString(R.string.select_from_gallery)), PICK_VIDEO_REQUEST_CODE);
}); });
selectAgainTextView.setOnClickListener(view -> { selectAgainTextView.setOnClickListener(view -> {
@ -516,12 +528,12 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
subredditSelected = true; subredditSelected = true;
subredditIsUser = data.getBooleanExtra(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_IS_USER, false); subredditIsUser = data.getBooleanExtra(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_IS_USER, false);
subredditNameTextView.setTextColor(getResources().getColor(R.color.primaryTextColor)); subredditNameTextView.setTextColor(resources.getColor(R.color.primaryTextColor));
subredditNameTextView.setText(subredditName); subredditNameTextView.setText(subredditName);
displaySubredditIcon(); displaySubredditIcon();
flairTextView.setVisibility(View.VISIBLE); flairTextView.setVisibility(View.VISIBLE);
flairTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent)); flairTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
flairTextView.setText(getString(R.string.flair)); flairTextView.setText(getString(R.string.flair));
flair = null; flair = null;
} }
@ -559,7 +571,7 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
public void flairSelected(Flair flair) { public void flairSelected(Flair flair) {
this.flair = flair; this.flair = flair;
flairTextView.setText(flair.getText()); flairTextView.setText(flair.getText());
flairTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark)); flairTextView.setBackgroundColor(flairColor);
} }
@Subscribe @Subscribe

View File

@ -2,6 +2,7 @@ package ml.docilealligator.infinityforreddit.Activity;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.res.ColorStateList;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.content.res.Resources; import android.content.res.Resources;
import android.os.Build; import android.os.Build;
@ -69,6 +70,7 @@ import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditData;
import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditViewModel; import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditViewModel;
import ml.docilealligator.infinityforreddit.SubredditSubscription; import ml.docilealligator.infinityforreddit.SubredditSubscription;
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.Utils.Utils;
import pl.droidsonroids.gif.GifImageView; import pl.droidsonroids.gif.GifImageView;
import retrofit2.Retrofit; import retrofit2.Retrofit;
@ -458,6 +460,9 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
fab.setVisibility(View.GONE); fab.setVisibility(View.GONE);
} }
int unsubscribedColor = Utils.getAttributeColor(this, R.attr.unsubscribed);
int subscribedColor = Utils.getAttributeColor(this, R.attr.subscribed);
subscribeSubredditChip.setOnClickListener(view -> { subscribeSubredditChip.setOnClickListener(view -> {
if (mAccessToken == null) { if (mAccessToken == null) {
Toast.makeText(ViewSubredditDetailActivity.this, R.string.login_first, Toast.LENGTH_SHORT).show(); Toast.makeText(ViewSubredditDetailActivity.this, R.string.login_first, Toast.LENGTH_SHORT).show();
@ -473,7 +478,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
@Override @Override
public void onSubredditSubscriptionSuccess() { public void onSubredditSubscriptionSuccess() {
subscribeSubredditChip.setText(R.string.unsubscribe); subscribeSubredditChip.setText(R.string.unsubscribe);
subscribeSubredditChip.setChipBackgroundColor(getResources().getColorStateList(R.color.colorAccent)); subscribeSubredditChip.setChipBackgroundColor(ColorStateList.valueOf(subscribedColor));
makeSnackbar(R.string.subscribed, false); makeSnackbar(R.string.subscribed, false);
subscriptionReady = true; subscriptionReady = true;
} }
@ -491,7 +496,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
@Override @Override
public void onSubredditSubscriptionSuccess() { public void onSubredditSubscriptionSuccess() {
subscribeSubredditChip.setText(R.string.subscribe); subscribeSubredditChip.setText(R.string.subscribe);
subscribeSubredditChip.setChipBackgroundColor(getResources().getColorStateList(R.color.backgroundColorPrimaryDark)); subscribeSubredditChip.setChipBackgroundColor(ColorStateList.valueOf(unsubscribedColor));
makeSnackbar(R.string.unsubscribed, false); makeSnackbar(R.string.unsubscribed, false);
subscriptionReady = true; subscriptionReady = true;
} }
@ -511,14 +516,14 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
@Override @Override
public void isSubscribed() { public void isSubscribed() {
subscribeSubredditChip.setText(R.string.unsubscribe); subscribeSubredditChip.setText(R.string.unsubscribe);
subscribeSubredditChip.setChipBackgroundColor(getResources().getColorStateList(R.color.colorAccent)); subscribeSubredditChip.setChipBackgroundColor(ColorStateList.valueOf(subscribedColor));
subscriptionReady = true; subscriptionReady = true;
} }
@Override @Override
public void isNotSubscribed() { public void isNotSubscribed() {
subscribeSubredditChip.setText(R.string.subscribe); subscribeSubredditChip.setText(R.string.subscribe);
subscribeSubredditChip.setChipBackgroundColor(getResources().getColorStateList(R.color.backgroundColorPrimaryDark)); subscribeSubredditChip.setChipBackgroundColor(ColorStateList.valueOf(unsubscribedColor));
subscriptionReady = true; subscriptionReady = true;
} }
}).execute(); }).execute();

View File

@ -2,12 +2,12 @@ package ml.docilealligator.infinityforreddit.Activity;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.res.ColorStateList;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.content.res.Resources; import android.content.res.Resources;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.util.TypedValue;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
@ -65,7 +65,6 @@ import ml.docilealligator.infinityforreddit.Post.PostDataSource;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.ReadMessage; import ml.docilealligator.infinityforreddit.ReadMessage;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.SortType; import ml.docilealligator.infinityforreddit.SortType;
import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback; import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback;
import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUserDao; import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUserDao;
@ -73,6 +72,8 @@ import ml.docilealligator.infinityforreddit.User.UserDao;
import ml.docilealligator.infinityforreddit.User.UserData; import ml.docilealligator.infinityforreddit.User.UserData;
import ml.docilealligator.infinityforreddit.User.UserViewModel; import ml.docilealligator.infinityforreddit.User.UserViewModel;
import ml.docilealligator.infinityforreddit.UserFollowing; import ml.docilealligator.infinityforreddit.UserFollowing;
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.Utils.Utils;
import pl.droidsonroids.gif.GifImageView; import pl.droidsonroids.gif.GifImageView;
import retrofit2.Retrofit; import retrofit2.Retrofit;
@ -205,19 +206,12 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
expandedTabTextColor = resources.getColor(R.color.tabLayoutWithExpandedCollapsingToolbarTextColor); expandedTabTextColor = Utils.getAttributeColor(this, R.attr.tabLayoutWithExpandedCollapsingToolbarTextColor);
expandedTabIndicatorColor = resources.getColor(R.color.tabLayoutWithExpandedCollapsingToolbarTabIndicator); expandedTabIndicatorColor = Utils.getAttributeColor(this, R.attr.tabLayoutWithExpandedCollapsingToolbarTabIndicator);
expandedTabBackgroundColor = Utils.getAttributeColor(this, R.attr.tabLayoutWithExpandedCollapsingToolbarTabBackground);
TypedValue expandedTabBackgroundColorTypedValue = new TypedValue(); collapsedTabTextColor = Utils.getAttributeColor(this, R.attr.tabLayoutWithCollapsedCollapsingToolbarTextColor);
getTheme().resolveAttribute(R.attr.tabLayoutWithExpandedCollapsingToolbarTabBackground, expandedTabBackgroundColorTypedValue, true); collapsedTabIndicatorColor = Utils.getAttributeColor(this, R.attr.tabLayoutWithCollapsedCollapsingToolbarTabIndicator);
expandedTabBackgroundColor = expandedTabBackgroundColorTypedValue.data; collapsedTabBackgroundColor = Utils.getAttributeColor(this, R.attr.tabLayoutWithCollapsedCollapsingToolbarTabBackground);
collapsedTabTextColor = resources.getColor(R.color.tabLayoutWithCollapsedCollapsingToolbarTextColor);
collapsedTabIndicatorColor = resources.getColor(R.color.tabLayoutWithCollapsedCollapsingToolbarTabIndicator);
TypedValue collapsedTabBackgroundColorTypedValue = new TypedValue();
getTheme().resolveAttribute(R.attr.tabLayoutWithCollapsedCollapsingToolbarTabBackground, collapsedTabBackgroundColorTypedValue, true);
collapsedTabBackgroundColor = collapsedTabBackgroundColorTypedValue.data;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1
&& (resources.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT && (resources.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT
@ -315,6 +309,9 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
}); });
} }
int unsubscribedColor = Utils.getAttributeColor(this, R.attr.unsubscribed);
int subscribedColor = Utils.getAttributeColor(this, R.attr.subscribed);
if (userData.isCanBeFollowed()) { if (userData.isCanBeFollowed()) {
subscribeUserChip.setVisibility(View.VISIBLE); subscribeUserChip.setVisibility(View.VISIBLE);
subscribeUserChip.setOnClickListener(view -> { subscribeUserChip.setOnClickListener(view -> {
@ -331,7 +328,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
@Override @Override
public void onUserFollowingSuccess() { public void onUserFollowingSuccess() {
subscribeUserChip.setText(R.string.unfollow); subscribeUserChip.setText(R.string.unfollow);
subscribeUserChip.setChipBackgroundColor(resources.getColorStateList(R.color.colorAccent)); subscribeUserChip.setChipBackgroundColor(ColorStateList.valueOf(subscribedColor));
showMessage(R.string.followed, false); showMessage(R.string.followed, false);
subscriptionReady = true; subscriptionReady = true;
} }
@ -348,7 +345,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
@Override @Override
public void onUserFollowingSuccess() { public void onUserFollowingSuccess() {
subscribeUserChip.setText(R.string.follow); subscribeUserChip.setText(R.string.follow);
subscribeUserChip.setChipBackgroundColor(resources.getColorStateList(R.color.backgroundColorPrimaryDark)); subscribeUserChip.setChipBackgroundColor(ColorStateList.valueOf(unsubscribedColor));
showMessage(R.string.unfollowed, false); showMessage(R.string.unfollowed, false);
subscriptionReady = true; subscriptionReady = true;
} }
@ -367,14 +364,14 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
@Override @Override
public void isSubscribed() { public void isSubscribed() {
subscribeUserChip.setText(R.string.unfollow); subscribeUserChip.setText(R.string.unfollow);
subscribeUserChip.setChipBackgroundColor(resources.getColorStateList(R.color.colorAccent)); subscribeUserChip.setChipBackgroundColor(ColorStateList.valueOf(subscribedColor));
subscriptionReady = true; subscriptionReady = true;
} }
@Override @Override
public void isNotSubscribed() { public void isNotSubscribed() {
subscribeUserChip.setText(R.string.follow); subscribeUserChip.setText(R.string.follow);
subscribeUserChip.setChipBackgroundColor(resources.getColorStateList(R.color.backgroundColorPrimaryDark)); subscribeUserChip.setChipBackgroundColor(ColorStateList.valueOf(unsubscribedColor));
subscriptionReady = true; subscriptionReady = true;
} }
}).execute(); }).execute();

View File

@ -11,7 +11,6 @@ import android.text.Spannable;
import android.text.Spanned; import android.text.Spanned;
import android.text.style.SuperscriptSpan; import android.text.style.SuperscriptSpan;
import android.text.util.Linkify; import android.text.util.Linkify;
import android.util.TypedValue;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -131,6 +130,12 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
private boolean mHasMoreComments; private boolean mHasMoreComments;
private boolean loadMoreCommentsFailed; private boolean loadMoreCommentsFailed;
private int mCommentBackgroundColor; private int mCommentBackgroundColor;
private int mUsernameColor;
private int mSubmitterColor;
private int mModeratorColor;
private int mUpvotedColor;
private int mDownvotedColor;
private float mScale; private float mScale;
private ShareLinkBottomSheetFragment mShareLinkBottomSheetFragment; private ShareLinkBottomSheetFragment mShareLinkBottomSheetFragment;
private CopyTextBottomSheetFragment mCopyTextBottomSheetFragment; private CopyTextBottomSheetFragment mCopyTextBottomSheetFragment;
@ -239,10 +244,12 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
mHasMoreComments = false; mHasMoreComments = false;
loadMoreCommentsFailed = false; loadMoreCommentsFailed = false;
mScale = activity.getResources().getDisplayMetrics().density; mScale = activity.getResources().getDisplayMetrics().density;
mCommentBackgroundColor = Utils.getAttributeColor(activity, R.attr.cardViewBackgroundColor);
TypedValue typedValue = new TypedValue(); mSubmitterColor = Utils.getAttributeColor(activity, R.attr.submitter);
mActivity.getTheme().resolveAttribute(R.attr.cardViewBackgroundColor, typedValue, true); mModeratorColor = Utils.getAttributeColor(activity, R.attr.moderator);
mCommentBackgroundColor = typedValue.data; mUsernameColor = Utils.getAttributeColor(activity, R.attr.username);
mUpvotedColor = Utils.getAttributeColor(activity, R.attr.upvoted);
mDownvotedColor = Utils.getAttributeColor(activity, R.attr.downvoted);
mShareLinkBottomSheetFragment = new ShareLinkBottomSheetFragment(); mShareLinkBottomSheetFragment = new ShareLinkBottomSheetFragment();
mCopyTextBottomSheetFragment = new CopyTextBottomSheetFragment(); mCopyTextBottomSheetFragment = new CopyTextBottomSheetFragment();
@ -400,13 +407,13 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
switch (mPost.getVoteType()) { switch (mPost.getVoteType()) {
case 1: case 1:
//Upvote //Upvote
((PostDetailViewHolder) holder).mUpvoteButton.setColorFilter(ContextCompat.getColor(mActivity, R.color.upvoted), PorterDuff.Mode.SRC_IN); ((PostDetailViewHolder) holder).mUpvoteButton.setColorFilter(mUpvotedColor, PorterDuff.Mode.SRC_IN);
((PostDetailViewHolder) holder).mScoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.upvoted)); ((PostDetailViewHolder) holder).mScoreTextView.setTextColor(mUpvotedColor);
break; break;
case -1: case -1:
//Downvote //Downvote
((PostDetailViewHolder) holder).mDownvoteButton.setColorFilter(ContextCompat.getColor(mActivity, R.color.downvoted), PorterDuff.Mode.SRC_IN); ((PostDetailViewHolder) holder).mDownvoteButton.setColorFilter(mDownvotedColor, PorterDuff.Mode.SRC_IN);
((PostDetailViewHolder) holder).mScoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.downvoted)); ((PostDetailViewHolder) holder).mScoreTextView.setTextColor(mDownvotedColor);
break; break;
case 0: case 0:
((PostDetailViewHolder) holder).mUpvoteButton.clearColorFilter(); ((PostDetailViewHolder) holder).mUpvoteButton.clearColorFilter();
@ -733,16 +740,16 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
} }
if (comment.isSubmitter()) { if (comment.isSubmitter()) {
((CommentViewHolder) holder).authorTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.submitter)); ((CommentViewHolder) holder).authorTextView.setTextColor(mSubmitterColor);
((CommentViewHolder) holder).authorTypeImageView.setVisibility(View.VISIBLE); ((CommentViewHolder) holder).authorTypeImageView.setVisibility(View.VISIBLE);
((CommentViewHolder) holder).authorTypeImageView. ((CommentViewHolder) holder).authorTypeImageView.
setColorFilter(ContextCompat.getColor(mActivity, R.color.submitter), android.graphics.PorterDuff.Mode.SRC_IN); setColorFilter(mSubmitterColor, android.graphics.PorterDuff.Mode.SRC_IN);
((CommentViewHolder) holder).authorTypeImageView.setImageResource(R.drawable.ic_mic_14dp); ((CommentViewHolder) holder).authorTypeImageView.setImageResource(R.drawable.ic_mic_14dp);
} else if (comment.isModerator()) { } else if (comment.isModerator()) {
((CommentViewHolder) holder).authorTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.moderator)); ((CommentViewHolder) holder).authorTextView.setTextColor(mModeratorColor);
((CommentViewHolder) holder).authorTypeImageView.setVisibility(View.VISIBLE); ((CommentViewHolder) holder).authorTypeImageView.setVisibility(View.VISIBLE);
((CommentViewHolder) holder).authorTypeImageView. ((CommentViewHolder) holder).authorTypeImageView.
setColorFilter(ContextCompat.getColor(mActivity, R.color.moderator), android.graphics.PorterDuff.Mode.SRC_IN); setColorFilter(mModeratorColor, android.graphics.PorterDuff.Mode.SRC_IN);
((CommentViewHolder) holder).authorTypeImageView.setImageResource(R.drawable.ic_verified_user_14dp); ((CommentViewHolder) holder).authorTypeImageView.setImageResource(R.drawable.ic_verified_user_14dp);
} }
@ -822,13 +829,13 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
switch (comment.getVoteType()) { switch (comment.getVoteType()) {
case CommentData.VOTE_TYPE_UPVOTE: case CommentData.VOTE_TYPE_UPVOTE:
((CommentViewHolder) holder).upVoteButton ((CommentViewHolder) holder).upVoteButton
.setColorFilter(ContextCompat.getColor(mActivity, R.color.upvoted), android.graphics.PorterDuff.Mode.SRC_IN); .setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
((CommentViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.upvoted)); ((CommentViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor);
break; break;
case CommentData.VOTE_TYPE_DOWNVOTE: case CommentData.VOTE_TYPE_DOWNVOTE:
((CommentViewHolder) holder).downVoteButton ((CommentViewHolder) holder).downVoteButton
.setColorFilter(ContextCompat.getColor(mActivity, R.color.downvoted), android.graphics.PorterDuff.Mode.SRC_IN); .setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
((CommentViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.downvoted)); ((CommentViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor);
break; break;
} }
@ -897,8 +904,8 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
//Not upvoted before //Not upvoted before
comment.setVoteType(CommentData.VOTE_TYPE_UPVOTE); comment.setVoteType(CommentData.VOTE_TYPE_UPVOTE);
newVoteType = RedditUtils.DIR_UPVOTE; newVoteType = RedditUtils.DIR_UPVOTE;
((CommentViewHolder) holder).upVoteButton.setColorFilter(ContextCompat.getColor(mActivity, R.color.upvoted), android.graphics.PorterDuff.Mode.SRC_IN); ((CommentViewHolder) holder).upVoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
((CommentViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.upvoted)); ((CommentViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor);
} else { } else {
//Upvoted before //Upvoted before
comment.setVoteType(CommentData.VOTE_TYPE_NO_VOTE); comment.setVoteType(CommentData.VOTE_TYPE_NO_VOTE);
@ -915,8 +922,8 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
public void onVoteThingSuccess(int position) { public void onVoteThingSuccess(int position) {
if (newVoteType.equals(RedditUtils.DIR_UPVOTE)) { if (newVoteType.equals(RedditUtils.DIR_UPVOTE)) {
comment.setVoteType(CommentData.VOTE_TYPE_UPVOTE); comment.setVoteType(CommentData.VOTE_TYPE_UPVOTE);
((CommentViewHolder) holder).upVoteButton.setColorFilter(ContextCompat.getColor(mActivity, R.color.upvoted), android.graphics.PorterDuff.Mode.SRC_IN); ((CommentViewHolder) holder).upVoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
((CommentViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.upvoted)); ((CommentViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor);
} else { } else {
comment.setVoteType(CommentData.VOTE_TYPE_NO_VOTE); comment.setVoteType(CommentData.VOTE_TYPE_NO_VOTE);
((CommentViewHolder) holder).upVoteButton.clearColorFilter(); ((CommentViewHolder) holder).upVoteButton.clearColorFilter();
@ -954,8 +961,8 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
//Not downvoted before //Not downvoted before
comment.setVoteType(CommentData.VOTE_TYPE_DOWNVOTE); comment.setVoteType(CommentData.VOTE_TYPE_DOWNVOTE);
newVoteType = RedditUtils.DIR_DOWNVOTE; newVoteType = RedditUtils.DIR_DOWNVOTE;
((CommentViewHolder) holder).downVoteButton.setColorFilter(ContextCompat.getColor(mActivity, R.color.downvoted), android.graphics.PorterDuff.Mode.SRC_IN); ((CommentViewHolder) holder).downVoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
((CommentViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.downvoted)); ((CommentViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor);
} else { } else {
//Downvoted before //Downvoted before
comment.setVoteType(CommentData.VOTE_TYPE_NO_VOTE); comment.setVoteType(CommentData.VOTE_TYPE_NO_VOTE);
@ -972,8 +979,8 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
public void onVoteThingSuccess(int position1) { public void onVoteThingSuccess(int position1) {
if (newVoteType.equals(RedditUtils.DIR_DOWNVOTE)) { if (newVoteType.equals(RedditUtils.DIR_DOWNVOTE)) {
comment.setVoteType(CommentData.VOTE_TYPE_DOWNVOTE); comment.setVoteType(CommentData.VOTE_TYPE_DOWNVOTE);
((CommentViewHolder) holder).downVoteButton.setColorFilter(ContextCompat.getColor(mActivity, R.color.downvoted), android.graphics.PorterDuff.Mode.SRC_IN); ((CommentViewHolder) holder).downVoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
((CommentViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.downvoted)); ((CommentViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor);
} else { } else {
comment.setVoteType(CommentData.VOTE_TYPE_NO_VOTE); comment.setVoteType(CommentData.VOTE_TYPE_NO_VOTE);
((CommentViewHolder) holder).downVoteButton.clearColorFilter(); ((CommentViewHolder) holder).downVoteButton.clearColorFilter();
@ -1602,8 +1609,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
@Override @Override
public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) { public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
if (holder instanceof CommentViewHolder) { if (holder instanceof CommentViewHolder) {
((CommentViewHolder) holder).authorTextView.setTextColor( ((CommentViewHolder) holder).authorTextView.setTextColor(mUsernameColor);
ContextCompat.getColor(mActivity, R.color.colorPrimaryDarkDayNightTheme));
mGlide.clear(((CommentViewHolder) holder).authorTypeImageView); mGlide.clear(((CommentViewHolder) holder).authorTypeImageView);
((CommentViewHolder) holder).authorFlairTextView.setVisibility(View.GONE); ((CommentViewHolder) holder).authorFlairTextView.setVisibility(View.GONE);
((CommentViewHolder) holder).authorTypeImageView.setVisibility(View.GONE); ((CommentViewHolder) holder).authorTypeImageView.setVisibility(View.GONE);
@ -1791,8 +1797,8 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
//Not upvoted before //Not upvoted before
mPost.setVoteType(1); mPost.setVoteType(1);
newVoteType = RedditUtils.DIR_UPVOTE; newVoteType = RedditUtils.DIR_UPVOTE;
mUpvoteButton.setColorFilter(ContextCompat.getColor(mActivity, R.color.upvoted), android.graphics.PorterDuff.Mode.SRC_IN); mUpvoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
mScoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.upvoted)); mScoreTextView.setTextColor(mUpvotedColor);
} else { } else {
//Upvoted before //Upvoted before
mPost.setVoteType(0); mPost.setVoteType(0);
@ -1811,8 +1817,8 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
public void onVoteThingSuccess() { public void onVoteThingSuccess() {
if (newVoteType.equals(RedditUtils.DIR_UPVOTE)) { if (newVoteType.equals(RedditUtils.DIR_UPVOTE)) {
mPost.setVoteType(1); mPost.setVoteType(1);
mUpvoteButton.setColorFilter(ContextCompat.getColor(mActivity, R.color.upvoted), android.graphics.PorterDuff.Mode.SRC_IN); mUpvoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
mScoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.upvoted)); mScoreTextView.setTextColor(mUpvotedColor);
} else { } else {
mPost.setVoteType(0); mPost.setVoteType(0);
mUpvoteButton.clearColorFilter(); mUpvoteButton.clearColorFilter();
@ -1865,8 +1871,8 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
//Not upvoted before //Not upvoted before
mPost.setVoteType(-1); mPost.setVoteType(-1);
newVoteType = RedditUtils.DIR_DOWNVOTE; newVoteType = RedditUtils.DIR_DOWNVOTE;
mDownvoteButton.setColorFilter(ContextCompat.getColor(mActivity, R.color.downvoted), android.graphics.PorterDuff.Mode.SRC_IN); mDownvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
mScoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.downvoted)); mScoreTextView.setTextColor(mDownvotedColor);
} else { } else {
//Upvoted before //Upvoted before
mPost.setVoteType(0); mPost.setVoteType(0);
@ -1885,8 +1891,8 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
public void onVoteThingSuccess() { public void onVoteThingSuccess() {
if (newVoteType.equals(RedditUtils.DIR_DOWNVOTE)) { if (newVoteType.equals(RedditUtils.DIR_DOWNVOTE)) {
mPost.setVoteType(-1); mPost.setVoteType(-1);
mDownvoteButton.setColorFilter(ContextCompat.getColor(mActivity, R.color.downvoted), android.graphics.PorterDuff.Mode.SRC_IN); mDownvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
mScoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.downvoted)); mScoreTextView.setTextColor(mDownvotedColor);
} else { } else {
mPost.setVoteType(0); mPost.setVoteType(0);
mDownvoteButton.clearColorFilter(); mDownvoteButton.clearColorFilter();

View File

@ -66,8 +66,10 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
private Markwon mMarkwon; private Markwon mMarkwon;
private String mAccessToken; private String mAccessToken;
private String mAccountName; private String mAccountName;
private int mTextColorPrimaryDark; private int mUsernameColor;
private int mColorAccent; private int mSubredditColor;
private int mUpvotedColor;
private int mDownvotedColor;
private boolean mVoteButtonsOnTheRight; private boolean mVoteButtonsOnTheRight;
private boolean mShowElapsedTime; private boolean mShowElapsedTime;
private boolean mShowCommentDivider; private boolean mShowCommentDivider;
@ -115,8 +117,10 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
mShowCommentDivider = showCommentDivider; mShowCommentDivider = showCommentDivider;
mShowAbsoluteNumberOfVotes = showAbsoluteNumberOfVotes; mShowAbsoluteNumberOfVotes = showAbsoluteNumberOfVotes;
mRetryLoadingMoreCallback = retryLoadingMoreCallback; mRetryLoadingMoreCallback = retryLoadingMoreCallback;
mTextColorPrimaryDark = mContext.getResources().getColor(R.color.colorPrimaryDarkDayNightTheme); mSubredditColor = Utils.getAttributeColor(context, R.attr.subreddit);
mColorAccent = mContext.getResources().getColor(R.color.colorAccent); mUsernameColor = Utils.getAttributeColor(context, R.attr.username);
mUpvotedColor = Utils.getAttributeColor(context, R.attr.upvoted);
mDownvotedColor = Utils.getAttributeColor(context, R.attr.downvoted);
} }
@NonNull @NonNull
@ -138,7 +142,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
if (comment != null) { if (comment != null) {
if (comment.getSubredditName().substring(2).equals(comment.getLinkAuthor())) { if (comment.getSubredditName().substring(2).equals(comment.getLinkAuthor())) {
((DataViewHolder) holder).authorTextView.setText("u/" + comment.getLinkAuthor()); ((DataViewHolder) holder).authorTextView.setText("u/" + comment.getLinkAuthor());
((DataViewHolder) holder).authorTextView.setTextColor(mTextColorPrimaryDark); ((DataViewHolder) holder).authorTextView.setTextColor(mUsernameColor);
((DataViewHolder) holder).authorTextView.setOnClickListener(view -> { ((DataViewHolder) holder).authorTextView.setOnClickListener(view -> {
Intent intent = new Intent(mContext, ViewUserDetailActivity.class); Intent intent = new Intent(mContext, ViewUserDetailActivity.class);
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, comment.getLinkAuthor()); intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, comment.getLinkAuthor());
@ -146,7 +150,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
}); });
} else { } else {
((DataViewHolder) holder).authorTextView.setText("r/" + comment.getSubredditName()); ((DataViewHolder) holder).authorTextView.setText("r/" + comment.getSubredditName());
((DataViewHolder) holder).authorTextView.setTextColor(mColorAccent); ((DataViewHolder) holder).authorTextView.setTextColor(mSubredditColor);
((DataViewHolder) holder).authorTextView.setOnClickListener(view -> { ((DataViewHolder) holder).authorTextView.setOnClickListener(view -> {
Intent intent = new Intent(mContext, ViewSubredditDetailActivity.class); Intent intent = new Intent(mContext, ViewSubredditDetailActivity.class);
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, comment.getSubredditName()); intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, comment.getSubredditName());
@ -169,13 +173,13 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
switch (comment.getVoteType()) { switch (comment.getVoteType()) {
case CommentData.VOTE_TYPE_UPVOTE: case CommentData.VOTE_TYPE_UPVOTE:
((DataViewHolder) holder).upvoteButton ((DataViewHolder) holder).upvoteButton
.setColorFilter(ContextCompat.getColor(mContext, R.color.upvoted), android.graphics.PorterDuff.Mode.SRC_IN); .setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
((DataViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mContext, R.color.upvoted)); ((DataViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor);
break; break;
case CommentData.VOTE_TYPE_DOWNVOTE: case CommentData.VOTE_TYPE_DOWNVOTE:
((DataViewHolder) holder).downvoteButton ((DataViewHolder) holder).downvoteButton
.setColorFilter(ContextCompat.getColor(mContext, R.color.downvoted), android.graphics.PorterDuff.Mode.SRC_IN); .setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
((DataViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mContext, R.color.downvoted)); ((DataViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor);
break; break;
} }
@ -221,8 +225,8 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
comment.setVoteType(CommentData.VOTE_TYPE_UPVOTE); comment.setVoteType(CommentData.VOTE_TYPE_UPVOTE);
newVoteType = RedditUtils.DIR_UPVOTE; newVoteType = RedditUtils.DIR_UPVOTE;
((DataViewHolder) holder).upvoteButton ((DataViewHolder) holder).upvoteButton
.setColorFilter(ContextCompat.getColor(mContext, R.color.upvoted), android.graphics.PorterDuff.Mode.SRC_IN); .setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
((DataViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mContext, R.color.upvoted)); ((DataViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor);
} else { } else {
//Upvoted before //Upvoted before
comment.setVoteType(CommentData.VOTE_TYPE_NO_VOTE); comment.setVoteType(CommentData.VOTE_TYPE_NO_VOTE);
@ -239,8 +243,8 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
public void onVoteThingSuccess(int position) { public void onVoteThingSuccess(int position) {
if (newVoteType.equals(RedditUtils.DIR_UPVOTE)) { if (newVoteType.equals(RedditUtils.DIR_UPVOTE)) {
comment.setVoteType(CommentData.VOTE_TYPE_UPVOTE); comment.setVoteType(CommentData.VOTE_TYPE_UPVOTE);
((DataViewHolder) holder).upvoteButton.setColorFilter(ContextCompat.getColor(mContext, R.color.upvoted), android.graphics.PorterDuff.Mode.SRC_IN); ((DataViewHolder) holder).upvoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
((DataViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mContext, R.color.upvoted)); ((DataViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor);
} else { } else {
comment.setVoteType(CommentData.VOTE_TYPE_NO_VOTE); comment.setVoteType(CommentData.VOTE_TYPE_NO_VOTE);
((DataViewHolder) holder).upvoteButton.clearColorFilter(); ((DataViewHolder) holder).upvoteButton.clearColorFilter();
@ -273,8 +277,8 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
//Not downvoted before //Not downvoted before
comment.setVoteType(CommentData.VOTE_TYPE_DOWNVOTE); comment.setVoteType(CommentData.VOTE_TYPE_DOWNVOTE);
newVoteType = RedditUtils.DIR_DOWNVOTE; newVoteType = RedditUtils.DIR_DOWNVOTE;
((DataViewHolder) holder).downvoteButton.setColorFilter(ContextCompat.getColor(mContext, R.color.downvoted), android.graphics.PorterDuff.Mode.SRC_IN); ((DataViewHolder) holder).downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
((DataViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mContext, R.color.downvoted)); ((DataViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor);
} else { } else {
//Downvoted before //Downvoted before
comment.setVoteType(CommentData.VOTE_TYPE_NO_VOTE); comment.setVoteType(CommentData.VOTE_TYPE_NO_VOTE);
@ -291,8 +295,8 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
public void onVoteThingSuccess(int position1) { public void onVoteThingSuccess(int position1) {
if (newVoteType.equals(RedditUtils.DIR_DOWNVOTE)) { if (newVoteType.equals(RedditUtils.DIR_DOWNVOTE)) {
comment.setVoteType(CommentData.VOTE_TYPE_DOWNVOTE); comment.setVoteType(CommentData.VOTE_TYPE_DOWNVOTE);
((DataViewHolder) holder).downvoteButton.setColorFilter(ContextCompat.getColor(mContext, R.color.downvoted), android.graphics.PorterDuff.Mode.SRC_IN); ((DataViewHolder) holder).downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
((DataViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mContext, R.color.downvoted)); ((DataViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor);
} else { } else {
comment.setVoteType(CommentData.VOTE_TYPE_NO_VOTE); comment.setVoteType(CommentData.VOTE_TYPE_NO_VOTE);
((DataViewHolder) holder).downvoteButton.clearColorFilter(); ((DataViewHolder) holder).downvoteButton.clearColorFilter();

View File

@ -6,7 +6,6 @@ import android.content.res.Resources;
import android.net.Uri; import android.net.Uri;
import android.text.style.SuperscriptSpan; import android.text.style.SuperscriptSpan;
import android.text.util.Linkify; import android.text.util.Linkify;
import android.util.TypedValue;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -32,6 +31,7 @@ import ml.docilealligator.infinityforreddit.Message;
import ml.docilealligator.infinityforreddit.NetworkState; import ml.docilealligator.infinityforreddit.NetworkState;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.ReadMessage; import ml.docilealligator.infinityforreddit.ReadMessage;
import ml.docilealligator.infinityforreddit.Utils.Utils;
import retrofit2.Retrofit; import retrofit2.Retrofit;
public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, RecyclerView.ViewHolder> { public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, RecyclerView.ViewHolder> {
@ -57,6 +57,7 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
private NetworkState networkState; private NetworkState networkState;
private RetryLoadingMoreCallback mRetryLoadingMoreCallback; private RetryLoadingMoreCallback mRetryLoadingMoreCallback;
private int mMessageBackgroundColor; private int mMessageBackgroundColor;
private int usernameColor;
public MessageRecyclerViewAdapter(Context context, Retrofit oauthRetrofit, String accessToken, public MessageRecyclerViewAdapter(Context context, Retrofit oauthRetrofit, String accessToken,
RetryLoadingMoreCallback retryLoadingMoreCallback) { RetryLoadingMoreCallback retryLoadingMoreCallback) {
@ -92,9 +93,8 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
mAccessToken = accessToken; mAccessToken = accessToken;
mResources = context.getResources(); mResources = context.getResources();
TypedValue typedValue = new TypedValue(); mMessageBackgroundColor = Utils.getAttributeColor(context, R.attr.cardViewBackgroundColor);
mContext.getTheme().resolveAttribute(R.attr.cardViewBackgroundColor, typedValue, true); usernameColor = Utils.getAttributeColor(context, R.attr.username);
mMessageBackgroundColor = typedValue.data;
} }
@NonNull @NonNull
@ -120,7 +120,7 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
} }
if (message.wasComment()) { if (message.wasComment()) {
((DataViewHolder) holder).authorTextView.setTextColor(mResources.getColor(R.color.colorPrimaryDarkDayNightTheme)); ((DataViewHolder) holder).authorTextView.setTextColor(usernameColor);
((DataViewHolder) holder).titleTextView.setText(message.getTitle()); ((DataViewHolder) holder).titleTextView.setText(message.getTitle());
} else { } else {
((DataViewHolder) holder).titleTextView.setVisibility(View.GONE); ((DataViewHolder) holder).titleTextView.setVisibility(View.GONE);

View File

@ -98,6 +98,10 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
private boolean canStartActivity = true; private boolean canStartActivity = true;
private int mPostType; private int mPostType;
private int mPostLayout; private int mPostLayout;
private int mSubredditColor;
private int mUsernameColor;
private int mUpvotedColor;
private int mDownvotedColor;
private float mScale; private float mScale;
private boolean mDisplaySubredditName; private boolean mDisplaySubredditName;
private boolean mVoteButtonsOnTheRight; private boolean mVoteButtonsOnTheRight;
@ -131,6 +135,10 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
mShowDividerInCompactLayout = showDividerInCompactLayout; mShowDividerInCompactLayout = showDividerInCompactLayout;
mShowAbsoluteNumberOfVotes = showAbsoluteNumberOfVotes; mShowAbsoluteNumberOfVotes = showAbsoluteNumberOfVotes;
mPostLayout = postLayout; mPostLayout = postLayout;
mSubredditColor = Utils.getAttributeColor(activity, R.attr.subreddit);
mUsernameColor = Utils.getAttributeColor(activity, R.attr.username);
mUpvotedColor = Utils.getAttributeColor(activity, R.attr.upvoted);
mDownvotedColor = Utils.getAttributeColor(activity, R.attr.downvoted);
mScale = activity.getResources().getDisplayMetrics().density; mScale = activity.getResources().getDisplayMetrics().density;
mGlide = Glide.with(mActivity.getApplicationContext()); mGlide = Glide.with(mActivity.getApplicationContext());
mRedditDataRoomDatabase = redditDataRoomDatabase; mRedditDataRoomDatabase = redditDataRoomDatabase;
@ -391,13 +399,13 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
switch (voteType) { switch (voteType) {
case 1: case 1:
//Upvoted //Upvoted
((PostViewHolder) holder).upvoteButton.setColorFilter(ContextCompat.getColor(mActivity, R.color.upvoted), android.graphics.PorterDuff.Mode.SRC_IN); ((PostViewHolder) holder).upvoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
((PostViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.upvoted)); ((PostViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor);
break; break;
case -1: case -1:
//Downvoted //Downvoted
((PostViewHolder) holder).downvoteButton.setColorFilter(ContextCompat.getColor(mActivity, R.color.downvoted), android.graphics.PorterDuff.Mode.SRC_IN); ((PostViewHolder) holder).downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
((PostViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.downvoted)); ((PostViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor);
break; break;
} }
@ -551,8 +559,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
post.setVoteType(1); post.setVoteType(1);
newVoteType = RedditUtils.DIR_UPVOTE; newVoteType = RedditUtils.DIR_UPVOTE;
((PostViewHolder) holder).upvoteButton ((PostViewHolder) holder).upvoteButton
.setColorFilter(ContextCompat.getColor(mActivity, R.color.upvoted), android.graphics.PorterDuff.Mode.SRC_IN); .setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
((PostViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.upvoted)); ((PostViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor);
} else { } else {
//Upvoted before //Upvoted before
post.setVoteType(0); post.setVoteType(0);
@ -569,8 +577,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
if (newVoteType.equals(RedditUtils.DIR_UPVOTE)) { if (newVoteType.equals(RedditUtils.DIR_UPVOTE)) {
post.setVoteType(1); post.setVoteType(1);
((PostViewHolder) holder).upvoteButton ((PostViewHolder) holder).upvoteButton
.setColorFilter(ContextCompat.getColor(mActivity, R.color.upvoted), android.graphics.PorterDuff.Mode.SRC_IN); .setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
((PostViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.upvoted)); ((PostViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor);
} else { } else {
post.setVoteType(0); post.setVoteType(0);
((PostViewHolder) holder).upvoteButton.clearColorFilter(); ((PostViewHolder) holder).upvoteButton.clearColorFilter();
@ -622,8 +630,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
post.setVoteType(-1); post.setVoteType(-1);
newVoteType = RedditUtils.DIR_DOWNVOTE; newVoteType = RedditUtils.DIR_DOWNVOTE;
((PostViewHolder) holder).downvoteButton ((PostViewHolder) holder).downvoteButton
.setColorFilter(ContextCompat.getColor(mActivity, R.color.downvoted), android.graphics.PorterDuff.Mode.SRC_IN); .setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
((PostViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.downvoted)); ((PostViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor);
} else { } else {
//Downvoted before //Downvoted before
post.setVoteType(0); post.setVoteType(0);
@ -640,8 +648,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
if (newVoteType.equals(RedditUtils.DIR_DOWNVOTE)) { if (newVoteType.equals(RedditUtils.DIR_DOWNVOTE)) {
post.setVoteType(-1); post.setVoteType(-1);
((PostViewHolder) holder).downvoteButton ((PostViewHolder) holder).downvoteButton
.setColorFilter(ContextCompat.getColor(mActivity, R.color.downvoted), android.graphics.PorterDuff.Mode.SRC_IN); .setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
((PostViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.downvoted)); ((PostViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor);
} else { } else {
post.setVoteType(0); post.setVoteType(0);
((PostViewHolder) holder).downvoteButton.clearColorFilter(); ((PostViewHolder) holder).downvoteButton.clearColorFilter();
@ -823,7 +831,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
} }
} }
((PostCompactViewHolder) holder).nameTextView.setTextColor(mActivity.getResources().getColor(R.color.colorAccent)); ((PostCompactViewHolder) holder).nameTextView.setTextColor(mSubredditColor);
((PostCompactViewHolder) holder).nameTextView.setText(subredditNamePrefixed); ((PostCompactViewHolder) holder).nameTextView.setText(subredditNamePrefixed);
((PostCompactViewHolder) holder).nameTextView.setOnClickListener(view -> { ((PostCompactViewHolder) holder).nameTextView.setOnClickListener(view -> {
@ -879,7 +887,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
.into(((PostCompactViewHolder) holder).iconGifImageView); .into(((PostCompactViewHolder) holder).iconGifImageView);
} }
((PostCompactViewHolder) holder).nameTextView.setTextColor(mActivity.getResources().getColor(R.color.colorPrimaryDarkDayNightTheme)); ((PostCompactViewHolder) holder).nameTextView.setTextColor(mUsernameColor);
((PostCompactViewHolder) holder).nameTextView.setText(authorPrefixed); ((PostCompactViewHolder) holder).nameTextView.setText(authorPrefixed);
((PostCompactViewHolder) holder).nameTextView.setOnClickListener(view -> { ((PostCompactViewHolder) holder).nameTextView.setOnClickListener(view -> {
@ -946,13 +954,13 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
switch (voteType) { switch (voteType) {
case 1: case 1:
//Upvoted //Upvoted
((PostCompactViewHolder) holder).upvoteButton.setColorFilter(ContextCompat.getColor(mActivity, R.color.upvoted), android.graphics.PorterDuff.Mode.SRC_IN); ((PostCompactViewHolder) holder).upvoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
((PostCompactViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.upvoted)); ((PostCompactViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor);
break; break;
case -1: case -1:
//Downvoted //Downvoted
((PostCompactViewHolder) holder).downvoteButton.setColorFilter(ContextCompat.getColor(mActivity, R.color.downvoted), android.graphics.PorterDuff.Mode.SRC_IN); ((PostCompactViewHolder) holder).downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
((PostCompactViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.downvoted)); ((PostCompactViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor);
break; break;
} }
@ -1097,8 +1105,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
post.setVoteType(1); post.setVoteType(1);
newVoteType = RedditUtils.DIR_UPVOTE; newVoteType = RedditUtils.DIR_UPVOTE;
((PostCompactViewHolder) holder).upvoteButton ((PostCompactViewHolder) holder).upvoteButton
.setColorFilter(ContextCompat.getColor(mActivity, R.color.upvoted), android.graphics.PorterDuff.Mode.SRC_IN); .setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
((PostCompactViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.upvoted)); ((PostCompactViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor);
} else { } else {
//Upvoted before //Upvoted before
post.setVoteType(0); post.setVoteType(0);
@ -1115,8 +1123,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
if (newVoteType.equals(RedditUtils.DIR_UPVOTE)) { if (newVoteType.equals(RedditUtils.DIR_UPVOTE)) {
post.setVoteType(1); post.setVoteType(1);
((PostCompactViewHolder) holder).upvoteButton ((PostCompactViewHolder) holder).upvoteButton
.setColorFilter(ContextCompat.getColor(mActivity, R.color.upvoted), android.graphics.PorterDuff.Mode.SRC_IN); .setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
((PostCompactViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.upvoted)); ((PostCompactViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor);
} else { } else {
post.setVoteType(0); post.setVoteType(0);
((PostCompactViewHolder) holder).upvoteButton.clearColorFilter(); ((PostCompactViewHolder) holder).upvoteButton.clearColorFilter();
@ -1168,8 +1176,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
post.setVoteType(-1); post.setVoteType(-1);
newVoteType = RedditUtils.DIR_DOWNVOTE; newVoteType = RedditUtils.DIR_DOWNVOTE;
((PostCompactViewHolder) holder).downvoteButton ((PostCompactViewHolder) holder).downvoteButton
.setColorFilter(ContextCompat.getColor(mActivity, R.color.downvoted), android.graphics.PorterDuff.Mode.SRC_IN); .setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
((PostCompactViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.downvoted)); ((PostCompactViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor);
} else { } else {
//Downvoted before //Downvoted before
post.setVoteType(0); post.setVoteType(0);
@ -1186,8 +1194,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
if (newVoteType.equals(RedditUtils.DIR_DOWNVOTE)) { if (newVoteType.equals(RedditUtils.DIR_DOWNVOTE)) {
post.setVoteType(-1); post.setVoteType(-1);
((PostCompactViewHolder) holder).downvoteButton ((PostCompactViewHolder) holder).downvoteButton
.setColorFilter(ContextCompat.getColor(mActivity, R.color.downvoted), android.graphics.PorterDuff.Mode.SRC_IN); .setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
((PostCompactViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.downvoted)); ((PostCompactViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor);
} else { } else {
post.setVoteType(0); post.setVoteType(0);
((PostCompactViewHolder) holder).downvoteButton.clearColorFilter(); ((PostCompactViewHolder) holder).downvoteButton.clearColorFilter();

View File

@ -76,9 +76,13 @@ class AppModule {
@Provides @Provides
@Singleton @Singleton
OkHttpClient provideOkHttpClient(@Named("no_oauth") Retrofit retrofit, RedditDataRoomDatabase accountRoomDatabase) { OkHttpClient provideOkHttpClient(RedditDataRoomDatabase accountRoomDatabase) {
OkHttpClient.Builder okHttpClientBuilder = new OkHttpClient.Builder(); OkHttpClient.Builder okHttpClientBuilder = new OkHttpClient.Builder();
okHttpClientBuilder.authenticator(new AccessTokenAuthenticator(retrofit, accountRoomDatabase)); okHttpClientBuilder.authenticator(new AccessTokenAuthenticator(accountRoomDatabase));
/*.connectTimeout(30, TimeUnit.SECONDS)
.readTimeout(30, TimeUnit.SECONDS)
.writeTimeout(30, TimeUnit.SECONDS)
.connectionPool(new ConnectionPool(0, 1, TimeUnit.NANOSECONDS));*/
//.addInterceptor(new Okhttp3DebugInterceptor(mApplication)); //.addInterceptor(new Okhttp3DebugInterceptor(mApplication));
return okHttpClientBuilder.build(); return okHttpClientBuilder.build();
} }

View File

@ -1,6 +1,7 @@
package ml.docilealligator.infinityforreddit.Utils; package ml.docilealligator.infinityforreddit.Utils;
import android.content.Context; import android.content.Context;
import android.util.TypedValue;
import java.util.Locale; import java.util.Locale;
@ -73,4 +74,10 @@ public class Utils {
return String.format(Locale.US, "%.1f", (float) votes / 1000) + "K"; return String.format(Locale.US, "%.1f", (float) votes / 1000) + "K";
} }
} }
public static int getAttributeColor(Context context, int attrId) {
TypedValue typedValue = new TypedValue();
context.getTheme().resolveAttribute(attrId, typedValue, true);
return typedValue.data;
}
} }

View File

@ -76,7 +76,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="@dimen/fab_margin" android:layout_margin="@dimen/fab_margin"
android:layout_gravity="bottom|end" android:layout_gravity="bottom|end"
app:backgroundTint="@color/backgroundColorPrimary" app:backgroundTint="?attr/colorPrimaryLightTheme"
app:srcCompat="@drawable/ic_add_bottom_app_bar_24dp" app:srcCompat="@drawable/ic_add_bottom_app_bar_24dp"
app:tint="@android:color/white" /> app:tint="@android:color/white" />

View File

@ -92,7 +92,7 @@
android:textSize="?attr/font_default" android:textSize="?attr/font_default"
android:visibility="gone" android:visibility="gone"
app:lib_setRadius="3dp" app:lib_setRadius="3dp"
app:lib_setRoundedBorderColor="@color/colorPrimaryDarkDayNightTheme" app:lib_setRoundedBorderColor="?attr/flairColor"
app:lib_setRoundedView="true" app:lib_setRoundedView="true"
app:lib_setShape="rectangle" /> app:lib_setShape="rectangle" />
@ -106,7 +106,7 @@
android:textColor="@color/primaryTextColor" android:textColor="@color/primaryTextColor"
android:textSize="?attr/font_default" android:textSize="?attr/font_default"
app:lib_setRadius="3dp" app:lib_setRadius="3dp"
app:lib_setRoundedBorderColor="@color/colorPrimaryDarkDayNightTheme" app:lib_setRoundedBorderColor="?attr/spoilerColor"
app:lib_setRoundedView="true" app:lib_setRoundedView="true"
app:lib_setShape="rectangle" /> app:lib_setShape="rectangle" />
@ -164,7 +164,7 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@+id/select_from_library_fab_post_image_activity" app:layout_constraintEnd_toStartOf="@+id/select_from_library_fab_post_image_activity"
app:layout_constraintHorizontal_chainStyle="spread" app:layout_constraintHorizontal_chainStyle="spread"
app:backgroundTint="@color/backgroundColorPrimary" app:backgroundTint="?attr/colorPrimaryLightTheme"
app:tint="@android:color/white" /> app:tint="@android:color/white" />
<com.google.android.material.floatingactionbutton.FloatingActionButton <com.google.android.material.floatingactionbutton.FloatingActionButton
@ -177,7 +177,7 @@
app:layout_constraintStart_toEndOf="@+id/capture_fab_post_image_activity" app:layout_constraintStart_toEndOf="@+id/capture_fab_post_image_activity"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_chainStyle="spread" app:layout_constraintHorizontal_chainStyle="spread"
app:backgroundTint="@color/backgroundColorPrimary" app:backgroundTint="?attr/colorPrimaryLightTheme"
app:tint="@android:color/white" /> app:tint="@android:color/white" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -92,7 +92,7 @@
android:textSize="?attr/font_default" android:textSize="?attr/font_default"
android:visibility="gone" android:visibility="gone"
app:lib_setRadius="3dp" app:lib_setRadius="3dp"
app:lib_setRoundedBorderColor="@color/colorPrimaryDarkDayNightTheme" app:lib_setRoundedBorderColor="?attr/flairColor"
app:lib_setRoundedView="true" app:lib_setRoundedView="true"
app:lib_setShape="rectangle" /> app:lib_setShape="rectangle" />
@ -106,7 +106,7 @@
android:textColor="@color/primaryTextColor" android:textColor="@color/primaryTextColor"
android:textSize="?attr/font_default" android:textSize="?attr/font_default"
app:lib_setRadius="3dp" app:lib_setRadius="3dp"
app:lib_setRoundedBorderColor="@color/colorPrimaryDarkDayNightTheme" app:lib_setRoundedBorderColor="?attr/spoilerColor"
app:lib_setRoundedView="true" app:lib_setRoundedView="true"
app:lib_setShape="rectangle" /> app:lib_setShape="rectangle" />

View File

@ -92,7 +92,7 @@
android:textSize="?attr/font_default" android:textSize="?attr/font_default"
android:visibility="gone" android:visibility="gone"
app:lib_setRadius="3dp" app:lib_setRadius="3dp"
app:lib_setRoundedBorderColor="@color/colorPrimaryDarkDayNightTheme" app:lib_setRoundedBorderColor="?attr/flairColor"
app:lib_setRoundedView="true" app:lib_setRoundedView="true"
app:lib_setShape="rectangle" /> app:lib_setShape="rectangle" />
@ -106,7 +106,7 @@
android:textColor="@color/primaryTextColor" android:textColor="@color/primaryTextColor"
android:textSize="?attr/font_default" android:textSize="?attr/font_default"
app:lib_setRadius="3dp" app:lib_setRadius="3dp"
app:lib_setRoundedBorderColor="@color/colorPrimaryDarkDayNightTheme" app:lib_setRoundedBorderColor="?attr/spoilerColor"
app:lib_setRoundedView="true" app:lib_setRoundedView="true"
app:lib_setShape="rectangle" /> app:lib_setShape="rectangle" />

View File

@ -92,7 +92,7 @@
android:textSize="?attr/font_default" android:textSize="?attr/font_default"
android:visibility="gone" android:visibility="gone"
app:lib_setRadius="3dp" app:lib_setRadius="3dp"
app:lib_setRoundedBorderColor="@color/colorPrimaryDarkDayNightTheme" app:lib_setRoundedBorderColor="?attr/flairColor"
app:lib_setRoundedView="true" app:lib_setRoundedView="true"
app:lib_setShape="rectangle" /> app:lib_setShape="rectangle" />
@ -106,7 +106,7 @@
android:textColor="@color/primaryTextColor" android:textColor="@color/primaryTextColor"
android:textSize="?attr/font_default" android:textSize="?attr/font_default"
app:lib_setRadius="3dp" app:lib_setRadius="3dp"
app:lib_setRoundedBorderColor="@color/colorPrimaryDarkDayNightTheme" app:lib_setRoundedBorderColor="?attr/spoilerColor"
app:lib_setRoundedView="true" app:lib_setRoundedView="true"
app:lib_setShape="rectangle" /> app:lib_setShape="rectangle" />
@ -164,7 +164,7 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@+id/select_from_library_fab_post_video_activity" app:layout_constraintEnd_toStartOf="@+id/select_from_library_fab_post_video_activity"
app:layout_constraintHorizontal_chainStyle="spread" app:layout_constraintHorizontal_chainStyle="spread"
app:backgroundTint="@color/backgroundColorPrimary" app:backgroundTint="?attr/colorPrimaryLightTheme"
app:tint="@android:color/white" /> app:tint="@android:color/white" />
<com.google.android.material.floatingactionbutton.FloatingActionButton <com.google.android.material.floatingactionbutton.FloatingActionButton
@ -177,7 +177,7 @@
app:layout_constraintStart_toEndOf="@+id/capture_fab_post_video_activity" app:layout_constraintStart_toEndOf="@+id/capture_fab_post_video_activity"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_chainStyle="spread" app:layout_constraintHorizontal_chainStyle="spread"
app:backgroundTint="@color/backgroundColorPrimary" app:backgroundTint="?attr/colorPrimaryLightTheme"
app:tint="@android:color/white" /> app:tint="@android:color/white" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -76,7 +76,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="bottom|end" android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin" android:layout_margin="@dimen/fab_margin"
app:backgroundTint="@color/backgroundColorPrimary" app:backgroundTint="?attr/colorPrimaryLightTheme"
app:tint="@android:color/white" app:tint="@android:color/white"
app:srcCompat="@drawable/ic_keyboard_arrow_down_24dp" /> app:srcCompat="@drawable/ic_keyboard_arrow_down_24dp" />

View File

@ -203,7 +203,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="@dimen/fab_margin" android:layout_margin="@dimen/fab_margin"
android:visibility="gone" android:visibility="gone"
app:backgroundTint="@color/backgroundColorPrimary" app:backgroundTint="?attr/colorPrimaryLightTheme"
app:srcCompat="@drawable/ic_add_bottom_app_bar_24dp" app:srcCompat="@drawable/ic_add_bottom_app_bar_24dp"
app:tint="@android:color/white" app:tint="@android:color/white"
app:layout_anchor="@id/bottom_navigation_view_subreddit_detail_activity" /> app:layout_anchor="@id/bottom_navigation_view_subreddit_detail_activity" />

View File

@ -66,7 +66,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="16dp" android:layout_marginTop="16dp"
android:textSize="?attr/font_18" android:textSize="?attr/font_18"
android:textColor="@color/colorPrimaryDarkDayNightTheme" android:textColor="?attr/username"
android:layout_gravity="center_horizontal"/> android:layout_gravity="center_horizontal"/>
<TextView <TextView

View File

@ -131,7 +131,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="@dimen/fab_margin" android:layout_margin="@dimen/fab_margin"
android:visibility="gone" android:visibility="gone"
app:backgroundTint="@color/backgroundColorPrimary" app:backgroundTint="?attr/colorPrimaryLightTheme"
app:srcCompat="@drawable/ic_add_bottom_app_bar_24dp" app:srcCompat="@drawable/ic_add_bottom_app_bar_24dp"
app:tint="@android:color/white" app:tint="@android:color/white"
app:layout_anchor="@id/bottom_navigation_main_activity" /> app:layout_anchor="@id/bottom_navigation_main_activity" />

View File

@ -14,8 +14,7 @@
<View <View
android:id="@+id/vertical_block_item_post_comment" android:id="@+id/vertical_block_item_post_comment"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent" />
android:background="@color/colorPrimaryDarkDayNightTheme"/>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -48,7 +47,7 @@
android:layout_marginEnd="8dp" android:layout_marginEnd="8dp"
android:ellipsize="end" android:ellipsize="end"
android:maxLines="2" android:maxLines="2"
android:textColor="@color/colorPrimaryDarkDayNightTheme" android:textColor="?attr/username"
android:textSize="?attr/font_default" android:textSize="?attr/font_default"
app:layout_constraintBottom_toTopOf="@id/author_flair_text_view_item_post_comment" app:layout_constraintBottom_toTopOf="@id/author_flair_text_view_item_post_comment"
app:layout_constraintEnd_toStartOf="@+id/barrier" app:layout_constraintEnd_toStartOf="@+id/barrier"
@ -62,7 +61,7 @@
android:layout_marginEnd="8dp" android:layout_marginEnd="8dp"
android:ellipsize="end" android:ellipsize="end"
android:maxLines="2" android:maxLines="2"
android:textColor="@color/authorFlairTextColor" android:textColor="?attr/authorFlairTextColor"
android:textSize="?attr/font_12" android:textSize="?attr/font_12"
android:visibility="gone" android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"

View File

@ -22,7 +22,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentEnd="true" android:layout_alignParentEnd="true"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:backgroundTint="@color/backgroundColorPrimary" android:backgroundTint="?attr/colorPrimaryLightTheme"
android:textColor="@android:color/white" android:textColor="@android:color/white"
android:text="@string/retry" android:text="@string/retry"
android:textSize="?attr/font_default" /> android:textSize="?attr/font_default" />

View File

@ -12,8 +12,7 @@
<View <View
android:id="@+id/vertical_block_item_load_more_comments" android:id="@+id/vertical_block_item_load_more_comments"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent" />
android:background="@color/colorPrimaryDarkDayNightTheme" />
<TextView <TextView
android:id="@+id/placeholder_text_view_item_load_more_comments" android:id="@+id/placeholder_text_view_item_load_more_comments"

View File

@ -49,7 +49,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="16dp" android:layout_marginStart="16dp"
android:layout_marginEnd="8dp" android:layout_marginEnd="8dp"
android:textColor="@color/colorPrimaryDarkDayNightTheme" android:textColor="?attr/username"
android:textSize="?attr/font_default" android:textSize="?attr/font_default"
android:maxLines="2" android:maxLines="2"
android:ellipsize="end" android:ellipsize="end"
@ -64,7 +64,7 @@
android:layout_width="24dp" android:layout_width="24dp"
android:layout_height="24dp" android:layout_height="24dp"
android:layout_marginEnd="8dp" android:layout_marginEnd="8dp"
android:tint="@color/backgroundColorPrimaryDark" android:tint="?attr/stickiedPost"
android:visibility="gone" android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@id/name_text_view_item_post" app:layout_constraintStart_toEndOf="@id/name_text_view_item_post"
@ -127,8 +127,8 @@
android:padding="4dp" android:padding="4dp"
android:textSize="?attr/font_12" android:textSize="?attr/font_12"
android:textColor="@android:color/white" android:textColor="@android:color/white"
app:lib_setRoundedBGColor="@color/backgroundColorPrimaryDark" app:lib_setRoundedBGColor="?attr/post_type"
app:lib_setRoundedBorderColor="@color/backgroundColorPrimaryDark" app:lib_setRoundedBorderColor="?attr/post_type"
app:lib_setRadius="3dp" app:lib_setRadius="3dp"
app:lib_setRoundedView="true" app:lib_setRoundedView="true"
app:lib_setShape="rectangle" /> app:lib_setShape="rectangle" />
@ -144,8 +144,8 @@
android:padding="4dp" android:padding="4dp"
android:visibility="gone" android:visibility="gone"
app:lib_setRadius="3dp" app:lib_setRadius="3dp"
app:lib_setRoundedBGColor="@color/spoilerBackgroundColor" app:lib_setRoundedBGColor="?attr/spoilerColor"
app:lib_setRoundedBorderColor="@color/spoilerBackgroundColor" app:lib_setRoundedBorderColor="?attr/spoilerColor"
app:lib_setRoundedView="true" app:lib_setRoundedView="true"
app:lib_setShape="rectangle" /> app:lib_setShape="rectangle" />
@ -174,8 +174,8 @@
android:padding="4dp" android:padding="4dp"
android:visibility="gone" android:visibility="gone"
app:lib_setRadius="3dp" app:lib_setRadius="3dp"
app:lib_setRoundedBGColor="@color/flairBackgroundColor" app:lib_setRoundedBGColor="?attr/flairColor"
app:lib_setRoundedBorderColor="@color/flairBackgroundColor" app:lib_setRoundedBorderColor="?attr/flairColor"
app:lib_setRoundedView="true" app:lib_setRoundedView="true"
app:lib_setShape="rectangle" /> app:lib_setShape="rectangle" />
@ -194,7 +194,7 @@
android:layout_width="24dp" android:layout_width="24dp"
android:layout_height="24dp" android:layout_height="24dp"
android:src="@drawable/ic_archive_outline" android:src="@drawable/ic_archive_outline"
android:tint="@color/archivedTint" android:tint="?attr/archivedTint"
android:visibility="gone" /> android:visibility="gone" />
<ImageView <ImageView
@ -202,7 +202,7 @@
android:layout_width="24dp" android:layout_width="24dp"
android:layout_height="24dp" android:layout_height="24dp"
android:src="@drawable/ic_outline_lock_24dp" android:src="@drawable/ic_outline_lock_24dp"
android:tint="@color/lockedIconTint" android:tint="?attr/lockedIconTint"
android:visibility="gone" /> android:visibility="gone" />
<ImageView <ImageView
@ -210,7 +210,7 @@
android:layout_width="24dp" android:layout_width="24dp"
android:layout_height="24dp" android:layout_height="24dp"
android:src="@drawable/crosspost" android:src="@drawable/crosspost"
android:tint="@color/colorAccent" android:tint="?attr/crosspost"
android:visibility="gone" /> android:visibility="gone" />
</com.nex3z.flowlayout.FlowLayout> </com.nex3z.flowlayout.FlowLayout>

View File

@ -47,7 +47,7 @@
android:layout_width="24dp" android:layout_width="24dp"
android:layout_height="24dp" android:layout_height="24dp"
android:layout_marginEnd="8dp" android:layout_marginEnd="8dp"
android:tint="@color/backgroundColorPrimaryDark" android:tint="?attr/stickiedPost"
android:visibility="gone" android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/guideline2" app:layout_constraintEnd_toStartOf="@+id/guideline2"
@ -115,8 +115,8 @@
android:textColor="@android:color/white" android:textColor="@android:color/white"
android:textSize="?attr/font_10" android:textSize="?attr/font_10"
app:lib_setRadius="3dp" app:lib_setRadius="3dp"
app:lib_setRoundedBGColor="@color/backgroundColorPrimaryDark" app:lib_setRoundedBGColor="?attr/post_type"
app:lib_setRoundedBorderColor="@color/backgroundColorPrimaryDark" app:lib_setRoundedBorderColor="?attr/post_type"
app:lib_setRoundedView="true" app:lib_setRoundedView="true"
app:lib_setShape="rectangle" /> app:lib_setShape="rectangle" />
@ -131,8 +131,8 @@
android:textSize="?attr/font_10" android:textSize="?attr/font_10"
android:visibility="gone" android:visibility="gone"
app:lib_setRadius="3dp" app:lib_setRadius="3dp"
app:lib_setRoundedBGColor="@color/spoilerBackgroundColor" app:lib_setRoundedBGColor="?attr/spoilerColor"
app:lib_setRoundedBorderColor="@color/spoilerBackgroundColor" app:lib_setRoundedBorderColor="?attr/spoilerColor"
app:lib_setRoundedView="true" app:lib_setRoundedView="true"
app:lib_setShape="rectangle" /> app:lib_setShape="rectangle" />
@ -161,8 +161,8 @@
android:textSize="?attr/font_10" android:textSize="?attr/font_10"
android:visibility="gone" android:visibility="gone"
app:lib_setRadius="3dp" app:lib_setRadius="3dp"
app:lib_setRoundedBGColor="@color/flairBackgroundColor" app:lib_setRoundedBGColor="?attr/flairColor"
app:lib_setRoundedBorderColor="@color/flairBackgroundColor" app:lib_setRoundedBorderColor="?attr/flairColor"
app:lib_setRoundedView="true" app:lib_setRoundedView="true"
app:lib_setShape="rectangle" /> app:lib_setShape="rectangle" />
@ -181,7 +181,7 @@
android:layout_width="24dp" android:layout_width="24dp"
android:layout_height="24dp" android:layout_height="24dp"
android:src="@drawable/ic_archive_outline" android:src="@drawable/ic_archive_outline"
android:tint="@color/archivedTint" android:tint="?attr/archivedTint"
android:visibility="gone" /> android:visibility="gone" />
<ImageView <ImageView
@ -189,7 +189,7 @@
android:layout_width="24dp" android:layout_width="24dp"
android:layout_height="24dp" android:layout_height="24dp"
android:src="@drawable/ic_outline_lock_24dp" android:src="@drawable/ic_outline_lock_24dp"
android:tint="@color/lockedIconTint" android:tint="?attr/lockedIconTint"
android:visibility="gone" /> android:visibility="gone" />
<ImageView <ImageView
@ -197,7 +197,7 @@
android:layout_width="24dp" android:layout_width="24dp"
android:layout_height="24dp" android:layout_height="24dp"
android:src="@drawable/crosspost" android:src="@drawable/crosspost"
android:tint="@color/colorAccent" android:tint="?attr/crosspost"
android:visibility="gone" /> android:visibility="gone" />
</com.nex3z.flowlayout.FlowLayout> </com.nex3z.flowlayout.FlowLayout>

View File

@ -26,7 +26,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="16dp" android:layout_marginStart="16dp"
android:layout_marginEnd="8dp" android:layout_marginEnd="8dp"
android:textColor="@color/colorAccent" android:textColor="?attr/subreddit"
android:textSize="?attr/font_default" android:textSize="?attr/font_default"
android:maxLines="2" android:maxLines="2"
android:ellipsize="end" android:ellipsize="end"
@ -41,7 +41,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="16dp" android:layout_marginStart="16dp"
android:layout_marginEnd="8dp" android:layout_marginEnd="8dp"
android:textColor="@color/colorPrimaryDarkDayNightTheme" android:textColor="?attr/username"
android:textSize="?attr/font_default" android:textSize="?attr/font_default"
android:maxLines="2" android:maxLines="2"
android:ellipsize="end" android:ellipsize="end"
@ -109,8 +109,8 @@
android:padding="4dp" android:padding="4dp"
android:textSize="?attr/font_12" android:textSize="?attr/font_12"
android:textColor="@android:color/white" android:textColor="@android:color/white"
app:lib_setRoundedBGColor="@color/backgroundColorPrimaryDark" app:lib_setRoundedBGColor="?attr/post_type"
app:lib_setRoundedBorderColor="@color/backgroundColorPrimaryDark" app:lib_setRoundedBorderColor="?attr/post_type"
app:lib_setRadius="3dp" app:lib_setRadius="3dp"
app:lib_setRoundedView="true" app:lib_setRoundedView="true"
app:lib_setShape="rectangle" /> app:lib_setShape="rectangle" />
@ -126,8 +126,8 @@
android:padding="4dp" android:padding="4dp"
android:visibility="gone" android:visibility="gone"
app:lib_setRadius="3dp" app:lib_setRadius="3dp"
app:lib_setRoundedBGColor="@color/spoilerBackgroundColor" app:lib_setRoundedBGColor="?attr/spoilerColor"
app:lib_setRoundedBorderColor="@color/spoilerBackgroundColor" app:lib_setRoundedBorderColor="?attr/spoilerColor"
app:lib_setRoundedView="true" app:lib_setRoundedView="true"
app:lib_setShape="rectangle" /> app:lib_setShape="rectangle" />
@ -156,8 +156,8 @@
android:textColor="@android:color/white" android:textColor="@android:color/white"
android:visibility="gone" android:visibility="gone"
app:lib_setRadius="3dp" app:lib_setRadius="3dp"
app:lib_setRoundedBGColor="@color/flairBackgroundColor" app:lib_setRoundedBGColor="?attr/flairColor"
app:lib_setRoundedBorderColor="@color/flairBackgroundColor" app:lib_setRoundedBorderColor="?attr/flairColor"
app:lib_setRoundedView="true" app:lib_setRoundedView="true"
app:lib_setShape="rectangle" /> app:lib_setShape="rectangle" />
@ -176,7 +176,7 @@
android:layout_width="20dp" android:layout_width="20dp"
android:layout_height="20dp" android:layout_height="20dp"
android:src="@drawable/ic_archive_outline" android:src="@drawable/ic_archive_outline"
android:tint="@color/archivedTint" android:tint="?attr/archivedTint"
android:visibility="gone" /> android:visibility="gone" />
<ImageView <ImageView
@ -184,7 +184,7 @@
android:layout_width="20dp" android:layout_width="20dp"
android:layout_height="20dp" android:layout_height="20dp"
android:src="@drawable/ic_outline_lock_24dp" android:src="@drawable/ic_outline_lock_24dp"
android:tint="@color/lockedIconTint" android:tint="?attr/lockedIconTint"
android:visibility="gone" /> android:visibility="gone" />
<ImageView <ImageView
@ -192,7 +192,7 @@
android:layout_width="20dp" android:layout_width="20dp"
android:layout_height="20dp" android:layout_height="20dp"
android:src="@drawable/crosspost" android:src="@drawable/crosspost"
android:tint="@color/colorAccent" android:tint="?attr/crosspost"
android:visibility="gone" /> android:visibility="gone" />
</com.nex3z.flowlayout.FlowLayout> </com.nex3z.flowlayout.FlowLayout>

View File

@ -36,7 +36,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:src="@drawable/ic_add_24dp" android:src="@drawable/ic_add_24dp"
android:tint="@color/colorPrimaryDarkDayNightTheme" android:tint="?attr/unsubscribed"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"

View File

@ -36,7 +36,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:src="@drawable/ic_add_24dp" android:src="@drawable/ic_add_24dp"
android:tint="@color/colorPrimaryDarkDayNightTheme" android:tint="?attr/unsubscribed"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"

View File

@ -10,7 +10,7 @@
<color name="primaryTextColor">#FFFFFF</color> <color name="primaryTextColor">#FFFFFF</color>
<color name="colorPrimaryDarkDayNightTheme">#1E88E5</color> <!--<color name="colorPrimaryDarkDayNightTheme">#1E88E5</color>-->
<color name="dividerColor">#69666C</color> <color name="dividerColor">#69666C</color>
@ -18,9 +18,9 @@
<color name="backgroundColor">#121212</color> <color name="backgroundColor">#121212</color>
<color name="backgroundColorPrimary">#1565C0</color> <!--<color name="backgroundColorPrimary">#1565C0</color>
<color name="backgroundColorPrimaryDark">#1565C0</color> <color name="backgroundColorPrimaryDark">#1565C0</color>-->
<color name="backgroundColorInverse">#FFFFFF</color> <color name="backgroundColorInverse">#FFFFFF</color>
@ -28,7 +28,7 @@
<color name="voteAndReplyUnavailableVoteButtonColor">#3C3C3C</color> <color name="voteAndReplyUnavailableVoteButtonColor">#3C3C3C</color>
<color name="tabLayoutWithExpandedCollapsingToolbarTextColor">#FFFFFF</color> <!--<color name="tabLayoutWithExpandedCollapsingToolbarTextColor">#FFFFFF</color>
<color name="tabLayoutWithExpandedCollapsingToolbarTabBackground">@color/backgroundColor</color> <color name="tabLayoutWithExpandedCollapsingToolbarTabBackground">@color/backgroundColor</color>
@ -38,7 +38,7 @@
<color name="tabLayoutWithCollapsedCollapsingToolbarTabBackground">@color/colorPrimary</color> <color name="tabLayoutWithCollapsedCollapsingToolbarTabBackground">@color/colorPrimary</color>
<color name="tabLayoutWithCollapsedCollapsingToolbarTabIndicator">@color/tabLayoutWithCollapsedCollapsingToolbarTextColor</color> <color name="tabLayoutWithCollapsedCollapsingToolbarTabIndicator">@color/tabLayoutWithCollapsedCollapsingToolbarTextColor</color>-->
<color name="navBarColor">@color/backgroundColor</color> <color name="navBarColor">@color/backgroundColor</color>
@ -60,5 +60,5 @@
<color name="commentVerticalBar6">#00B925</color> <color name="commentVerticalBar6">#00B925</color>
<color name="commentVerticalBar7">#EE4602</color> <color name="commentVerticalBar7">#EE4602</color>
<color name="toolbarAndTabBackgroundColor">#282828</color> <!--<color name="toolbarAndTabBackgroundColor">#282828</color>-->
</resources> </resources>

View File

@ -30,13 +30,36 @@
<declare-styleable name="Theme"> <declare-styleable name="Theme">
<attr name="colorPrimary" format="color"/> <attr name="colorPrimary" format="color"/>
<attr name="colorPrimaryDark" format="color"/> <attr name="colorPrimaryDark" format="color"/>
<attr name="colorAccent" format="color" />
<attr name="colorPrimaryLightTheme" format="color" />
<attr name="backgroundColor" format="color"/> <attr name="backgroundColor" format="color"/>
<attr name="roundedBottomSheetPrimaryBackground" format="color"/> <attr name="roundedBottomSheetPrimaryBackground" format="color"/>
<attr name="cardViewBackgroundColor" format="color"/> <attr name="cardViewBackgroundColor" format="color"/>
<attr name="toolbarAndTabBackgroundColor" format="color"/> <attr name="toolbarAndTabBackgroundColor" format="color"/>
<attr name="circularProgressBarBackground" format="color"/> <attr name="circularProgressBarBackground" format="color"/>
<attr name="tabLayoutWithExpandedCollapsingToolbarTabBackground" format="color"/> <attr name="tabLayoutWithExpandedCollapsingToolbarTabBackground" format="color"/>
<attr name="tabLayoutWithExpandedCollapsingToolbarTextColor" format="color" />
<attr name="tabLayoutWithExpandedCollapsingToolbarTabIndicator" format="color" />
<attr name="tabLayoutWithCollapsedCollapsingToolbarTabBackground" format="color"/> <attr name="tabLayoutWithCollapsedCollapsingToolbarTabBackground" format="color"/>
<attr name="tabLayoutWithCollapsedCollapsingToolbarTextColor" format="color" />
<attr name="tabLayoutWithCollapsedCollapsingToolbarTabIndicator" format="color" />
<attr name="navBarColor" format="color" /> <attr name="navBarColor" format="color" />
<attr name="upvoted" format="color" />
<attr name="downvoted" format="color" />
<attr name="post_type" format="color" />
<attr name="spoilerColor" format="color" />
<attr name="nsfwColor" format="color" />
<attr name="flairColor" format="color" />
<attr name="archivedTint" format="color" />
<attr name="lockedIconTint" format="color" />
<attr name="crosspost" format="color" />
<attr name="stickiedPost" format="color" />
<attr name="subscribed" format="color" />
<attr name="unsubscribed" format="color" />
<attr name="username" format="color" />
<attr name="subreddit" format="color" />
<attr name="authorFlairTextColor" format="color" />
<attr name="submitter" format="color" />
<attr name="moderator" format="color" />
</declare-styleable> </declare-styleable>
</resources> </resources>

View File

@ -10,7 +10,7 @@
<color name="primaryTextColor">#000000</color> <color name="primaryTextColor">#000000</color>
<color name="colorPrimaryDarkDayNightTheme">@color/colorPrimaryDark</color> <!--<color name="colorPrimaryDarkDayNightTheme">@color/colorPrimaryDark</color>-->
<color name="dividerColor">#E0E0E0</color> <color name="dividerColor">#E0E0E0</color>
@ -18,9 +18,9 @@
<color name="backgroundColor">#FFFFFF</color> <color name="backgroundColor">#FFFFFF</color>
<color name="backgroundColorPrimary">@color/colorPrimary</color> <!--<color name="backgroundColorPrimary">@color/colorPrimary</color>
<color name="backgroundColorPrimaryDark">@color/colorPrimaryDark</color> <color name="backgroundColorPrimaryDark">@color/colorPrimaryDark</color>-->
<color name="backgroundColorInverse">#000000</color> <color name="backgroundColorInverse">#000000</color>
@ -28,13 +28,13 @@
<color name="roundedBottomSheetPrimaryNavigationBarColor">@android:color/black</color> <color name="roundedBottomSheetPrimaryNavigationBarColor">@android:color/black</color>
<color name="upvoted">#E91E63</color> <!--<color name="upvoted">#E91E63</color>
<color name="downvoted">#007DDE</color> <color name="downvoted">#007DDE</color>-->
<color name="voteAndReplyUnavailableVoteButtonColor">#F0F0F0</color> <color name="voteAndReplyUnavailableVoteButtonColor">#F0F0F0</color>
<color name="tabLayoutWithExpandedCollapsingToolbarTextColor">@color/colorPrimary</color> <!--<color name="tabLayoutWithExpandedCollapsingToolbarTextColor">@color/colorPrimary</color>
<color name="tabLayoutWithExpandedCollapsingToolbarTabBackground">#FFFFFF</color> <color name="tabLayoutWithExpandedCollapsingToolbarTabBackground">#FFFFFF</color>
@ -44,7 +44,7 @@
<color name="tabLayoutWithCollapsedCollapsingToolbarTabBackground">@color/colorPrimary</color> <color name="tabLayoutWithCollapsedCollapsingToolbarTabBackground">@color/colorPrimary</color>
<color name="tabLayoutWithCollapsedCollapsingToolbarTabIndicator">@color/tabLayoutWithCollapsedCollapsingToolbarTextColor</color> <color name="tabLayoutWithCollapsedCollapsingToolbarTabIndicator">@color/tabLayoutWithCollapsedCollapsingToolbarTextColor</color>-->
<color name="navBarColor">#FFFFFF</color> <color name="navBarColor">#FFFFFF</color>
@ -54,9 +54,9 @@
<color name="unreadMessageBackgroundColor">#B3E5F9</color> <color name="unreadMessageBackgroundColor">#B3E5F9</color>
<color name="archivedTint">#B4009F</color> <!--<color name="archivedTint">#B4009F</color>
<color name="lockedIconTint">#EE7302</color> <color name="lockedIconTint">#EE7302</color>-->
<color name="notificationIconColor">@color/colorPrimary</color> <color name="notificationIconColor">@color/colorPrimary</color>
@ -70,7 +70,7 @@
<color name="commentVerticalBar6">#02EE6E</color> <color name="commentVerticalBar6">#02EE6E</color>
<color name="commentVerticalBar7">#EE4602</color> <color name="commentVerticalBar7">#EE4602</color>
<color name="toolbarAndTabBackgroundColor">@color/colorPrimary</color> <!--<color name="toolbarAndTabBackgroundColor">@color/colorPrimary</color>
<color name="submitter">#EE8A02</color> <color name="submitter">#EE8A02</color>
@ -84,5 +84,5 @@
<color name="usernameColor">#0D47A1</color> <color name="usernameColor">#0D47A1</color>
<color name="subredditNameColor">#FF4081</color> <color name="subredditNameColor">#FF4081</color>-->
</resources> </resources>

View File

@ -218,7 +218,7 @@
<style name="Theme" /> <style name="Theme" />
<style name="Theme.Default"> <!--<style name="Theme.Default">
<item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="backgroundColor">@color/backgroundColor</item> <item name="backgroundColor">@color/backgroundColor</item>
@ -255,6 +255,114 @@
<item name="tabLayoutWithExpandedCollapsingToolbarTabBackground">#000000</item> <item name="tabLayoutWithExpandedCollapsingToolbarTabBackground">#000000</item>
<item name="tabLayoutWithCollapsedCollapsingToolbarTabBackground">#000000</item> <item name="tabLayoutWithCollapsedCollapsingToolbarTabBackground">#000000</item>
<item name="navBarColor">#000000</item> <item name="navBarColor">#000000</item>
</style>-->
<style name="Theme.Default">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="colorPrimaryLightTheme">@color/colorPrimary</item>
<item name="backgroundColor">@color/backgroundColor</item>
<item name="roundedBottomSheetPrimaryBackground">@color/roundedBottomSheetPrimaryBackground</item>
<item name="cardViewBackgroundColor">@color/cardViewBackgroundColor</item>
<item name="toolbarAndTabBackgroundColor">@color/colorPrimary</item>
<item name="circularProgressBarBackground">#FFFFFF</item>
<item name="tabLayoutWithExpandedCollapsingToolbarTabBackground">#FFFFFF</item>
<item name="tabLayoutWithExpandedCollapsingToolbarTextColor">@color/colorPrimary</item>
<item name="tabLayoutWithExpandedCollapsingToolbarTabIndicator">@color/colorPrimary</item>
<item name="tabLayoutWithCollapsedCollapsingToolbarTabBackground">@color/colorPrimary</item>
<item name="tabLayoutWithCollapsedCollapsingToolbarTextColor">#FFFFFF</item>
<item name="tabLayoutWithCollapsedCollapsingToolbarTabIndicator">#FFFFFF</item>
<item name="navBarColor">@color/backgroundColor</item>
<item name="upvoted">#E91E63</item>
<item name="downvoted">#007DDE</item>
<item name="post_type">@color/colorPrimaryDark</item>
<item name="spoilerColor">#EE02EB</item>
<item name="nsfwColor">@color/colorAccent</item>
<item name="flairColor">#00AA8C</item>
<item name="archivedTint">#B4009F</item>
<item name="lockedIconTint">#EE7302</item>
<item name="crosspost">@color/colorAccent</item>
<item name="stickiedPost">@color/colorPrimaryDark</item>
<item name="subscribed">@color/colorAccent</item>
<item name="unsubscribed">@color/colorPrimaryDark</item>
<item name="username">@color/colorPrimaryDark</item>
<item name="subreddit">@color/colorAccent</item>
<item name="authorFlairTextColor">#EE02C4</item>
<item name="submitter">#EE8A02</item>
<item name="moderator">#00BA81</item>
</style>
<style name="Theme.Default.NormalDark">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="colorPrimaryLightTheme">#1565C0</item>
<item name="backgroundColor">@color/backgroundColor</item>
<item name="roundedBottomSheetPrimaryBackground">@color/roundedBottomSheetPrimaryBackground</item>
<item name="cardViewBackgroundColor">@color/cardViewBackgroundColor</item>
<item name="toolbarAndTabBackgroundColor">#282828</item>
<item name="circularProgressBarBackground">@color/colorPrimary</item>
<item name="tabLayoutWithExpandedCollapsingToolbarTabBackground">@color/backgroundColor</item>
<item name="tabLayoutWithExpandedCollapsingToolbarTextColor">#FFFFFF</item>
<item name="tabLayoutWithExpandedCollapsingToolbarTabIndicator">#FFFFFF</item>
<item name="tabLayoutWithCollapsedCollapsingToolbarTabBackground">@color/colorPrimary</item>
<item name="tabLayoutWithCollapsedCollapsingToolbarTextColor">#FFFFFF</item>
<item name="tabLayoutWithCollapsedCollapsingToolbarTabIndicator">#FFFFFF</item>
<item name="navBarColor">@color/backgroundColor</item>
<item name="upvoted">#E91E63</item>
<item name="downvoted">#007DDE</item>
<item name="post_type">#0D47A1</item>
<item name="spoilerColor">#EE02EB</item>
<item name="nsfwColor">@color/colorAccent</item>
<item name="flairColor">#00AA8C</item>
<item name="archivedTint">#B4009F</item>
<item name="lockedIconTint">#EE7302</item>
<item name="crosspost">@color/colorAccent</item>
<item name="stickiedPost">#1565C0</item>
<item name="subscribed">@color/colorAccent</item>
<item name="unsubscribed">#1565C0</item>
<item name="username">#0D47A1</item>
<item name="subreddit">@color/colorAccent</item>
<item name="authorFlairTextColor">#EE02C4</item>
<item name="submitter">#EE8A02</item>
<item name="moderator">#00BA81</item>
</style>
<style name="Theme.Default.AmoledDark">
<item name="colorPrimary">#000000</item>
<item name="colorPrimaryDark">#000000</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="colorPrimaryLightTheme">#1565C0</item>
<item name="backgroundColor">#000000</item>
<item name="roundedBottomSheetPrimaryBackground">#000000</item>
<item name="cardViewBackgroundColor">#000000</item>
<item name="toolbarAndTabBackgroundColor">#000000</item>
<item name="circularProgressBarBackground">#000000</item>
<item name="tabLayoutWithExpandedCollapsingToolbarTabBackground">@color/backgroundColor</item>
<item name="tabLayoutWithExpandedCollapsingToolbarTextColor">#FFFFFF</item>
<item name="tabLayoutWithExpandedCollapsingToolbarTabIndicator">#FFFFFF</item>
<item name="tabLayoutWithCollapsedCollapsingToolbarTabBackground">@color/colorPrimary</item>
<item name="tabLayoutWithCollapsedCollapsingToolbarTextColor">#FFFFFF</item>
<item name="tabLayoutWithCollapsedCollapsingToolbarTabIndicator">#FFFFFF</item>
<item name="navBarColor">#000000</item>
<item name="upvoted">#E91E63</item>
<item name="downvoted">#007DDE</item>
<item name="post_type">#0D47A1</item>
<item name="spoilerColor">#EE02EB</item>
<item name="nsfwColor">@color/colorAccent</item>
<item name="flairColor">#00AA8C</item>
<item name="archivedTint">#B4009F</item>
<item name="lockedIconTint">#EE7302</item>
<item name="crosspost">@color/colorAccent</item>
<item name="stickiedPost">#1565C0</item>
<item name="subscribed">@color/colorAccent</item>
<item name="unsubscribed">#1565C0</item>
<item name="username">#0D47A1</item>
<item name="subreddit">@color/colorAccent</item>
<item name="authorFlairTextColor">#EE02C4</item>
<item name="submitter">#EE8A02</item>
<item name="moderator">#00BA81</item>
</style> </style>
</resources> </resources>