diff options
36 files changed, 456 insertions, 245 deletions
diff --git a/.idea/gradle.xml b/.idea/gradle.xml index f43d4284..5cd135a0 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -1,11 +1,10 @@ <?xml version="1.0" encoding="UTF-8"?> <project version="4"> + <component name="GradleMigrationSettings" migrationVersion="1" /> <component name="GradleSettings"> <option name="linkedExternalProjectsSettings"> <GradleProjectSettings> - <compositeConfiguration> - <compositeBuild compositeDefinitionSource="SCRIPT" /> - </compositeConfiguration> + <option name="testRunner" value="PLATFORM" /> <option name="distributionType" value="DEFAULT_WRAPPED" /> <option name="externalProjectPath" value="$PROJECT_DIR$" /> <option name="modules"> diff --git a/app/build.gradle b/app/build.gradle index 4dcb03a6..f849d8aa 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -72,7 +72,7 @@ dependencies { implementation "io.noties.markwon:simple-ext:4.2.0" implementation "io.noties.markwon:recycler-table:4.2.0" 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 'com.libRG:customtextview:2.2' implementation 'com.github.Deishelon:RoundedBottomSheet:1.0.1' diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/AccessTokenAuthenticator.java b/app/src/main/java/ml/docilealligator/infinityforreddit/AccessTokenAuthenticator.java index 8440fec7..22483fad 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/AccessTokenAuthenticator.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/AccessTokenAuthenticator.java @@ -19,13 +19,17 @@ import okhttp3.Response; import okhttp3.Route; import retrofit2.Call; import retrofit2.Retrofit; +import retrofit2.converter.scalars.ScalarsConverterFactory; class AccessTokenAuthenticator implements Authenticator { private Retrofit mRetrofit; private RedditDataRoomDatabase mRedditDataRoomDatabase; - AccessTokenAuthenticator(Retrofit retrofit, RedditDataRoomDatabase accountRoomDatabase) { - mRetrofit = retrofit; + AccessTokenAuthenticator(RedditDataRoomDatabase accountRoomDatabase) { + mRetrofit = new Retrofit.Builder() + .baseUrl(RedditUtils.API_BASE_URI) + .addConverterFactory(ScalarsConverterFactory.create()) + .build(); mRedditDataRoomDatabase = accountRoomDatabase; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostImageActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostImageActivity.java index 93e6ed69..ee68d38d 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostImageActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostImageActivity.java @@ -2,6 +2,7 @@ package ml.docilealligator.infinityforreddit.Activity; import android.content.Intent; import android.content.SharedPreferences; +import android.content.res.Resources; import android.net.Uri; import android.os.Build; import android.os.Bundle; @@ -52,6 +53,7 @@ import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.Service.SubmitPostService; +import ml.docilealligator.infinityforreddit.Utils.Utils; import pl.droidsonroids.gif.GifImageView; import retrofit2.Retrofit; @@ -128,9 +130,13 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF private boolean loadSubredditIconSuccessful = true; private boolean isPosting; private Uri imageUri; + private int flairColor; + private int spoilerColor; + private int nsfwColor; private Flair flair; private boolean isSpoiler = false; private boolean isNSFW = false; + private Resources resources; private Menu mMemu; private RequestManager mGlide; private FlairBottomSheetFragment flairSelectionBottomSheetFragment; @@ -155,6 +161,12 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF 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) { mNullAccessToken = savedInstanceState.getBoolean(NULL_ACCESS_TOKEN_STATE); mAccessToken = savedInstanceState.getString(ACCESS_TOKEN_STATE); @@ -180,7 +192,7 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF } if (subredditName != null) { - subredditNameTextView.setTextColor(getResources().getColor(R.color.primaryTextColor)); + subredditNameTextView.setTextColor(resources.getColor(R.color.primaryTextColor)); subredditNameTextView.setText(subredditName); flairTextView.setVisibility(View.VISIBLE); if (!loadSubredditIconSuccessful) { @@ -195,13 +207,13 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF if (flair != null) { flairTextView.setText(flair.getText()); - flairTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark)); + flairTextView.setBackgroundColor(flairColor); } if (isSpoiler) { - spoilerTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark)); + spoilerTextView.setBackgroundColor(spoilerColor); } if (isNSFW) { - nsfwTextView.setBackgroundColor(getResources().getColor(R.color.colorAccent)); + nsfwTextView.setBackgroundColor(nsfwColor); } } else { getCurrentAccount(); @@ -212,7 +224,7 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF loadSubredditIconSuccessful = false; subredditName = getIntent().getStringExtra(EXTRA_SUBREDDIT_NAME); subredditSelected = true; - subredditNameTextView.setTextColor(getResources().getColor(R.color.primaryTextColor)); + subredditNameTextView.setTextColor(resources.getColor(R.color.primaryTextColor)); subredditNameTextView.setText(subredditName); loadSubredditIcon(); } else { @@ -260,7 +272,7 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF flairSelectionBottomSheetFragment.setArguments(bundle); flairSelectionBottomSheetFragment.show(getSupportFragmentManager(), flairSelectionBottomSheetFragment.getTag()); } else { - flairTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent)); + flairTextView.setBackgroundColor(resources.getColor(android.R.color.transparent)); flairTextView.setText(getString(R.string.flair)); flair = null; } @@ -268,20 +280,20 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF spoilerTextView.setOnClickListener(view -> { if (!isSpoiler) { - spoilerTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark)); + spoilerTextView.setBackgroundColor(spoilerColor); isSpoiler = true; } else { - spoilerTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent)); + spoilerTextView.setBackgroundColor(resources.getColor(android.R.color.transparent)); isSpoiler = false; } }); nsfwTextView.setOnClickListener(view -> { if (!isNSFW) { - nsfwTextView.setBackgroundColor(getResources().getColor(R.color.colorAccent)); + nsfwTextView.setBackgroundColor(nsfwColor); isNSFW = true; } else { - nsfwTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent)); + nsfwTextView.setBackgroundColor(resources.getColor(android.R.color.transparent)); isNSFW = false; } }); @@ -306,7 +318,7 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); - startActivityForResult(Intent.createChooser(intent, getResources().getString(R.string.select_from_gallery)), PICK_IMAGE_REQUEST_CODE); + startActivityForResult(Intent.createChooser(intent, resources.getString(R.string.select_from_gallery)), PICK_IMAGE_REQUEST_CODE); }); selectAgainTextView.setOnClickListener(view -> { @@ -495,12 +507,12 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF subredditSelected = true; 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); displaySubredditIcon(); 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)); flair = null; } @@ -531,7 +543,7 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF public void flairSelected(Flair flair) { this.flair = flair; flairTextView.setText(flair.getText()); - flairTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark)); + flairTextView.setBackgroundColor(flairColor); } @Subscribe diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostLinkActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostLinkActivity.java index afa9fc3d..094a7757 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostLinkActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostLinkActivity.java @@ -2,6 +2,7 @@ package ml.docilealligator.infinityforreddit.Activity; import android.content.Intent; import android.content.SharedPreferences; +import android.content.res.Resources; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; @@ -42,6 +43,7 @@ import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.Service.SubmitPostService; import ml.docilealligator.infinityforreddit.Utils.RedditUtils; +import ml.docilealligator.infinityforreddit.Utils.Utils; import pl.droidsonroids.gif.GifImageView; import retrofit2.Retrofit; @@ -102,9 +104,13 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr private boolean subredditIsUser; private boolean loadSubredditIconSuccessful = true; private boolean isPosting; + private int flairColor; + private int spoilerColor; + private int nsfwColor; private Flair flair; private boolean isSpoiler = false; private boolean isNSFW = false; + private Resources resources; private Menu mMemu; private RequestManager mGlide; private FlairBottomSheetFragment flairSelectionBottomSheetFragment; @@ -129,6 +135,12 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr 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) { mNullAccessToken = savedInstanceState.getBoolean(NULL_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); if (subredditName != null) { - subredditNameTextView.setTextColor(getResources().getColor(R.color.primaryTextColor)); + subredditNameTextView.setTextColor(resources.getColor(R.color.primaryTextColor)); subredditNameTextView.setText(subredditName); flairTextView.setVisibility(View.VISIBLE); if (!loadSubredditIconSuccessful) { @@ -163,13 +175,13 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr if (flair != null) { flairTextView.setText(flair.getText()); - flairTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark)); + flairTextView.setBackgroundColor(flairColor); } if (isSpoiler) { - spoilerTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark)); + spoilerTextView.setBackgroundColor(spoilerColor); } if (isNSFW) { - nsfwTextView.setBackgroundColor(getResources().getColor(R.color.colorAccent)); + nsfwTextView.setBackgroundColor(nsfwColor); } } else { getCurrentAccount(); @@ -180,7 +192,7 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr loadSubredditIconSuccessful = false; subredditName = getIntent().getStringExtra(EXTRA_SUBREDDIT_NAME); subredditSelected = true; - subredditNameTextView.setTextColor(getResources().getColor(R.color.primaryTextColor)); + subredditNameTextView.setTextColor(resources.getColor(R.color.primaryTextColor)); subredditNameTextView.setText(subredditName); flairTextView.setVisibility(View.VISIBLE); loadSubredditIcon(); @@ -229,7 +241,7 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr flairSelectionBottomSheetFragment.setArguments(bundle); flairSelectionBottomSheetFragment.show(getSupportFragmentManager(), flairSelectionBottomSheetFragment.getTag()); } else { - flairTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent)); + flairTextView.setBackgroundColor(resources.getColor(android.R.color.transparent)); flairTextView.setText(getString(R.string.flair)); flair = null; } @@ -237,20 +249,20 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr spoilerTextView.setOnClickListener(view -> { if (!isSpoiler) { - spoilerTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark)); + spoilerTextView.setBackgroundColor(spoilerColor); isSpoiler = true; } else { - spoilerTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent)); + spoilerTextView.setBackgroundColor(resources.getColor(android.R.color.transparent)); isSpoiler = false; } }); nsfwTextView.setOnClickListener(view -> { if (!isNSFW) { - nsfwTextView.setBackgroundColor(getResources().getColor(R.color.colorAccent)); + nsfwTextView.setBackgroundColor(nsfwColor); isNSFW = true; } else { - nsfwTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent)); + nsfwTextView.setBackgroundColor(resources.getColor(android.R.color.transparent)); isNSFW = false; } }); @@ -415,12 +427,12 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr subredditSelected = true; 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); displaySubredditIcon(); 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)); flair = null; } @@ -437,7 +449,7 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr public void flairSelected(Flair flair) { this.flair = flair; flairTextView.setText(flair.getText()); - flairTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark)); + flairTextView.setBackgroundColor(flairColor); } @Subscribe diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostTextActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostTextActivity.java index 7cb8a95f..4f10e848 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostTextActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostTextActivity.java @@ -2,6 +2,7 @@ package ml.docilealligator.infinityforreddit.Activity; import android.content.Intent; import android.content.SharedPreferences; +import android.content.res.Resources; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; @@ -42,6 +43,7 @@ import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.Service.SubmitPostService; import ml.docilealligator.infinityforreddit.Utils.RedditUtils; +import ml.docilealligator.infinityforreddit.Utils.Utils; import pl.droidsonroids.gif.GifImageView; import retrofit2.Retrofit; @@ -102,9 +104,13 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr private boolean subredditIsUser; private boolean loadSubredditIconSuccessful = true; private boolean isPosting; + private int flairColor; + private int spoilerColor; + private int nsfwColor; private Flair flair; private boolean isSpoiler = false; private boolean isNSFW = false; + private Resources resources; private Menu mMemu; private RequestManager mGlide; private FlairBottomSheetFragment flairSelectionBottomSheetFragment; @@ -129,6 +135,12 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr 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) { mNullAccessToken = savedInstanceState.getBoolean(NULL_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); if (subredditName != null) { - subredditNameTextView.setTextColor(getResources().getColor(R.color.primaryTextColor)); + subredditNameTextView.setTextColor(resources.getColor(R.color.primaryTextColor)); subredditNameTextView.setText(subredditName); flairTextView.setVisibility(View.VISIBLE); if (!loadSubredditIconSuccessful) { @@ -163,13 +175,13 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr if (flair != null) { flairTextView.setText(flair.getText()); - flairTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark)); + flairTextView.setBackgroundColor(flairColor); } if (isSpoiler) { - spoilerTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark)); + spoilerTextView.setBackgroundColor(spoilerColor); } if (isNSFW) { - nsfwTextView.setBackgroundColor(getResources().getColor(R.color.colorAccent)); + nsfwTextView.setBackgroundColor(nsfwColor); } } else { getCurrentAccount(); @@ -180,7 +192,7 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr loadSubredditIconSuccessful = false; subredditName = getIntent().getStringExtra(EXTRA_SUBREDDIT_NAME); subredditSelected = true; - subredditNameTextView.setTextColor(getResources().getColor(R.color.primaryTextColor)); + subredditNameTextView.setTextColor(resources.getColor(R.color.primaryTextColor)); subredditNameTextView.setText(subredditName); flairTextView.setVisibility(View.VISIBLE); loadSubredditIcon(); @@ -233,7 +245,7 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr flairSelectionBottomSheetFragment.setArguments(bundle); flairSelectionBottomSheetFragment.show(getSupportFragmentManager(), flairSelectionBottomSheetFragment.getTag()); } else { - flairTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent)); + flairTextView.setBackgroundColor(resources.getColor(android.R.color.transparent)); flairTextView.setText(getString(R.string.flair)); flair = null; } @@ -241,20 +253,20 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr spoilerTextView.setOnClickListener(view -> { if (!isSpoiler) { - spoilerTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark)); + spoilerTextView.setBackgroundColor(spoilerColor); isSpoiler = true; } else { - spoilerTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent)); + spoilerTextView.setBackgroundColor(resources.getColor(android.R.color.transparent)); isSpoiler = false; } }); nsfwTextView.setOnClickListener(view -> { if (!isNSFW) { - nsfwTextView.setBackgroundColor(getResources().getColor(R.color.colorAccent)); + nsfwTextView.setBackgroundColor(nsfwColor); isNSFW = true; } else { - nsfwTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent)); + nsfwTextView.setBackgroundColor(resources.getColor(android.R.color.transparent)); isNSFW = false; } }); @@ -415,12 +427,12 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr subredditSelected = true; 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); displaySubredditIcon(); 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)); flair = null; } @@ -437,7 +449,7 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr public void flairSelected(Flair flair) { this.flair = flair; flairTextView.setText(flair.getText()); - flairTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark)); + flairTextView.setBackgroundColor(flairColor); } @Subscribe diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostVideoActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostVideoActivity.java index 2fb18a16..91ea4157 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostVideoActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostVideoActivity.java @@ -2,6 +2,7 @@ package ml.docilealligator.infinityforreddit.Activity; import android.content.Intent; import android.content.SharedPreferences; +import android.content.res.Resources; import android.net.Uri; import android.os.Build; import android.os.Bundle; @@ -54,6 +55,7 @@ import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.Service.SubmitPostService; +import ml.docilealligator.infinityforreddit.Utils.Utils; import pl.droidsonroids.gif.GifImageView; import retrofit2.Retrofit; @@ -134,9 +136,13 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF private boolean loadSubredditIconSuccessful = true; private boolean isPosting; private boolean wasPlaying; + private int flairColor; + private int spoilerColor; + private int nsfwColor; private Flair flair; private boolean isSpoiler = false; private boolean isNSFW = false; + private Resources resources; private Menu mMemu; private RequestManager mGlide; private FlairBottomSheetFragment mFlairSelectionBottomSheetFragment; @@ -169,6 +175,12 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF 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) { subredditName = savedInstanceState.getString(SUBREDDIT_NAME_STATE); iconUrl = savedInstanceState.getString(SUBREDDIT_ICON_STATE); @@ -193,7 +205,7 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF } if (subredditName != null) { - subredditNameTextView.setTextColor(getResources().getColor(R.color.primaryTextColor)); + subredditNameTextView.setTextColor(resources.getColor(R.color.primaryTextColor)); subredditNameTextView.setText(subredditName); flairTextView.setVisibility(View.VISIBLE); if (!loadSubredditIconSuccessful) { @@ -208,13 +220,13 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF if (flair != null) { flairTextView.setText(flair.getText()); - flairTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark)); + flairTextView.setBackgroundColor(flairColor); } if (isSpoiler) { - spoilerTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark)); + spoilerTextView.setBackgroundColor(spoilerColor); } if (isNSFW) { - nsfwTextView.setBackgroundColor(getResources().getColor(R.color.colorAccent)); + nsfwTextView.setBackgroundColor(nsfwColor); } } else { getCurrentAccount(); @@ -225,7 +237,7 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF loadSubredditIconSuccessful = false; subredditName = getIntent().getStringExtra(EXTRA_SUBREDDIT_NAME); subredditSelected = true; - subredditNameTextView.setTextColor(getResources().getColor(R.color.primaryTextColor)); + subredditNameTextView.setTextColor(resources.getColor(R.color.primaryTextColor)); subredditNameTextView.setText(subredditName); loadSubredditIcon(); } else { @@ -273,7 +285,7 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF mFlairSelectionBottomSheetFragment.setArguments(bundle); mFlairSelectionBottomSheetFragment.show(getSupportFragmentManager(), mFlairSelectionBottomSheetFragment.getTag()); } else { - flairTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent)); + flairTextView.setBackgroundColor(resources.getColor(android.R.color.transparent)); flairTextView.setText(getString(R.string.flair)); flair = null; } @@ -281,20 +293,20 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF spoilerTextView.setOnClickListener(view -> { if (!isSpoiler) { - spoilerTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark)); + spoilerTextView.setBackgroundColor(spoilerColor); isSpoiler = true; } else { - spoilerTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent)); + spoilerTextView.setBackgroundColor(resources.getColor(android.R.color.transparent)); isSpoiler = false; } }); nsfwTextView.setOnClickListener(view -> { if (!isNSFW) { - nsfwTextView.setBackgroundColor(getResources().getColor(R.color.colorAccent)); + nsfwTextView.setBackgroundColor(nsfwColor); isNSFW = true; } else { - nsfwTextView.setBackgroundColor(getResources().getColor(android.R.color.transparent)); + nsfwTextView.setBackgroundColor(resources.getColor(android.R.color.transparent)); isNSFW = false; } }); @@ -310,7 +322,7 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF Intent intent = new Intent(); intent.setType("video/*"); 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 -> { @@ -516,12 +528,12 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF subredditSelected = true; 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); displaySubredditIcon(); 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)); flair = null; } @@ -559,7 +571,7 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF public void flairSelected(Flair flair) { this.flair = flair; flairTextView.setText(flair.getText()); - flairTextView.setBackgroundColor(getResources().getColor(R.color.backgroundColorPrimaryDark)); + flairTextView.setBackgroundColor(flairColor); } @Subscribe diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java index 72e90cd7..99374dc5 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java @@ -2,6 +2,7 @@ package ml.docilealligator.infinityforreddit.Activity; import android.content.Intent; import android.content.SharedPreferences; +import android.content.res.ColorStateList; import android.content.res.Configuration; import android.content.res.Resources; import android.os.Build; @@ -69,6 +70,7 @@ import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditData; import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditViewModel; import ml.docilealligator.infinityforreddit.SubredditSubscription; import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; +import ml.docilealligator.infinityforreddit.Utils.Utils; import pl.droidsonroids.gif.GifImageView; import retrofit2.Retrofit; @@ -458,6 +460,9 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp fab.setVisibility(View.GONE); } + int unsubscribedColor = Utils.getAttributeColor(this, R.attr.unsubscribed); + int subscribedColor = Utils.getAttributeColor(this, R.attr.subscribed); + subscribeSubredditChip.setOnClickListener(view -> { if (mAccessToken == null) { Toast.makeText(ViewSubredditDetailActivity.this, R.string.login_first, Toast.LENGTH_SHORT).show(); @@ -473,7 +478,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp @Override public void onSubredditSubscriptionSuccess() { subscribeSubredditChip.setText(R.string.unsubscribe); - subscribeSubredditChip.setChipBackgroundColor(getResources().getColorStateList(R.color.colorAccent)); + subscribeSubredditChip.setChipBackgroundColor(ColorStateList.valueOf(subscribedColor)); makeSnackbar(R.string.subscribed, false); subscriptionReady = true; } @@ -491,7 +496,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp @Override public void onSubredditSubscriptionSuccess() { subscribeSubredditChip.setText(R.string.subscribe); - subscribeSubredditChip.setChipBackgroundColor(getResources().getColorStateList(R.color.backgroundColorPrimaryDark)); + subscribeSubredditChip.setChipBackgroundColor(ColorStateList.valueOf(unsubscribedColor)); makeSnackbar(R.string.unsubscribed, false); subscriptionReady = true; } @@ -511,14 +516,14 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp @Override public void isSubscribed() { subscribeSubredditChip.setText(R.string.unsubscribe); - subscribeSubredditChip.setChipBackgroundColor(getResources().getColorStateList(R.color.colorAccent)); + subscribeSubredditChip.setChipBackgroundColor(ColorStateList.valueOf(subscribedColor)); subscriptionReady = true; } @Override public void isNotSubscribed() { subscribeSubredditChip.setText(R.string.subscribe); - subscribeSubredditChip.setChipBackgroundColor(getResources().getColorStateList(R.color.backgroundColorPrimaryDark)); + subscribeSubredditChip.setChipBackgroundColor(ColorStateList.valueOf(unsubscribedColor)); subscriptionReady = true; } }).execute(); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewUserDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewUserDetailActivity.java index 53eb9720..35a98f69 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewUserDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewUserDetailActivity.java @@ -2,12 +2,12 @@ package ml.docilealligator.infinityforreddit.Activity; import android.content.Intent; import android.content.SharedPreferences; +import android.content.res.ColorStateList; import android.content.res.Configuration; import android.content.res.Resources; import android.os.AsyncTask; import android.os.Build; import android.os.Bundle; -import android.util.TypedValue; import android.view.KeyEvent; import android.view.Menu; import android.view.MenuItem; @@ -65,7 +65,6 @@ import ml.docilealligator.infinityforreddit.Post.PostDataSource; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.ReadMessage; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; -import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.SortType; import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback; 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.UserViewModel; import ml.docilealligator.infinityforreddit.UserFollowing; +import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; +import ml.docilealligator.infinityforreddit.Utils.Utils; import pl.droidsonroids.gif.GifImageView; import retrofit2.Retrofit; @@ -205,19 +206,12 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele setSupportActionBar(toolbar); - expandedTabTextColor = resources.getColor(R.color.tabLayoutWithExpandedCollapsingToolbarTextColor); - expandedTabIndicatorColor = resources.getColor(R.color.tabLayoutWithExpandedCollapsingToolbarTabIndicator); - - TypedValue expandedTabBackgroundColorTypedValue = new TypedValue(); - getTheme().resolveAttribute(R.attr.tabLayoutWithExpandedCollapsingToolbarTabBackground, expandedTabBackgroundColorTypedValue, true); - expandedTabBackgroundColor = expandedTabBackgroundColorTypedValue.data; - - 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; + expandedTabTextColor = Utils.getAttributeColor(this, R.attr.tabLayoutWithExpandedCollapsingToolbarTextColor); + expandedTabIndicatorColor = Utils.getAttributeColor(this, R.attr.tabLayoutWithExpandedCollapsingToolbarTabIndicator); + expandedTabBackgroundColor = Utils.getAttributeColor(this, R.attr.tabLayoutWithExpandedCollapsingToolbarTabBackground); + collapsedTabTextColor = Utils.getAttributeColor(this, R.attr.tabLayoutWithCollapsedCollapsingToolbarTextColor); + collapsedTabIndicatorColor = Utils.getAttributeColor(this, R.attr.tabLayoutWithCollapsedCollapsingToolbarTabIndicator); + collapsedTabBackgroundColor = Utils.getAttributeColor(this, R.attr.tabLayoutWithCollapsedCollapsingToolbarTabBackground); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1 && (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()) { subscribeUserChip.setVisibility(View.VISIBLE); subscribeUserChip.setOnClickListener(view -> { @@ -331,7 +328,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele @Override public void onUserFollowingSuccess() { subscribeUserChip.setText(R.string.unfollow); - subscribeUserChip.setChipBackgroundColor(resources.getColorStateList(R.color.colorAccent)); + subscribeUserChip.setChipBackgroundColor(ColorStateList.valueOf(subscribedColor)); showMessage(R.string.followed, false); subscriptionReady = true; } @@ -348,7 +345,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele @Override public void onUserFollowingSuccess() { subscribeUserChip.setText(R.string.follow); - subscribeUserChip.setChipBackgroundColor(resources.getColorStateList(R.color.backgroundColorPrimaryDark)); + subscribeUserChip.setChipBackgroundColor(ColorStateList.valueOf(unsubscribedColor)); showMessage(R.string.unfollowed, false); subscriptionReady = true; } @@ -367,14 +364,14 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele @Override public void isSubscribed() { subscribeUserChip.setText(R.string.unfollow); - subscribeUserChip.setChipBackgroundColor(resources.getColorStateList(R.color.colorAccent)); + subscribeUserChip.setChipBackgroundColor(ColorStateList.valueOf(subscribedColor)); subscriptionReady = true; } @Override public void isNotSubscribed() { subscribeUserChip.setText(R.string.follow); - subscribeUserChip.setChipBackgroundColor(resources.getColorStateList(R.color.backgroundColorPrimaryDark)); + subscribeUserChip.setChipBackgroundColor(ColorStateList.valueOf(unsubscribedColor)); subscriptionReady = true; } }).execute(); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java index 5545e1e8..7aa282f1 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java @@ -11,7 +11,6 @@ import android.text.Spannable; import android.text.Spanned; import android.text.style.SuperscriptSpan; import android.text.util.Linkify; -import android.util.TypedValue; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -131,6 +130,12 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy private boolean mHasMoreComments; private boolean loadMoreCommentsFailed; private int mCommentBackgroundColor; + private int mUsernameColor; + private int mSubmitterColor; + private int mModeratorColor; + private int mUpvotedColor; + private int mDownvotedColor; + private float mScale; private ShareLinkBottomSheetFragment mShareLinkBottomSheetFragment; private CopyTextBottomSheetFragment mCopyTextBottomSheetFragment; @@ -239,10 +244,12 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy mHasMoreComments = false; loadMoreCommentsFailed = false; mScale = activity.getResources().getDisplayMetrics().density; - - TypedValue typedValue = new TypedValue(); - mActivity.getTheme().resolveAttribute(R.attr.cardViewBackgroundColor, typedValue, true); - mCommentBackgroundColor = typedValue.data; + mCommentBackgroundColor = Utils.getAttributeColor(activity, R.attr.cardViewBackgroundColor); + mSubmitterColor = Utils.getAttributeColor(activity, R.attr.submitter); + mModeratorColor = Utils.getAttributeColor(activity, R.attr.moderator); + mUsernameColor = Utils.getAttributeColor(activity, R.attr.username); + mUpvotedColor = Utils.getAttributeColor(activity, R.attr.upvoted); + mDownvotedColor = Utils.getAttributeColor(activity, R.attr.downvoted); mShareLinkBottomSheetFragment = new ShareLinkBottomSheetFragment(); mCopyTextBottomSheetFragment = new CopyTextBottomSheetFragment(); @@ -400,13 +407,13 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy switch (mPost.getVoteType()) { case 1: //Upvote - ((PostDetailViewHolder) holder).mUpvoteButton.setColorFilter(ContextCompat.getColor(mActivity, R.color.upvoted), PorterDuff.Mode.SRC_IN); - ((PostDetailViewHolder) holder).mScoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.upvoted)); + ((PostDetailViewHolder) holder).mUpvoteButton.setColorFilter(mUpvotedColor, PorterDuff.Mode.SRC_IN); + ((PostDetailViewHolder) holder).mScoreTextView.setTextColor(mUpvotedColor); break; case -1: //Downvote - ((PostDetailViewHolder) holder).mDownvoteButton.setColorFilter(ContextCompat.getColor(mActivity, R.color.downvoted), PorterDuff.Mode.SRC_IN); - ((PostDetailViewHolder) holder).mScoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.downvoted)); + ((PostDetailViewHolder) holder).mDownvoteButton.setColorFilter(mDownvotedColor, PorterDuff.Mode.SRC_IN); + ((PostDetailViewHolder) holder).mScoreTextView.setTextColor(mDownvotedColor); break; case 0: ((PostDetailViewHolder) holder).mUpvoteButton.clearColorFilter(); @@ -733,16 +740,16 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy } 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. - 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); } 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. - 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); } @@ -822,13 +829,13 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy switch (comment.getVoteType()) { case CommentData.VOTE_TYPE_UPVOTE: ((CommentViewHolder) holder).upVoteButton - .setColorFilter(ContextCompat.getColor(mActivity, R.color.upvoted), android.graphics.PorterDuff.Mode.SRC_IN); - ((CommentViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.upvoted)); + .setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN); + ((CommentViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor); break; case CommentData.VOTE_TYPE_DOWNVOTE: ((CommentViewHolder) holder).downVoteButton - .setColorFilter(ContextCompat.getColor(mActivity, R.color.downvoted), android.graphics.PorterDuff.Mode.SRC_IN); - ((CommentViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.downvoted)); + .setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN); + ((CommentViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor); break; } @@ -897,8 +904,8 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy //Not upvoted before comment.setVoteType(CommentData.VOTE_TYPE_UPVOTE); newVoteType = RedditUtils.DIR_UPVOTE; - ((CommentViewHolder) holder).upVoteButton.setColorFilter(ContextCompat.getColor(mActivity, R.color.upvoted), android.graphics.PorterDuff.Mode.SRC_IN); - ((CommentViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.upvoted)); + ((CommentViewHolder) holder).upVoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN); + ((CommentViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor); } else { //Upvoted before comment.setVoteType(CommentData.VOTE_TYPE_NO_VOTE); @@ -915,8 +922,8 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy public void onVoteThingSuccess(int position) { if (newVoteType.equals(RedditUtils.DIR_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).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.upvoted)); + ((CommentViewHolder) holder).upVoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN); + ((CommentViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor); } else { comment.setVoteType(CommentData.VOTE_TYPE_NO_VOTE); ((CommentViewHolder) holder).upVoteButton.clearColorFilter(); @@ -954,8 +961,8 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy //Not downvoted before comment.setVoteType(CommentData.VOTE_TYPE_DOWNVOTE); newVoteType = RedditUtils.DIR_DOWNVOTE; - ((CommentViewHolder) holder).downVoteButton.setColorFilter(ContextCompat.getColor(mActivity, R.color.downvoted), android.graphics.PorterDuff.Mode.SRC_IN); - ((CommentViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.downvoted)); + ((CommentViewHolder) holder).downVoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN); + ((CommentViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor); } else { //Downvoted before comment.setVoteType(CommentData.VOTE_TYPE_NO_VOTE); @@ -972,8 +979,8 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy public void onVoteThingSuccess(int position1) { if (newVoteType.equals(RedditUtils.DIR_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).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.downvoted)); + ((CommentViewHolder) holder).downVoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN); + ((CommentViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor); } else { comment.setVoteType(CommentData.VOTE_TYPE_NO_VOTE); ((CommentViewHolder) holder).downVoteButton.clearColorFilter(); @@ -1602,8 +1609,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy @Override public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) { if (holder instanceof CommentViewHolder) { - ((CommentViewHolder) holder).authorTextView.setTextColor( - ContextCompat.getColor(mActivity, R.color.colorPrimaryDarkDayNightTheme)); + ((CommentViewHolder) holder).authorTextView.setTextColor(mUsernameColor); mGlide.clear(((CommentViewHolder) holder).authorTypeImageView); ((CommentViewHolder) holder).authorFlairTextView.setVisibility(View.GONE); ((CommentViewHolder) holder).authorTypeImageView.setVisibility(View.GONE); @@ -1791,8 +1797,8 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy //Not upvoted before mPost.setVoteType(1); newVoteType = RedditUtils.DIR_UPVOTE; - mUpvoteButton.setColorFilter(ContextCompat.getColor(mActivity, R.color.upvoted), android.graphics.PorterDuff.Mode.SRC_IN); - mScoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.upvoted)); + mUpvoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN); + mScoreTextView.setTextColor(mUpvotedColor); } else { //Upvoted before mPost.setVoteType(0); @@ -1811,8 +1817,8 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy public void onVoteThingSuccess() { if (newVoteType.equals(RedditUtils.DIR_UPVOTE)) { mPost.setVoteType(1); - mUpvoteButton.setColorFilter(ContextCompat.getColor(mActivity, R.color.upvoted), android.graphics.PorterDuff.Mode.SRC_IN); - mScoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.upvoted)); + mUpvoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN); + mScoreTextView.setTextColor(mUpvotedColor); } else { mPost.setVoteType(0); mUpvoteButton.clearColorFilter(); @@ -1865,8 +1871,8 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy //Not upvoted before mPost.setVoteType(-1); newVoteType = RedditUtils.DIR_DOWNVOTE; - mDownvoteButton.setColorFilter(ContextCompat.getColor(mActivity, R.color.downvoted), android.graphics.PorterDuff.Mode.SRC_IN); - mScoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.downvoted)); + mDownvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN); + mScoreTextView.setTextColor(mDownvotedColor); } else { //Upvoted before mPost.setVoteType(0); @@ -1885,8 +1891,8 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy public void onVoteThingSuccess() { if (newVoteType.equals(RedditUtils.DIR_DOWNVOTE)) { mPost.setVoteType(-1); - mDownvoteButton.setColorFilter(ContextCompat.getColor(mActivity, R.color.downvoted), android.graphics.PorterDuff.Mode.SRC_IN); - mScoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.downvoted)); + mDownvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN); + mScoreTextView.setTextColor(mDownvotedColor); } else { mPost.setVoteType(0); mDownvoteButton.clearColorFilter(); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentsListingRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentsListingRecyclerViewAdapter.java index ee21f521..82aa865b 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentsListingRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentsListingRecyclerViewAdapter.java @@ -66,8 +66,10 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment private Markwon mMarkwon; private String mAccessToken; private String mAccountName; - private int mTextColorPrimaryDark; - private int mColorAccent; + private int mUsernameColor; + private int mSubredditColor; + private int mUpvotedColor; + private int mDownvotedColor; private boolean mVoteButtonsOnTheRight; private boolean mShowElapsedTime; private boolean mShowCommentDivider; @@ -115,8 +117,10 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment mShowCommentDivider = showCommentDivider; mShowAbsoluteNumberOfVotes = showAbsoluteNumberOfVotes; mRetryLoadingMoreCallback = retryLoadingMoreCallback; - mTextColorPrimaryDark = mContext.getResources().getColor(R.color.colorPrimaryDarkDayNightTheme); - mColorAccent = mContext.getResources().getColor(R.color.colorAccent); + mSubredditColor = Utils.getAttributeColor(context, R.attr.subreddit); + mUsernameColor = Utils.getAttributeColor(context, R.attr.username); + mUpvotedColor = Utils.getAttributeColor(context, R.attr.upvoted); + mDownvotedColor = Utils.getAttributeColor(context, R.attr.downvoted); } @NonNull @@ -138,7 +142,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment if (comment != null) { if (comment.getSubredditName().substring(2).equals(comment.getLinkAuthor())) { ((DataViewHolder) holder).authorTextView.setText("u/" + comment.getLinkAuthor()); - ((DataViewHolder) holder).authorTextView.setTextColor(mTextColorPrimaryDark); + ((DataViewHolder) holder).authorTextView.setTextColor(mUsernameColor); ((DataViewHolder) holder).authorTextView.setOnClickListener(view -> { Intent intent = new Intent(mContext, ViewUserDetailActivity.class); intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, comment.getLinkAuthor()); @@ -146,7 +150,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment }); } else { ((DataViewHolder) holder).authorTextView.setText("r/" + comment.getSubredditName()); - ((DataViewHolder) holder).authorTextView.setTextColor(mColorAccent); + ((DataViewHolder) holder).authorTextView.setTextColor(mSubredditColor); ((DataViewHolder) holder).authorTextView.setOnClickListener(view -> { Intent intent = new Intent(mContext, ViewSubredditDetailActivity.class); intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, comment.getSubredditName()); @@ -169,13 +173,13 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment switch (comment.getVoteType()) { case CommentData.VOTE_TYPE_UPVOTE: ((DataViewHolder) holder).upvoteButton - .setColorFilter(ContextCompat.getColor(mContext, R.color.upvoted), android.graphics.PorterDuff.Mode.SRC_IN); - ((DataViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mContext, R.color.upvoted)); + .setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN); + ((DataViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor); break; case CommentData.VOTE_TYPE_DOWNVOTE: ((DataViewHolder) holder).downvoteButton - .setColorFilter(ContextCompat.getColor(mContext, R.color.downvoted), android.graphics.PorterDuff.Mode.SRC_IN); - ((DataViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mContext, R.color.downvoted)); + .setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN); + ((DataViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor); break; } @@ -221,8 +225,8 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment comment.setVoteType(CommentData.VOTE_TYPE_UPVOTE); newVoteType = RedditUtils.DIR_UPVOTE; ((DataViewHolder) holder).upvoteButton - .setColorFilter(ContextCompat.getColor(mContext, R.color.upvoted), android.graphics.PorterDuff.Mode.SRC_IN); - ((DataViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mContext, R.color.upvoted)); + .setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN); + ((DataViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor); } else { //Upvoted before comment.setVoteType(CommentData.VOTE_TYPE_NO_VOTE); @@ -239,8 +243,8 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment public void onVoteThingSuccess(int position) { if (newVoteType.equals(RedditUtils.DIR_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).scoreTextView.setTextColor(ContextCompat.getColor(mContext, R.color.upvoted)); + ((DataViewHolder) holder).upvoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN); + ((DataViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor); } else { comment.setVoteType(CommentData.VOTE_TYPE_NO_VOTE); ((DataViewHolder) holder).upvoteButton.clearColorFilter(); @@ -273,8 +277,8 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment //Not downvoted before comment.setVoteType(CommentData.VOTE_TYPE_DOWNVOTE); newVoteType = RedditUtils.DIR_DOWNVOTE; - ((DataViewHolder) holder).downvoteButton.setColorFilter(ContextCompat.getColor(mContext, R.color.downvoted), android.graphics.PorterDuff.Mode.SRC_IN); - ((DataViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mContext, R.color.downvoted)); + ((DataViewHolder) holder).downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN); + ((DataViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor); } else { //Downvoted before comment.setVoteType(CommentData.VOTE_TYPE_NO_VOTE); @@ -291,8 +295,8 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment public void onVoteThingSuccess(int position1) { if (newVoteType.equals(RedditUtils.DIR_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).scoreTextView.setTextColor(ContextCompat.getColor(mContext, R.color.downvoted)); + ((DataViewHolder) holder).downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN); + ((DataViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor); } else { comment.setVoteType(CommentData.VOTE_TYPE_NO_VOTE); ((DataViewHolder) holder).downvoteButton.clearColorFilter(); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/MessageRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/MessageRecyclerViewAdapter.java index 497002dc..764b51e0 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/MessageRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/MessageRecyclerViewAdapter.java @@ -6,7 +6,6 @@ import android.content.res.Resources; import android.net.Uri; import android.text.style.SuperscriptSpan; import android.text.util.Linkify; -import android.util.TypedValue; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -32,6 +31,7 @@ import ml.docilealligator.infinityforreddit.Message; import ml.docilealligator.infinityforreddit.NetworkState; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.ReadMessage; +import ml.docilealligator.infinityforreddit.Utils.Utils; import retrofit2.Retrofit; public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, RecyclerView.ViewHolder> { @@ -57,6 +57,7 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl private NetworkState networkState; private RetryLoadingMoreCallback mRetryLoadingMoreCallback; private int mMessageBackgroundColor; + private int usernameColor; public MessageRecyclerViewAdapter(Context context, Retrofit oauthRetrofit, String accessToken, RetryLoadingMoreCallback retryLoadingMoreCallback) { @@ -92,9 +93,8 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl mAccessToken = accessToken; mResources = context.getResources(); - TypedValue typedValue = new TypedValue(); - mContext.getTheme().resolveAttribute(R.attr.cardViewBackgroundColor, typedValue, true); - mMessageBackgroundColor = typedValue.data; + mMessageBackgroundColor = Utils.getAttributeColor(context, R.attr.cardViewBackgroundColor); + usernameColor = Utils.getAttributeColor(context, R.attr.username); } @NonNull @@ -120,7 +120,7 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl } if (message.wasComment()) { - ((DataViewHolder) holder).authorTextView.setTextColor(mResources.getColor(R.color.colorPrimaryDarkDayNightTheme)); + ((DataViewHolder) holder).authorTextView.setTextColor(usernameColor); ((DataViewHolder) holder).titleTextView.setText(message.getTitle()); } else { ((DataViewHolder) holder).titleTextView.setVisibility(View.GONE); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java index f08c39f6..878b502d 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java @@ -98,6 +98,10 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView private boolean canStartActivity = true; private int mPostType; private int mPostLayout; + private int mSubredditColor; + private int mUsernameColor; + private int mUpvotedColor; + private int mDownvotedColor; private float mScale; private boolean mDisplaySubredditName; private boolean mVoteButtonsOnTheRight; @@ -131,6 +135,10 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView mShowDividerInCompactLayout = showDividerInCompactLayout; mShowAbsoluteNumberOfVotes = showAbsoluteNumberOfVotes; 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; mGlide = Glide.with(mActivity.getApplicationContext()); mRedditDataRoomDatabase = redditDataRoomDatabase; @@ -391,13 +399,13 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView switch (voteType) { case 1: //Upvoted - ((PostViewHolder) holder).upvoteButton.setColorFilter(ContextCompat.getColor(mActivity, R.color.upvoted), android.graphics.PorterDuff.Mode.SRC_IN); - ((PostViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.upvoted)); + ((PostViewHolder) holder).upvoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN); + ((PostViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor); break; case -1: //Downvoted - ((PostViewHolder) holder).downvoteButton.setColorFilter(ContextCompat.getColor(mActivity, R.color.downvoted), android.graphics.PorterDuff.Mode.SRC_IN); - ((PostViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.downvoted)); + ((PostViewHolder) holder).downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN); + ((PostViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor); break; } @@ -551,8 +559,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView post.setVoteType(1); newVoteType = RedditUtils.DIR_UPVOTE; ((PostViewHolder) holder).upvoteButton - .setColorFilter(ContextCompat.getColor(mActivity, R.color.upvoted), android.graphics.PorterDuff.Mode.SRC_IN); - ((PostViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.upvoted)); + .setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN); + ((PostViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor); } else { //Upvoted before post.setVoteType(0); @@ -569,8 +577,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView if (newVoteType.equals(RedditUtils.DIR_UPVOTE)) { post.setVoteType(1); ((PostViewHolder) holder).upvoteButton - .setColorFilter(ContextCompat.getColor(mActivity, R.color.upvoted), android.graphics.PorterDuff.Mode.SRC_IN); - ((PostViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.upvoted)); + .setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN); + ((PostViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor); } else { post.setVoteType(0); ((PostViewHolder) holder).upvoteButton.clearColorFilter(); @@ -622,8 +630,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView post.setVoteType(-1); newVoteType = RedditUtils.DIR_DOWNVOTE; ((PostViewHolder) holder).downvoteButton - .setColorFilter(ContextCompat.getColor(mActivity, R.color.downvoted), android.graphics.PorterDuff.Mode.SRC_IN); - ((PostViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.downvoted)); + .setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN); + ((PostViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor); } else { //Downvoted before post.setVoteType(0); @@ -640,8 +648,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView if (newVoteType.equals(RedditUtils.DIR_DOWNVOTE)) { post.setVoteType(-1); ((PostViewHolder) holder).downvoteButton - .setColorFilter(ContextCompat.getColor(mActivity, R.color.downvoted), android.graphics.PorterDuff.Mode.SRC_IN); - ((PostViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.downvoted)); + .setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN); + ((PostViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor); } else { post.setVoteType(0); ((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.setOnClickListener(view -> { @@ -879,7 +887,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView .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.setOnClickListener(view -> { @@ -946,13 +954,13 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView switch (voteType) { case 1: //Upvoted - ((PostCompactViewHolder) holder).upvoteButton.setColorFilter(ContextCompat.getColor(mActivity, R.color.upvoted), android.graphics.PorterDuff.Mode.SRC_IN); - ((PostCompactViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.upvoted)); + ((PostCompactViewHolder) holder).upvoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN); + ((PostCompactViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor); break; case -1: //Downvoted - ((PostCompactViewHolder) holder).downvoteButton.setColorFilter(ContextCompat.getColor(mActivity, R.color.downvoted), android.graphics.PorterDuff.Mode.SRC_IN); - ((PostCompactViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.downvoted)); + ((PostCompactViewHolder) holder).downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN); + ((PostCompactViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor); break; } @@ -1097,8 +1105,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView post.setVoteType(1); newVoteType = RedditUtils.DIR_UPVOTE; ((PostCompactViewHolder) holder).upvoteButton - .setColorFilter(ContextCompat.getColor(mActivity, R.color.upvoted), android.graphics.PorterDuff.Mode.SRC_IN); - ((PostCompactViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.upvoted)); + .setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN); + ((PostCompactViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor); } else { //Upvoted before post.setVoteType(0); @@ -1115,8 +1123,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView if (newVoteType.equals(RedditUtils.DIR_UPVOTE)) { post.setVoteType(1); ((PostCompactViewHolder) holder).upvoteButton - .setColorFilter(ContextCompat.getColor(mActivity, R.color.upvoted), android.graphics.PorterDuff.Mode.SRC_IN); - ((PostCompactViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.upvoted)); + .setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN); + ((PostCompactViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor); } else { post.setVoteType(0); ((PostCompactViewHolder) holder).upvoteButton.clearColorFilter(); @@ -1168,8 +1176,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView post.setVoteType(-1); newVoteType = RedditUtils.DIR_DOWNVOTE; ((PostCompactViewHolder) holder).downvoteButton - .setColorFilter(ContextCompat.getColor(mActivity, R.color.downvoted), android.graphics.PorterDuff.Mode.SRC_IN); - ((PostCompactViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.downvoted)); + .setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN); + ((PostCompactViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor); } else { //Downvoted before post.setVoteType(0); @@ -1186,8 +1194,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView if (newVoteType.equals(RedditUtils.DIR_DOWNVOTE)) { post.setVoteType(-1); ((PostCompactViewHolder) holder).downvoteButton - .setColorFilter(ContextCompat.getColor(mActivity, R.color.downvoted), android.graphics.PorterDuff.Mode.SRC_IN); - ((PostCompactViewHolder) holder).scoreTextView.setTextColor(ContextCompat.getColor(mActivity, R.color.downvoted)); + .setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN); + ((PostCompactViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor); } else { post.setVoteType(0); ((PostCompactViewHolder) holder).downvoteButton.clearColorFilter(); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/AppModule.java b/app/src/main/java/ml/docilealligator/infinityforreddit/AppModule.java index 8bdf0d5d..96389c00 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/AppModule.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/AppModule.java @@ -76,9 +76,13 @@ class AppModule { @Provides @Singleton - OkHttpClient provideOkHttpClient(@Named("no_oauth") Retrofit retrofit, RedditDataRoomDatabase accountRoomDatabase) { + OkHttpClient provideOkHttpClient(RedditDataRoomDatabase accountRoomDatabase) { 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)); return okHttpClientBuilder.build(); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/Utils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/Utils.java index 552f8515..fc71392f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/Utils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/Utils.java @@ -1,6 +1,7 @@ package ml.docilealligator.infinityforreddit.Utils; import android.content.Context; +import android.util.TypedValue; import java.util.Locale; @@ -73,4 +74,10 @@ public class Utils { 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; + } } diff --git a/app/src/main/res/layout/activity_multi_reddit_listing.xml b/app/src/main/res/layout/activity_multi_reddit_listing.xml index 1669a8c8..ef04c4e7 100644 --- a/app/src/main/res/layout/activity_multi_reddit_listing.xml +++ b/app/src/main/res/layout/activity_multi_reddit_listing.xml @@ -76,7 +76,7 @@ android:layout_height="wrap_content" android:layout_margin="@dimen/fab_margin" android:layout_gravity="bottom|end" - app:backgroundTint="@color/backgroundColorPrimary" + app:backgroundTint="?attr/colorPrimaryLightTheme" app:srcCompat="@drawable/ic_add_bottom_app_bar_24dp" app:tint="@android:color/white" /> diff --git a/app/src/main/res/layout/activity_post_image.xml b/app/src/main/res/layout/activity_post_image.xml index 9c320679..92254896 100644 --- a/app/src/main/res/layout/activity_post_image.xml +++ b/app/src/main/res/layout/activity_post_image.xml @@ -92,7 +92,7 @@ android:textSize="?attr/font_default" android:visibility="gone" app:lib_setRadius="3dp" - app:lib_setRoundedBorderColor="@color/colorPrimaryDarkDayNightTheme" + app:lib_setRoundedBorderColor="?attr/flairColor" app:lib_setRoundedView="true" app:lib_setShape="rectangle" /> @@ -106,7 +106,7 @@ android:textColor="@color/primaryTextColor" android:textSize="?attr/font_default" app:lib_setRadius="3dp" - app:lib_setRoundedBorderColor="@color/colorPrimaryDarkDayNightTheme" + app:lib_setRoundedBorderColor="?attr/spoilerColor" app:lib_setRoundedView="true" app:lib_setShape="rectangle" /> @@ -164,7 +164,7 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toStartOf="@+id/select_from_library_fab_post_image_activity" app:layout_constraintHorizontal_chainStyle="spread" - app:backgroundTint="@color/backgroundColorPrimary" + app:backgroundTint="?attr/colorPrimaryLightTheme" app:tint="@android:color/white" /> <com.google.android.material.floatingactionbutton.FloatingActionButton @@ -177,7 +177,7 @@ app:layout_constraintStart_toEndOf="@+id/capture_fab_post_image_activity" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_chainStyle="spread" - app:backgroundTint="@color/backgroundColorPrimary" + app:backgroundTint="?attr/colorPrimaryLightTheme" app:tint="@android:color/white" /> </androidx.constraintlayout.widget.ConstraintLayout> diff --git a/app/src/main/res/layout/activity_post_link.xml b/app/src/main/res/layout/activity_post_link.xml index 24ba75b6..7aed97e1 100644 --- a/app/src/main/res/layout/activity_post_link.xml +++ b/app/src/main/res/layout/activity_post_link.xml @@ -92,7 +92,7 @@ android:textSize="?attr/font_default" android:visibility="gone" app:lib_setRadius="3dp" - app:lib_setRoundedBorderColor="@color/colorPrimaryDarkDayNightTheme" + app:lib_setRoundedBorderColor="?attr/flairColor" app:lib_setRoundedView="true" app:lib_setShape="rectangle" /> @@ -106,7 +106,7 @@ android:textColor="@color/primaryTextColor" android:textSize="?attr/font_default" app:lib_setRadius="3dp" - app:lib_setRoundedBorderColor="@color/colorPrimaryDarkDayNightTheme" + app:lib_setRoundedBorderColor="?attr/spoilerColor" app:lib_setRoundedView="true" app:lib_setShape="rectangle" /> diff --git a/app/src/main/res/layout/activity_post_text.xml b/app/src/main/res/layout/activity_post_text.xml index 7cabdf0b..5f6d638d 100644 --- a/app/src/main/res/layout/activity_post_text.xml +++ b/app/src/main/res/layout/activity_post_text.xml @@ -92,7 +92,7 @@ android:textSize="?attr/font_default" android:visibility="gone" app:lib_setRadius="3dp" - app:lib_setRoundedBorderColor="@color/colorPrimaryDarkDayNightTheme" + app:lib_setRoundedBorderColor="?attr/flairColor" app:lib_setRoundedView="true" app:lib_setShape="rectangle" /> @@ -106,7 +106,7 @@ android:textColor="@color/primaryTextColor" android:textSize="?attr/font_default" app:lib_setRadius="3dp" - app:lib_setRoundedBorderColor="@color/colorPrimaryDarkDayNightTheme" + app:lib_setRoundedBorderColor="?attr/spoilerColor" app:lib_setRoundedView="true" app:lib_setShape="rectangle" /> diff --git a/app/src/main/res/layout/activity_post_video.xml b/app/src/main/res/layout/activity_post_video.xml index 2e3057d5..341034a7 100644 --- a/app/src/main/res/layout/activity_post_video.xml +++ b/app/src/main/res/layout/activity_post_video.xml @@ -92,7 +92,7 @@ android:textSize="?attr/font_default" android:visibility="gone" app:lib_setRadius="3dp" - app:lib_setRoundedBorderColor="@color/colorPrimaryDarkDayNightTheme" + app:lib_setRoundedBorderColor="?attr/flairColor" app:lib_setRoundedView="true" app:lib_setShape="rectangle" /> @@ -106,7 +106,7 @@ android:textColor="@color/primaryTextColor" android:textSize="?attr/font_default" app:lib_setRadius="3dp" - app:lib_setRoundedBorderColor="@color/colorPrimaryDarkDayNightTheme" + app:lib_setRoundedBorderColor="?attr/spoilerColor" app:lib_setRoundedView="true" app:lib_setShape="rectangle" /> @@ -164,7 +164,7 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toStartOf="@+id/select_from_library_fab_post_video_activity" app:layout_constraintHorizontal_chainStyle="spread" - app:backgroundTint="@color/backgroundColorPrimary" + app:backgroundTint="?attr/colorPrimaryLightTheme" app:tint="@android:color/white" /> <com.google.android.material.floatingactionbutton.FloatingActionButton @@ -177,7 +177,7 @@ app:layout_constraintStart_toEndOf="@+id/capture_fab_post_video_activity" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_chainStyle="spread" - app:backgroundTint="@color/backgroundColorPrimary" + app:backgroundTint="?attr/colorPrimaryLightTheme" app:tint="@android:color/white" /> </androidx.constraintlayout.widget.ConstraintLayout> diff --git a/app/src/main/res/layout/activity_view_post_detail.xml b/app/src/main/res/layout/activity_view_post_detail.xml index 4ee9dff7..fb9bb240 100644 --- a/app/src/main/res/layout/activity_view_post_detail.xml +++ b/app/src/main/res/layout/activity_view_post_detail.xml @@ -76,7 +76,7 @@ android:layout_height="wrap_content" android:layout_gravity="bottom|end" android:layout_margin="@dimen/fab_margin" - app:backgroundTint="@color/backgroundColorPrimary" + app:backgroundTint="?attr/colorPrimaryLightTheme" app:tint="@android:color/white" app:srcCompat="@drawable/ic_keyboard_arrow_down_24dp" /> diff --git a/app/src/main/res/layout/activity_view_subreddit_detail.xml b/app/src/main/res/layout/activity_view_subreddit_detail.xml index 6743aef0..f36640ce 100644 --- a/app/src/main/res/layout/activity_view_subreddit_detail.xml +++ b/app/src/main/res/layout/activity_view_subreddit_detail.xml @@ -203,7 +203,7 @@ android:layout_height="wrap_content" android:layout_margin="@dimen/fab_margin" android:visibility="gone" - app:backgroundTint="@color/backgroundColorPrimary" + app:backgroundTint="?attr/colorPrimaryLightTheme" app:srcCompat="@drawable/ic_add_bottom_app_bar_24dp" app:tint="@android:color/white" app:layout_anchor="@id/bottom_navigation_view_subreddit_detail_activity" /> diff --git a/app/src/main/res/layout/activity_view_user_detail.xml b/app/src/main/res/layout/activity_view_user_detail.xml index efeee887..f1d257e6 100644 --- a/app/src/main/res/layout/activity_view_user_detail.xml +++ b/app/src/main/res/layout/activity_view_user_detail.xml @@ -66,7 +66,7 @@ android:layout_height="wrap_content" android:layout_marginTop="16dp" android:textSize="?attr/font_18" - android:textColor="@color/colorPrimaryDarkDayNightTheme" + android:textColor="?attr/username" android:layout_gravity="center_horizontal"/> <TextView diff --git a/app/src/main/res/layout/app_bar_main.xml b/app/src/main/res/layout/app_bar_main.xml index 34b44e02..88de7dcf 100644 --- a/app/src/main/res/layout/app_bar_main.xml +++ b/app/src/main/res/layout/app_bar_main.xml @@ -131,7 +131,7 @@ android:layout_height="wrap_content" android:layout_margin="@dimen/fab_margin" android:visibility="gone" - app:backgroundTint="@color/backgroundColorPrimary" + app:backgroundTint="?attr/colorPrimaryLightTheme" app:srcCompat="@drawable/ic_add_bottom_app_bar_24dp" app:tint="@android:color/white" app:layout_anchor="@id/bottom_navigation_main_activity" /> diff --git a/app/src/main/res/layout/item_comment.xml b/app/src/main/res/layout/item_comment.xml index f80d6bfb..88307a62 100644 --- a/app/src/main/res/layout/item_comment.xml +++ b/app/src/main/res/layout/item_comment.xml @@ -14,8 +14,7 @@ <View android:id="@+id/vertical_block_item_post_comment" android:layout_width="0dp" - android:layout_height="match_parent" - android:background="@color/colorPrimaryDarkDayNightTheme"/> + android:layout_height="match_parent" /> <LinearLayout android:layout_width="match_parent" @@ -48,7 +47,7 @@ android:layout_marginEnd="8dp" android:ellipsize="end" android:maxLines="2" - android:textColor="@color/colorPrimaryDarkDayNightTheme" + android:textColor="?attr/username" android:textSize="?attr/font_default" app:layout_constraintBottom_toTopOf="@id/author_flair_text_view_item_post_comment" app:layout_constraintEnd_toStartOf="@+id/barrier" @@ -62,7 +61,7 @@ android:layout_marginEnd="8dp" android:ellipsize="end" android:maxLines="2" - android:textColor="@color/authorFlairTextColor" + android:textColor="?attr/authorFlairTextColor" android:textSize="?attr/font_12" android:visibility="gone" app:layout_constraintBottom_toBottomOf="parent" diff --git a/app/src/main/res/layout/item_footer_error.xml b/app/src/main/res/layout/item_footer_error.xml index 161ad1ab..fba52052 100644 --- a/app/src/main/res/layout/item_footer_error.xml +++ b/app/src/main/res/layout/item_footer_error.xml @@ -22,7 +22,7 @@ android:layout_height="wrap_content" android:layout_alignParentEnd="true" android:layout_centerVertical="true" - android:backgroundTint="@color/backgroundColorPrimary" + android:backgroundTint="?attr/colorPrimaryLightTheme" android:textColor="@android:color/white" android:text="@string/retry" android:textSize="?attr/font_default" /> diff --git a/app/src/main/res/layout/item_load_more_comments_placeholder.xml b/app/src/main/res/layout/item_load_more_comments_placeholder.xml index 0a4a0047..8c0fb3e1 100644 --- a/app/src/main/res/layout/item_load_more_comments_placeholder.xml +++ b/app/src/main/res/layout/item_load_more_comments_placeholder.xml @@ -12,8 +12,7 @@ <View android:id="@+id/vertical_block_item_load_more_comments" android:layout_width="wrap_content" - android:layout_height="match_parent" - android:background="@color/colorPrimaryDarkDayNightTheme" /> + android:layout_height="match_parent" /> <TextView android:id="@+id/placeholder_text_view_item_load_more_comments" diff --git a/app/src/main/res/layout/item_post.xml b/app/src/main/res/layout/item_post.xml index 80fee855..113f6855 100644 --- a/app/src/main/res/layout/item_post.xml +++ b/app/src/main/res/layout/item_post.xml @@ -49,7 +49,7 @@ android:layout_height="wrap_content" android:layout_marginStart="16dp" android:layout_marginEnd="8dp" - android:textColor="@color/colorPrimaryDarkDayNightTheme" + android:textColor="?attr/username" android:textSize="?attr/font_default" android:maxLines="2" android:ellipsize="end" @@ -64,7 +64,7 @@ android:layout_width="24dp" android:layout_height="24dp" android:layout_marginEnd="8dp" - android:tint="@color/backgroundColorPrimaryDark" + android:tint="?attr/stickiedPost" android:visibility="gone" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toEndOf="@id/name_text_view_item_post" @@ -127,8 +127,8 @@ android:padding="4dp" android:textSize="?attr/font_12" android:textColor="@android:color/white" - app:lib_setRoundedBGColor="@color/backgroundColorPrimaryDark" - app:lib_setRoundedBorderColor="@color/backgroundColorPrimaryDark" + app:lib_setRoundedBGColor="?attr/post_type" + app:lib_setRoundedBorderColor="?attr/post_type" app:lib_setRadius="3dp" app:lib_setRoundedView="true" app:lib_setShape="rectangle" /> @@ -144,8 +144,8 @@ android:padding="4dp" android:visibility="gone" app:lib_setRadius="3dp" - app:lib_setRoundedBGColor="@color/spoilerBackgroundColor" - app:lib_setRoundedBorderColor="@color/spoilerBackgroundColor" + app:lib_setRoundedBGColor="?attr/spoilerColor" + app:lib_setRoundedBorderColor="?attr/spoilerColor" app:lib_setRoundedView="true" app:lib_setShape="rectangle" /> @@ -174,8 +174,8 @@ android:padding="4dp" android:visibility="gone" app:lib_setRadius="3dp" - app:lib_setRoundedBGColor="@color/flairBackgroundColor" - app:lib_setRoundedBorderColor="@color/flairBackgroundColor" + app:lib_setRoundedBGColor="?attr/flairColor" + app:lib_setRoundedBorderColor="?attr/flairColor" app:lib_setRoundedView="true" app:lib_setShape="rectangle" /> @@ -194,7 +194,7 @@ android:layout_width="24dp" android:layout_height="24dp" android:src="@drawable/ic_archive_outline" - android:tint="@color/archivedTint" + android:tint="?attr/archivedTint" android:visibility="gone" /> <ImageView @@ -202,7 +202,7 @@ android:layout_width="24dp" android:layout_height="24dp" android:src="@drawable/ic_outline_lock_24dp" - android:tint="@color/lockedIconTint" + android:tint="?attr/lockedIconTint" android:visibility="gone" /> <ImageView @@ -210,7 +210,7 @@ android:layout_width="24dp" android:layout_height="24dp" android:src="@drawable/crosspost" - android:tint="@color/colorAccent" + android:tint="?attr/crosspost" android:visibility="gone" /> </com.nex3z.flowlayout.FlowLayout> diff --git a/app/src/main/res/layout/item_post_compact.xml b/app/src/main/res/layout/item_post_compact.xml index 7123c4db..ef7c2fe9 100644 --- a/app/src/main/res/layout/item_post_compact.xml +++ b/app/src/main/res/layout/item_post_compact.xml @@ -47,7 +47,7 @@ android:layout_width="24dp" android:layout_height="24dp" android:layout_marginEnd="8dp" - android:tint="@color/backgroundColorPrimaryDark" + android:tint="?attr/stickiedPost" android:visibility="gone" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toStartOf="@+id/guideline2" @@ -115,8 +115,8 @@ android:textColor="@android:color/white" android:textSize="?attr/font_10" app:lib_setRadius="3dp" - app:lib_setRoundedBGColor="@color/backgroundColorPrimaryDark" - app:lib_setRoundedBorderColor="@color/backgroundColorPrimaryDark" + app:lib_setRoundedBGColor="?attr/post_type" + app:lib_setRoundedBorderColor="?attr/post_type" app:lib_setRoundedView="true" app:lib_setShape="rectangle" /> @@ -131,8 +131,8 @@ android:textSize="?attr/font_10" android:visibility="gone" app:lib_setRadius="3dp" - app:lib_setRoundedBGColor="@color/spoilerBackgroundColor" - app:lib_setRoundedBorderColor="@color/spoilerBackgroundColor" + app:lib_setRoundedBGColor="?attr/spoilerColor" + app:lib_setRoundedBorderColor="?attr/spoilerColor" app:lib_setRoundedView="true" app:lib_setShape="rectangle" /> @@ -161,8 +161,8 @@ android:textSize="?attr/font_10" android:visibility="gone" app:lib_setRadius="3dp" - app:lib_setRoundedBGColor="@color/flairBackgroundColor" - app:lib_setRoundedBorderColor="@color/flairBackgroundColor" + app:lib_setRoundedBGColor="?attr/flairColor" + app:lib_setRoundedBorderColor="?attr/flairColor" app:lib_setRoundedView="true" app:lib_setShape="rectangle" /> @@ -181,7 +181,7 @@ android:layout_width="24dp" android:layout_height="24dp" android:src="@drawable/ic_archive_outline" - android:tint="@color/archivedTint" + android:tint="?attr/archivedTint" android:visibility="gone" /> <ImageView @@ -189,7 +189,7 @@ android:layout_width="24dp" android:layout_height="24dp" android:src="@drawable/ic_outline_lock_24dp" - android:tint="@color/lockedIconTint" + android:tint="?attr/lockedIconTint" android:visibility="gone" /> <ImageView @@ -197,7 +197,7 @@ android:layout_width="24dp" android:layout_height="24dp" android:src="@drawable/crosspost" - android:tint="@color/colorAccent" + android:tint="?attr/crosspost" android:visibility="gone" /> </com.nex3z.flowlayout.FlowLayout> diff --git a/app/src/main/res/layout/item_post_detail.xml b/app/src/main/res/layout/item_post_detail.xml index 54d48283..e0bcc418 100644 --- a/app/src/main/res/layout/item_post_detail.xml +++ b/app/src/main/res/layout/item_post_detail.xml @@ -26,7 +26,7 @@ android:layout_height="wrap_content" android:layout_marginStart="16dp" android:layout_marginEnd="8dp" - android:textColor="@color/colorAccent" + android:textColor="?attr/subreddit" android:textSize="?attr/font_default" android:maxLines="2" android:ellipsize="end" @@ -41,7 +41,7 @@ android:layout_height="wrap_content" android:layout_marginStart="16dp" android:layout_marginEnd="8dp" - android:textColor="@color/colorPrimaryDarkDayNightTheme" + android:textColor="?attr/username" android:textSize="?attr/font_default" android:maxLines="2" android:ellipsize="end" @@ -109,8 +109,8 @@ android:padding="4dp" android:textSize="?attr/font_12" android:textColor="@android:color/white" - app:lib_setRoundedBGColor="@color/backgroundColorPrimaryDark" - app:lib_setRoundedBorderColor="@color/backgroundColorPrimaryDark" + app:lib_setRoundedBGColor="?attr/post_type" + app:lib_setRoundedBorderColor="?attr/post_type" app:lib_setRadius="3dp" app:lib_setRoundedView="true" app:lib_setShape="rectangle" /> @@ -126,8 +126,8 @@ android:padding="4dp" android:visibility="gone" app:lib_setRadius="3dp" - app:lib_setRoundedBGColor="@color/spoilerBackgroundColor" - app:lib_setRoundedBorderColor="@color/spoilerBackgroundColor" + app:lib_setRoundedBGColor="?attr/spoilerColor" + app:lib_setRoundedBorderColor="?attr/spoilerColor" app:lib_setRoundedView="true" app:lib_setShape="rectangle" /> @@ -156,8 +156,8 @@ android:textColor="@android:color/white" android:visibility="gone" app:lib_setRadius="3dp" - app:lib_setRoundedBGColor="@color/flairBackgroundColor" - app:lib_setRoundedBorderColor="@color/flairBackgroundColor" + app:lib_setRoundedBGColor="?attr/flairColor" + app:lib_setRoundedBorderColor="?attr/flairColor" app:lib_setRoundedView="true" app:lib_setShape="rectangle" /> @@ -176,7 +176,7 @@ android:layout_width="20dp" android:layout_height="20dp" android:src="@drawable/ic_archive_outline" - android:tint="@color/archivedTint" + android:tint="?attr/archivedTint" android:visibility="gone" /> <ImageView @@ -184,7 +184,7 @@ android:layout_width="20dp" android:layout_height="20dp" android:src="@drawable/ic_outline_lock_24dp" - android:tint="@color/lockedIconTint" + android:tint="?attr/lockedIconTint" android:visibility="gone" /> <ImageView @@ -192,7 +192,7 @@ android:layout_width="20dp" android:layout_height="20dp" android:src="@drawable/crosspost" - android:tint="@color/colorAccent" + android:tint="?attr/crosspost" android:visibility="gone" /> </com.nex3z.flowlayout.FlowLayout> diff --git a/app/src/main/res/layout/item_subreddit_listing.xml b/app/src/main/res/layout/item_subreddit_listing.xml index 68157c95..f9797e7e 100644 --- a/app/src/main/res/layout/item_subreddit_listing.xml +++ b/app/src/main/res/layout/item_subreddit_listing.xml @@ -36,7 +36,7 @@ android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:src="@drawable/ic_add_24dp" - android:tint="@color/colorPrimaryDarkDayNightTheme" + android:tint="?attr/unsubscribed" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="parent" app:layout_constraintBottom_toBottomOf="parent" diff --git a/app/src/main/res/layout/item_user_listing.xml b/app/src/main/res/layout/item_user_listing.xml index a69b6a37..9ba6d291 100644 --- a/app/src/main/res/layout/item_user_listing.xml +++ b/app/src/main/res/layout/item_user_listing.xml @@ -36,7 +36,7 @@ android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:src="@drawable/ic_add_24dp" - android:tint="@color/colorPrimaryDarkDayNightTheme" + android:tint="?attr/unsubscribed" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="parent" app:layout_constraintBottom_toBottomOf="parent" diff --git a/app/src/main/res/values-night/colors.xml b/app/src/main/res/values-night/colors.xml index f5d0ec6c..61bd090a 100644 --- a/app/src/main/res/values-night/colors.xml +++ b/app/src/main/res/values-night/colors.xml @@ -10,7 +10,7 @@ <color name="primaryTextColor">#FFFFFF</color> - <color name="colorPrimaryDarkDayNightTheme">#1E88E5</color> + <!--<color name="colorPrimaryDarkDayNightTheme">#1E88E5</color>--> <color name="dividerColor">#69666C</color> @@ -18,9 +18,9 @@ <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> @@ -28,7 +28,7 @@ <color name="voteAndReplyUnavailableVoteButtonColor">#3C3C3C</color> - <color name="tabLayoutWithExpandedCollapsingToolbarTextColor">#FFFFFF</color> + <!--<color name="tabLayoutWithExpandedCollapsingToolbarTextColor">#FFFFFF</color> <color name="tabLayoutWithExpandedCollapsingToolbarTabBackground">@color/backgroundColor</color> @@ -38,7 +38,7 @@ <color name="tabLayoutWithCollapsedCollapsingToolbarTabBackground">@color/colorPrimary</color> - <color name="tabLayoutWithCollapsedCollapsingToolbarTabIndicator">@color/tabLayoutWithCollapsedCollapsingToolbarTextColor</color> + <color name="tabLayoutWithCollapsedCollapsingToolbarTabIndicator">@color/tabLayoutWithCollapsedCollapsingToolbarTextColor</color>--> <color name="navBarColor">@color/backgroundColor</color> @@ -60,5 +60,5 @@ <color name="commentVerticalBar6">#00B925</color> <color name="commentVerticalBar7">#EE4602</color> - <color name="toolbarAndTabBackgroundColor">#282828</color> + <!--<color name="toolbarAndTabBackgroundColor">#282828</color>--> </resources> diff --git a/app/src/main/res/values/attr.xml b/app/src/main/res/values/attr.xml index 37fc5341..9f35b9be 100644 --- a/app/src/main/res/values/attr.xml +++ b/app/src/main/res/values/attr.xml @@ -30,13 +30,36 @@ <declare-styleable name="Theme"> <attr name="colorPrimary" format="color"/> <attr name="colorPrimaryDark" format="color"/> + <attr name="colorAccent" format="color" /> + <attr name="colorPrimaryLightTheme" format="color" /> <attr name="backgroundColor" format="color"/> <attr name="roundedBottomSheetPrimaryBackground" format="color"/> <attr name="cardViewBackgroundColor" format="color"/> <attr name="toolbarAndTabBackgroundColor" format="color"/> <attr name="circularProgressBarBackground" format="color"/> <attr name="tabLayoutWithExpandedCollapsingToolbarTabBackground" format="color"/> + <attr name="tabLayoutWithExpandedCollapsingToolbarTextColor" format="color" /> + <attr name="tabLayoutWithExpandedCollapsingToolbarTabIndicator" format="color" /> <attr name="tabLayoutWithCollapsedCollapsingToolbarTabBackground" format="color"/> + <attr name="tabLayoutWithCollapsedCollapsingToolbarTextColor" format="color" /> + <attr name="tabLayoutWithCollapsedCollapsingToolbarTabIndicator" 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> </resources>
\ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 43811d56..c7880cd7 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -10,7 +10,7 @@ <color name="primaryTextColor">#000000</color> - <color name="colorPrimaryDarkDayNightTheme">@color/colorPrimaryDark</color> + <!--<color name="colorPrimaryDarkDayNightTheme">@color/colorPrimaryDark</color>--> <color name="dividerColor">#E0E0E0</color> @@ -18,9 +18,9 @@ <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> @@ -28,13 +28,13 @@ <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="tabLayoutWithExpandedCollapsingToolbarTextColor">@color/colorPrimary</color> + <!--<color name="tabLayoutWithExpandedCollapsingToolbarTextColor">@color/colorPrimary</color> <color name="tabLayoutWithExpandedCollapsingToolbarTabBackground">#FFFFFF</color> @@ -44,7 +44,7 @@ <color name="tabLayoutWithCollapsedCollapsingToolbarTabBackground">@color/colorPrimary</color> - <color name="tabLayoutWithCollapsedCollapsingToolbarTabIndicator">@color/tabLayoutWithCollapsedCollapsingToolbarTextColor</color> + <color name="tabLayoutWithCollapsedCollapsingToolbarTabIndicator">@color/tabLayoutWithCollapsedCollapsingToolbarTextColor</color>--> <color name="navBarColor">#FFFFFF</color> @@ -54,9 +54,9 @@ <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> @@ -70,7 +70,7 @@ <color name="commentVerticalBar6">#02EE6E</color> <color name="commentVerticalBar7">#EE4602</color> - <color name="toolbarAndTabBackgroundColor">@color/colorPrimary</color> + <!--<color name="toolbarAndTabBackgroundColor">@color/colorPrimary</color> <color name="submitter">#EE8A02</color> @@ -84,5 +84,5 @@ <color name="usernameColor">#0D47A1</color> - <color name="subredditNameColor">#FF4081</color> + <color name="subredditNameColor">#FF4081</color>--> </resources> diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index b91ecdb1..79085b9b 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -218,7 +218,7 @@ <style name="Theme" /> - <style name="Theme.Default"> + <!--<style name="Theme.Default"> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="backgroundColor">@color/backgroundColor</item> @@ -255,6 +255,114 @@ <item name="tabLayoutWithExpandedCollapsingToolbarTabBackground">#000000</item> <item name="tabLayoutWithCollapsedCollapsingToolbarTabBackground">#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> </resources> |