aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/ml
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2020-03-15 05:12:02 +0000
committerAlex Ning <chineseperson5@gmail.com>2020-03-15 05:12:02 +0000
commite076e2374f8bba9e268a124e67e473ecdbd06f21 (patch)
treedfd90592ce759c0dee37a5d11dc5520e4531425d /app/src/main/java/ml
parent1c1b084566ca3c65652310e403faee5f061d36ee (diff)
downloadinfinity-for-reddit-e076e2374f8bba9e268a124e67e473ecdbd06f21.tar
infinity-for-reddit-e076e2374f8bba9e268a124e67e473ecdbd06f21.tar.gz
infinity-for-reddit-e076e2374f8bba9e268a124e67e473ecdbd06f21.tar.bz2
infinity-for-reddit-e076e2374f8bba9e268a124e67e473ecdbd06f21.tar.lz
infinity-for-reddit-e076e2374f8bba9e268a124e67e473ecdbd06f21.tar.xz
infinity-for-reddit-e076e2374f8bba9e268a124e67e473ecdbd06f21.tar.zst
infinity-for-reddit-e076e2374f8bba9e268a124e67e473ecdbd06f21.zip
Implement custom multiple themes (Buggy).
Diffstat (limited to 'app/src/main/java/ml')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountPostsActivity.java14
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountSavedThingActivity.java22
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/BaseActivity.java41
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CommentActivity.java26
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CreateMultiRedditActivity.java31
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/EditCommentActivity.java20
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/EditPostActivity.java23
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/FilteredThingActivity.java20
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LinkResolverActivity.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LoginActivity.java24
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java30
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MultiRedditListingActivity.java29
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostImageActivity.java62
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostLinkActivity.java72
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostTextActivity.java60
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/PostVideoActivity.java62
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/RulesActivity.java23
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchActivity.java29
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchResultActivity.java21
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchSubredditsResultActivity.java20
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SettingsActivity.java20
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditMultiselectionActivity.java28
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditSelectionActivity.java20
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubscribedThingListingActivity.java21
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewMessageActivity.java37
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewMultiRedditDetailActivity.java21
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java40
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSidebarActivity.java45
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java39
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewUserDetailActivity.java44
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java168
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentsListingRecyclerViewAdapter.java46
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/FlairBottomSheetRecyclerViewAdapter.java8
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/FollowedUsersRecyclerViewAdapter.java11
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/MessageRecyclerViewAdapter.java42
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/MultiRedditListingRecyclerViewAdapter.java11
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/NavigationDrawerRecyclerViewAdapter.java18
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java92
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/RulesRecyclerViewAdapter.java10
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/SubredditListingRecyclerViewAdapter.java26
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/SubredditMultiselectionRecyclerViewAdapter.java14
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/SubscribedSubredditsRecyclerViewAdapter.java15
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/UserListingRecyclerViewAdapter.java125
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/AppModule.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeWrapper.java248
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CommentsListingFragment.java17
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/FlairBottomSheetFragment.java19
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/FollowedUsersListingFragment.java44
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java40
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SubredditListingFragment.java17
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SubscribedSubredditsListingFragment.java35
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/UserListingFragment.java17
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/FragmentCommunicator.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/NotificationUtils.java10
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Okhttp3DebugInterceptor.java42
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/PullNotificationWorker.java10
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Service/SubmitPostService.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Utils/CustomThemeSharedPreferencesUtils.java66
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java52
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Utils/Utils.java5
60 files changed, 1628 insertions, 542 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountPostsActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountPostsActivity.java
index 5ac722bd..721fddfb 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountPostsActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountPostsActivity.java
@@ -11,6 +11,7 @@ import android.view.WindowManager;
import androidx.annotation.NonNull;
import androidx.appcompat.widget.Toolbar;
+import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.fragment.app.Fragment;
import com.google.android.material.appbar.AppBarLayout;
@@ -49,6 +50,8 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect
private static final String ACCOUNT_NAME_STATE = "ANS";
private static final String FRAGMENT_OUT_STATE = "FOS";
+ @BindView(R.id.coordinator_layout_account_posts_activity)
+ CoordinatorLayout coordinatorLayout;
@BindView(R.id.collapsing_toolbar_layout_account_posts_activity)
CollapsingToolbarLayout collapsingToolbarLayout;
@BindView(R.id.appbar_layout_account_posts_activity)
@@ -84,6 +87,8 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect
EventBus.getDefault().register(this);
+ applyCustomTheme();
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Window window = getWindow();
@@ -145,8 +150,15 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect
}
@Override
- protected void applyCustomTheme() {
+ protected CustomThemeWrapper getCustomThemeWrapper() {
+ return mCustomThemeWrapper;
+ }
+ @Override
+ protected void applyCustomTheme() {
+ int themeType = mCustomThemeWrapper.getThemeType();
+ coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor(themeType));
+ appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor(themeType));
}
private void getCurrentAccountAndInitializeFragment() {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountSavedThingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountSavedThingActivity.java
index 0b10698a..0606920c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountSavedThingActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/AccountSavedThingActivity.java
@@ -1,7 +1,6 @@
package ml.docilealligator.infinityforreddit.Activity;
import android.content.SharedPreferences;
-import android.content.res.Resources;
import android.os.Build;
import android.os.Bundle;
import android.view.KeyEvent;
@@ -13,6 +12,7 @@ import android.view.WindowManager;
import androidx.annotation.NonNull;
import androidx.appcompat.widget.Toolbar;
+import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
@@ -31,6 +31,7 @@ import javax.inject.Named;
import butterknife.BindView;
import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
+import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.Event.ChangeNSFWEvent;
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.Fragment.CommentsListingFragment;
@@ -49,6 +50,8 @@ public class AccountSavedThingActivity extends BaseActivity {
private static final String ACCOUNT_NAME_STATE = "ANS";
private static final String IS_IN_LAZY_MODE_STATE = "IILMS";
+ @BindView(R.id.coordinator_layout_account_saved_thing_activity)
+ CoordinatorLayout coordinatorLayout;
@BindView(R.id.collapsing_toolbar_layout_account_saved_thing_activity)
CollapsingToolbarLayout collapsingToolbarLayout;
@BindView(R.id.appbar_layout_account_saved_thing_activity)
@@ -67,6 +70,8 @@ public class AccountSavedThingActivity extends BaseActivity {
@Inject
@Named("default")
SharedPreferences mSharedPreferences;
+ @Inject
+ CustomThemeWrapper mCustomThemeWrapper;
private SectionsPagerAdapter sectionsPagerAdapter;
private Menu mMenu;
private AppBarLayout.LayoutParams params;
@@ -87,7 +92,7 @@ public class AccountSavedThingActivity extends BaseActivity {
EventBus.getDefault().register(this);
- Resources resources = getResources();
+ applyCustomTheme();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Window window = getWindow();
@@ -143,6 +148,19 @@ public class AccountSavedThingActivity extends BaseActivity {
return mSharedPreferences;
}
+ @Override
+ protected CustomThemeWrapper getCustomThemeWrapper() {
+ return mCustomThemeWrapper;
+ }
+
+ @Override
+ protected void applyCustomTheme() {
+ int themeType = mCustomThemeWrapper.getThemeType();
+ coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor(themeType));
+ appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor(themeType));
+ applyTabLayoutTheme(tabLayout, mCustomThemeWrapper, themeType);
+ }
+
private void getCurrentAccountAndInitializeViewPager() {
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
if (account == null) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/BaseActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/BaseActivity.java
index e937eedf..86a73107 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/BaseActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/BaseActivity.java
@@ -1,6 +1,7 @@
package ml.docilealligator.infinityforreddit.Activity;
import android.content.SharedPreferences;
+import android.content.res.ColorStateList;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Build;
@@ -15,14 +16,16 @@ import androidx.appcompat.app.AppCompatDelegate;
import androidx.appcompat.widget.Toolbar;
import com.google.android.material.appbar.AppBarLayout;
+import com.google.android.material.floatingactionbutton.FloatingActionButton;
+import com.google.android.material.tabs.TabLayout;
import ml.docilealligator.infinityforreddit.AppBarStateChangeListener;
import ml.docilealligator.infinityforreddit.ContentFontStyle;
+import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.FontStyle;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.TitleFontStyle;
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
-import ml.docilealligator.infinityforreddit.Utils.Utils;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM;
@@ -43,10 +46,10 @@ public abstract class BaseActivity extends AppCompatActivity {
SharedPreferences mSharedPreferences = getSharedPreferences();
boolean systemDefault = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q;
- int themeType = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.THEME_KEY, "2"));
+ int systemThemeType = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.THEME_KEY, "2"));
immersiveInterface = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O &&
mSharedPreferences.getBoolean(SharedPreferencesUtils.IMMERSIVE_INTERFACE_KEY, true);
- switch (themeType) {
+ switch (systemThemeType) {
case 0:
AppCompatDelegate.setDefaultNightMode(MODE_NIGHT_NO);
getTheme().applyStyle(R.style.Theme_Purple, true);
@@ -89,8 +92,11 @@ public abstract class BaseActivity extends AppCompatActivity {
getTheme().applyStyle(ContentFontStyle.valueOf(mSharedPreferences
.getString(SharedPreferencesUtils.CONTENT_FONT_SIZE_KEY, ContentFontStyle.Normal.name())).getResId(), true);
+ CustomThemeWrapper customThemeWrapper = getCustomThemeWrapper();
+ int themeType = customThemeWrapper.getThemeType();
Window window = getWindow();
View decorView = window.getDecorView();
+ window.setStatusBarColor(customThemeWrapper.getColorPrimaryDark(themeType));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
if (lightStatusbar) {
decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR | View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
@@ -105,7 +111,7 @@ public abstract class BaseActivity extends AppCompatActivity {
systemVisibilityToolbarCollapsed = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR | View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
}
}
- window.setNavigationBarColor(Utils.getAttributeColor(this, R.attr.navBarColor));
+ window.setNavigationBarColor(customThemeWrapper.getNavBarColor(themeType));
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (lightStatusbar) {
decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
@@ -117,7 +123,11 @@ public abstract class BaseActivity extends AppCompatActivity {
}
}
- public abstract SharedPreferences getSharedPreferences();
+ protected abstract SharedPreferences getSharedPreferences();
+
+ protected abstract CustomThemeWrapper getCustomThemeWrapper();
+
+ protected abstract void applyCustomTheme();
protected boolean isChangeStatusBarIconColor() {
return changeStatusBarIconColor;
@@ -167,9 +177,24 @@ public abstract class BaseActivity extends AppCompatActivity {
return 0;
}
- public void setTransparentStatusBarAfterToolbarCollapsed(boolean transparentStatusBarAfterToolbarCollapsed) {
- this.transparentStatusBarAfterToolbarCollapsed = transparentStatusBarAfterToolbarCollapsed;
+ protected void setTransparentStatusBarAfterToolbarCollapsed() {
+ this.transparentStatusBarAfterToolbarCollapsed = true;
}
- protected abstract void applyCustomTheme();
+ protected void applyTabLayoutTheme(TabLayout tabLayout, CustomThemeWrapper customThemeWrapper, int themeType) {
+ int toolbarAndTabBackgroundColor = customThemeWrapper.getToolbarAndTabBackgroundColor(themeType);
+ tabLayout.setBackgroundColor(toolbarAndTabBackgroundColor);
+ tabLayout.setSelectedTabIndicatorColor(customThemeWrapper.getTabLayoutWithCollapsedCollapsingToolbarTabIndicator(themeType));
+ tabLayout.setTabTextColors(customThemeWrapper.getTabLayoutWithCollapsedCollapsingToolbarTextColor(themeType),
+ customThemeWrapper.getTabLayoutWithCollapsedCollapsingToolbarTextColor(themeType));
+ }
+
+ protected void applyFABTheme(FloatingActionButton fab, CustomThemeWrapper customThemeWrapper, int themeType) {
+ fab.setBackgroundTintList(ColorStateList.valueOf(customThemeWrapper.getColorPrimaryLightTheme(themeType)));
+ fab.setImageTintList(ColorStateList.valueOf(customThemeWrapper.getFABIconColor(themeType)));
+ /*Drawable myFabSrc = getResources().getDrawable(R.drawable.ic_add_bottom_app_bar_24dp);
+ Drawable willBeWhite = myFabSrc.getConstantState().newDrawable();
+ willBeWhite.mutate().setColorFilter(Color.WHITE, PorterDuff.Mode.MULTIPLY);
+ fab.setImageDrawable(willBeWhite);*/
+ }
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CommentActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CommentActivity.java
index fd422e9e..27c2695e 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CommentActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CommentActivity.java
@@ -49,12 +49,12 @@ import io.noties.markwon.simple.ext.SimpleExtPlugin;
import io.noties.markwon.urlprocessor.UrlProcessorRelativeToAbsolute;
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
import ml.docilealligator.infinityforreddit.CommentData;
+import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.SendComment;
-import ml.docilealligator.infinityforreddit.Utils.Utils;
import retrofit2.Retrofit;
public class CommentActivity extends BaseActivity {
@@ -79,6 +79,8 @@ public class CommentActivity extends BaseActivity {
Toolbar toolbar;
@BindView(R.id.comment_parent_markwon_view_comment_activity)
TextView commentParentMarkwonView;
+ @BindView(R.id.divider_comment_activity)
+ View divider;
@BindView(R.id.content_markdown_view_comment_activity)
RecyclerView contentMarkdownRecyclerView;
@BindView(R.id.comment_edit_text_comment_activity)
@@ -91,6 +93,8 @@ public class CommentActivity extends BaseActivity {
@Inject
@Named("default")
SharedPreferences mSharedPreferences;
+ @Inject
+ CustomThemeWrapper mCustomThemeWrapper;
private boolean mNullAccessToken = false;
private String mAccessToken;
private String parentFullname;
@@ -98,6 +102,7 @@ public class CommentActivity extends BaseActivity {
private int parentPosition;
private boolean isSubmitting = false;
private boolean isReplying;
+ private int markdownColor;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -111,6 +116,8 @@ public class CommentActivity extends BaseActivity {
EventBus.getDefault().register(this);
+ applyCustomTheme();
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && isChangeStatusBarIconColor()) {
addOnOffsetChangedListener(appBarLayout);
}
@@ -155,7 +162,6 @@ public class CommentActivity extends BaseActivity {
if (parentBody != null && !parentBody.equals("")) {
contentMarkdownRecyclerView.setVisibility(View.VISIBLE);
contentMarkdownRecyclerView.setNestedScrollingEnabled(false);
- int markdownColor = Utils.getAttributeColor(this, R.attr.secondaryTextColor);
Markwon postBodyMarkwon = Markwon.builder(this)
.usePlugin(new AbstractMarkwonPlugin() {
@Override
@@ -219,6 +225,22 @@ public class CommentActivity extends BaseActivity {
return mSharedPreferences;
}
+ @Override
+ protected CustomThemeWrapper getCustomThemeWrapper() {
+ return mCustomThemeWrapper;
+ }
+
+ @Override
+ protected void applyCustomTheme() {
+ int themeType = mCustomThemeWrapper.getThemeType();
+ coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor(themeType));
+ appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor(themeType));
+ commentParentMarkwonView.setTextColor(mCustomThemeWrapper.getCommentColor(themeType));
+ divider.setBackgroundColor(mCustomThemeWrapper.getDividerColor(themeType));
+ commentEditText.setTextColor(mCustomThemeWrapper.getCommentColor(themeType));
+ markdownColor = mCustomThemeWrapper.getSecondaryTextColor(themeType);
+ }
+
private void getCurrentAccount() {
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
if (account == null) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CreateMultiRedditActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CreateMultiRedditActivity.java
index 61593cd9..464e69af 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CreateMultiRedditActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CreateMultiRedditActivity.java
@@ -6,6 +6,7 @@ import android.os.Build;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
+import android.view.View;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.Switch;
@@ -28,6 +29,7 @@ import javax.inject.Named;
import butterknife.BindView;
import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
+import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.MultiReddit.CreateMultiReddit;
import ml.docilealligator.infinityforreddit.MultiReddit.MultiRedditJSONModel;
@@ -52,10 +54,16 @@ public class CreateMultiRedditActivity extends BaseActivity {
Toolbar toolbar;
@BindView(R.id.multi_reddit_name_edit_text_create_multi_reddit_activity)
EditText nameEditText;
+ @BindView(R.id.divider_1_create_multi_reddit_activity)
+ View divider1;
@BindView(R.id.description_edit_text_create_multi_reddit_activity)
EditText descriptionEditText;
+ @BindView(R.id.divider_2_create_multi_reddit_activity)
+ View divider2;
@BindView(R.id.visibility_wrapper_linear_layout_create_multi_reddit_activity)
LinearLayout visibilityLinearLayout;
+ @BindView(R.id.visibility_text_view_create_multi_reddit_activity)
+ TextView visibilityTextView;
@BindView(R.id.visibility_switch_create_multi_reddit_activity)
Switch visibilitySwitch;
@BindView(R.id.select_subreddit_text_view_create_multi_reddit_activity)
@@ -68,6 +76,8 @@ public class CreateMultiRedditActivity extends BaseActivity {
@Inject
@Named("default")
SharedPreferences mSharedPreferences;
+ @Inject
+ CustomThemeWrapper mCustomThemeWrapper;
private boolean mNullAccessToken = false;
private String mAccessToken;
private String mAccountName;
@@ -82,6 +92,8 @@ public class CreateMultiRedditActivity extends BaseActivity {
ButterKnife.bind(this);
+ applyCustomTheme();
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && isChangeStatusBarIconColor()) {
addOnOffsetChangedListener(appBarLayout);
}
@@ -224,4 +236,23 @@ public class CreateMultiRedditActivity extends BaseActivity {
public SharedPreferences getSharedPreferences() {
return mSharedPreferences;
}
+
+ @Override
+ protected CustomThemeWrapper getCustomThemeWrapper() {
+ return mCustomThemeWrapper;
+ }
+
+ @Override
+ protected void applyCustomTheme() {
+ int themeType = mCustomThemeWrapper.getThemeType();
+ appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor(themeType));
+ int primaryTextColor = mCustomThemeWrapper.getPrimaryTextColor(themeType);
+ nameEditText.setTextColor(primaryTextColor);
+ int dividerColor = mCustomThemeWrapper.getDividerColor(themeType);
+ divider1.setBackgroundColor(dividerColor);
+ divider2.setBackgroundColor(dividerColor);
+ descriptionEditText.setTextColor(primaryTextColor);
+ visibilityTextView.setTextColor(primaryTextColor);
+ selectSubredditTextView.setTextColor(primaryTextColor);
+ }
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/EditCommentActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/EditCommentActivity.java
index b71dd151..de67e642 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/EditCommentActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/EditCommentActivity.java
@@ -30,6 +30,7 @@ import javax.inject.Named;
import butterknife.BindView;
import butterknife.ButterKnife;
+import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
@@ -57,7 +58,7 @@ public class EditCommentActivity extends BaseActivity {
AppBarLayout appBarLayout;
@BindView(R.id.toolbar_edit_comment_activity)
Toolbar toolbar;
- @BindView(R.id.post_text_content_edit_text_edit_comment_activity)
+ @BindView(R.id.comment_edit_text_edit_comment_activity)
EditText contentEditText;
@Inject
@Named("oauth")
@@ -65,6 +66,8 @@ public class EditCommentActivity extends BaseActivity {
@Inject
@Named("default")
SharedPreferences mSharedPreferences;
+ @Inject
+ CustomThemeWrapper mCustomThemeWrapper;
private String mFullName;
private String mAccessToken;
private String mCommentContent;
@@ -82,6 +85,8 @@ public class EditCommentActivity extends BaseActivity {
EventBus.getDefault().register(this);
+ applyCustomTheme();
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && isChangeStatusBarIconColor()) {
addOnOffsetChangedListener(appBarLayout);
}
@@ -107,6 +112,19 @@ public class EditCommentActivity extends BaseActivity {
}
@Override
+ protected CustomThemeWrapper getCustomThemeWrapper() {
+ return mCustomThemeWrapper;
+ }
+
+ @Override
+ protected void applyCustomTheme() {
+ int themeType = mCustomThemeWrapper.getThemeType();
+ coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor(themeType));
+ appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor(themeType));
+ contentEditText.setTextColor(mCustomThemeWrapper.getCommentColor(themeType));
+ }
+
+ @Override
protected void onPause() {
super.onPause();
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/EditPostActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/EditPostActivity.java
index fa0a3d74..cd9ac208 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/EditPostActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/EditPostActivity.java
@@ -7,6 +7,7 @@ import android.os.Build;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
+import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.TextView;
@@ -31,6 +32,7 @@ import javax.inject.Named;
import butterknife.BindView;
import butterknife.ButterKnife;
+import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
@@ -56,6 +58,8 @@ public class EditPostActivity extends BaseActivity {
Toolbar toolbar;
@BindView(R.id.post_title_text_view_edit_post_activity)
TextView titleTextView;
+ @BindView(R.id.divider_edit_post_activity)
+ View divider;
@BindView(R.id.post_text_content_edit_text_edit_post_activity)
EditText contentEditText;
@Inject
@@ -64,6 +68,8 @@ public class EditPostActivity extends BaseActivity {
@Inject
@Named("default")
SharedPreferences mSharedPreferences;
+ @Inject
+ CustomThemeWrapper mCustomThemeWrapper;
private String mFullName;
private String mAccessToken;
private String mPostContent;
@@ -81,6 +87,8 @@ public class EditPostActivity extends BaseActivity {
EventBus.getDefault().register(this);
+ applyCustomTheme();
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && isChangeStatusBarIconColor()) {
addOnOffsetChangedListener(appBarLayout);
}
@@ -107,6 +115,21 @@ public class EditPostActivity extends BaseActivity {
}
@Override
+ protected CustomThemeWrapper getCustomThemeWrapper() {
+ return mCustomThemeWrapper;
+ }
+
+ @Override
+ protected void applyCustomTheme() {
+ int themeType = mCustomThemeWrapper.getThemeType();
+ coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor(themeType));
+ appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor(themeType));
+ titleTextView.setTextColor(mCustomThemeWrapper.getPostTitleColor(themeType));
+ divider.setBackgroundColor(mCustomThemeWrapper.getPostTitleColor(themeType));
+ contentEditText.setTextColor(mCustomThemeWrapper.getPostContentColor(themeType));
+ }
+
+ @Override
protected void onPause() {
super.onPause();
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/FilteredThingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/FilteredThingActivity.java
index 66a9b154..791fbb9c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/FilteredThingActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/FilteredThingActivity.java
@@ -11,6 +11,7 @@ import android.view.WindowManager;
import androidx.annotation.NonNull;
import androidx.appcompat.widget.Toolbar;
+import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.fragment.app.Fragment;
import com.google.android.material.appbar.AppBarLayout;
@@ -25,6 +26,7 @@ import javax.inject.Named;
import butterknife.BindView;
import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
+import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.Fragment.PostFragment;
import ml.docilealligator.infinityforreddit.Fragment.PostLayoutBottomSheetFragment;
@@ -56,6 +58,8 @@ public class FilteredThingActivity extends BaseActivity implements SortTypeSelec
private static final String ACCESS_TOKEN_STATE = "ATS";
private static final String FRAGMENT_OUT_STATE = "FOS";
+ @BindView(R.id.coordinator_layout_filtered_thing_activity)
+ CoordinatorLayout coordinatorLayout;
@BindView(R.id.appbar_layout_filtered_posts_activity)
AppBarLayout appBarLayout;
@BindView(R.id.collapsing_toolbar_layout_filtered_posts_activity)
@@ -67,6 +71,8 @@ public class FilteredThingActivity extends BaseActivity implements SortTypeSelec
@Inject
@Named("default")
SharedPreferences mSharedPreferences;
+ @Inject
+ CustomThemeWrapper mCustomThemeWrapper;
private boolean isInLazyMode = false;
private boolean mNullAccessToken = false;
private String mAccessToken;
@@ -97,6 +103,8 @@ public class FilteredThingActivity extends BaseActivity implements SortTypeSelec
EventBus.getDefault().register(this);
+ applyCustomTheme();
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Window window = getWindow();
@@ -160,6 +168,18 @@ public class FilteredThingActivity extends BaseActivity implements SortTypeSelec
return mSharedPreferences;
}
+ @Override
+ protected CustomThemeWrapper getCustomThemeWrapper() {
+ return mCustomThemeWrapper;
+ }
+
+ @Override
+ protected void applyCustomTheme() {
+ int themeType = mCustomThemeWrapper.getThemeType();
+ coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor(themeType));
+ appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor(themeType));
+ }
+
private void getCurrentAccountAndBindView(int filter) {
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
if (account == null) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LinkResolverActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LinkResolverActivity.java
index b112ee47..4dd5afb7 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LinkResolverActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LinkResolverActivity.java
@@ -20,10 +20,10 @@ import java.util.List;
import javax.inject.Inject;
import javax.inject.Named;
+import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
-import ml.docilealligator.infinityforreddit.Utils.Utils;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY;
import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM;
@@ -47,6 +47,8 @@ public class LinkResolverActivity extends AppCompatActivity {
@Inject
@Named("default")
SharedPreferences mSharedPreferences;
+ @Inject
+ CustomThemeWrapper mCustomThemeWrapper;
public static Uri getRedditUriByPath(String path) {
return Uri.parse("https://www.reddit.com" + path);
@@ -237,7 +239,7 @@ public class LinkResolverActivity extends AppCompatActivity {
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
// add share action to menu list
builder.addDefaultShareMenuItem();
- builder.setToolbarColor(Utils.getAttributeColor(this, R.attr.colorPrimary));
+ builder.setToolbarColor(mCustomThemeWrapper.getColorPrimary(mCustomThemeWrapper.getThemeType()));
CustomTabsIntent customTabsIntent = builder.build();
customTabsIntent.intent.setPackage(resolveInfos.get(0).activityInfo.packageName);
if (uri.getScheme() == null) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LoginActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LoginActivity.java
index 212dbd0f..a6d7eaad 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LoginActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LoginActivity.java
@@ -15,6 +15,7 @@ import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.widget.Toolbar;
+import androidx.coordinatorlayout.widget.CoordinatorLayout;
import com.google.android.material.appbar.AppBarLayout;
@@ -30,6 +31,7 @@ import javax.inject.Named;
import butterknife.BindView;
import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.AsyncTask.ParseAndInsertNewAccountAsyncTask;
+import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.FetchMyInfo;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.ParseAndSaveAccountInfo;
@@ -44,10 +46,12 @@ import retrofit2.Retrofit;
public class LoginActivity extends BaseActivity {
- @BindView(R.id.toolbar_login_activity)
- Toolbar toolbar;
+ @BindView(R.id.coordinator_layout_login_activity)
+ CoordinatorLayout coordinatorLayout;
@BindView(R.id.appbar_layout_login_activity)
AppBarLayout appBarLayout;
+ @BindView(R.id.toolbar_login_activity)
+ Toolbar toolbar;
@BindView(R.id.webview_login_activity)
WebView webView;
@Inject
@@ -61,6 +65,8 @@ public class LoginActivity extends BaseActivity {
@Inject
@Named("default")
SharedPreferences mSharedPreferences;
+ @Inject
+ CustomThemeWrapper mCustomThemeWrapper;
private String authCode;
@Override
@@ -72,6 +78,8 @@ public class LoginActivity extends BaseActivity {
ButterKnife.bind(this);
+ applyCustomTheme();
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && isChangeStatusBarIconColor()) {
addOnOffsetChangedListener(appBarLayout);
}
@@ -208,6 +216,18 @@ public class LoginActivity extends BaseActivity {
}
@Override
+ protected CustomThemeWrapper getCustomThemeWrapper() {
+ return mCustomThemeWrapper;
+ }
+
+ @Override
+ protected void applyCustomTheme() {
+ int themeType = mCustomThemeWrapper.getThemeType();
+ coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor(themeType));
+ appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor(themeType));
+ }
+
+ @Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home) {
finish();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java
index b9c74256..5ae60914 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java
@@ -42,6 +42,7 @@ import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.google.android.material.bottomappbar.BottomAppBar;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
+import com.google.android.material.navigation.NavigationView;
import com.google.android.material.tabs.TabLayout;
import org.greenrobot.eventbus.EventBus;
@@ -61,6 +62,7 @@ import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask
import ml.docilealligator.infinityforreddit.AsyncTask.InsertSubscribedThingsAsyncTask;
import ml.docilealligator.infinityforreddit.AsyncTask.SwitchAccountAsyncTask;
import ml.docilealligator.infinityforreddit.AsyncTask.SwitchToAnonymousAccountAsyncTask;
+import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.Event.ChangeConfirmToExitEvent;
import ml.docilealligator.infinityforreddit.Event.ChangeLockBottomAppBarEvent;
import ml.docilealligator.infinityforreddit.Event.ChangeNSFWEvent;
@@ -116,6 +118,8 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
@BindView(R.id.drawer_layout)
DrawerLayout drawer;
+ @BindView(R.id.navigation_view_main_activity)
+ NavigationView navigationView;
@BindView(R.id.coordinator_layout_main_activity)
CoordinatorLayout coordinatorLayout;
@BindView(R.id.appbar_layout_main_activity)
@@ -154,6 +158,8 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
@Inject
@Named("default")
SharedPreferences mSharedPreferences;
+ @Inject
+ CustomThemeWrapper mCustomThemeWrapper;
private SectionsPagerAdapter sectionsPagerAdapter;
private AppBarLayout.LayoutParams params;
private PostTypeBottomSheetFragment postTypeBottomSheetFragment;
@@ -193,6 +199,8 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
EventBus.getDefault().register(this);
+ applyCustomTheme();
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Window window = getWindow();
@@ -273,6 +281,23 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
return mSharedPreferences;
}
+ @Override
+ protected CustomThemeWrapper getCustomThemeWrapper() {
+ return mCustomThemeWrapper;
+ }
+
+ @Override
+ protected void applyCustomTheme() {
+ int themeType = mCustomThemeWrapper.getThemeType();
+ int backgroundColor = mCustomThemeWrapper.getBackgroundColor(themeType);
+ drawer.setBackgroundColor(backgroundColor);
+ navigationView.setBackgroundColor(backgroundColor);
+ appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor(themeType));
+ applyTabLayoutTheme(tabLayout, mCustomThemeWrapper, themeType);
+ bottomNavigationView.setBackgroundColor(backgroundColor);
+ applyFABTheme(fab, mCustomThemeWrapper, themeType);
+ }
+
private void getCurrentAccountAndBindView() {
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
boolean enableNotification = mSharedPreferences.getBoolean(SharedPreferencesUtils.ENABLE_NOTIFICATION_KEY, true);
@@ -418,8 +443,9 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
}
boolean nsfwEnabled = mSharedPreferences.getBoolean(SharedPreferencesUtils.NSFW_KEY, false);
- adapter = new NavigationDrawerRecyclerViewAdapter(this, mAccountName, mProfileImageUrl,
- mBannerImageUrl, mKarma, nsfwEnabled, new NavigationDrawerRecyclerViewAdapter.ItemClickListener() {
+ adapter = new NavigationDrawerRecyclerViewAdapter(this, mCustomThemeWrapper, mAccountName,
+ mProfileImageUrl, mBannerImageUrl, mKarma, nsfwEnabled,
+ new NavigationDrawerRecyclerViewAdapter.ItemClickListener() {
@Override
public void onMenuClick(int stringId) {
Intent intent = null;
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MultiRedditListingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MultiRedditListingActivity.java
index 8080794e..90a66e8a 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MultiRedditListingActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MultiRedditListingActivity.java
@@ -15,6 +15,7 @@ import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.widget.Toolbar;
+import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
@@ -35,13 +36,13 @@ import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.Adapter.MultiRedditListingRecyclerViewAdapter;
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
import ml.docilealligator.infinityforreddit.AsyncTask.InsertMultiRedditAsyncTask;
+import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.MultiReddit.FetchMultiReddit;
import ml.docilealligator.infinityforreddit.MultiReddit.MultiReddit;
import ml.docilealligator.infinityforreddit.MultiReddit.MultiRedditViewModel;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
-import ml.docilealligator.infinityforreddit.Utils.Utils;
import retrofit2.Retrofit;
public class MultiRedditListingActivity extends BaseActivity {
@@ -51,6 +52,8 @@ public class MultiRedditListingActivity extends BaseActivity {
private static final String ACCESS_TOKEN_STATE = "ATS";
private static final String ACCOUNT_NAME_STATE = "ANS";
+ @BindView(R.id.coordinator_layout_multi_reddit_listing_activity)
+ CoordinatorLayout mCoordinatorLayout;
@BindView(R.id.appbar_layout_multi_reddit_listing_activity)
AppBarLayout mAppBarLayout;
@BindView(R.id.toolbar_multi_reddit_listing_activity)
@@ -75,6 +78,8 @@ public class MultiRedditListingActivity extends BaseActivity {
@Inject
@Named("oauth")
Retrofit mOauthRetrofit;
+ @Inject
+ CustomThemeWrapper mCustomThemeWrapper;
MultiRedditViewModel mMultiRedditViewModel;
private RequestManager mGlide;
@@ -92,6 +97,8 @@ public class MultiRedditListingActivity extends BaseActivity {
ButterKnife.bind(this);
+ applyCustomTheme();
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Window window = getWindow();
@@ -114,8 +121,6 @@ public class MultiRedditListingActivity extends BaseActivity {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mSwipeRefreshLayout.setOnRefreshListener(this::loadMultiReddits);
- mSwipeRefreshLayout.setProgressBackgroundColorSchemeColor(Utils.getAttributeColor(this, R.attr.cardViewBackgroundColor));
- mSwipeRefreshLayout.setColorSchemeColors(Utils.getAttributeColor(this, R.attr.colorAccent));
if (savedInstanceState != null) {
mInsertSuccess = savedInstanceState.getBoolean(INSERT_MULTI_REDDIT_STATE);
@@ -156,7 +161,7 @@ public class MultiRedditListingActivity extends BaseActivity {
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
MultiRedditListingRecyclerViewAdapter adapter = new MultiRedditListingRecyclerViewAdapter(this,
- mOauthRetrofit, mRedditDataRoomDatabase, mAccessToken, mAccountName);
+ mOauthRetrofit, mRedditDataRoomDatabase, mCustomThemeWrapper, mAccessToken, mAccountName);
mRecyclerView.setAdapter(adapter);
mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
@@ -240,4 +245,20 @@ public class MultiRedditListingActivity extends BaseActivity {
public SharedPreferences getSharedPreferences() {
return mSharedPreferences;
}
+
+ @Override
+ protected CustomThemeWrapper getCustomThemeWrapper() {
+ return mCustomThemeWrapper;
+ }
+
+ @Override
+ protected void applyCustomTheme() {
+ int themeType = mCustomThemeWrapper.getThemeType();
+ mCoordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor(themeType));
+ mAppBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor(themeType));
+ mSwipeRefreshLayout.setProgressBackgroundColorSchemeColor(mCustomThemeWrapper.getCardViewBackgroundColor(themeType));
+ mSwipeRefreshLayout.setColorSchemeColors(mCustomThemeWrapper.getColorAccent(themeType));
+ mErrorTextView.setTextColor(mCustomThemeWrapper.getSecondaryTextColor(themeType));
+ applyFABTheme(fab, mCustomThemeWrapper, themeType);
+ }
}
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 949b5428..e37a0269 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.ColorStateList;
import android.content.res.Resources;
import android.net.Uri;
import android.os.Build;
@@ -46,6 +47,7 @@ import butterknife.ButterKnife;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
import ml.docilealligator.infinityforreddit.AsyncTask.LoadSubredditIconAsyncTask;
+import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.Event.SubmitImagePostEvent;
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.Flair;
@@ -54,7 +56,6 @@ 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;
@@ -92,14 +93,20 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
TextView subredditNameTextView;
@BindView(R.id.rules_button_post_image_activity)
Button rulesButton;
+ @BindView(R.id.divider_1_post_image_activity)
+ View divider1;
@BindView(R.id.flair_custom_text_view_post_image_activity)
CustomTextView flairTextView;
@BindView(R.id.spoiler_custom_text_view_post_image_activity)
CustomTextView spoilerTextView;
@BindView(R.id.nsfw_custom_text_view_post_image_activity)
CustomTextView nsfwTextView;
+ @BindView(R.id.divider_2_post_image_activity)
+ View divider2;
@BindView(R.id.post_title_edit_text_post_image_activity)
EditText titleEditText;
+ @BindView(R.id.divider_3_post_image_activity)
+ View divider3;
@BindView(R.id.select_image_constraint_layout_post_image_activity)
ConstraintLayout constraintLayout;
@BindView(R.id.capture_fab_post_image_activity)
@@ -124,6 +131,8 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
@Inject
@Named("default")
SharedPreferences mSharedPreferences;
+ @Inject
+ CustomThemeWrapper mCustomThemeWrapper;
private boolean mNullAccessToken = false;
private String mAccessToken;
private String mAccountName;
@@ -159,6 +168,8 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
EventBus.getDefault().register(this);
+ applyCustomTheme();
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && isChangeStatusBarIconColor()) {
addOnOffsetChangedListener(appBarLayout);
}
@@ -170,11 +181,6 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
mPostingSnackbar = Snackbar.make(coordinatorLayout, R.string.posting, Snackbar.LENGTH_INDEFINITE);
- primaryTextColor = Utils.getAttributeColor(this, R.attr.primaryTextColor);
- 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) {
@@ -218,12 +224,15 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
if (flair != null) {
flairTextView.setText(flair.getText());
flairTextView.setBackgroundColor(flairColor);
+ flairTextView.setBorderColor(flairColor);
}
if (isSpoiler) {
spoilerTextView.setBackgroundColor(spoilerColor);
+ spoilerTextView.setBorderColor(spoilerColor);
}
if (isNSFW) {
nsfwTextView.setBackgroundColor(nsfwColor);
+ nsfwTextView.setBorderColor(nsfwColor);
}
} else {
getCurrentAccount();
@@ -291,6 +300,7 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
spoilerTextView.setOnClickListener(view -> {
if (!isSpoiler) {
spoilerTextView.setBackgroundColor(spoilerColor);
+ spoilerTextView.setBorderColor(spoilerColor);
isSpoiler = true;
} else {
spoilerTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
@@ -301,6 +311,7 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
nsfwTextView.setOnClickListener(view -> {
if (!isNSFW) {
nsfwTextView.setBackgroundColor(nsfwColor);
+ nsfwTextView.setBorderColor(nsfwColor);
isNSFW = true;
} else {
nsfwTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
@@ -345,6 +356,44 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
return mSharedPreferences;
}
+ @Override
+ protected CustomThemeWrapper getCustomThemeWrapper() {
+ return mCustomThemeWrapper;
+ }
+
+ @Override
+ protected void applyCustomTheme() {
+ int themeType = mCustomThemeWrapper.getThemeType();
+ coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor(themeType));
+ appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor(themeType));
+ rulesButton.setTextColor(mCustomThemeWrapper.getButtonTextColor(themeType));
+ rulesButton.setBackgroundTintList(ColorStateList.valueOf(mCustomThemeWrapper.getColorPrimaryLightTheme(themeType)));
+ int dividerColor = mCustomThemeWrapper.getDividerColor(themeType);
+ divider1.setBackgroundColor(dividerColor);
+ divider2.setBackgroundColor(dividerColor);
+ divider3.setBackgroundColor(dividerColor);
+ /*int flairColor = mCustomThemeWrapper.getFlairColor(themeType);
+ flairTextView.setBackgroundColor(flairColor);
+ flairTextView.setBorderColor(flairColor);
+ flairTextView.setTextColor(primaryTextColor);
+ int spoilerColor = mCustomThemeWrapper.getSpoilerColor(themeType);
+ spoilerTextView.setBackgroundColor(spoilerColor);
+ spoilerTextView.setBorderColor(spoilerColor);
+ spoilerTextView.setTextColor(primaryTextColor);
+ int nsfwColor = mCustomThemeWrapper.getNsfwColor(themeType);
+ nsfwTextView.setBackgroundColor(nsfwColor);
+ nsfwTextView.setBorderColor(nsfwColor);
+ nsfwTextView.setTextColor(primaryTextColor);*/
+ primaryTextColor = mCustomThemeWrapper.getPrimaryTextColor(themeType);
+ flairColor = mCustomThemeWrapper.getFlairColor(themeType);
+ spoilerColor = mCustomThemeWrapper.getSpoilerColor(themeType);
+ nsfwColor = mCustomThemeWrapper.getNsfwColor(themeType);
+ titleEditText.setTextColor(primaryTextColor);
+ applyFABTheme(captureFab, mCustomThemeWrapper, themeType);
+ applyFABTheme(selectFromLibraryFab, mCustomThemeWrapper, themeType);
+ selectAgainTextView.setTextColor(mCustomThemeWrapper.getColorAccent(themeType));
+ }
+
private void getCurrentAccount() {
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
if (account == null) {
@@ -554,6 +603,7 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
this.flair = flair;
flairTextView.setText(flair.getText());
flairTextView.setBackgroundColor(flairColor);
+ flairTextView.setBorderColor(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 dd9fee91..b9d64913 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.ColorStateList;
import android.content.res.Resources;
import android.os.Build;
import android.os.Bundle;
@@ -36,6 +37,7 @@ import butterknife.ButterKnife;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
import ml.docilealligator.infinityforreddit.AsyncTask.LoadSubredditIconAsyncTask;
+import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.Event.SubmitTextOrLinkPostEvent;
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.Flair;
@@ -45,7 +47,6 @@ 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;
@@ -80,6 +81,12 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
TextView subredditNameTextView;
@BindView(R.id.rules_button_post_link_activity)
Button rulesButton;
+ @BindView(R.id.divider_1_post_link_activity)
+ View divider1;
+ @BindView(R.id.divider_2_post_link_activity)
+ View divider2;
+ @BindView(R.id.divider_3_post_link_activity)
+ View divider3;
@BindView(R.id.flair_custom_text_view_post_link_activity)
CustomTextView flairTextView;
@BindView(R.id.spoiler_custom_text_view_post_link_activity)
@@ -89,7 +96,7 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
@BindView(R.id.post_title_edit_text_post_link_activity)
EditText titleEditText;
@BindView(R.id.post_link_edit_text_post_link_activity)
- EditText contentEditText;
+ EditText linkEditText;
@Inject
@Named("no_oauth")
Retrofit mRetrofit;
@@ -101,6 +108,8 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
@Inject
@Named("default")
SharedPreferences mSharedPreferences;
+ @Inject
+ CustomThemeWrapper mCustomThemeWrapper;
private boolean mNullAccessToken = false;
private String mAccessToken;
private String iconUrl;
@@ -134,6 +143,8 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
EventBus.getDefault().register(this);
+ applyCustomTheme();
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && isChangeStatusBarIconColor()) {
addOnOffsetChangedListener(appBarLayout);
}
@@ -145,11 +156,6 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
mPostingSnackbar = Snackbar.make(coordinatorLayout, R.string.posting, Snackbar.LENGTH_INDEFINITE);
- primaryTextColor = Utils.getAttributeColor(this, R.attr.primaryTextColor);
- 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) {
@@ -187,12 +193,15 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
if (flair != null) {
flairTextView.setText(flair.getText());
flairTextView.setBackgroundColor(flairColor);
+ flairTextView.setBorderColor(flairColor);
}
if (isSpoiler) {
spoilerTextView.setBackgroundColor(spoilerColor);
+ spoilerTextView.setBorderColor(spoilerColor);
}
if (isNSFW) {
nsfwTextView.setBackgroundColor(nsfwColor);
+ nsfwTextView.setBorderColor(nsfwColor);
}
} else {
getCurrentAccount();
@@ -215,7 +224,7 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
String link = getIntent().getStringExtra(EXTRA_LINK);
if (link != null) {
- contentEditText.setText(link);
+ linkEditText.setText(link);
}
}
@@ -261,6 +270,7 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
spoilerTextView.setOnClickListener(view -> {
if (!isSpoiler) {
spoilerTextView.setBackgroundColor(spoilerColor);
+ spoilerTextView.setBorderColor(spoilerColor);
isSpoiler = true;
} else {
spoilerTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
@@ -271,6 +281,7 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
nsfwTextView.setOnClickListener(view -> {
if (!isNSFW) {
nsfwTextView.setBackgroundColor(nsfwColor);
+ nsfwTextView.setBorderColor(nsfwColor);
isNSFW = true;
} else {
nsfwTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
@@ -284,6 +295,42 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
return mSharedPreferences;
}
+ @Override
+ protected CustomThemeWrapper getCustomThemeWrapper() {
+ return mCustomThemeWrapper;
+ }
+
+ @Override
+ protected void applyCustomTheme() {
+ int themeType = mCustomThemeWrapper.getThemeType();
+ coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor(themeType));
+ appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor(themeType));
+ rulesButton.setTextColor(mCustomThemeWrapper.getButtonTextColor(themeType));
+ rulesButton.setBackgroundTintList(ColorStateList.valueOf(mCustomThemeWrapper.getColorPrimaryLightTheme(themeType)));
+ int dividerColor = mCustomThemeWrapper.getDividerColor(themeType);
+ divider1.setBackgroundColor(dividerColor);
+ divider2.setBackgroundColor(dividerColor);
+ divider3.setBackgroundColor(dividerColor);
+ /*int flairColor = mCustomThemeWrapper.getFlairColor(themeType);
+ flairTextView.setBackgroundColor(flairColor);
+ flairTextView.setBorderColor(flairColor);
+ flairTextView.setTextColor(primaryTextColor);
+ int spoilerColor = mCustomThemeWrapper.getSpoilerColor(themeType);
+ spoilerTextView.setBackgroundColor(spoilerColor);
+ spoilerTextView.setBorderColor(spoilerColor);
+ spoilerTextView.setTextColor(primaryTextColor);
+ int nsfwColor = mCustomThemeWrapper.getNsfwColor(themeType);
+ nsfwTextView.setBackgroundColor(nsfwColor);
+ nsfwTextView.setBorderColor(nsfwColor);
+ nsfwTextView.setTextColor(primaryTextColor);*/
+ primaryTextColor = mCustomThemeWrapper.getPrimaryTextColor(themeType);
+ flairColor = mCustomThemeWrapper.getFlairColor(themeType);
+ spoilerColor = mCustomThemeWrapper.getSpoilerColor(themeType);
+ nsfwColor = mCustomThemeWrapper.getNsfwColor(themeType);
+ titleEditText.setTextColor(primaryTextColor);
+ linkEditText.setTextColor(primaryTextColor);
+ }
+
private void getCurrentAccount() {
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
if (account == null) {
@@ -344,7 +391,7 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
promptAlertDialog(R.string.exit_when_submit, R.string.exit_when_submit_post_detail);
return true;
} else {
- if (!titleEditText.getText().toString().equals("") || !contentEditText.getText().toString().equals("")) {
+ if (!titleEditText.getText().toString().equals("") || !linkEditText.getText().toString().equals("")) {
promptAlertDialog(R.string.discard, R.string.discard_detail);
return true;
}
@@ -362,7 +409,7 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
return true;
}
- if (contentEditText.getText() == null || contentEditText.getText().toString().equals("")) {
+ if (linkEditText.getText() == null || linkEditText.getText().toString().equals("")) {
Snackbar.make(coordinatorLayout, R.string.link_required, Snackbar.LENGTH_SHORT).show();
return true;
}
@@ -385,7 +432,7 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
intent.putExtra(SubmitPostService.EXTRA_ACCESS_TOKEN, mAccessToken);
intent.putExtra(SubmitPostService.EXTRA_SUBREDDIT_NAME, subredditName);
intent.putExtra(SubmitPostService.EXTRA_TITLE, titleEditText.getText().toString());
- intent.putExtra(SubmitPostService.EXTRA_CONTENT, contentEditText.getText().toString());
+ intent.putExtra(SubmitPostService.EXTRA_CONTENT, linkEditText.getText().toString());
intent.putExtra(SubmitPostService.EXTRA_KIND, RedditUtils.KIND_LINK);
intent.putExtra(SubmitPostService.EXTRA_FLAIR, flair);
intent.putExtra(SubmitPostService.EXTRA_IS_SPOILER, isSpoiler);
@@ -404,7 +451,7 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
if (isPosting) {
promptAlertDialog(R.string.exit_when_submit, R.string.exit_when_submit_post_detail);
} else {
- if (!titleEditText.getText().toString().equals("") || !contentEditText.getText().toString().equals("")) {
+ if (!titleEditText.getText().toString().equals("") || !linkEditText.getText().toString().equals("")) {
promptAlertDialog(R.string.discard, R.string.discard_detail);
} else {
finish();
@@ -461,6 +508,7 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
this.flair = flair;
flairTextView.setText(flair.getText());
flairTextView.setBackgroundColor(flairColor);
+ flairTextView.setBorderColor(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 c310b3c3..87903ab1 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.ColorStateList;
import android.content.res.Resources;
import android.os.Build;
import android.os.Bundle;
@@ -36,6 +37,7 @@ import butterknife.ButterKnife;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
import ml.docilealligator.infinityforreddit.AsyncTask.LoadSubredditIconAsyncTask;
+import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.Event.SubmitTextOrLinkPostEvent;
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.Flair;
@@ -45,7 +47,6 @@ 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;
@@ -80,14 +81,20 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
TextView subredditNameTextView;
@BindView(R.id.rules_button_post_text_activity)
Button rulesButton;
+ @BindView(R.id.divider_1_post_text_activity)
+ View divider1;
@BindView(R.id.flair_custom_text_view_post_text_activity)
CustomTextView flairTextView;
@BindView(R.id.spoiler_custom_text_view_post_text_activity)
CustomTextView spoilerTextView;
@BindView(R.id.nsfw_custom_text_view_post_text_activity)
CustomTextView nsfwTextView;
+ @BindView(R.id.divider_2_post_text_activity)
+ View divider2;
@BindView(R.id.post_title_edit_text_post_text_activity)
EditText titleEditText;
+ @BindView(R.id.divider_3_post_text_activity)
+ View divider3;
@BindView(R.id.post_text_content_edit_text_post_text_activity)
EditText contentEditText;
@Inject
@@ -101,6 +108,8 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
@Inject
@Named("default")
SharedPreferences mSharedPreferences;
+ @Inject
+ CustomThemeWrapper mCustomThemeWrapper;
private boolean mNullAccessToken = false;
private String mAccessToken;
private String iconUrl;
@@ -134,6 +143,8 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
EventBus.getDefault().register(this);
+ applyCustomTheme();
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && isChangeStatusBarIconColor()) {
addOnOffsetChangedListener(appBarLayout);
}
@@ -145,11 +156,6 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
mPostingSnackbar = Snackbar.make(coordinatorLayout, R.string.posting, Snackbar.LENGTH_INDEFINITE);
- primaryTextColor = Utils.getAttributeColor(this, R.attr.primaryTextColor);
- 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) {
@@ -187,12 +193,15 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
if (flair != null) {
flairTextView.setText(flair.getText());
flairTextView.setBackgroundColor(flairColor);
+ flairTextView.setBorderColor(flairColor);
}
if (isSpoiler) {
spoilerTextView.setBackgroundColor(spoilerColor);
+ spoilerTextView.setBorderColor(spoilerColor);
}
if (isNSFW) {
nsfwTextView.setBackgroundColor(nsfwColor);
+ nsfwTextView.setBorderColor(nsfwColor);
}
} else {
getCurrentAccount();
@@ -265,6 +274,7 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
spoilerTextView.setOnClickListener(view -> {
if (!isSpoiler) {
spoilerTextView.setBackgroundColor(spoilerColor);
+ spoilerTextView.setBorderColor(spoilerColor);
isSpoiler = true;
} else {
spoilerTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
@@ -275,6 +285,7 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
nsfwTextView.setOnClickListener(view -> {
if (!isNSFW) {
nsfwTextView.setBackgroundColor(nsfwColor);
+ nsfwTextView.setBorderColor(nsfwColor);
isNSFW = true;
} else {
nsfwTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
@@ -288,6 +299,42 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
return mSharedPreferences;
}
+ @Override
+ protected CustomThemeWrapper getCustomThemeWrapper() {
+ return mCustomThemeWrapper;
+ }
+
+ @Override
+ protected void applyCustomTheme() {
+ int themeType = mCustomThemeWrapper.getThemeType();
+ coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor(themeType));
+ appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor(themeType));
+ rulesButton.setTextColor(mCustomThemeWrapper.getButtonTextColor(themeType));
+ rulesButton.setBackgroundTintList(ColorStateList.valueOf(mCustomThemeWrapper.getColorPrimaryLightTheme(themeType)));
+ int dividerColor = mCustomThemeWrapper.getDividerColor(themeType);
+ divider1.setBackgroundColor(dividerColor);
+ divider2.setBackgroundColor(dividerColor);
+ divider3.setBackgroundColor(dividerColor);
+ /*int flairColor = mCustomThemeWrapper.getFlairColor(themeType);
+ flairTextView.setBackgroundColor(flairColor);
+ flairTextView.setBorderColor(flairColor);
+ flairTextView.setTextColor(primaryTextColor);
+ int spoilerColor = mCustomThemeWrapper.getSpoilerColor(themeType);
+ spoilerTextView.setBackgroundColor(spoilerColor);
+ spoilerTextView.setBorderColor(spoilerColor);
+ spoilerTextView.setTextColor(primaryTextColor);
+ int nsfwColor = mCustomThemeWrapper.getNsfwColor(themeType);
+ nsfwTextView.setBackgroundColor(nsfwColor);
+ nsfwTextView.setBorderColor(nsfwColor);
+ nsfwTextView.setTextColor(primaryTextColor);*/
+ primaryTextColor = mCustomThemeWrapper.getPrimaryTextColor(themeType);
+ flairColor = mCustomThemeWrapper.getFlairColor(themeType);
+ spoilerColor = mCustomThemeWrapper.getSpoilerColor(themeType);
+ nsfwColor = mCustomThemeWrapper.getNsfwColor(themeType);
+ titleEditText.setTextColor(primaryTextColor);
+ contentEditText.setTextColor(primaryTextColor);
+ }
+
private void getCurrentAccount() {
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
if (account == null) {
@@ -461,6 +508,7 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
this.flair = flair;
flairTextView.setText(flair.getText());
flairTextView.setBackgroundColor(flairColor);
+ flairTextView.setBorderColor(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 d73f9704..d7853720 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.ColorStateList;
import android.content.res.Resources;
import android.net.Uri;
import android.os.Build;
@@ -48,6 +49,7 @@ import butterknife.ButterKnife;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
import ml.docilealligator.infinityforreddit.AsyncTask.LoadSubredditIconAsyncTask;
+import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.Event.SubmitVideoPostEvent;
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.Flair;
@@ -56,7 +58,6 @@ 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;
@@ -94,14 +95,20 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
TextView subredditNameTextView;
@BindView(R.id.rules_button_post_video_activity)
Button rulesButton;
+ @BindView(R.id.divider_1_post_video_activity)
+ View divider1;
@BindView(R.id.flair_custom_text_view_post_video_activity)
CustomTextView flairTextView;
@BindView(R.id.spoiler_custom_text_view_post_video_activity)
CustomTextView spoilerTextView;
@BindView(R.id.nsfw_custom_text_view_post_video_activity)
CustomTextView nsfwTextView;
+ @BindView(R.id.divider_2_post_video_activity)
+ View divider2;
@BindView(R.id.post_title_edit_text_post_video_activity)
EditText titleEditText;
+ @BindView(R.id.divider_3_post_video_activity)
+ View divider3;
@BindView(R.id.select_video_constraint_layout_post_video_activity)
ConstraintLayout constraintLayout;
@BindView(R.id.capture_fab_post_video_activity)
@@ -129,6 +136,8 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
@Inject
@Named("default")
SharedPreferences mSharedPreferences;
+ @Inject
+ CustomThemeWrapper mCustomThemeWrapper;
private boolean mNullAccessToken = false;
private String mAccessToken;
private String mAccountName;
@@ -167,6 +176,8 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
EventBus.getDefault().register(this);
+ applyCustomTheme();
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && isChangeStatusBarIconColor()) {
addOnOffsetChangedListener(appBarLayout);
}
@@ -184,11 +195,6 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
mPostingSnackbar = Snackbar.make(coordinatorLayout, R.string.posting, Snackbar.LENGTH_INDEFINITE);
- primaryTextColor = Utils.getAttributeColor(this, R.attr.primaryTextColor);
- 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) {
@@ -231,12 +237,15 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
if (flair != null) {
flairTextView.setText(flair.getText());
flairTextView.setBackgroundColor(flairColor);
+ flairTextView.setBorderColor(flairColor);
}
if (isSpoiler) {
spoilerTextView.setBackgroundColor(spoilerColor);
+ spoilerTextView.setBorderColor(spoilerColor);
}
if (isNSFW) {
nsfwTextView.setBackgroundColor(nsfwColor);
+ nsfwTextView.setBorderColor(nsfwColor);
}
} else {
getCurrentAccount();
@@ -304,6 +313,7 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
spoilerTextView.setOnClickListener(view -> {
if (!isSpoiler) {
spoilerTextView.setBackgroundColor(spoilerColor);
+ spoilerTextView.setBorderColor(spoilerColor);
isSpoiler = true;
} else {
spoilerTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
@@ -314,6 +324,7 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
nsfwTextView.setOnClickListener(view -> {
if (!isNSFW) {
nsfwTextView.setBackgroundColor(nsfwColor);
+ nsfwTextView.setBorderColor(nsfwColor);
isNSFW = true;
} else {
nsfwTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
@@ -350,6 +361,44 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
return mSharedPreferences;
}
+ @Override
+ protected CustomThemeWrapper getCustomThemeWrapper() {
+ return mCustomThemeWrapper;
+ }
+
+ @Override
+ protected void applyCustomTheme() {
+ int themeType = mCustomThemeWrapper.getThemeType();
+ coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor(themeType));
+ appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor(themeType));
+ rulesButton.setTextColor(mCustomThemeWrapper.getButtonTextColor(themeType));
+ rulesButton.setBackgroundTintList(ColorStateList.valueOf(mCustomThemeWrapper.getColorPrimaryLightTheme(themeType)));
+ int dividerColor = mCustomThemeWrapper.getDividerColor(themeType);
+ divider1.setBackgroundColor(dividerColor);
+ divider2.setBackgroundColor(dividerColor);
+ divider3.setBackgroundColor(dividerColor);
+ /*int flairColor = mCustomThemeWrapper.getFlairColor(themeType);
+ flairTextView.setBackgroundColor(flairColor);
+ flairTextView.setBorderColor(flairColor);
+ flairTextView.setTextColor(primaryTextColor);
+ int spoilerColor = mCustomThemeWrapper.getSpoilerColor(themeType);
+ spoilerTextView.setBackgroundColor(spoilerColor);
+ spoilerTextView.setBorderColor(spoilerColor);
+ spoilerTextView.setTextColor(primaryTextColor);
+ int nsfwColor = mCustomThemeWrapper.getNsfwColor(themeType);
+ nsfwTextView.setBackgroundColor(nsfwColor);
+ nsfwTextView.setBorderColor(nsfwColor);
+ nsfwTextView.setTextColor(primaryTextColor);*/
+ primaryTextColor = mCustomThemeWrapper.getPrimaryTextColor(themeType);
+ flairColor = mCustomThemeWrapper.getFlairColor(themeType);
+ spoilerColor = mCustomThemeWrapper.getSpoilerColor(themeType);
+ nsfwColor = mCustomThemeWrapper.getNsfwColor(themeType);
+ titleEditText.setTextColor(primaryTextColor);
+ applyFABTheme(captureFab, mCustomThemeWrapper, themeType);
+ applyFABTheme(selectFromLibraryFab, mCustomThemeWrapper, themeType);
+ selectAgainTextView.setTextColor(mCustomThemeWrapper.getColorAccent(themeType));
+ }
+
private void getCurrentAccount() {
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
if (account == null) {
@@ -582,6 +631,7 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
this.flair = flair;
flairTextView.setText(flair.getText());
flairTextView.setBackgroundColor(flairColor);
+ flairTextView.setBorderColor(flairColor);
}
@Subscribe
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/RulesActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/RulesActivity.java
index 826debd6..fb337711 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/RulesActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/RulesActivity.java
@@ -13,6 +13,7 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.appcompat.widget.Toolbar;
+import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
@@ -32,6 +33,7 @@ import javax.inject.Named;
import butterknife.BindView;
import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.Adapter.RulesRecyclerViewAdapter;
+import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
@@ -48,6 +50,8 @@ public class RulesActivity extends BaseActivity {
static final String EXTRA_SUBREDDIT_NAME = "ESN";
+ @BindView(R.id.coordinator_layout_rules_activity)
+ CoordinatorLayout coordinatorLayout;
@BindView(R.id.appbar_layout_rules_activity)
AppBarLayout appBarLayout;
@BindView(R.id.toolbar_rules_activity)
@@ -64,6 +68,8 @@ public class RulesActivity extends BaseActivity {
@Inject
@Named("default")
SharedPreferences mSharedPreferences;
+ @Inject
+ CustomThemeWrapper mCustomThemeWrapper;
private String mSubredditName;
private RulesRecyclerViewAdapter mAdapter;
@@ -79,6 +85,8 @@ public class RulesActivity extends BaseActivity {
EventBus.getDefault().register(this);
+ applyCustomTheme();
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Window window = getWindow();
@@ -103,7 +111,7 @@ public class RulesActivity extends BaseActivity {
mSubredditName = getIntent().getExtras().getString(EXTRA_SUBREDDIT_NAME);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
- mAdapter = new RulesRecyclerViewAdapter(this);
+ mAdapter = new RulesRecyclerViewAdapter(this, mCustomThemeWrapper);
recyclerView.setAdapter(mAdapter);
fetchRules();
@@ -114,6 +122,19 @@ public class RulesActivity extends BaseActivity {
return mSharedPreferences;
}
+ @Override
+ protected CustomThemeWrapper getCustomThemeWrapper() {
+ return mCustomThemeWrapper;
+ }
+
+ @Override
+ protected void applyCustomTheme() {
+ int themeType = mCustomThemeWrapper.getThemeType();
+ coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor(themeType));
+ appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor(themeType));
+ errorTextView.setTextColor(mCustomThemeWrapper.getSecondaryTextColor(themeType));
+ }
+
private void fetchRules() {
progressBar.setVisibility(View.VISIBLE);
errorTextView.setVisibility(View.GONE);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchActivity.java
index 58716b61..d0900491 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchActivity.java
@@ -4,6 +4,7 @@ import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
+import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
@@ -15,8 +16,10 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.Toolbar;
+import androidx.coordinatorlayout.widget.CoordinatorLayout;
import com.ferfalk.simplesearchview.SimpleSearchView;
+import com.google.android.material.appbar.AppBarLayout;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
@@ -26,6 +29,7 @@ import javax.inject.Named;
import butterknife.BindView;
import butterknife.ButterKnife;
+import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
@@ -45,17 +49,25 @@ public class SearchActivity extends BaseActivity {
private static final int SUBREDDIT_SELECTION_REQUEST_CODE = 0;
private static final int SUBREDDIT_SEARCH_REQUEST_CODE = 1;
+ @BindView(R.id.coordinator_layout_search_activity)
+ CoordinatorLayout coordinatorLayout;
+ @BindView(R.id.appbar_layout_search_activity)
+ AppBarLayout appBarLayout;
@BindView(R.id.toolbar)
Toolbar toolbar;
@BindView(R.id.search_view_search_activity)
SimpleSearchView simpleSearchView;
@BindView(R.id.subreddit_name_relative_layout_search_activity)
RelativeLayout subredditNameRelativeLayout;
+ @BindView(R.id.search_in_text_view_search_activity)
+ TextView searchInTextView;
@BindView(R.id.subreddit_name_text_view_search_activity)
TextView subredditNameTextView;
@Inject
@Named("default")
SharedPreferences mSharedPreferences;
+ @Inject
+ CustomThemeWrapper mCustomThemeWrapper;
private String query;
private String subredditName;
private boolean subredditIsUser;
@@ -72,6 +84,8 @@ public class SearchActivity extends BaseActivity {
EventBus.getDefault().register(this);
+ applyCustomTheme();
+
setSupportActionBar(toolbar);
boolean searchOnlySubreddits = getIntent().getBooleanExtra(EXTRA_SEARCH_ONLY_SUBREDDITS, false);
@@ -169,6 +183,21 @@ public class SearchActivity extends BaseActivity {
}
@Override
+ protected CustomThemeWrapper getCustomThemeWrapper() {
+ return mCustomThemeWrapper;
+ }
+
+ @Override
+ protected void applyCustomTheme() {
+ int themeType = mCustomThemeWrapper.getThemeType();
+ coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor(themeType));
+ appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor(themeType));
+ simpleSearchView.setSearchBackground(new ColorDrawable(mCustomThemeWrapper.getColorPrimary(themeType)));
+ searchInTextView.setTextColor(mCustomThemeWrapper.getColorAccent(themeType));
+ subredditNameTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor(themeType));
+ }
+
+ @Override
protected void onStart() {
super.onStart();
simpleSearchView.showSearch(false);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchResultActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchResultActivity.java
index f21c6515..fb2bd7f0 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchResultActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchResultActivity.java
@@ -13,6 +13,7 @@ import android.view.WindowManager;
import androidx.annotation.NonNull;
import androidx.appcompat.widget.Toolbar;
+import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
@@ -30,6 +31,7 @@ import javax.inject.Named;
import butterknife.BindView;
import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
+import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.Event.ChangeNSFWEvent;
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.Fragment.PostFragment;
@@ -56,6 +58,8 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
private static final String NULL_ACCESS_TOKEN_STATE = "NATS";
private static final String ACCESS_TOKEN_STATE = "ATS";
private static final String ACCOUNT_NAME_STATE = "ANS";
+ @BindView(R.id.coordinator_layout_search_result_activity)
+ CoordinatorLayout coordinatorLayout;
@BindView(R.id.appbar_layout_search_result_activity)
AppBarLayout appBarLayout;
@BindView(R.id.toolbar_search_result_activity)
@@ -69,6 +73,8 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
@Inject
@Named("default")
SharedPreferences mSharedPreferences;
+ @Inject
+ CustomThemeWrapper mCustomThemeWrapper;
private boolean mNullAccessToken = false;
private String mAccessToken;
private String mAccountName;
@@ -92,6 +98,8 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
EventBus.getDefault().register(this);
+ applyCustomTheme();
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Window window = getWindow();
@@ -156,6 +164,19 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
return mSharedPreferences;
}
+ @Override
+ protected CustomThemeWrapper getCustomThemeWrapper() {
+ return mCustomThemeWrapper;
+ }
+
+ @Override
+ protected void applyCustomTheme() {
+ int themeType = mCustomThemeWrapper.getThemeType();
+ coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor(themeType));
+ appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor(themeType));
+ applyTabLayoutTheme(tabLayout, mCustomThemeWrapper, themeType);
+ }
+
private void getCurrentAccountAndInitializeViewPager() {
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
if (account == null) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchSubredditsResultActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchSubredditsResultActivity.java
index ba1ba5c9..8801f126 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchSubredditsResultActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SearchSubredditsResultActivity.java
@@ -11,6 +11,7 @@ import android.view.WindowManager;
import androidx.annotation.NonNull;
import androidx.appcompat.widget.Toolbar;
+import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.fragment.app.Fragment;
import com.google.android.material.appbar.AppBarLayout;
@@ -24,6 +25,7 @@ import javax.inject.Named;
import butterknife.BindView;
import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
+import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.Fragment.SubredditListingFragment;
import ml.docilealligator.infinityforreddit.Infinity;
@@ -41,6 +43,8 @@ public class SearchSubredditsResultActivity extends BaseActivity {
private static final String ACCOUNT_NAME_STATE = "ANS";
private static final String FRAGMENT_OUT_STATE = "FOS";
+ @BindView(R.id.coordinator_layout_search_subreddits_result_activity)
+ CoordinatorLayout coordinatorLayout;
@BindView(R.id.appbar_layout_search_subreddits_result_activity)
AppBarLayout appBarLayout;
@BindView(R.id.toolbar_search_subreddits_result_activity)
@@ -51,6 +55,8 @@ public class SearchSubredditsResultActivity extends BaseActivity {
@Inject
@Named("default")
SharedPreferences mSharedPreferences;
+ @Inject
+ CustomThemeWrapper mCustomThemeWrapper;
private boolean mNullAccessToken = false;
private String mAccessToken;
private String mAccountName;
@@ -67,6 +73,8 @@ public class SearchSubredditsResultActivity extends BaseActivity {
EventBus.getDefault().register(this);
+ applyCustomTheme();
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Window window = getWindow();
@@ -105,6 +113,18 @@ public class SearchSubredditsResultActivity extends BaseActivity {
return mSharedPreferences;
}
+ @Override
+ protected CustomThemeWrapper getCustomThemeWrapper() {
+ return mCustomThemeWrapper;
+ }
+
+ @Override
+ protected void applyCustomTheme() {
+ int themeType = mCustomThemeWrapper.getThemeType();
+ coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor(themeType));
+ appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor(themeType));
+ }
+
private void getCurrentAccountAndInitializeFragment(String query) {
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
if (account == null) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SettingsActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SettingsActivity.java
index 81b16bef..84f6e15d 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SettingsActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SettingsActivity.java
@@ -7,6 +7,7 @@ import android.view.MenuItem;
import androidx.annotation.NonNull;
import androidx.appcompat.widget.Toolbar;
+import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.fragment.app.Fragment;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
@@ -18,6 +19,7 @@ import javax.inject.Named;
import butterknife.BindView;
import butterknife.ButterKnife;
+import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.Settings.AboutPreferenceFragment;
@@ -29,6 +31,8 @@ public class SettingsActivity extends BaseActivity implements
private static final String TITLE_STATE = "TS";
+ @BindView(R.id.coordinator_layout_settings_activity)
+ CoordinatorLayout coordinatorLayout;
@BindView(R.id.appbar_layout_settings_activity)
AppBarLayout appBarLayout;
@BindView(R.id.toolbar_settings_activity)
@@ -37,6 +41,8 @@ public class SettingsActivity extends BaseActivity implements
@Inject
@Named("default")
SharedPreferences mSharedPreferences;
+ @Inject
+ CustomThemeWrapper mCustomThemeWrapper;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -48,6 +54,8 @@ public class SettingsActivity extends BaseActivity implements
ButterKnife.bind(this);
+ applyCustomTheme();
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && isChangeStatusBarIconColor()) {
addOnOffsetChangedListener(appBarLayout);
}
@@ -80,6 +88,18 @@ public class SettingsActivity extends BaseActivity implements
}
@Override
+ protected CustomThemeWrapper getCustomThemeWrapper() {
+ return mCustomThemeWrapper;
+ }
+
+ @Override
+ protected void applyCustomTheme() {
+ int themeType = mCustomThemeWrapper.getThemeType();
+ coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor(themeType));
+ appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor(themeType));
+ }
+
+ @Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
if (item.getItemId() == android.R.id.home) {
onBackPressed();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditMultiselectionActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditMultiselectionActivity.java
index 3be8274c..84db99aa 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditMultiselectionActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditMultiselectionActivity.java
@@ -11,11 +11,13 @@ import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.LinearLayout;
+import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.Toolbar;
+import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
@@ -34,6 +36,7 @@ import butterknife.BindView;
import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.Adapter.SubredditMultiselectionRecyclerViewAdapter;
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
+import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
@@ -56,6 +59,8 @@ public class SubredditMultiselectionActivity extends BaseActivity {
private static final String SELECTED_SUBSCRIBED_SUBREDDITS_STATE = "SSSS";
private static final String SELECTED_OTHER_SUBREDDITS_STATE = "SOSS";
+ @BindView(R.id.coordinator_layout_subreddits_multiselection_activity)
+ CoordinatorLayout mCoordinatorLayout;
@BindView(R.id.appbar_layout_subreddits_multiselection_activity)
AppBarLayout mAppBarLayout;
@BindView(R.id.toolbar_subscribed_subreddits_multiselection_activity)
@@ -68,6 +73,8 @@ public class SubredditMultiselectionActivity extends BaseActivity {
LinearLayout mLinearLayout;
@BindView(R.id.no_subscriptions_image_view_subscribed_subreddits_multiselection_activity)
ImageView mImageView;
+ @BindView(R.id.error_text_view_subscribed_subreddits_multiselection_activity)
+ TextView mErrorTextView;
@Inject
@Named("oauth")
Retrofit mOauthRetrofit;
@@ -76,6 +83,8 @@ public class SubredditMultiselectionActivity extends BaseActivity {
@Inject
@Named("default")
SharedPreferences mSharedPreferences;
+ @Inject
+ CustomThemeWrapper mCustomThemeWrapper;
private boolean mNullAccessToken = false;
private String mAccessToken;
private String mAccountName;
@@ -90,6 +99,8 @@ public class SubredditMultiselectionActivity extends BaseActivity {
ButterKnife.bind(this);
+ applyCustomTheme();
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Window window = getWindow();
@@ -151,8 +162,8 @@ public class SubredditMultiselectionActivity extends BaseActivity {
private void bindView(ArrayList<SubredditWithSelection> selectedSubscribedSubreddits,
ArrayList<SubredditWithSelection> otherSubreddits) {
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
- mAdapter = new SubredditMultiselectionRecyclerViewAdapter(this, selectedSubscribedSubreddits,
- otherSubreddits);
+ mAdapter = new SubredditMultiselectionRecyclerViewAdapter(this, mCustomThemeWrapper,
+ selectedSubscribedSubreddits, otherSubreddits);
mRecyclerView.setAdapter(mAdapter);
mSubscribedSubredditViewModel = new ViewModelProvider(this,
@@ -232,4 +243,17 @@ public class SubredditMultiselectionActivity extends BaseActivity {
public SharedPreferences getSharedPreferences() {
return mSharedPreferences;
}
+
+ @Override
+ protected CustomThemeWrapper getCustomThemeWrapper() {
+ return mCustomThemeWrapper;
+ }
+
+ @Override
+ protected void applyCustomTheme() {
+ int themeType = mCustomThemeWrapper.getThemeType();
+ mCoordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor(themeType));
+ mAppBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor(themeType));
+ mErrorTextView.setTextColor(mCustomThemeWrapper.getSecondaryTextColor(themeType));
+ }
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditSelectionActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditSelectionActivity.java
index ee9efb95..fe4c0b70 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditSelectionActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubredditSelectionActivity.java
@@ -13,6 +13,7 @@ import android.view.WindowManager;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.Toolbar;
+import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.fragment.app.Fragment;
import com.google.android.material.appbar.AppBarLayout;
@@ -29,6 +30,7 @@ import butterknife.BindView;
import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
import ml.docilealligator.infinityforreddit.AsyncTask.InsertSubscribedThingsAsyncTask;
+import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.FetchSubscribedThing;
import ml.docilealligator.infinityforreddit.Fragment.SubscribedSubredditsListingFragment;
@@ -55,6 +57,8 @@ public class SubredditSelectionActivity extends BaseActivity {
private static final String ACCOUNT_PROFILE_IMAGE_URL = "APIU";
private static final String FRAGMENT_OUT_STATE = "FOS";
+ @BindView(R.id.coordinator_layout_subreddit_selection_activity)
+ CoordinatorLayout coordinatorLayout;
@BindView(R.id.appbar_layout_subreddit_selection_activity)
AppBarLayout appBarLayout;
@BindView(R.id.toolbar_subreddit_selection_activity)
@@ -67,6 +71,8 @@ public class SubredditSelectionActivity extends BaseActivity {
@Inject
@Named("default")
SharedPreferences mSharedPreferences;
+ @Inject
+ CustomThemeWrapper mCustomThemeWrapper;
private boolean mNullAccessToken = false;
private String mAccessToken;
private String mAccountName;
@@ -86,6 +92,8 @@ public class SubredditSelectionActivity extends BaseActivity {
EventBus.getDefault().register(this);
+ applyCustomTheme();
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Window window = getWindow();
@@ -127,6 +135,18 @@ public class SubredditSelectionActivity extends BaseActivity {
return mSharedPreferences;
}
+ @Override
+ protected CustomThemeWrapper getCustomThemeWrapper() {
+ return mCustomThemeWrapper;
+ }
+
+ @Override
+ protected void applyCustomTheme() {
+ int themeType = mCustomThemeWrapper.getThemeType();
+ coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor(themeType));
+ appBarLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor(themeType));
+ }
+
private void getCurrentAccountAndBindView() {
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
if (account == null) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubscribedThingListingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubscribedThingListingActivity.java
index d7da38ef..d5d15dd0 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubscribedThingListingActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/SubscribedThingListingActivity.java
@@ -11,6 +11,7 @@ import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.widget.Toolbar;
+import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
@@ -31,6 +32,7 @@ import butterknife.BindView;
import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
import ml.docilealligator.infinityforreddit.AsyncTask.InsertSubscribedThingsAsyncTask;
+import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.FetchSubscribedThing;
import ml.docilealligator.infinityforreddit.Fragment.FollowedUsersListingFragment;
@@ -51,6 +53,8 @@ public class SubscribedThingListingActivity extends BaseActivity {
private static final String ACCESS_TOKEN_STATE = "ATS";
private static final String ACCOUNT_NAME_STATE = "ANS";
+ @BindView(R.id.coordinator_layout_subscribed_thing_listing_activity)
+ CoordinatorLayout coordinatorLayout;
@BindView(R.id.appbar_layout_subscribed_thing_listing_activity)
AppBarLayout appBarLayout;
@BindView(R.id.toolbar_subscribed_thing_listing_activity)
@@ -67,6 +71,8 @@ public class SubscribedThingListingActivity extends BaseActivity {
@Inject
@Named("default")
SharedPreferences mSharedPreferences;
+ @Inject
+ CustomThemeWrapper mCustomThemeWrapper;
private boolean mNullAccessToken = false;
private String mAccessToken;
private String mAccountName;
@@ -85,6 +91,8 @@ public class SubscribedThingListingActivity extends BaseActivity {
EventBus.getDefault().register(this);
+ applyCustomTheme();
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Window window = getWindow();
@@ -121,6 +129,19 @@ public class SubscribedThingListingActivity extends BaseActivity {
return mSharedPreferences;
}
+ @Override
+ protected CustomThemeWrapper getCustomThemeWrapper() {
+ return mCustomThemeWrapper;
+ }
+
+ @Override
+ protected void applyCustomTheme() {
+ int themeType = mCustomThemeWrapper.getThemeType();
+ coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor(themeType));
+ appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor(themeType));
+ applyTabLayoutTheme(tabLayout, mCustomThemeWrapper, themeType);
+ }
+
private void getCurrentAccountAndInitializeViewPager() {
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
if (account == null) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewMessageActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewMessageActivity.java
index c765f863..a13eef1d 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewMessageActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewMessageActivity.java
@@ -1,7 +1,6 @@
package ml.docilealligator.infinityforreddit.Activity;
import android.content.SharedPreferences;
-import android.content.res.Resources;
import android.os.Build;
import android.os.Bundle;
import android.view.Menu;
@@ -16,6 +15,7 @@ import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.widget.Toolbar;
+import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
@@ -38,6 +38,7 @@ import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.Adapter.MessageRecyclerViewAdapter;
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
import ml.docilealligator.infinityforreddit.AsyncTask.SwitchAccountAsyncTask;
+import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.FetchMessages;
import ml.docilealligator.infinityforreddit.Infinity;
@@ -45,7 +46,6 @@ import ml.docilealligator.infinityforreddit.MessageViewModel;
import ml.docilealligator.infinityforreddit.NetworkState;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
-import ml.docilealligator.infinityforreddit.Utils.Utils;
import retrofit2.Retrofit;
public class ViewMessageActivity extends BaseActivity {
@@ -56,10 +56,12 @@ public class ViewMessageActivity extends BaseActivity {
private static final String ACCESS_TOKEN_STATE = "ATS";
private static final String NEW_ACCOUNT_NAME_STATE = "NANS";
+ @BindView(R.id.coordinator_layout_view_message_activity)
+ CoordinatorLayout mCoordinatorLayout;
@BindView(R.id.collapsing_toolbar_layout_view_message_activity)
CollapsingToolbarLayout collapsingToolbarLayout;
@BindView(R.id.appbar_layout_view_message_activity)
- AppBarLayout appBarLayout;
+ AppBarLayout mAppBarLayout;
@BindView(R.id.toolbar_view_message_activity)
Toolbar toolbar;
@BindView(R.id.swipe_refresh_layout_view_message_activity)
@@ -81,6 +83,8 @@ public class ViewMessageActivity extends BaseActivity {
@Inject
@Named("default")
SharedPreferences mSharedPreferences;
+ @Inject
+ CustomThemeWrapper mCustomThemeWrapper;
private boolean mNullAccessToken = false;
private String mAccessToken;
private String mNewAccountName;
@@ -99,15 +103,15 @@ public class ViewMessageActivity extends BaseActivity {
EventBus.getDefault().register(this);
- mGlide = Glide.with(this);
+ applyCustomTheme();
- Resources resources = getResources();
+ mGlide = Glide.with(this);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Window window = getWindow();
if (isChangeStatusBarIconColor()) {
- addOnOffsetChangedListener(appBarLayout);
+ addOnOffsetChangedListener(mAppBarLayout);
}
if (isImmersiveInterface()) {
@@ -145,6 +149,21 @@ public class ViewMessageActivity extends BaseActivity {
return mSharedPreferences;
}
+ @Override
+ protected CustomThemeWrapper getCustomThemeWrapper() {
+ return mCustomThemeWrapper;
+ }
+
+ @Override
+ protected void applyCustomTheme() {
+ int themeType = mCustomThemeWrapper.getThemeType();
+ mCoordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor(themeType));
+ mAppBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor(themeType));
+ mSwipeRefreshLayout.setProgressBackgroundColorSchemeColor(mCustomThemeWrapper.getCardViewBackgroundColor(themeType));
+ mSwipeRefreshLayout.setColorSchemeColors(mCustomThemeWrapper.getColorAccent(themeType));
+ mFetchMessageInfoTextView.setTextColor(mCustomThemeWrapper.getSecondaryTextColor(themeType));
+ }
+
private void getCurrentAccountAndFetchMessage() {
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
if (mNewAccountName != null) {
@@ -179,8 +198,8 @@ public class ViewMessageActivity extends BaseActivity {
}
private void bindView() {
- mAdapter = new MessageRecyclerViewAdapter(this, mOauthRetrofit, mAccessToken,
- () -> mMessageViewModel.retryLoadingMore());
+ mAdapter = new MessageRecyclerViewAdapter(this, mOauthRetrofit, mCustomThemeWrapper,
+ mAccessToken, () -> mMessageViewModel.retryLoadingMore());
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
mRecyclerView.setLayoutManager(layoutManager);
mRecyclerView.setAdapter(mAdapter);
@@ -225,8 +244,6 @@ public class ViewMessageActivity extends BaseActivity {
});
mSwipeRefreshLayout.setOnRefreshListener(this::onRefresh);
- mSwipeRefreshLayout.setProgressBackgroundColorSchemeColor(Utils.getAttributeColor(this, R.attr.cardViewBackgroundColor));
- mSwipeRefreshLayout.setColorSchemeColors(Utils.getAttributeColor(this, R.attr.colorAccent));
}
private void showErrorView(int stringResId) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewMultiRedditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewMultiRedditDetailActivity.java
index 2cd68c10..94a40c85 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewMultiRedditDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewMultiRedditDetailActivity.java
@@ -2,7 +2,6 @@ package ml.docilealligator.infinityforreddit.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
-import android.content.res.Resources;
import android.os.Build;
import android.os.Bundle;
import android.view.Menu;
@@ -13,6 +12,7 @@ import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.widget.Toolbar;
+import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.fragment.app.Fragment;
import com.google.android.material.appbar.AppBarLayout;
@@ -25,6 +25,7 @@ import javax.inject.Named;
import butterknife.BindView;
import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
+import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.Fragment.PostFragment;
import ml.docilealligator.infinityforreddit.Fragment.PostLayoutBottomSheetFragment;
import ml.docilealligator.infinityforreddit.Fragment.SortTimeBottomSheetFragment;
@@ -53,6 +54,8 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
private static final String ACCESS_TOKEN_STATE = "ATS";
private static final String ACCOUNT_NAME_STATE = "ANS";
+ @BindView(R.id.coordinator_layout_view_multi_reddit_detail_activity)
+ CoordinatorLayout coordinatorLayout;
@BindView(R.id.appbar_layout_view_multi_reddit_detail_activity)
AppBarLayout appBarLayout;
@BindView(R.id.collapsing_toolbar_layout_view_multi_reddit_detail_activity)
@@ -70,6 +73,8 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
@Inject
@Named("default")
SharedPreferences mSharedPreferences;
+ @Inject
+ CustomThemeWrapper mCustomThemeWrapper;
private boolean mNullAccessToken = false;
private String mAccessToken;
private String mAccountName;
@@ -90,7 +95,7 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
ButterKnife.bind(this);
- Resources resources = getResources();
+ applyCustomTheme();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Window window = getWindow();
@@ -310,4 +315,16 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
public SharedPreferences getSharedPreferences() {
return mSharedPreferences;
}
+
+ @Override
+ protected CustomThemeWrapper getCustomThemeWrapper() {
+ return mCustomThemeWrapper;
+ }
+
+ @Override
+ protected void applyCustomTheme() {
+ int themeType = mCustomThemeWrapper.getThemeType();
+ coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor(themeType));
+ appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor(themeType));
+ }
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java
index 230e6a2a..9437b2de 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java
@@ -52,6 +52,7 @@ import ml.docilealligator.infinityforreddit.Adapter.CommentAndPostRecyclerViewAd
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
import ml.docilealligator.infinityforreddit.AsyncTask.SwitchAccountAsyncTask;
import ml.docilealligator.infinityforreddit.CommentData;
+import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.DeleteThing;
import ml.docilealligator.infinityforreddit.Event.ChangeNSFWBlurEvent;
import ml.docilealligator.infinityforreddit.Event.ChangeSpoilerBlurEvent;
@@ -77,7 +78,6 @@ import ml.docilealligator.infinityforreddit.SortType;
import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback;
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
-import ml.docilealligator.infinityforreddit.Utils.Utils;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
@@ -130,7 +130,7 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
@BindView(R.id.coordinator_layout_view_post_detail)
CoordinatorLayout mCoordinatorLayout;
@BindView(R.id.appbar_layout_view_post_detail_activity)
- AppBarLayout appBarLayout;
+ AppBarLayout mAppBarLayout;
@BindView(R.id.toolbar_view_post_detail_activity)
Toolbar toolbar;
@BindView(R.id.swipe_refresh_layout_view_post_detail_activity)
@@ -156,6 +156,8 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
@Inject
@Named("default")
SharedPreferences mSharedPreferences;
+ @Inject
+ CustomThemeWrapper mCustomThemeWrapper;
private RequestManager mGlide;
private Locale mLocale;
private Menu mMenu;
@@ -195,6 +197,8 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
EventBus.getDefault().register(this);
+ applyCustomTheme();
+
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK_FROM_POST_DETAIL, true)) {
mSlidrInterface = Slidr.attach(this);
}
@@ -203,7 +207,7 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
Window window = getWindow();
if (isChangeStatusBarIconColor()) {
- addOnOffsetChangedListener(appBarLayout);
+ addOnOffsetChangedListener(mAppBarLayout);
}
if (isImmersiveInterface()) {
@@ -320,8 +324,6 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
}
mSwipeRefreshLayout.setOnRefreshListener(() -> refresh(true, true));
- mSwipeRefreshLayout.setProgressBackgroundColorSchemeColor(Utils.getAttributeColor(this, R.attr.cardViewBackgroundColor));
- mSwipeRefreshLayout.setColorSchemeColors(Utils.getAttributeColor(this, R.attr.colorAccent));
mSmoothScroller = new LinearSmoothScroller(this) {
@Override
@@ -359,6 +361,22 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
return mSharedPreferences;
}
+ @Override
+ protected CustomThemeWrapper getCustomThemeWrapper() {
+ return mCustomThemeWrapper;
+ }
+
+ @Override
+ protected void applyCustomTheme() {
+ int themeType = mCustomThemeWrapper.getThemeType();
+ mCoordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor(themeType));
+ mAppBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor(themeType));
+ mSwipeRefreshLayout.setProgressBackgroundColorSchemeColor(mCustomThemeWrapper.getCardViewBackgroundColor(themeType));
+ mSwipeRefreshLayout.setColorSchemeColors(mCustomThemeWrapper.getColorAccent(themeType));
+ mFetchPostInfoTextView.setTextColor(mCustomThemeWrapper.getSecondaryTextColor(themeType));
+ applyFABTheme(fab, mCustomThemeWrapper, themeType);
+ }
+
private void getCurrentAccountAndBindView() {
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
if (mNewAccountName != null) {
@@ -473,11 +491,11 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
mMenu.findItem(R.id.action_view_crosspost_parent_view_post_detail_activity).setVisible(mPost.getCrosspostParentId() != null);
}
- mAdapter = new CommentAndPostRecyclerViewAdapter(ViewPostDetailActivity.this, mRetrofit,
- mOauthRetrofit, mRedditDataRoomDatabase, mGlide, mAccessToken, mAccountName, mPost,
- mLocale, mSingleCommentId, isSingleCommentThreadMode, mNeedBlurNsfw, mNeedBlurSpoiler,
- mVoteButtonsOnTheRight, mShowElapsedTime, mExpandChildren, mShowCommentDivider,
- mShowAbsoluteNumberOfVotes,
+ mAdapter = new CommentAndPostRecyclerViewAdapter(ViewPostDetailActivity.this,
+ mCustomThemeWrapper, mRetrofit, mOauthRetrofit, mRedditDataRoomDatabase, mGlide,
+ mAccessToken, mAccountName, mPost, mLocale, mSingleCommentId, isSingleCommentThreadMode,
+ mNeedBlurNsfw, mNeedBlurSpoiler, mVoteButtonsOnTheRight, mShowElapsedTime,
+ mExpandChildren, mShowCommentDivider, mShowAbsoluteNumberOfVotes,
new CommentAndPostRecyclerViewAdapter.CommentRecyclerViewAdapterCallback() {
@Override
public void updatePost(Post post) {
@@ -597,7 +615,7 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
}
mAdapter = new CommentAndPostRecyclerViewAdapter(ViewPostDetailActivity.this,
- mRetrofit, mOauthRetrofit, mRedditDataRoomDatabase, mGlide,
+ mCustomThemeWrapper, mRetrofit, mOauthRetrofit, mRedditDataRoomDatabase, mGlide,
mAccessToken, mAccountName, mPost, mLocale, mSingleCommentId,
isSingleCommentThreadMode, mNeedBlurNsfw, mNeedBlurSpoiler,
mVoteButtonsOnTheRight, mShowElapsedTime, mExpandChildren, mShowCommentDivider,
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSidebarActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSidebarActivity.java
index 4955689b..c2679877 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSidebarActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSidebarActivity.java
@@ -2,7 +2,6 @@ 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;
@@ -19,6 +18,7 @@ import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.widget.Toolbar;
+import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
@@ -44,24 +44,26 @@ import io.noties.markwon.recycler.table.TableEntryPlugin;
import io.noties.markwon.simple.ext.SimpleExtPlugin;
import io.noties.markwon.urlprocessor.UrlProcessorRelativeToAbsolute;
import ml.docilealligator.infinityforreddit.AsyncTask.InsertSubredditDataAsyncTask;
+import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.FetchSubredditData;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditData;
import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditViewModel;
-import ml.docilealligator.infinityforreddit.Utils.Utils;
import retrofit2.Retrofit;
public class ViewSidebarActivity extends BaseActivity {
public static final String EXTRA_SUBREDDIT_NAME = "ESN";
+ @BindView(R.id.coordinator_layout_view_sidebar_activity)
+ CoordinatorLayout coordinatorLayout;
@BindView(R.id.appbar_layout_view_sidebar_activity)
AppBarLayout appBarLayout;
@BindView(R.id.toolbar_view_sidebar_activity)
Toolbar toolbar;
@BindView(R.id.swipe_refresh_layout_view_sidebar_activity)
- SwipeRefreshLayout mSwipeRefreshLayout;
+ SwipeRefreshLayout swipeRefreshLayout;
@BindView(R.id.markdown_recycler_view_view_sidebar_activity)
RecyclerView markdownRecyclerView;
@Inject
@@ -72,8 +74,11 @@ public class ViewSidebarActivity extends BaseActivity {
@Inject
@Named("default")
SharedPreferences mSharedPreferences;
+ @Inject
+ CustomThemeWrapper mCustomThemeWrapper;
private String subredditName;
private SubredditViewModel mSubredditViewModel;
+ private int markdownColor;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -83,7 +88,7 @@ public class ViewSidebarActivity extends BaseActivity {
ButterKnife.bind(this);
- Resources resources = getResources();
+ applyCustomTheme();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Window window = getWindow();
@@ -101,7 +106,7 @@ public class ViewSidebarActivity extends BaseActivity {
int px = (int) TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP,
16,
- resources.getDisplayMetrics()
+ getResources().getDisplayMetrics()
);
markdownRecyclerView.setPadding(px, px, px, navBarHeight);
}
@@ -119,7 +124,6 @@ public class ViewSidebarActivity extends BaseActivity {
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
- int markdownColor = Utils.getAttributeColor(this, R.attr.secondaryTextColor);
Markwon markwon = Markwon.builder(this)
.usePlugin(new AbstractMarkwonPlugin() {
@Override
@@ -172,23 +176,21 @@ public class ViewSidebarActivity extends BaseActivity {
}
});
- mSwipeRefreshLayout.setOnRefreshListener(this::fetchSubredditData);
- mSwipeRefreshLayout.setProgressBackgroundColorSchemeColor(Utils.getAttributeColor(this, R.attr.cardViewBackgroundColor));
- mSwipeRefreshLayout.setColorSchemeColors(Utils.getAttributeColor(this, R.attr.colorAccent));
+ swipeRefreshLayout.setOnRefreshListener(this::fetchSubredditData);
}
private void fetchSubredditData() {
- mSwipeRefreshLayout.setRefreshing(true);
+ swipeRefreshLayout.setRefreshing(true);
FetchSubredditData.fetchSubredditData(mRetrofit, subredditName, new FetchSubredditData.FetchSubredditDataListener() {
@Override
public void onFetchSubredditDataSuccess(SubredditData subredditData, int nCurrentOnlineSubscribers) {
- mSwipeRefreshLayout.setRefreshing(false);
- new InsertSubredditDataAsyncTask(mRedditDataRoomDatabase, subredditData, () -> mSwipeRefreshLayout.setRefreshing(false)).execute();
+ swipeRefreshLayout.setRefreshing(false);
+ new InsertSubredditDataAsyncTask(mRedditDataRoomDatabase, subredditData, () -> swipeRefreshLayout.setRefreshing(false)).execute();
}
@Override
public void onFetchSubredditDataFail() {
- mSwipeRefreshLayout.setRefreshing(false);
+ swipeRefreshLayout.setRefreshing(false);
Toast.makeText(ViewSidebarActivity.this, R.string.cannot_fetch_sidebar, Toast.LENGTH_SHORT).show();
}
});
@@ -206,7 +208,7 @@ public class ViewSidebarActivity extends BaseActivity {
finish();
return true;
} else if (item.getItemId() == R.id.action_refresh_view_sidebar_activity) {
- if (!mSwipeRefreshLayout.isRefreshing()) {
+ if (!swipeRefreshLayout.isRefreshing()) {
fetchSubredditData();
}
return true;
@@ -218,4 +220,19 @@ public class ViewSidebarActivity extends BaseActivity {
public SharedPreferences getSharedPreferences() {
return mSharedPreferences;
}
+
+ @Override
+ protected CustomThemeWrapper getCustomThemeWrapper() {
+ return mCustomThemeWrapper;
+ }
+
+ @Override
+ protected void applyCustomTheme() {
+ int themeType = mCustomThemeWrapper.getThemeType();
+ coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor(themeType));
+ appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor(themeType));
+ swipeRefreshLayout.setProgressBackgroundColorSchemeColor(mCustomThemeWrapper.getCardViewBackgroundColor(themeType));
+ swipeRefreshLayout.setColorSchemeColors(mCustomThemeWrapper.getColorAccent(themeType));
+ markdownColor = mCustomThemeWrapper.getSecondaryTextColor(themeType);
+ }
}
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 6d3b3cbe..1ccea602 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewSubredditDetailActivity.java
@@ -46,6 +46,7 @@ import ml.docilealligator.infinityforreddit.AsyncTask.CheckIsSubscribedToSubredd
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
import ml.docilealligator.infinityforreddit.AsyncTask.InsertSubredditDataAsyncTask;
import ml.docilealligator.infinityforreddit.AsyncTask.SwitchAccountAsyncTask;
+import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.Event.ChangeNSFWEvent;
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.FetchSubredditData;
@@ -66,7 +67,6 @@ 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;
@@ -93,6 +93,8 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
AppBarLayout appBarLayout;
@BindView(R.id.collapsing_toolbar_layout_view_subreddit_detail_activity)
CollapsingToolbarLayout collapsingToolbarLayout;
+ @BindView(R.id.toolbar_linear_layout_view_subreddit_detail_activity)
+ LinearLayout linearLayout;
@BindView(R.id.toolbar)
Toolbar toolbar;
@BindView(R.id.banner_image_view_view_subreddit_detail_activity)
@@ -134,6 +136,8 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
@Inject
@Named("default")
SharedPreferences mSharedPreferences;
+ @Inject
+ CustomThemeWrapper mCustomThemeWrapper;
private boolean mNullAccessToken = false;
private String mAccessToken;
private String mAccountName;
@@ -156,11 +160,13 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
private SortTimeBottomSheetFragment sortTimeBottomSheetFragment;
private PostLayoutBottomSheetFragment postLayoutBottomSheetFragment;
private SubredditViewModel mSubredditViewModel;
+ private int unsubscribedColor;
+ private int subscribedColor;
@Override
protected void onCreate(Bundle savedInstanceState) {
((Infinity) getApplication()).getAppComponent().inject(this);
- setTransparentStatusBarAfterToolbarCollapsed(true);
+ setTransparentStatusBarAfterToolbarCollapsed();
super.onCreate(savedInstanceState);
@@ -170,6 +176,8 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
EventBus.getDefault().register(this);
+ applyCustomTheme();
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Window window = getWindow();
@@ -329,6 +337,30 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
return mSharedPreferences;
}
+ @Override
+ protected CustomThemeWrapper getCustomThemeWrapper() {
+ return mCustomThemeWrapper;
+ }
+
+ @Override
+ protected void applyCustomTheme() {
+ int themeType = mCustomThemeWrapper.getThemeType();
+ int backgroundColor = mCustomThemeWrapper.getBackgroundColor(themeType);
+ coordinatorLayout.setBackgroundColor(backgroundColor);
+ appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor(themeType));
+ linearLayout.setBackgroundColor(backgroundColor);
+ subredditNameTextView.setTextColor(mCustomThemeWrapper.getSubreddit(themeType));
+ subscribeSubredditChip.setTextColor(mCustomThemeWrapper.getChipTextColor(themeType));
+ int primaryTextColor = mCustomThemeWrapper.getPrimaryTextColor(themeType);
+ nSubscribersTextView.setTextColor(primaryTextColor);
+ nOnlineSubscribersTextView.setTextColor(primaryTextColor);
+ descriptionTextView.setTextColor(primaryTextColor);
+ bottomNavigationView.setBackgroundColor(backgroundColor);
+ applyFABTheme(fab, mCustomThemeWrapper, themeType);
+ unsubscribedColor = mCustomThemeWrapper.getUnsubscribed(themeType);
+ subscribedColor = mCustomThemeWrapper.getSubscribed(themeType);
+ }
+
private void getCurrentAccountAndBindView() {
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
if (mNewAccountName != null) {
@@ -436,9 +468,6 @@ 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();
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 e15d805b..bc75db0a 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewUserDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewUserDetailActivity.java
@@ -49,6 +49,7 @@ import ml.docilealligator.infinityforreddit.AppBarStateChangeListener;
import ml.docilealligator.infinityforreddit.AsyncTask.CheckIsFollowingUserAsyncTask;
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
import ml.docilealligator.infinityforreddit.AsyncTask.SwitchAccountAsyncTask;
+import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.DeleteThing;
import ml.docilealligator.infinityforreddit.Event.ChangeNSFWEvent;
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
@@ -72,7 +73,6 @@ 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;
@@ -124,6 +124,8 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
@Inject
@Named("default")
SharedPreferences mSharedPreferences;
+ @Inject
+ CustomThemeWrapper mCustomThemeWrapper;
private SectionsPagerAdapter sectionsPagerAdapter;
private SubscribedUserDao subscribedUserDao;
private RequestManager glide;
@@ -146,6 +148,8 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
private int collapsedTabTextColor;
private int collapsedTabBackgroundColor;
private int collapsedTabIndicatorColor;
+ private int unsubscribedColor;
+ private int subscribedColor;
private boolean showToast = false;
private String mMessageFullname;
private String mNewAccountName;
@@ -153,7 +157,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
@Override
protected void onCreate(Bundle savedInstanceState) {
((Infinity) getApplication()).getAppComponent().inject(this);
- setTransparentStatusBarAfterToolbarCollapsed(true);
+ setTransparentStatusBarAfterToolbarCollapsed();
super.onCreate(savedInstanceState);
@@ -163,6 +167,8 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
EventBus.getDefault().register(this);
+ applyCustomTheme();
+
username = getIntent().getStringExtra(EXTRA_USER_NAME_KEY);
if (savedInstanceState == null) {
@@ -199,13 +205,6 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
setSupportActionBar(toolbar);
- 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.M) {
Window window = getWindow();
if (isImmersiveInterface()) {
@@ -307,9 +306,6 @@ 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 -> {
@@ -406,6 +402,30 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
return mSharedPreferences;
}
+ @Override
+ protected CustomThemeWrapper getCustomThemeWrapper() {
+ return mCustomThemeWrapper;
+ }
+
+ @Override
+ protected void applyCustomTheme() {
+ int themeType = mCustomThemeWrapper.getThemeType();
+ coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor(themeType));
+ appBarLayout.setBackgroundColor(mCustomThemeWrapper.getToolbarAndTabBackgroundColor(themeType));
+ expandedTabTextColor = mCustomThemeWrapper.getTabLayoutWithExpandedCollapsingToolbarTextColor(themeType);
+ expandedTabIndicatorColor = mCustomThemeWrapper.getTabLayoutWithExpandedCollapsingToolbarTabIndicator(themeType);
+ expandedTabBackgroundColor = mCustomThemeWrapper.getTabLayoutWithExpandedCollapsingToolbarTabBackground(themeType);
+ collapsedTabTextColor = mCustomThemeWrapper.getTabLayoutWithCollapsedCollapsingToolbarTextColor(themeType);
+ collapsedTabIndicatorColor = mCustomThemeWrapper.getTabLayoutWithCollapsedCollapsingToolbarTabIndicator(themeType);
+ collapsedTabBackgroundColor = mCustomThemeWrapper.getTabLayoutWithCollapsedCollapsingToolbarTabBackground(themeType);
+ unsubscribedColor = mCustomThemeWrapper.getUnsubscribed(themeType);
+ subscribedColor = mCustomThemeWrapper.getSubscribed(themeType);
+ userNameTextView.setTextColor(mCustomThemeWrapper.getUsername(themeType));
+ karmaTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor(themeType));
+ subscribeUserChip.setTextColor(mCustomThemeWrapper.getChipTextColor(themeType));
+ applyTabLayoutTheme(tabLayout, mCustomThemeWrapper, themeType);
+ }
+
private void getCurrentAccountAndInitializeViewPager() {
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
if (mNewAccountName != null) {
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 ab7c0b21..d4ff5510 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java
@@ -1,6 +1,7 @@
package ml.docilealligator.infinityforreddit.Adapter;
import android.content.Intent;
+import android.content.res.ColorStateList;
import android.graphics.ColorFilter;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
@@ -37,6 +38,7 @@ import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.RequestOptions;
import com.bumptech.glide.request.target.Target;
import com.libRG.CustomTextView;
+import com.lsjwzh.widget.materialloadingprogressbar.CircleProgressBar;
import com.santalu.aspectratioimageview.AspectRatioImageView;
import org.commonmark.ext.gfm.tables.TableBlock;
@@ -70,6 +72,7 @@ import ml.docilealligator.infinityforreddit.Activity.ViewVideoActivity;
import ml.docilealligator.infinityforreddit.AsyncTask.LoadSubredditIconAsyncTask;
import ml.docilealligator.infinityforreddit.AsyncTask.LoadUserDataAsyncTask;
import ml.docilealligator.infinityforreddit.CommentData;
+import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.CustomView.AspectRatioGifImageView;
import ml.docilealligator.infinityforreddit.CustomView.MarkwonLinearLayoutManager;
import ml.docilealligator.infinityforreddit.FetchComment;
@@ -128,11 +131,28 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
private boolean isInitiallyLoadingFailed;
private boolean mHasMoreComments;
private boolean loadMoreCommentsFailed;
+
+ private int mColorPrimaryLightTheme;
+ private int mColorAccent;
+ private int mCardViewColor;
private int mSecondaryTextColor;
+ private int mPostTitleColor;
+ private int mPrimaryTextColor;
+ private int mCommentTextColor;
private int mCommentBackgroundColor;
+ private int mPostTypeColor;
+ private int mDividerColor;
+ private int mSubredditColor;
private int mUsernameColor;
private int mSubmitterColor;
private int mModeratorColor;
+ private int mSpoilerColor;
+ private int mFlairColor;
+ private int mNSFWColor;
+ private int mArchivedTintColor;
+ private int mLockedTintColor;
+ private int mCrosspostTintColor;
+ private int mNoPreviewLinkBackgroundColor;
private int mUpvotedColor;
private int mDownvotedColor;
private int mCommentVerticalBarColor1;
@@ -144,12 +164,14 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
private int mCommentVerticalBarColor7;
private int mSingleCommentThreadBackgroundColor;
private int mVoteAndReplyUnavailableVoteButtonColor;
+ private int mButtonTextColor;
private float mScale;
private ShareLinkBottomSheetFragment mShareLinkBottomSheetFragment;
private CopyTextBottomSheetFragment mCopyTextBottomSheetFragment;
- public CommentAndPostRecyclerViewAdapter(AppCompatActivity activity, Retrofit retrofit, Retrofit oauthRetrofit,
+ public CommentAndPostRecyclerViewAdapter(AppCompatActivity activity, CustomThemeWrapper customThemeWrapper,
+ Retrofit retrofit, Retrofit oauthRetrofit,
RedditDataRoomDatabase redditDataRoomDatabase, RequestManager glide,
String accessToken, String accountName, Post post, Locale locale,
String singleCommentId, boolean isSingleCommentThreadMode,
@@ -162,8 +184,9 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
mOauthRetrofit = oauthRetrofit;
mRedditDataRoomDatabase = redditDataRoomDatabase;
mGlide = glide;
- mSecondaryTextColor = Utils.getAttributeColor(activity, R.attr.secondaryTextColor);
- int markdownColor = mSecondaryTextColor;
+ int themeType = customThemeWrapper.getThemeType();
+ mSecondaryTextColor = customThemeWrapper.getSecondaryTextColor(themeType);
+ int markdownColor = customThemeWrapper.getPostContentColor(themeType);
mPostDetailMarkwon = Markwon.builder(mActivity)
.usePlugin(new AbstractMarkwonPlugin() {
@Override
@@ -254,21 +277,39 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
mHasMoreComments = false;
loadMoreCommentsFailed = false;
mScale = activity.getResources().getDisplayMetrics().density;
- 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);
- mCommentVerticalBarColor1 = Utils.getAttributeColor(activity, R.attr.commentVerticalBarColor1);
- mCommentVerticalBarColor2 = Utils.getAttributeColor(activity, R.attr.commentVerticalBarColor2);
- mCommentVerticalBarColor3 = Utils.getAttributeColor(activity, R.attr.commentVerticalBarColor3);
- mCommentVerticalBarColor4 = Utils.getAttributeColor(activity, R.attr.commentVerticalBarColor4);
- mCommentVerticalBarColor5 = Utils.getAttributeColor(activity, R.attr.commentVerticalBarColor5);
- mCommentVerticalBarColor6 = Utils.getAttributeColor(activity, R.attr.commentVerticalBarColor6);
- mCommentVerticalBarColor7 = Utils.getAttributeColor(activity, R.attr.commentVerticalBarColor7);
- mSingleCommentThreadBackgroundColor = Utils.getAttributeColor(activity, R.attr.singleCommentThreadBackgroundColor);
- mVoteAndReplyUnavailableVoteButtonColor = Utils.getAttributeColor(activity, R.attr.voteAndReplyUnavailableVoteButtonColor);
+
+ mColorPrimaryLightTheme = customThemeWrapper.getColorPrimaryLightTheme(themeType);
+ mColorAccent = customThemeWrapper.getColorAccent(themeType);
+ mCardViewColor = customThemeWrapper.getCardViewBackgroundColor(themeType);
+ mPostTitleColor = customThemeWrapper.getPostTitleColor(themeType);
+ mPrimaryTextColor = customThemeWrapper.getPrimaryTextColor(themeType);
+ mCommentTextColor = customThemeWrapper.getCommentColor(themeType);
+ mDividerColor = customThemeWrapper.getDividerColor(themeType);
+ mCommentBackgroundColor = customThemeWrapper.getCommentBackgroundColor(themeType);
+ mPostTypeColor = customThemeWrapper.getPostType(themeType);
+ mSubmitterColor = customThemeWrapper.getSubmitter(themeType);
+ mModeratorColor = customThemeWrapper.getModerator(themeType);
+ mSpoilerColor = customThemeWrapper.getSpoilerColor(themeType);
+ mNSFWColor = customThemeWrapper.getNsfwColor(themeType);
+ mArchivedTintColor = customThemeWrapper.getArchivedTint(themeType);
+ mLockedTintColor = customThemeWrapper.getLockedIconTint(themeType);
+ mCrosspostTintColor = customThemeWrapper.getCrosspost(themeType);
+ mNoPreviewLinkBackgroundColor = customThemeWrapper.getNoPreviewLinkBackgroundColor(themeType);
+ mFlairColor = customThemeWrapper.getFlairColor(themeType);
+ mSubredditColor = customThemeWrapper.getSubreddit(themeType);
+ mUsernameColor = customThemeWrapper.getUsername(themeType);
+ mUpvotedColor = customThemeWrapper.getUpvoted(themeType);
+ mDownvotedColor = customThemeWrapper.getDownvoted(themeType);
+ mCommentVerticalBarColor1 = customThemeWrapper.getCommentVerticalBarColor1(themeType);
+ mCommentVerticalBarColor2 = customThemeWrapper.getCommentVerticalBarColor2(themeType);
+ mCommentVerticalBarColor3 = customThemeWrapper.getCommentVerticalBarColor3(themeType);
+ mCommentVerticalBarColor4 = customThemeWrapper.getCommentVerticalBarColor4(themeType);
+ mCommentVerticalBarColor5 = customThemeWrapper.getCommentVerticalBarColor5(themeType);
+ mCommentVerticalBarColor6 = customThemeWrapper.getCommentVerticalBarColor6(themeType);
+ mCommentVerticalBarColor7 = customThemeWrapper.getCommentVerticalBarColor7(themeType);
+ mSingleCommentThreadBackgroundColor = customThemeWrapper.getSingleCommentThreadBackgroundColor(themeType);
+ mVoteAndReplyUnavailableVoteButtonColor = customThemeWrapper.getVoteAndReplyUnavailableVoteButtonColor(themeType);
+ mButtonTextColor = customThemeWrapper.getButtonTextColor(themeType);
mShareLinkBottomSheetFragment = new ShareLinkBottomSheetFragment();
mCopyTextBottomSheetFragment = new CopyTextBottomSheetFragment();
@@ -491,12 +532,12 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
}
if (mPost.isSpoiler()) {
- ((PostDetailViewHolder) holder).spoilerTextView.setVisibility(View.VISIBLE);
+ ((PostDetailViewHolder) holder).mSpoilerTextView.setVisibility(View.VISIBLE);
}
if (mPost.getFlair() != null) {
- ((PostDetailViewHolder) holder).flairTextView.setVisibility(View.VISIBLE);
- ((PostDetailViewHolder) holder).flairTextView.setText(mPost.getFlair());
+ ((PostDetailViewHolder) holder).mFlairTextView.setVisibility(View.VISIBLE);
+ ((PostDetailViewHolder) holder).mFlairTextView.setText(mPost.getFlair());
}
if (mPost.isNSFW()) {
@@ -543,9 +584,9 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
case Post.LINK_TYPE:
((PostDetailViewHolder) holder).mTypeTextView.setText("LINK");
- ((PostDetailViewHolder) holder).linkTextView.setVisibility(View.VISIBLE);
+ ((PostDetailViewHolder) holder).mLinkTextView.setVisibility(View.VISIBLE);
String domain = Uri.parse(mPost.getUrl()).getHost();
- ((PostDetailViewHolder) holder).linkTextView.setText(domain);
+ ((PostDetailViewHolder) holder).mLinkTextView.setText(domain);
((PostDetailViewHolder) holder).mImageView.setOnClickListener(view -> {
Intent intent = new Intent(mActivity, LinkResolverActivity.class);
@@ -589,9 +630,9 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
case Post.NO_PREVIEW_LINK_TYPE:
((PostDetailViewHolder) holder).mTypeTextView.setText("LINK");
- ((PostDetailViewHolder) holder).linkTextView.setVisibility(View.VISIBLE);
+ ((PostDetailViewHolder) holder).mLinkTextView.setVisibility(View.VISIBLE);
String noPreviewLinkDomain = Uri.parse(mPost.getUrl()).getHost();
- ((PostDetailViewHolder) holder).linkTextView.setText(noPreviewLinkDomain);
+ ((PostDetailViewHolder) holder).mLinkTextView.setText(noPreviewLinkDomain);
if (mPost.getSelfText() != null && !mPost.getSelfText().equals("")) {
((PostDetailViewHolder) holder).mContentMarkdownView.setVisibility(View.VISIBLE);
@@ -1645,8 +1686,8 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
((PostDetailViewHolder) holder).mUpvoteButton.clearColorFilter();
((PostDetailViewHolder) holder).mScoreTextView.setTextColor(mSecondaryTextColor);
((PostDetailViewHolder) holder).mDownvoteButton.clearColorFilter();
- ((PostDetailViewHolder) holder).flairTextView.setVisibility(View.GONE);
- ((PostDetailViewHolder) holder).spoilerTextView.setVisibility(View.GONE);
+ ((PostDetailViewHolder) holder).mFlairTextView.setVisibility(View.GONE);
+ ((PostDetailViewHolder) holder).mSpoilerTextView.setVisibility(View.GONE);
((PostDetailViewHolder) holder).mNSFWTextView.setVisibility(View.GONE);
} else if (holder instanceof LoadMoreChildCommentsViewHolder) {
((LoadMoreChildCommentsViewHolder) holder).itemView.setPadding(0, 0, 0, 0);
@@ -1711,11 +1752,11 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
@BindView(R.id.nsfw_text_view_item_post_detail)
CustomTextView mNSFWTextView;
@BindView(R.id.spoiler_custom_text_view_item_post_detail)
- CustomTextView spoilerTextView;
+ CustomTextView mSpoilerTextView;
@BindView(R.id.flair_custom_text_view_item_post_detail)
- CustomTextView flairTextView;
+ CustomTextView mFlairTextView;
@BindView(R.id.link_text_view_item_post_detail)
- TextView linkTextView;
+ TextView mLinkTextView;
@BindView(R.id.image_view_wrapper_item_post_detail)
RelativeLayout mRelativeLayout;
@BindView(R.id.load_wrapper_item_post_detail)
@@ -1957,6 +1998,26 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
constraintSet.setHorizontalBias(commentsCountTextView.getId(), 0);
constraintSet.applyTo(mBottomConstraintLayout);
}
+
+ itemView.setBackgroundColor(mCardViewColor);
+ mSubredditTextView.setTextColor(mSubredditColor);
+ mUserTextView.setTextColor(mUsernameColor);
+ mPostTimeTextView.setTextColor(mSecondaryTextColor);
+ mTitleTextView.setTextColor(mPostTitleColor);
+ mTypeTextView.setBackgroundColor(mPostTypeColor);
+ mTypeTextView.setBorderColor(mPostTypeColor);
+ mSpoilerTextView.setBackgroundColor(mSpoilerColor);
+ mSpoilerTextView.setBorderColor(mSpoilerColor);
+ mNSFWTextView.setBackgroundColor(mNSFWColor);
+ mNSFWTextView.setBorderColor(mNSFWColor);
+ mFlairTextView.setBackgroundColor(mFlairColor);
+ mFlairTextView.setBorderColor(mFlairColor);
+ mArchivedImageView.setColorFilter(mArchivedTintColor, PorterDuff.Mode.SRC_IN);
+ mLockedImageView.setColorFilter(mLockedTintColor, PorterDuff.Mode.SRC_IN);
+ mCrosspostImageView.setColorFilter(mCrosspostTintColor, PorterDuff.Mode.SRC_IN);
+ mLinkTextView.setTextColor(mSecondaryTextColor);
+ mNoPreviewLinkImageView.setBackgroundColor(mNoPreviewLinkBackgroundColor);
+ mLoadImageErrorTextView.setTextColor(mPrimaryTextColor);
}
}
@@ -2017,8 +2078,16 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
}
if (mShowCommentDivider) {
+ commentDivider.setBackgroundColor(mDividerColor);
commentDivider.setVisibility(View.VISIBLE);
}
+
+ itemView.setBackgroundColor(mCommentBackgroundColor);
+ authorTextView.setTextColor(mUsernameColor);
+ commentTimeTextView.setTextColor(mSecondaryTextColor);
+ commentMarkdownView.setTextColor(mCommentTextColor);
+ authorFlairTextView.setTextColor(mFlairColor);
+ commentDivider.setBackgroundColor(mDividerColor);
}
}
@@ -2037,33 +2106,58 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
if (mShowCommentDivider) {
commentDivider.setVisibility(View.VISIBLE);
}
+
+ itemView.setBackgroundColor(mCommentBackgroundColor);
+ placeholderTextView.setTextColor(mPrimaryTextColor);
+ commentDivider.setBackgroundColor(mDividerColor);
}
}
class LoadCommentsViewHolder extends RecyclerView.ViewHolder {
+ @BindView(R.id.comment_progress_bar_item_load_comments)
+ CircleProgressBar circleProgressBar;
+
LoadCommentsViewHolder(@NonNull View itemView) {
super(itemView);
+ ButterKnife.bind(this, itemView);
+ circleProgressBar.setColorSchemeColors(mColorAccent);
}
}
class LoadCommentsFailedViewHolder extends RecyclerView.ViewHolder {
+ @BindView(R.id.error_text_view_item_load_comments_failed_placeholder)
+ TextView errorTextView;
+
LoadCommentsFailedViewHolder(@NonNull View itemView) {
super(itemView);
- itemView.setOnClickListener(view -> {
- mCommentRecyclerViewAdapterCallback.retryFetchingComments();
- });
+ ButterKnife.bind(this, itemView);
+ itemView.setOnClickListener(view -> mCommentRecyclerViewAdapterCallback.retryFetchingComments());
+ itemView.setBackgroundColor(mCommentBackgroundColor);
+ errorTextView.setTextColor(mSecondaryTextColor);
}
}
class NoCommentViewHolder extends RecyclerView.ViewHolder {
+ @BindView(R.id.error_text_view_item_no_comment_placeholder)
+ TextView errorTextView;
+
NoCommentViewHolder(@NonNull View itemView) {
super(itemView);
+ ButterKnife.bind(this, itemView);
+ itemView.setBackgroundColor(mCommentBackgroundColor);
+ errorTextView.setTextColor(mSecondaryTextColor);
}
}
class IsLoadingMoreCommentsViewHolder extends RecyclerView.ViewHolder {
+ @BindView(R.id.progress_bar_item_comment_footer_loading)
+ ProgressBar progressbar;
+
IsLoadingMoreCommentsViewHolder(@NonNull View itemView) {
super(itemView);
+ ButterKnife.bind(this, itemView);
+ itemView.setBackgroundColor(mCommentBackgroundColor);
+ progressbar.setIndeterminateTintList(ColorStateList.valueOf(mColorAccent));
}
}
@@ -2076,8 +2170,11 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
LoadMoreCommentsFailedViewHolder(@NonNull View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
-
retryButton.setOnClickListener(view -> mCommentRecyclerViewAdapterCallback.retryFetchingMoreComments());
+ itemView.setBackgroundColor(mCommentBackgroundColor);
+ errorTextView.setTextColor(mSecondaryTextColor);
+ retryButton.setBackgroundTintList(ColorStateList.valueOf(mColorPrimaryLightTheme));
+ retryButton.setTextColor(mButtonTextColor);
}
}
@@ -2092,6 +2189,9 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
mSingleCommentId = null;
((ViewPostDetailActivity) mActivity).changeToSingleThreadMode();
}
+
+ itemView.setBackgroundColor(mCommentBackgroundColor);
+ ((TextView) itemView).setTextColor(mColorAccent);
});
}
}
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 078aa57b..9c5b6f2d 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentsListingRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentsListingRecyclerViewAdapter.java
@@ -2,6 +2,7 @@ package ml.docilealligator.infinityforreddit.Adapter;
import android.content.Context;
import android.content.Intent;
+import android.content.res.ColorStateList;
import android.net.Uri;
import android.os.Bundle;
import android.text.style.SuperscriptSpan;
@@ -12,6 +13,7 @@ import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
+import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
@@ -36,6 +38,7 @@ import ml.docilealligator.infinityforreddit.Activity.ViewPostDetailActivity;
import ml.docilealligator.infinityforreddit.Activity.ViewSubredditDetailActivity;
import ml.docilealligator.infinityforreddit.Activity.ViewUserDetailActivity;
import ml.docilealligator.infinityforreddit.CommentData;
+import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.Fragment.CommentMoreBottomSheetFragment;
import ml.docilealligator.infinityforreddit.NetworkState;
import ml.docilealligator.infinityforreddit.R;
@@ -65,11 +68,17 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
private Markwon mMarkwon;
private String mAccessToken;
private String mAccountName;
+ private int mColorPrimaryLightTheme;
private int mSecondaryTextColor;
+ private int mCommentBackgroundColor;
+ private int mCommentColor;
+ private int mDividerColor;
private int mUsernameColor;
private int mSubredditColor;
private int mUpvotedColor;
private int mDownvotedColor;
+ private int mButtonTextColor;
+ private int mColorAccent;
private boolean mVoteButtonsOnTheRight;
private boolean mShowElapsedTime;
private boolean mShowCommentDivider;
@@ -78,9 +87,10 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
private RetryLoadingMoreCallback mRetryLoadingMoreCallback;
public CommentsListingRecyclerViewAdapter(Context context, Retrofit oauthRetrofit,
- String accessToken, String accountName,
- boolean voteButtonsOnTheRight, boolean showElapsedTime,
- boolean showCommentDivider, boolean showAbsoluteNumberOfVotes,
+ CustomThemeWrapper customThemeWrapper, String accessToken,
+ String accountName, boolean voteButtonsOnTheRight,
+ boolean showElapsedTime, boolean showCommentDivider,
+ boolean showAbsoluteNumberOfVotes,
RetryLoadingMoreCallback retryLoadingMoreCallback) {
super(DIFF_CALLBACK);
mContext = context;
@@ -117,11 +127,18 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
mShowCommentDivider = showCommentDivider;
mShowAbsoluteNumberOfVotes = showAbsoluteNumberOfVotes;
mRetryLoadingMoreCallback = retryLoadingMoreCallback;
- mSecondaryTextColor = Utils.getAttributeColor(context, R.attr.secondaryTextColor);
- 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);
+ int themeType = customThemeWrapper.getThemeType();
+ mColorPrimaryLightTheme = customThemeWrapper.getColorPrimaryLightTheme(themeType);
+ mSecondaryTextColor = customThemeWrapper.getSecondaryTextColor(themeType);
+ mCommentBackgroundColor = customThemeWrapper.getCommentBackgroundColor(themeType);
+ mCommentColor = customThemeWrapper.getCommentColor(themeType);
+ mDividerColor = customThemeWrapper.getDividerColor(themeType);
+ mSubredditColor = customThemeWrapper.getSubreddit(themeType);
+ mUsernameColor = customThemeWrapper.getUsername(themeType);
+ mUpvotedColor = customThemeWrapper.getUpvoted(themeType);
+ mDownvotedColor = customThemeWrapper.getDownvoted(themeType);
+ mButtonTextColor = customThemeWrapper.getButtonTextColor(themeType);
+ mColorAccent = customThemeWrapper.getColorAccent(themeType);
}
@NonNull
@@ -473,6 +490,12 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
if (mShowCommentDivider) {
commentDivider.setVisibility(View.VISIBLE);
}
+
+ itemView.setBackgroundColor(mCommentBackgroundColor);
+ authorTextView.setTextColor(mUsernameColor);
+ commentTimeTextView.setTextColor(mSecondaryTextColor);
+ commentMarkdownView.setTextColor(mCommentColor);
+ commentDivider.setBackgroundColor(mDividerColor);
}
}
@@ -487,13 +510,20 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
ButterKnife.bind(this, itemView);
errorTextView.setText(R.string.load_comments_failed);
retryButton.setOnClickListener(view -> mRetryLoadingMoreCallback.retryLoadingMore());
+ errorTextView.setTextColor(mSecondaryTextColor);
+ retryButton.setBackgroundTintList(ColorStateList.valueOf(mColorPrimaryLightTheme));
+ retryButton.setTextColor(mButtonTextColor);
}
}
class LoadingViewHolder extends RecyclerView.ViewHolder {
+ @BindView(R.id.progress_bar_item_footer_loading)
+ ProgressBar progressBar;
+
LoadingViewHolder(@NonNull View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
+ progressBar.setIndeterminateTintList(ColorStateList.valueOf(mColorAccent));
}
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/FlairBottomSheetRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/FlairBottomSheetRecyclerViewAdapter.java
index e5a869dc..173b38f8 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/FlairBottomSheetRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/FlairBottomSheetRecyclerViewAdapter.java
@@ -19,15 +19,20 @@ import java.util.ArrayList;
import butterknife.BindView;
import butterknife.ButterKnife;
+import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.Flair;
import ml.docilealligator.infinityforreddit.R;
public class FlairBottomSheetRecyclerViewAdapter extends RecyclerView.Adapter<FlairBottomSheetRecyclerViewAdapter.FlairViewHolder> {
private Context context;
private ArrayList<Flair> flairs;
+ private int flairColor;
private ItemClickListener itemClickListener;
- public FlairBottomSheetRecyclerViewAdapter(Context context, ItemClickListener itemClickListener) {
+
+ public FlairBottomSheetRecyclerViewAdapter(Context context, CustomThemeWrapper customThemeWrapper,
+ ItemClickListener itemClickListener) {
this.context = context;
+ flairColor = customThemeWrapper.getFlairColor(customThemeWrapper.getThemeType());
this.itemClickListener = itemClickListener;
}
@@ -103,6 +108,7 @@ public class FlairBottomSheetRecyclerViewAdapter extends RecyclerView.Adapter<Fl
super(itemView);
ButterKnife.bind(this, itemView);
this.itemView = itemView;
+ flairTextView.setTextColor(flairColor);
}
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/FollowedUsersRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/FollowedUsersRecyclerViewAdapter.java
index 7978f89b..71166e3a 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/FollowedUsersRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/FollowedUsersRecyclerViewAdapter.java
@@ -22,6 +22,7 @@ import butterknife.BindView;
import butterknife.ButterKnife;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import ml.docilealligator.infinityforreddit.Activity.ViewUserDetailActivity;
+import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.FavoriteThing;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
@@ -42,15 +43,21 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
private RedditDataRoomDatabase mRedditDataRoomDatabase;
private String mAccessToken;
private RequestManager glide;
+ private int mUsernameColor;
+ private int mSecondaryTextColor;
public FollowedUsersRecyclerViewAdapter(Context context, Retrofit oauthRetrofit,
RedditDataRoomDatabase redditDataRoomDatabase,
+ CustomThemeWrapper customThemeWrapper,
String accessToken) {
mContext = context;
mOauthRetrofit = oauthRetrofit;
mRedditDataRoomDatabase = redditDataRoomDatabase;
mAccessToken = accessToken;
glide = Glide.with(context.getApplicationContext());
+ int themeType = customThemeWrapper.getThemeType();
+ mUsernameColor = customThemeWrapper.getUsername(themeType);
+ mSecondaryTextColor = customThemeWrapper.getSecondaryTextColor(themeType);
}
@Override
@@ -294,6 +301,7 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
FavoriteUserViewHolder(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
+ userNameTextView.setTextColor(mUsernameColor);
}
}
@@ -308,6 +316,7 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
UserViewHolder(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
+ userNameTextView.setTextColor(mUsernameColor);
}
}
@@ -318,6 +327,7 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
super(itemView);
ButterKnife.bind(this, itemView);
dividerTextView.setText(R.string.favorites);
+ dividerTextView.setTextColor(mSecondaryTextColor);
}
}
@@ -328,6 +338,7 @@ public class FollowedUsersRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
super(itemView);
ButterKnife.bind(this, itemView);
dividerTextView.setText(R.string.all);
+ dividerTextView.setTextColor(mSecondaryTextColor);
}
}
}
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 854bb95d..b1cfb9e7 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/MessageRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/MessageRecyclerViewAdapter.java
@@ -2,7 +2,7 @@ package ml.docilealligator.infinityforreddit.Adapter;
import android.content.Context;
import android.content.Intent;
-import android.content.res.Resources;
+import android.content.res.ColorStateList;
import android.net.Uri;
import android.text.style.SuperscriptSpan;
import android.text.util.Linkify;
@@ -10,6 +10,7 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
+import android.widget.ProgressBar;
import android.widget.TextView;
import androidx.annotation.NonNull;
@@ -27,11 +28,11 @@ import io.noties.markwon.linkify.LinkifyPlugin;
import io.noties.markwon.simple.ext.SimpleExtPlugin;
import ml.docilealligator.infinityforreddit.Activity.LinkResolverActivity;
import ml.docilealligator.infinityforreddit.Activity.ViewUserDetailActivity;
+import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
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> {
@@ -53,16 +54,20 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
private Retrofit mOauthRetrofit;
private Markwon mMarkwon;
private String mAccessToken;
- private Resources mResources;
private NetworkState networkState;
private RetryLoadingMoreCallback mRetryLoadingMoreCallback;
+ private int mColorAccent;
private int mMessageBackgroundColor;
private int mUsernameColor;
private int mPrimaryTextColor;
+ private int mSecondaryTextColor;
private int mUnreadMessageBackgroundColor;
+ private int mColorPrimaryLightTheme;
+ private int mButtonTextColor;
- public MessageRecyclerViewAdapter(Context context, Retrofit oauthRetrofit, String accessToken,
- RetryLoadingMoreCallback retryLoadingMoreCallback) {
+ public MessageRecyclerViewAdapter(Context context, Retrofit oauthRetrofit,
+ CustomThemeWrapper customThemeWrapper,
+ String accessToken, RetryLoadingMoreCallback retryLoadingMoreCallback) {
super(DIFF_CALLBACK);
mContext = context;
mOauthRetrofit = oauthRetrofit;
@@ -93,12 +98,16 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
)
.build();
mAccessToken = accessToken;
- mResources = context.getResources();
- mMessageBackgroundColor = Utils.getAttributeColor(context, R.attr.cardViewBackgroundColor);
- mUsernameColor = Utils.getAttributeColor(context, R.attr.username);
- mPrimaryTextColor = Utils.getAttributeColor(context, R.attr.primaryTextColor);
- mUnreadMessageBackgroundColor = Utils.getAttributeColor(context, R.attr.unreadMessageBackgroundColor);
+ int themeType = customThemeWrapper.getThemeType();
+ mColorAccent = customThemeWrapper.getColorAccent(themeType);
+ mMessageBackgroundColor = customThemeWrapper.getCardViewBackgroundColor(themeType);
+ mUsernameColor = customThemeWrapper.getUsername(themeType);
+ mPrimaryTextColor = customThemeWrapper.getPrimaryTextColor(themeType);
+ mSecondaryTextColor = customThemeWrapper.getSecondaryTextColor(themeType);
+ mUnreadMessageBackgroundColor = customThemeWrapper.getUnreadMessageBackgroundColor(themeType);
+ mColorPrimaryLightTheme = customThemeWrapper.getColorPrimaryLightTheme(themeType);
+ mButtonTextColor = customThemeWrapper.getButtonTextColor(themeType);
}
@NonNull
@@ -232,7 +241,6 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
}
class DataViewHolder extends RecyclerView.ViewHolder {
- View itemView;
@BindView(R.id.author_text_view_item_message)
TextView authorTextView;
@BindView(R.id.subject_text_view_item_message)
@@ -245,7 +253,10 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
DataViewHolder(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
- this.itemView = itemView;
+ authorTextView.setTextColor(mUsernameColor);
+ subjectTextView.setTextColor(mPrimaryTextColor);
+ titleTextView.setTextColor(mPrimaryTextColor);
+ contentCustomMarkwonView.setTextColor(mSecondaryTextColor);
}
}
@@ -259,14 +270,21 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
super(itemView);
ButterKnife.bind(this, itemView);
errorTextView.setText(R.string.load_comments_failed);
+ errorTextView.setTextColor(mSecondaryTextColor);
retryButton.setOnClickListener(view -> mRetryLoadingMoreCallback.retryLoadingMore());
+ retryButton.setBackgroundTintList(ColorStateList.valueOf(mColorPrimaryLightTheme));
+ retryButton.setTextColor(mButtonTextColor);
}
}
class LoadingViewHolder extends RecyclerView.ViewHolder {
+ @BindView(R.id.progress_bar_item_footer_loading)
+ ProgressBar progressBar;
+
LoadingViewHolder(@NonNull View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
+ progressBar.setIndeterminateTintList(ColorStateList.valueOf(mColorAccent));
}
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/MultiRedditListingRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/MultiRedditListingRecyclerViewAdapter.java
index 119e78ff..86222840 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/MultiRedditListingRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/MultiRedditListingRecyclerViewAdapter.java
@@ -22,6 +22,7 @@ import butterknife.BindView;
import butterknife.ButterKnife;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import ml.docilealligator.infinityforreddit.Activity.ViewMultiRedditDetailActivity;
+import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.MultiReddit.FavoriteMultiReddit;
import ml.docilealligator.infinityforreddit.MultiReddit.MultiReddit;
import ml.docilealligator.infinityforreddit.R;
@@ -45,9 +46,12 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<
private String mAccountName;
private List<MultiReddit> mMultiReddits;
private List<MultiReddit> mFavoriteMultiReddits;
+ private int mPrimaryTextColor;
+ private int mSecondaryTextColor;
public MultiRedditListingRecyclerViewAdapter(Context context, Retrofit oauthRetrofit,
RedditDataRoomDatabase redditDataRoomDatabase,
+ CustomThemeWrapper customThemeWrapper,
String accessToken, String accountName) {
mContext = context;
mGlide = Glide.with(context.getApplicationContext());
@@ -55,6 +59,9 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<
mRedditDataRoomDatabase = redditDataRoomDatabase;
mAccessToken = accessToken;
mAccountName = accountName;
+ int themeType = customThemeWrapper.getThemeType();
+ mPrimaryTextColor = customThemeWrapper.getPrimaryTextColor(themeType);
+ mSecondaryTextColor = customThemeWrapper.getSecondaryTextColor(themeType);
}
@Override
@@ -313,6 +320,7 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<
MultiRedditViewHolder(@NonNull View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
+ multiRedditNameTextView.setTextColor(mPrimaryTextColor);
}
}
@@ -327,6 +335,7 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<
FavoriteMultiRedditViewHolder(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
+ multiRedditNameTextView.setTextColor(mPrimaryTextColor);
}
}
@@ -337,6 +346,7 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<
super(itemView);
ButterKnife.bind(this, itemView);
dividerTextView.setText(R.string.favorites);
+ dividerTextView.setTextColor(mSecondaryTextColor);
}
}
@@ -347,6 +357,7 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<
super(itemView);
ButterKnife.bind(this, itemView);
dividerTextView.setText(R.string.all);
+ dividerTextView.setTextColor(mSecondaryTextColor);
}
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/NavigationDrawerRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/NavigationDrawerRecyclerViewAdapter.java
index ab8dc12c..020367f8 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/NavigationDrawerRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/NavigationDrawerRecyclerViewAdapter.java
@@ -23,6 +23,7 @@ import butterknife.BindView;
import butterknife.ButterKnife;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import ml.docilealligator.infinityforreddit.Account.Account;
+import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase.SubscribedSubredditData;
import pl.droidsonroids.gif.GifImageView;
@@ -56,8 +57,12 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re
private boolean isInMainPage = true;
private ArrayList<SubscribedSubredditData> subscribedSubreddits;
private ArrayList<Account> accounts;
+ private int primaryTextColor;
+ private int secondaryTextColor;
+ private int dividerColor;
- public NavigationDrawerRecyclerViewAdapter(Context context, String accountName, String userIconUrl,
+ public NavigationDrawerRecyclerViewAdapter(Context context, CustomThemeWrapper customThemeWrapper,
+ String accountName, String userIconUrl,
String userBannerUrl, int karma, boolean isNSFWEnabled,
ItemClickListener itemClickListener) {
this.context = context;
@@ -70,6 +75,10 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re
this.isNSFWEnabled = isNSFWEnabled;
isLoggedIn = accountName != null;
this.itemClickListener = itemClickListener;
+ int themeType = customThemeWrapper.getThemeType();
+ primaryTextColor = customThemeWrapper.getPrimaryTextColor(themeType);
+ secondaryTextColor = customThemeWrapper.getSecondaryTextColor(themeType);
+ dividerColor = customThemeWrapper.getDividerColor(themeType);
}
@Override
@@ -439,6 +448,8 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re
NavHeaderViewHolder(@NonNull View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
+ accountNameTextView.setTextColor(secondaryTextColor);
+ karmaTextView.setTextColor(secondaryTextColor);
}
}
@@ -448,6 +459,7 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re
MenuGroupTitleViewHolder(@NonNull View itemView) {
super(itemView);
titleTextView = (TextView) itemView;
+ titleTextView.setTextColor(primaryTextColor);
}
}
@@ -457,6 +469,7 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re
MenuItemViewHolder(@NonNull View itemView) {
super(itemView);
menuTextView = (TextView) itemView;
+ menuTextView.setTextColor(primaryTextColor);
}
}
@@ -464,6 +477,7 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re
DividerViewHolder(@NonNull View itemView) {
super(itemView);
+ itemView.setBackgroundColor(dividerColor);
}
}
@@ -476,6 +490,7 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re
SubscribedThingViewHolder(@NonNull View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
+ subredditNameTextView.setTextColor(primaryTextColor);
}
}
@@ -488,6 +503,7 @@ public class NavigationDrawerRecyclerViewAdapter extends RecyclerView.Adapter<Re
AccountViewHolder(@NonNull View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
+ usernameTextView.setTextColor(primaryTextColor);
}
}
}
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 41dc90cf..17291ea4 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java
@@ -1,7 +1,9 @@
package ml.docilealligator.infinityforreddit.Adapter;
import android.content.Intent;
+import android.content.res.ColorStateList;
import android.graphics.ColorFilter;
+import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
@@ -52,6 +54,7 @@ import ml.docilealligator.infinityforreddit.Activity.ViewUserDetailActivity;
import ml.docilealligator.infinityforreddit.Activity.ViewVideoActivity;
import ml.docilealligator.infinityforreddit.AsyncTask.LoadSubredditIconAsyncTask;
import ml.docilealligator.infinityforreddit.AsyncTask.LoadUserDataAsyncTask;
+import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.CustomView.AspectRatioGifImageView;
import ml.docilealligator.infinityforreddit.Event.PostUpdateEventToDetailActivity;
import ml.docilealligator.infinityforreddit.Fragment.ShareLinkBottomSheetFragment;
@@ -97,12 +100,40 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
private boolean canStartActivity = true;
private int mPostType;
private int mPostLayout;
+ private int mColorPrimaryLightTheme;
+ private int mColorAccent;
+ private int mCardViewColor;
private int mSecondaryTextColor;
+ private int mPostTitleColor;
+ private int mPrimaryTextColor;
+ private int mCommentTextColor;
+ private int mCommentBackgroundColor;
+ private int mPostTypeColor;
+ private int mDividerColor;
private int mSubredditColor;
private int mUsernameColor;
+ private int mSubmitterColor;
+ private int mModeratorColor;
+ private int mSpoilerColor;
+ private int mFlairColor;
+ private int mNSFWColor;
+ private int mArchivedTintColor;
+ private int mLockedTintColor;
+ private int mCrosspostTintColor;
+ private int mNoPreviewLinkBackgroundColor;
private int mUpvotedColor;
private int mDownvotedColor;
+ private int mCommentVerticalBarColor1;
+ private int mCommentVerticalBarColor2;
+ private int mCommentVerticalBarColor3;
+ private int mCommentVerticalBarColor4;
+ private int mCommentVerticalBarColor5;
+ private int mCommentVerticalBarColor6;
+ private int mCommentVerticalBarColor7;
+ private int mSingleCommentThreadBackgroundColor;
private int mVoteAndReplyUnavailableVoteButtonColor;
+ private int mButtonBackgroundTint;
+ private int mButtonTextColor;
private float mScale;
private boolean mDisplaySubredditName;
private boolean mVoteButtonsOnTheRight;
@@ -116,7 +147,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
private ShareLinkBottomSheetFragment mShareLinkBottomSheetFragment;
public PostRecyclerViewAdapter(AppCompatActivity activity, Retrofit oauthRetrofit, Retrofit retrofit,
- RedditDataRoomDatabase redditDataRoomDatabase, String accessToken,
+ RedditDataRoomDatabase redditDataRoomDatabase,
+ CustomThemeWrapper customThemeWrapper, String accessToken,
int postType, int postLayout, boolean displaySubredditName,
boolean needBlurNSFW, boolean needBlurSpoiler, boolean voteButtonsOnTheRight,
boolean showElapsedTime, boolean showDividerInCompactLayout,
@@ -136,12 +168,16 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
mShowDividerInCompactLayout = showDividerInCompactLayout;
mShowAbsoluteNumberOfVotes = showAbsoluteNumberOfVotes;
mPostLayout = postLayout;
- mSecondaryTextColor = Utils.getAttributeColor(activity, R.attr.secondaryTextColor);
- 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);
- mVoteAndReplyUnavailableVoteButtonColor = Utils.getAttributeColor(activity, R.attr.voteAndReplyUnavailableVoteButtonColor);
+ int themeType = customThemeWrapper.getThemeType();
+ mColorPrimaryLightTheme = customThemeWrapper.getColorPrimaryLightTheme(themeType);
+ mColorAccent = customThemeWrapper.getColorAccent(themeType);
+ mPrimaryTextColor = customThemeWrapper.getPrimaryTextColor(themeType);
+ mSecondaryTextColor = customThemeWrapper.getSecondaryTextColor(themeType);
+ mSubredditColor = customThemeWrapper.getSubreddit(themeType);
+ mUsernameColor = customThemeWrapper.getUsername(themeType);
+ mUpvotedColor = customThemeWrapper.getUpvoted(themeType);
+ mDownvotedColor = customThemeWrapper.getDownvoted(themeType);
+ mVoteAndReplyUnavailableVoteButtonColor = customThemeWrapper.getVoteAndReplyUnavailableVoteButtonColor(themeType);
mScale = activity.getResources().getDisplayMetrics().density;
mGlide = Glide.with(mActivity.getApplicationContext());
mRedditDataRoomDatabase = redditDataRoomDatabase;
@@ -1584,6 +1620,24 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
constraintSet.setHorizontalBias(commentsCountTextView.getId(), 0);
constraintSet.applyTo(bottomConstraintLayout);
}
+
+ subredditTextView.setTextColor(mSubredditColor);
+ userTextView.setTextColor(mUsernameColor);
+ postTimeTextView.setTextColor(mSecondaryTextColor);
+ titleTextView.setTextColor(mPrimaryTextColor);
+ typeTextView.setBackgroundColor(mPostTypeColor);
+ typeTextView.setBorderColor(mPostTypeColor);
+ spoilerTextView.setBackgroundColor(mSpoilerColor);
+ spoilerTextView.setBorderColor(mSpoilerColor);
+ nsfwTextView.setBackgroundColor(mNSFWColor);
+ nsfwTextView.setBorderColor(mNSFWColor);
+ flairTextView.setBackgroundColor(mFlairColor);
+ flairTextView.setBorderColor(mFlairColor);
+ archivedImageView.setColorFilter(mArchivedTintColor, PorterDuff.Mode.SRC_IN);
+ lockedImageView.setColorFilter(mLockedTintColor, PorterDuff.Mode.SRC_IN);
+ crosspostImageView.setColorFilter(mCrosspostTintColor, PorterDuff.Mode.SRC_IN);
+ linkTextView.setTextColor(mSecondaryTextColor);
+ noPreviewLinkImageView.setBackgroundColor(mNoPreviewLinkBackgroundColor);
}
}
@@ -1668,6 +1722,22 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
constraintSet.setHorizontalBias(commentsCountTextView.getId(), 0);
constraintSet.applyTo(bottomConstraintLayout);
}
+
+ postTimeTextView.setTextColor(mSecondaryTextColor);
+ titleTextView.setTextColor(mPrimaryTextColor);
+ typeTextView.setBackgroundColor(mPostTypeColor);
+ typeTextView.setBorderColor(mPostTypeColor);
+ spoilerTextView.setBackgroundColor(mSpoilerColor);
+ spoilerTextView.setBorderColor(mSpoilerColor);
+ nsfwTextView.setBackgroundColor(mNSFWColor);
+ nsfwTextView.setBorderColor(mNSFWColor);
+ flairTextView.setBackgroundColor(mFlairColor);
+ flairTextView.setBorderColor(mFlairColor);
+ archivedImageView.setColorFilter(mArchivedTintColor, PorterDuff.Mode.SRC_IN);
+ lockedImageView.setColorFilter(mLockedTintColor, PorterDuff.Mode.SRC_IN);
+ crosspostImageView.setColorFilter(mCrosspostTintColor, PorterDuff.Mode.SRC_IN);
+ linkTextView.setTextColor(mSecondaryTextColor);
+ noPreviewLinkImageView.setBackgroundColor(mNoPreviewLinkBackgroundColor);
}
}
@@ -1681,14 +1751,22 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
super(itemView);
ButterKnife.bind(this, itemView);
errorTextView.setText(R.string.load_more_posts_error);
+ errorTextView.setTextColor(mSecondaryTextColor);
retryButton.setOnClickListener(view -> mCallback.retryLoadingMore());
+ retryButton.setBackgroundTintList(ColorStateList.valueOf(mColorPrimaryLightTheme));
+ retryButton.setTextColor(mButtonTextColor);
+ itemView.setOnClickListener(view -> retryButton.performClick());
}
}
class LoadingViewHolder extends RecyclerView.ViewHolder {
+ @BindView(R.id.progress_bar_item_footer_loading)
+ ProgressBar progressBar;
+
LoadingViewHolder(@NonNull View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
+ progressBar.setIndeterminateTintList(ColorStateList.valueOf(mColorAccent));
}
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/RulesRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/RulesRecyclerViewAdapter.java
index 0300834d..80e246d6 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/RulesRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/RulesRecyclerViewAdapter.java
@@ -24,14 +24,17 @@ import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
import io.noties.markwon.linkify.LinkifyPlugin;
import io.noties.markwon.simple.ext.SimpleExtPlugin;
import ml.docilealligator.infinityforreddit.Activity.LinkResolverActivity;
+import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.Rule;
public class RulesRecyclerViewAdapter extends RecyclerView.Adapter<RulesRecyclerViewAdapter.RuleViewHolder> {
private Markwon markwon;
private ArrayList<Rule> rules;
+ private int mPrimaryTextColor;
+ private int mSecondaryTextColor;
- public RulesRecyclerViewAdapter(Context context) {
+ public RulesRecyclerViewAdapter(Context context, CustomThemeWrapper customThemeWrapper) {
markwon = Markwon.builder(context)
.usePlugin(new AbstractMarkwonPlugin() {
@Override
@@ -57,6 +60,9 @@ public class RulesRecyclerViewAdapter extends RecyclerView.Adapter<RulesRecycler
)
)
.build();
+ int themeType = customThemeWrapper.getThemeType();
+ mPrimaryTextColor = customThemeWrapper.getPrimaryTextColor(themeType);
+ mSecondaryTextColor = customThemeWrapper.getSecondaryTextColor(themeType);
}
@NonNull
@@ -100,6 +106,8 @@ public class RulesRecyclerViewAdapter extends RecyclerView.Adapter<RulesRecycler
RuleViewHolder(@NonNull View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
+ shortNameTextView.setTextColor(mPrimaryTextColor);
+ descriptionMarkwonView.setTextColor(mSecondaryTextColor);
}
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/SubredditListingRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/SubredditListingRecyclerViewAdapter.java
index 21646e8d..0ee42625 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/SubredditListingRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/SubredditListingRecyclerViewAdapter.java
@@ -1,11 +1,13 @@
package ml.docilealligator.infinityforreddit.Adapter;
import android.content.Context;
+import android.content.res.ColorStateList;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
+import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
@@ -24,6 +26,7 @@ import butterknife.BindView;
import butterknife.ButterKnife;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import ml.docilealligator.infinityforreddit.AsyncTask.CheckIsSubscribedToSubredditAsyncTask;
+import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.NetworkState;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
@@ -54,11 +57,18 @@ public class SubredditListingRecyclerViewAdapter extends PagedListAdapter<Subred
private String accessToken;
private String accountName;
private RedditDataRoomDatabase redditDataRoomDatabase;
+ private int colorPrimaryLightTheme;
+ private int primaryTextColor;
+ private int secondaryTextColor;
+ private int colorAccent;
+ private int buttonTextColor;
+ private int unsubscribed;
private NetworkState networkState;
private Callback callback;
public SubredditListingRecyclerViewAdapter(Context context, Retrofit oauthRetrofit, Retrofit retrofit,
+ CustomThemeWrapper customThemeWrapper,
String accessToken, String accountName,
RedditDataRoomDatabase redditDataRoomDatabase,
Callback callback) {
@@ -71,6 +81,13 @@ public class SubredditListingRecyclerViewAdapter extends PagedListAdapter<Subred
this.redditDataRoomDatabase = redditDataRoomDatabase;
this.callback = callback;
glide = Glide.with(context.getApplicationContext());
+ int themeType = customThemeWrapper.getThemeType();
+ colorPrimaryLightTheme = customThemeWrapper.getColorPrimaryLightTheme(themeType);
+ primaryTextColor = customThemeWrapper.getPrimaryTextColor(themeType);
+ secondaryTextColor = customThemeWrapper.getSecondaryTextColor(themeType);
+ colorAccent = customThemeWrapper.getColorAccent(themeType);
+ buttonTextColor = customThemeWrapper.getButtonTextColor(themeType);
+ unsubscribed = customThemeWrapper.getUnsubscribed(themeType);
}
@NonNull
@@ -209,6 +226,8 @@ public class SubredditListingRecyclerViewAdapter extends PagedListAdapter<Subred
DataViewHolder(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
+ subredditNameTextView.setTextColor(primaryTextColor);
+ subscribeButton.setColorFilter(unsubscribed, android.graphics.PorterDuff.Mode.SRC_IN);
}
}
@@ -223,13 +242,20 @@ public class SubredditListingRecyclerViewAdapter extends PagedListAdapter<Subred
ButterKnife.bind(this, itemView);
retryButton.setOnClickListener(view -> callback.retryLoadingMore());
errorTextView.setText(R.string.load_comments_failed);
+ errorTextView.setTextColor(secondaryTextColor);
+ retryButton.setBackgroundTintList(ColorStateList.valueOf(colorPrimaryLightTheme));
+ retryButton.setTextColor(buttonTextColor);
}
}
class LoadingViewHolder extends RecyclerView.ViewHolder {
+ @BindView(R.id.progress_bar_item_footer_loading)
+ ProgressBar progressBar;
+
LoadingViewHolder(@NonNull View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
+ progressBar.setIndeterminateTintList(ColorStateList.valueOf(colorAccent));
}
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/SubredditMultiselectionRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/SubredditMultiselectionRecyclerViewAdapter.java
index 350ef8fe..477648af 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/SubredditMultiselectionRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/SubredditMultiselectionRecyclerViewAdapter.java
@@ -1,6 +1,7 @@
package ml.docilealligator.infinityforreddit.Adapter;
import android.content.Context;
+import android.content.res.ColorStateList;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -21,6 +22,7 @@ import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
+import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditData;
import ml.docilealligator.infinityforreddit.SubredditWithSelection;
@@ -38,8 +40,10 @@ public class SubredditMultiselectionRecyclerViewAdapter extends RecyclerView.Ada
private ArrayList<SubredditWithSelection> selectedOtherSubreddits;
private Context context;
private RequestManager glide;
+ private int primaryTextColor;
+ private int colorAccent;
- public SubredditMultiselectionRecyclerViewAdapter(Context context,
+ public SubredditMultiselectionRecyclerViewAdapter(Context context, CustomThemeWrapper customThemeWrapper,
ArrayList<SubredditWithSelection> selectedSubscribedSubreddits,
ArrayList<SubredditWithSelection> otherSubreddits) {
this.context = context;
@@ -57,6 +61,10 @@ public class SubredditMultiselectionRecyclerViewAdapter extends RecyclerView.Ada
this.selectedOtherSubreddits.addAll(otherSubreddits);
this.otherSubreddits.addAll(otherSubreddits);
}
+
+ int themeType = customThemeWrapper.getThemeType();
+ primaryTextColor = customThemeWrapper.getPrimaryTextColor(themeType);
+ colorAccent = customThemeWrapper.getColorAccent(themeType);
}
@Override
@@ -256,6 +264,8 @@ public class SubredditMultiselectionRecyclerViewAdapter extends RecyclerView.Ada
super(itemView);
this.itemView = itemView;
ButterKnife.bind(this, itemView);
+ nameTextView.setTextColor(primaryTextColor);
+ checkBox.setButtonTintList(ColorStateList.valueOf(colorAccent));
}
}
@@ -272,6 +282,8 @@ public class SubredditMultiselectionRecyclerViewAdapter extends RecyclerView.Ada
super(itemView);
this.itemView = itemView;
ButterKnife.bind(this, itemView);
+ nameTextView.setTextColor(primaryTextColor);
+ checkBox.setButtonTintList(ColorStateList.valueOf(colorAccent));
}
}
} \ No newline at end of file
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/SubscribedSubredditsRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/SubscribedSubredditsRecyclerViewAdapter.java
index 3b2d43f9..9b9bdc92 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/SubscribedSubredditsRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/SubscribedSubredditsRecyclerViewAdapter.java
@@ -22,6 +22,7 @@ import butterknife.BindView;
import butterknife.ButterKnife;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import ml.docilealligator.infinityforreddit.Activity.ViewSubredditDetailActivity;
+import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.FavoriteThing;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
@@ -48,21 +49,29 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
private String userIconUrl;
private boolean hasClearSelectionRow;
+ private int primaryTextColor;
+ private int secondaryTextColor;
+
public SubscribedSubredditsRecyclerViewAdapter(Context context, Retrofit oauthRetrofit,
RedditDataRoomDatabase redditDataRoomDatabase,
+ CustomThemeWrapper customThemeWrapper,
String accessToken) {
mContext = context;
glide = Glide.with(context.getApplicationContext());
mOauthRetrofit = oauthRetrofit;
mRedditDataRoomDatabase = redditDataRoomDatabase;
this.accessToken = accessToken;
+ int themeType = customThemeWrapper.getThemeType();
+ primaryTextColor = customThemeWrapper.getPrimaryTextColor(themeType);
+ secondaryTextColor = customThemeWrapper.getSecondaryTextColor(themeType);
}
public SubscribedSubredditsRecyclerViewAdapter(Context context, Retrofit oauthRetrofit,
RedditDataRoomDatabase redditDataRoomDatabase,
+ CustomThemeWrapper customThemeWrapper,
String accessToken, boolean hasClearSelectionRow,
ItemClickListener itemClickListener) {
- this(context, oauthRetrofit, redditDataRoomDatabase, accessToken);
+ this(context, oauthRetrofit, redditDataRoomDatabase, customThemeWrapper, accessToken);
this.hasClearSelectionRow = hasClearSelectionRow;
this.itemClickListener = itemClickListener;
}
@@ -410,6 +419,7 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
SubredditViewHolder(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
+ subredditNameTextView.setTextColor(primaryTextColor);
}
}
@@ -424,6 +434,7 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
FavoriteSubredditViewHolder(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
+ subredditNameTextView.setTextColor(primaryTextColor);
}
}
@@ -434,6 +445,7 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
super(itemView);
ButterKnife.bind(this, itemView);
dividerTextView.setText(R.string.favorites);
+ dividerTextView.setTextColor(secondaryTextColor);
}
}
@@ -444,6 +456,7 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
super(itemView);
ButterKnife.bind(this, itemView);
dividerTextView.setText(R.string.all);
+ dividerTextView.setTextColor(secondaryTextColor);
}
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/UserListingRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/UserListingRecyclerViewAdapter.java
index 995b58cf..cf6771c0 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/UserListingRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/UserListingRecyclerViewAdapter.java
@@ -2,11 +2,13 @@ package ml.docilealligator.infinityforreddit.Adapter;
import android.content.Context;
import android.content.Intent;
+import android.content.res.ColorStateList;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
+import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
@@ -26,6 +28,7 @@ import butterknife.ButterKnife;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import ml.docilealligator.infinityforreddit.Activity.ViewUserDetailActivity;
import ml.docilealligator.infinityforreddit.AsyncTask.CheckIsFollowingUserAsyncTask;
+import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.NetworkState;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUserDao;
@@ -57,11 +60,18 @@ public class UserListingRecyclerViewAdapter extends PagedListAdapter<UserData, R
private String accountName;
private SubscribedUserDao subscribedUserDao;
+ private int primaryTextColor;
+ private int buttonTextColor;
+ private int colorPrimaryLightTheme;
+ private int colorAccent;
+ private int unsubscribedColor;
+
private NetworkState networkState;
private UserListingRecyclerViewAdapter.RetryLoadingMoreCallback retryLoadingMoreCallback;
public UserListingRecyclerViewAdapter(Context context, Retrofit oauthRetrofit, Retrofit retrofit,
- String accessToken, String accountName, SubscribedUserDao subscribedUserDao,
+ CustomThemeWrapper customThemeWrapper, String accessToken,
+ String accountName, SubscribedUserDao subscribedUserDao,
UserListingRecyclerViewAdapter.RetryLoadingMoreCallback retryLoadingMoreCallback) {
super(DIFF_CALLBACK);
this.context = context;
@@ -72,6 +82,12 @@ public class UserListingRecyclerViewAdapter extends PagedListAdapter<UserData, R
this.subscribedUserDao = subscribedUserDao;
this.retryLoadingMoreCallback = retryLoadingMoreCallback;
glide = Glide.with(context.getApplicationContext());
+ int themeType = customThemeWrapper.getThemeType();
+ primaryTextColor = customThemeWrapper.getPrimaryTextColor(themeType);
+ buttonTextColor = customThemeWrapper.getButtonTextColor(themeType);
+ colorPrimaryLightTheme = customThemeWrapper.getColorPrimaryLightTheme(themeType);
+ colorAccent = customThemeWrapper.getColorAccent(themeType);
+ unsubscribedColor = customThemeWrapper.getUnsubscribed(themeType);
}
@NonNull
@@ -93,54 +109,56 @@ public class UserListingRecyclerViewAdapter extends PagedListAdapter<UserData, R
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
if (holder instanceof UserListingRecyclerViewAdapter.DataViewHolder) {
UserData userData = getItem(position);
- ((UserListingRecyclerViewAdapter.DataViewHolder) holder).constraintLayout.setOnClickListener(view -> {
- Intent intent = new Intent(context, ViewUserDetailActivity.class);
- intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, userData.getName());
- context.startActivity(intent);
- });
-
- if (!userData.getIconUrl().equals("")) {
- glide.load(userData.getIconUrl())
- .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
- .error(glide.load(R.drawable.subreddit_default_icon)
- .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
- .into(((UserListingRecyclerViewAdapter.DataViewHolder) holder).iconGifImageView);
- } else {
- glide.load(R.drawable.subreddit_default_icon)
- .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
- .into(((UserListingRecyclerViewAdapter.DataViewHolder) holder).iconGifImageView);
- }
+ if (userData != null) {
+ ((UserListingRecyclerViewAdapter.DataViewHolder) holder).constraintLayout.setOnClickListener(view -> {
+ Intent intent = new Intent(context, ViewUserDetailActivity.class);
+ intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, userData.getName());
+ context.startActivity(intent);
+ });
+
+ if (!userData.getIconUrl().equals("")) {
+ glide.load(userData.getIconUrl())
+ .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
+ .error(glide.load(R.drawable.subreddit_default_icon)
+ .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
+ .into(((UserListingRecyclerViewAdapter.DataViewHolder) holder).iconGifImageView);
+ } else {
+ glide.load(R.drawable.subreddit_default_icon)
+ .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
+ .into(((UserListingRecyclerViewAdapter.DataViewHolder) holder).iconGifImageView);
+ }
+
+ ((UserListingRecyclerViewAdapter.DataViewHolder) holder).userNameTextView.setText(userData.getName());
- ((UserListingRecyclerViewAdapter.DataViewHolder) holder).UserNameTextView.setText(userData.getName());
-
- new CheckIsFollowingUserAsyncTask(subscribedUserDao, userData.getName(), accountName,
- new CheckIsFollowingUserAsyncTask.CheckIsFollowingUserListener() {
- @Override
- public void isSubscribed() {
- ((UserListingRecyclerViewAdapter.DataViewHolder) holder).subscribeButton.setVisibility(View.GONE);
- }
-
- @Override
- public void isNotSubscribed() {
- ((UserListingRecyclerViewAdapter.DataViewHolder) holder).subscribeButton.setVisibility(View.VISIBLE);
- ((UserListingRecyclerViewAdapter.DataViewHolder) holder).subscribeButton.setOnClickListener(view -> {
- UserFollowing.followUser(oauthRetrofit, retrofit,
- accessToken, userData.getName(), accountName, subscribedUserDao,
- new UserFollowing.UserFollowingListener() {
- @Override
- public void onUserFollowingSuccess() {
- ((UserListingRecyclerViewAdapter.DataViewHolder) holder).subscribeButton.setVisibility(View.GONE);
- Toast.makeText(context, R.string.followed, Toast.LENGTH_SHORT).show();
- }
-
- @Override
- public void onUserFollowingFail() {
- Toast.makeText(context, R.string.follow_failed, Toast.LENGTH_SHORT).show();
- }
- });
- });
- }
- }).execute();
+ new CheckIsFollowingUserAsyncTask(subscribedUserDao, userData.getName(), accountName,
+ new CheckIsFollowingUserAsyncTask.CheckIsFollowingUserListener() {
+ @Override
+ public void isSubscribed() {
+ ((UserListingRecyclerViewAdapter.DataViewHolder) holder).subscribeButton.setVisibility(View.GONE);
+ }
+
+ @Override
+ public void isNotSubscribed() {
+ ((UserListingRecyclerViewAdapter.DataViewHolder) holder).subscribeButton.setVisibility(View.VISIBLE);
+ ((UserListingRecyclerViewAdapter.DataViewHolder) holder).subscribeButton.setOnClickListener(view -> {
+ UserFollowing.followUser(oauthRetrofit, retrofit,
+ accessToken, userData.getName(), accountName, subscribedUserDao,
+ new UserFollowing.UserFollowingListener() {
+ @Override
+ public void onUserFollowingSuccess() {
+ ((UserListingRecyclerViewAdapter.DataViewHolder) holder).subscribeButton.setVisibility(View.GONE);
+ Toast.makeText(context, R.string.followed, Toast.LENGTH_SHORT).show();
+ }
+
+ @Override
+ public void onUserFollowingFail() {
+ Toast.makeText(context, R.string.follow_failed, Toast.LENGTH_SHORT).show();
+ }
+ });
+ });
+ }
+ }).execute();
+ }
}
}
@@ -204,13 +222,15 @@ public class UserListingRecyclerViewAdapter extends PagedListAdapter<UserData, R
@BindView(R.id.user_icon_gif_image_view_item_user_listing)
GifImageView iconGifImageView;
@BindView(R.id.user_name_text_view_item_user_listing)
- TextView UserNameTextView;
+ TextView userNameTextView;
@BindView(R.id.subscribe_image_view_item_user_listing)
ImageView subscribeButton;
DataViewHolder(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
+ userNameTextView.setTextColor(primaryTextColor);
+ subscribeButton.setColorFilter(unsubscribedColor, android.graphics.PorterDuff.Mode.SRC_IN);
}
}
@@ -225,13 +245,20 @@ public class UserListingRecyclerViewAdapter extends PagedListAdapter<UserData, R
ButterKnife.bind(this, itemView);
retryButton.setOnClickListener(view -> retryLoadingMoreCallback.retryLoadingMore());
errorTextView.setText(R.string.load_comments_failed);
+ errorTextView.setTextColor(primaryTextColor);
+ retryButton.setTextColor(buttonTextColor);
+ retryButton.setBackgroundTintList(ColorStateList.valueOf(colorPrimaryLightTheme));
}
}
class LoadingViewHolder extends RecyclerView.ViewHolder {
+ @BindView(R.id.progress_bar_item_footer_loading)
+ ProgressBar progressBar;
+
LoadingViewHolder(@NonNull View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
+ progressBar.setIndeterminateTintList(ColorStateList.valueOf(colorAccent));
}
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/AppModule.java b/app/src/main/java/ml/docilealligator/infinityforreddit/AppModule.java
index 8cf7f4fc..d28821b7 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/AppModule.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/AppModule.java
@@ -14,8 +14,8 @@ import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
+import ml.docilealligator.infinityforreddit.Utils.CustomThemeSharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
-import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import okhttp3.ConnectionPool;
import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
@@ -110,7 +110,7 @@ class AppModule {
@Named("theme")
@Singleton
SharedPreferences provideThemeSharedPreferences() {
- return mApplication.getSharedPreferences(SharedPreferencesUtils.THEME_SHARED_PREFERENCES_FILE, Context.MODE_PRIVATE);
+ return mApplication.getSharedPreferences(CustomThemeSharedPreferencesUtils.THEME_SHARED_PREFERENCES_FILE, Context.MODE_PRIVATE);
}
@Provides
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeWrapper.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeWrapper.java
index 63cb72d8..eae935a1 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeWrapper.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CustomTheme/CustomThemeWrapper.java
@@ -3,63 +3,13 @@ package ml.docilealligator.infinityforreddit.CustomTheme;
import android.content.SharedPreferences;
import android.graphics.Color;
-import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
+import ml.docilealligator.infinityforreddit.Utils.CustomThemeSharedPreferencesUtils;
-public class CustomThemeWrapper {
- public static final int NORMAL = 0;
- public static final int DARK = 1;
- public static final int AMOLED_DARK = 2;
-
- public int colorPrimary;
- public int colorPrimaryDark;
- public int colorAccent;
- public int colorPrimaryLightTheme;
- public int primaryTextColor;
- public int secondaryTextColor;
- public int backgroundColor;
- public int roundedBottomSheetPrimaryBackground;
- public int cardViewBackgroundColor;
- public int toolbarPrimaryTextAndIconColor;
- public int toolbarAndTabBackgroundColor;
- public int circularProgressBarBackground;
- public int tabLayoutWithExpandedCollapsingToolbarTabBackground;
- public int tabLayoutWithExpandedCollapsingToolbarTextColor;
- public int tabLayoutWithExpandedCollapsingToolbarTabIndicator;
- public int tabLayoutWithCollapsedCollapsingToolbarTabBackground;
- public int tabLayoutWithCollapsedCollapsingToolbarTextColor;
- public int tabLayoutWithCollapsedCollapsingToolbarTabIndicator;
- public int navBarColor;
- public int upvoted;
- public int downvoted;
- public int postType;
- public int spoilerColor;
- public int nsfwColor;
- public int flairColor;
- public int archivedTint;
- public int lockedIconTint;
- public int crosspost;
- public int stickiedPost;
- public int subscribed;
- public int unsubscribed;
- public int username;
- public int subreddit;
- public int authorFlairTextColor;
- public int submitter;
- public int moderator;
- public int notificationIconColor;
- public int singleCommentThreadBackgroundColor;
- public int unreadMessageBackgroundColor;
- public int dividerColor;
- public int noPreviewLinkBackgroundColor;
- public int voteAndReplyUnavailableVoteButtonColor;
- public int commentVerticalBarColor1;
- public int commentVerticalBarColor2;
- public int commentVerticalBarColor3;
- public int commentVerticalBarColor4;
- public int commentVerticalBarColor5;
- public int commentVerticalBarColor6;
- public int commentVerticalBarColor7;
+import static ml.docilealligator.infinityforreddit.Utils.CustomThemeSharedPreferencesUtils.AMOLED_DARK;
+import static ml.docilealligator.infinityforreddit.Utils.CustomThemeSharedPreferencesUtils.DARK;
+import static ml.docilealligator.infinityforreddit.Utils.CustomThemeSharedPreferencesUtils.NORMAL;
+public class CustomThemeWrapper {
private SharedPreferences themeSharedPreferences;
public CustomThemeWrapper(SharedPreferences themeSharedPreferences) {
@@ -76,296 +26,288 @@ public class CustomThemeWrapper {
return Color.parseColor(normalHex);
}
}
+
+ public int getThemeType() {
+ return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.THEME_TYPE_KEY, NORMAL);
+ }
+
public int getColorPrimary(int themeType) {
- //f
- return themeSharedPreferences.getInt(SharedPreferencesUtils.COLOR_PRIMARY,
+ return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.COLOR_PRIMARY,
getDefaultColor(themeType, "#1565C0", "#242424", "#000000"));
}
public int getColorPrimaryDark(int themeType) {
- //f
- return themeSharedPreferences.getInt(SharedPreferencesUtils.COLOR_PRIMARY_DARK,
+ return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.COLOR_PRIMARY_DARK,
getDefaultColor(themeType, "#0D47A1", "#121212", "#000000"));
}
public int getColorAccent(int themeType) {
- //f
- return themeSharedPreferences.getInt(SharedPreferencesUtils.COLOR_ACCENT,
+ return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.COLOR_ACCENT,
getDefaultColor(themeType, "#FF4081", "#FF4081", "#FF4081"));
}
public int getColorPrimaryLightTheme(int themeType) {
- //f
- return themeSharedPreferences.getInt(SharedPreferencesUtils.COLOR_PRIMARY_LIGHT_THEME,
+ return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.COLOR_PRIMARY_LIGHT_THEME,
getDefaultColor(themeType, "#1565C0", "#1565C0", "#1565C0"));
}
+ public int getPostTitleColor(int themeType) {
+ return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.POST_TITLE_COLOR,
+ getDefaultColor(themeType, "#000000", "#FFFFFF", "#FFFFFF"));
+ }
+
+ public int getPostContentColor(int themeType) {
+ return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.POST_CONTENT_COLOR,
+ getDefaultColor(themeType, "#8A000000", "#B3FFFFFF", "#B3FFFFFF"));
+ }
+
+ public int getCommentColor(int themeType) {
+ return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.COMMENT_COLOR,
+ getDefaultColor(themeType, "#000000", "#FFFFFF", "#FFFFFF"));
+ }
+
public int getPrimaryTextColor(int themeType) {
- //f
- return themeSharedPreferences.getInt(SharedPreferencesUtils.PRIMARY_TEXT_COLOR,
+ return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.PRIMARY_TEXT_COLOR,
getDefaultColor(themeType, "#000000", "#FFFFFF", "#FFFFFF"));
}
public int getSecondaryTextColor(int themeType) {
- //F
- return themeSharedPreferences.getInt(SharedPreferencesUtils.SECONDARY_TEXT_COLOR,
+ return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.SECONDARY_TEXT_COLOR,
getDefaultColor(themeType, "#8A000000", "#B3FFFFFF", "#B3FFFFFF"));
}
+ public int getButtonTextColor(int themeType) {
+ return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.BUTTON_TEXT_COLOR,
+ getDefaultColor(themeType, "#FFFFFF", "#FFFFFF", "#FFFFFF"));
+ }
+
public int getBackgroundColor(int themeType) {
- //F
- return themeSharedPreferences.getInt(SharedPreferencesUtils.BACKGROUND_COLOR,
+ return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.BACKGROUND_COLOR,
getDefaultColor(themeType, "#FFFFFF", "#121212", "#000000"));
}
public int getRoundedBottomSheetPrimaryBackground(int themeType) {
- //F
- return themeSharedPreferences.getInt(SharedPreferencesUtils.ROUNDED_BOTTOM_SHEET_PRIMARY_BACKGROUND,
- getDefaultColor(themeType, "#FFFFFF", "#121212", "#000000"));
+ return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.ROUNDED_BOTTOM_SHEET_PRIMARY_BACKGROUND,
+ getDefaultColor(themeType, "#FFFFFF", "#242424", "#000000"));
}
public int getCardViewBackgroundColor(int themeType) {
- //F
- return themeSharedPreferences.getInt(SharedPreferencesUtils.CARD_VIEW_BACKGROUND_COLOR,
+ return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.CARD_VIEW_BACKGROUND_COLOR,
+ getDefaultColor(themeType, "#FFFFFF", "#242424", "#000000"));
+ }
+
+ public int getCommentBackgroundColor(int themeType) {
+ return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.COMMENT_BACKGROUND_COLOR,
getDefaultColor(themeType, "#FFFFFF", "#242424", "#000000"));
}
public int getToolbarPrimaryTextAndIconColor(int themeType) {
- //F
- return themeSharedPreferences.getInt(SharedPreferencesUtils.TOOLBAR_PRIMARY_TEXT_AND_ICON_COLOR,
+ return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.TOOLBAR_PRIMARY_TEXT_AND_ICON_COLOR,
getDefaultColor(themeType, "#FFFFFF", "#FFFFFF", "#FFFFFF"));
}
public int getToolbarAndTabBackgroundColor(int themeType) {
- //F
- return themeSharedPreferences.getInt(SharedPreferencesUtils.TOOLBAR_AND_TAB_BACKGROUND_COLOR,
+ return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.TOOLBAR_AND_TAB_BACKGROUND_COLOR,
getDefaultColor(themeType, "#1565C0", "#282828", "#000000"));
}
public int getCircularProgressBarBackground(int themeType) {
- //F
- return themeSharedPreferences.getInt(SharedPreferencesUtils.CIRCULAR_PROGRESS_BAR_BACKGROUND,
+ return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.CIRCULAR_PROGRESS_BAR_BACKGROUND,
getDefaultColor(themeType, "#FFFFFF", "#242424", "#000000"));
}
public int getTabLayoutWithExpandedCollapsingToolbarTabBackground(int themeType) {
- //F
- return themeSharedPreferences.getInt(SharedPreferencesUtils.TAB_LAYOUT_WITH_EXPANDED_COLLAPSING_TOOLBAR_TAB_BACKGROUND,
+ return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.TAB_LAYOUT_WITH_EXPANDED_COLLAPSING_TOOLBAR_TAB_BACKGROUND,
getDefaultColor(themeType, "#FFFFFF", "#242424", "#000000"));
}
public int getTabLayoutWithExpandedCollapsingToolbarTextColor(int themeType) {
- //F
- return themeSharedPreferences.getInt(SharedPreferencesUtils.TAB_LAYOUT_WITH_EXPANDED_COLLAPSING_TOOLBAR_TEXT_COLOR,
+ return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.TAB_LAYOUT_WITH_EXPANDED_COLLAPSING_TOOLBAR_TEXT_COLOR,
getDefaultColor(themeType, "#1565C0", "#FFFFFF", "#FFFFFF"));
}
public int getTabLayoutWithExpandedCollapsingToolbarTabIndicator(int themeType) {
- //F
- return themeSharedPreferences.getInt(SharedPreferencesUtils.TAB_LAYOUT_WITH_EXPANDED_COLLAPSING_TOOLBAR_TAB_INDICATOR,
+ return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.TAB_LAYOUT_WITH_EXPANDED_COLLAPSING_TOOLBAR_TAB_INDICATOR,
getDefaultColor(themeType, "#1565C0", "#FFFFFF", "#FFFFFF"));
}
public int getTabLayoutWithCollapsedCollapsingToolbarTabBackground(int themeType) {
- //F
- return themeSharedPreferences.getInt(SharedPreferencesUtils.TAB_LAYOUT_WITH_COLLAPSED_COLLAPSING_TOOLBAR_TAB_BACKGROUND,
+ return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.TAB_LAYOUT_WITH_COLLAPSED_COLLAPSING_TOOLBAR_TAB_BACKGROUND,
getDefaultColor(themeType, "#1565C0", "#242424", "#000000"));
}
public int getTabLayoutWithCollapsedCollapsingToolbarTextColor(int themeType) {
- //F
- return themeSharedPreferences.getInt(SharedPreferencesUtils.TAB_LAYOUT_WITH_COLLAPSED_COLLAPSING_TOOLBAR_TEXT_COLOR,
+ return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.TAB_LAYOUT_WITH_COLLAPSED_COLLAPSING_TOOLBAR_TEXT_COLOR,
getDefaultColor(themeType, "#FFFFFF", "#FFFFFF", "#FFFFFF"));
}
public int getTabLayoutWithCollapsedCollapsingToolbarTabIndicator(int themeType) {
- //F
- return themeSharedPreferences.getInt(SharedPreferencesUtils.TAB_LAYOUT_WITH_COLLAPSED_COLLAPSING_TOOLBAR_TAB_INDICATOR,
+ return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.TAB_LAYOUT_WITH_COLLAPSED_COLLAPSING_TOOLBAR_TAB_INDICATOR,
getDefaultColor(themeType, "#FFFFFF", "#FFFFFF", "#FFFFFF"));
}
public int getNavBarColor(int themeType) {
- //F
- return themeSharedPreferences.getInt(SharedPreferencesUtils.NAV_BAR_COLOR,
+ return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.NAV_BAR_COLOR,
getDefaultColor(themeType, "#FFFFFF", "#121212", "#000000"));
}
public int getUpvoted(int themeType) {
- //F
- return themeSharedPreferences.getInt(SharedPreferencesUtils.UPVOTED,
+ return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.UPVOTED,
getDefaultColor(themeType, "#E91E63", "#E91E63", "#E91E63"));
}
public int getDownvoted(int themeType) {
- //F
- return themeSharedPreferences.getInt(SharedPreferencesUtils.DOWNVOTED,
+ return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.DOWNVOTED,
getDefaultColor(themeType, "#007DDE", "#007DDE", "#007DDE"));
}
public int getPostType(int themeType) {
- //F
- return themeSharedPreferences.getInt(SharedPreferencesUtils.POST_TYPE,
+ return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.POST_TYPE,
getDefaultColor(themeType, "#0D47A1", "#1565C0", "#1565C0"));
}
public int getSpoilerColor(int themeType) {
- //F
- return themeSharedPreferences.getInt(SharedPreferencesUtils.SPOILER_COLOR,
+ return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.SPOILER_COLOR,
getDefaultColor(themeType, "#EE02EB", "#EE02EB", "#EE02EB"));
}
public int getNsfwColor(int themeType) {
- //F
- return themeSharedPreferences.getInt(SharedPreferencesUtils.NSFW_COLOR,
+ return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.NSFW_COLOR,
getDefaultColor(themeType, "#FF4081", "#FF4081", "#FF4081"));
}
public int getFlairColor(int themeType) {
- //F
- return themeSharedPreferences.getInt(SharedPreferencesUtils.FLAIR_COLOR,
+ return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.FLAIR_COLOR,
getDefaultColor(themeType, "#00AA8C", "#00AA8C", "#00AA8C"));
}
public int getArchivedTint(int themeType) {
- //F
- return themeSharedPreferences.getInt(SharedPreferencesUtils.ARCHIVED_TINT,
+ return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.ARCHIVED_TINT,
getDefaultColor(themeType, "#B4009F", "#B4009F", "#B4009F"));
}
public int getLockedIconTint(int themeType) {
- //F
- return themeSharedPreferences.getInt(SharedPreferencesUtils.LOCKED_ICON_TINT,
+ return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.LOCKED_ICON_TINT,
getDefaultColor(themeType, "#EE7302", "#EE7302", "#EE7302"));
}
public int getCrosspost(int themeType) {
- //F
- return themeSharedPreferences.getInt(SharedPreferencesUtils.CROSSPOST,
+ return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.CROSSPOST,
getDefaultColor(themeType, "#FF4081", "#FF4081", "#FF4081"));
}
public int getStickiedPost(int themeType) {
- //F
- return themeSharedPreferences.getInt(SharedPreferencesUtils.STICKIED_POST,
+ return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.STICKIED_POST,
getDefaultColor(themeType, "#0D47A1", "#1565C0", "#1565C0"));
}
public int getSubscribed(int themeType) {
- //F
- return themeSharedPreferences.getInt(SharedPreferencesUtils.SUBSCRIBED,
+ return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.SUBSCRIBED,
getDefaultColor(themeType, "#FF4081", "#FF4081", "#FF4081"));
}
public int getUnsubscribed(int themeType) {
- //F
- return themeSharedPreferences.getInt(SharedPreferencesUtils.UNSUBSCRIBED,
+ return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.UNSUBSCRIBED,
getDefaultColor(themeType, "#0D47A1", "#1565C0", "#1565C0"));
}
public int getUsername(int themeType) {
- return themeSharedPreferences.getInt(SharedPreferencesUtils.USERNAME,
+ return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.USERNAME,
getDefaultColor(themeType, "#0D47A1", "#1E88E5", "#1E88E5"));
}
public int getSubreddit(int themeType) {
- //F
- return themeSharedPreferences.getInt(SharedPreferencesUtils.SUBREDDIT,
+ return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.SUBREDDIT,
getDefaultColor(themeType, "#E91E63", "#E91E63", "#E91E63"));
}
public int getAuthorFlairTextColor(int themeType) {
- //F
- return themeSharedPreferences.getInt(SharedPreferencesUtils.AUTHOR_FLAIR_TEXT_COLOR,
+ return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.AUTHOR_FLAIR_TEXT_COLOR,
getDefaultColor(themeType, "#EE02C4", "#EE02C4", "#EE02C4"));
}
public int getSubmitter(int themeType) {
- //F
- return themeSharedPreferences.getInt(SharedPreferencesUtils.SUBMITTER,
+ return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.SUBMITTER,
getDefaultColor(themeType, "#EE8A02", "#EE8A02", "#EE8A02"));
}
public int getModerator(int themeType) {
- //F
- return themeSharedPreferences.getInt(SharedPreferencesUtils.MODERATOR,
+ return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.MODERATOR,
getDefaultColor(themeType, "#00BA81", "#00BA81", "#00BA81"));
}
public int getNotificationIconColor(int themeType) {
- //F
- return themeSharedPreferences.getInt(SharedPreferencesUtils.NOTIFICATION_ICON_COLOR,
+ return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.NOTIFICATION_ICON_COLOR,
getDefaultColor(themeType, "#1565C0", "#1565C0", "#1565C0"));
}
public int getSingleCommentThreadBackgroundColor(int themeType) {
- //F
- return themeSharedPreferences.getInt(SharedPreferencesUtils.SINGLE_COMMENT_THREAD_BACKGROUND,
+ return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.SINGLE_COMMENT_THREAD_BACKGROUND,
getDefaultColor(themeType, "#B3E5F9", "#123E77", "#123E77"));
}
public int getUnreadMessageBackgroundColor(int themeType) {
- //F
- return themeSharedPreferences.getInt(SharedPreferencesUtils.UNREAD_MESSAGE_BACKGROUND_COLOR,
+ return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.UNREAD_MESSAGE_BACKGROUND_COLOR,
getDefaultColor(themeType, "#B3E5F9", "#123E77", "#123E77"));
}
public int getDividerColor(int themeType) {
- //F
- return themeSharedPreferences.getInt(SharedPreferencesUtils.DIVIDER_COLOR,
+ return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.DIVIDER_COLOR,
getDefaultColor(themeType, "#E0E0E0", "#69666C", "#69666C"));
}
public int getNoPreviewLinkBackgroundColor(int themeType) {
- //F
- return themeSharedPreferences.getInt(SharedPreferencesUtils.NO_PREVIEW_LINK_BACKGROUND_COLOR,
+ return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.NO_PREVIEW_LINK_BACKGROUND_COLOR,
getDefaultColor(themeType, "#E0E0E0", "#424242", "#424242"));
}
public int getVoteAndReplyUnavailableVoteButtonColor(int themeType) {
- //F
- return themeSharedPreferences.getInt(SharedPreferencesUtils.VOTE_AND_REPLY_UNAVAILABLE_VOTE_BUTTON_COLOR,
+ return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.VOTE_AND_REPLY_UNAVAILABLE_VOTE_BUTTON_COLOR,
getDefaultColor(themeType, "#F0F0F0", "#3C3C3C", "#3C3C3C"));
}
public int getCommentVerticalBarColor1(int themeType) {
- //F
- return themeSharedPreferences.getInt(SharedPreferencesUtils.COMMENT_VERTICAL_BAR_COLOR_1,
+ return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.COMMENT_VERTICAL_BAR_COLOR_1,
getDefaultColor(themeType, "#1565C0", "#1565C0", "#1565C0"));
}
public int getCommentVerticalBarColor2(int themeType) {
- //F
- return themeSharedPreferences.getInt(SharedPreferencesUtils.COMMENT_VERTICAL_BAR_COLOR_2,
+ return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.COMMENT_VERTICAL_BAR_COLOR_2,
getDefaultColor(themeType, "#EE02BE", "#C300B3", "#C300B3"));
}
public int getCommentVerticalBarColor3(int themeType) {
- //F
- return themeSharedPreferences.getInt(SharedPreferencesUtils.COMMENT_VERTICAL_BAR_COLOR_3,
+ return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.COMMENT_VERTICAL_BAR_COLOR_3,
getDefaultColor(themeType, "#02DFEE", "#00B8DA", "#00B8DA"));
}
public int getCommentVerticalBarColor4(int themeType) {
- //F
- return themeSharedPreferences.getInt(SharedPreferencesUtils.COMMENT_VERTICAL_BAR_COLOR_4,
+ return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.COMMENT_VERTICAL_BAR_COLOR_4,
getDefaultColor(themeType, "#EED502", "#EDCA00", "#EDCA00"));
}
public int getCommentVerticalBarColor5(int themeType) {
- //F
- return themeSharedPreferences.getInt(SharedPreferencesUtils.COMMENT_VERTICAL_BAR_COLOR_5,
+ return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.COMMENT_VERTICAL_BAR_COLOR_5,
getDefaultColor(themeType, "#EE0220", "#EE0219", "#EE0219"));
}
public int getCommentVerticalBarColor6(int themeType) {
- //F
- return themeSharedPreferences.getInt(SharedPreferencesUtils.COMMENT_VERTICAL_BAR_COLOR_6,
+ return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.COMMENT_VERTICAL_BAR_COLOR_6,
getDefaultColor(themeType, "#02EE6E", "#00B925", "#00B925"));
}
public int getCommentVerticalBarColor7(int themeType) {
- //F
- return themeSharedPreferences.getInt(SharedPreferencesUtils.COMMENT_VERTICAL_BAR_COLOR_7,
+ return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.COMMENT_VERTICAL_BAR_COLOR_7,
getDefaultColor(themeType, "#EE4602", "#EE4602", "#EE4602"));
}
+
+ public int getFABIconColor(int themeType) {
+ return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.FAB_ICON_COLOR,
+ getDefaultColor(themeType, "#1565C0", "#1565C0", "#1565C0"));
+ }
+
+ public int getChipTextColor(int themeType) {
+ return themeSharedPreferences.getInt(CustomThemeSharedPreferencesUtils.CHIP_TEXT_COLOR,
+ getDefaultColor(themeType, "#FFFFFF", "#FFFFFF", "#FFFFFF"));
+ }
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CommentsListingFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CommentsListingFragment.java
index 8cb75d6a..44e24f86 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CommentsListingFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CommentsListingFragment.java
@@ -34,6 +34,7 @@ import ml.docilealligator.infinityforreddit.Activity.BaseActivity;
import ml.docilealligator.infinityforreddit.Adapter.CommentsListingRecyclerViewAdapter;
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
import ml.docilealligator.infinityforreddit.CommentViewModel;
+import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.FragmentCommunicator;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.NetworkState;
@@ -82,6 +83,8 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni
@Inject
@Named("default")
SharedPreferences mSharedPreferences;
+ @Inject
+ CustomThemeWrapper customThemeWrapper;
private boolean mNullAccessToken = false;
private String mAccessToken;
private RequestManager mGlide;
@@ -105,6 +108,8 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni
ButterKnife.bind(this, rootView);
+ applyTheme();
+
mGlide = Glide.with(mActivity);
Resources resources = getResources();
@@ -154,7 +159,7 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni
mCommentRecyclerView.setLayoutManager(new LinearLayoutManager(mActivity));
boolean voteButtonsOnTheRight = mSharedPreferences.getBoolean(SharedPreferencesUtils.VOTE_BUTTONS_ON_THE_RIGHT_KEY, false);
- mAdapter = new CommentsListingRecyclerViewAdapter(mActivity, mOauthRetrofit,
+ mAdapter = new CommentsListingRecyclerViewAdapter(mActivity, mOauthRetrofit, customThemeWrapper,
getArguments().getString(EXTRA_ACCESS_TOKEN), getArguments().getString(EXTRA_ACCOUNT_NAME),
voteButtonsOnTheRight, mShowElapsedTime, mShowCommentDivider, mShowAbsoluteNumberOfVotes,
() -> mCommentViewModel.retryLoadingMore());
@@ -213,8 +218,6 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni
mCommentViewModel.getPaginationNetworkState().observe(this, networkState -> mAdapter.setNetworkState(networkState));
mSwipeRefreshLayout.setOnRefreshListener(() -> mCommentViewModel.refresh());
- mSwipeRefreshLayout.setProgressBackgroundColorSchemeColor(Utils.getAttributeColor(mActivity, R.attr.cardViewBackgroundColor));
- mSwipeRefreshLayout.setColorSchemeColors(Utils.getAttributeColor(mActivity, R.attr.colorAccent));
}
public void changeSortType(SortType sortType) {
@@ -241,6 +244,14 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni
mAdapter.setNetworkState(null);
}
+ @Override
+ public void applyTheme() {
+ int themeType = customThemeWrapper.getThemeType();
+ mSwipeRefreshLayout.setProgressBackgroundColorSchemeColor(customThemeWrapper.getCardViewBackgroundColor(themeType));
+ mSwipeRefreshLayout.setColorSchemeColors(customThemeWrapper.getColorAccent(themeType));
+ mFetchCommentInfoTextView.setTextColor(customThemeWrapper.getSecondaryTextColor(themeType));
+ }
+
private void showErrorView(int stringResId) {
if (mActivity != null && isAdded()) {
mSwipeRefreshLayout.setRefreshing(false);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/FlairBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/FlairBottomSheetFragment.java
index 15b17134..78b3c665 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/FlairBottomSheetFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/FlairBottomSheetFragment.java
@@ -2,6 +2,7 @@ package ml.docilealligator.infinityforreddit.Fragment;
import android.app.Activity;
+import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
@@ -24,6 +25,7 @@ import javax.inject.Named;
import butterknife.BindView;
import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.Adapter.FlairBottomSheetRecyclerViewAdapter;
+import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.FetchFlairs;
import ml.docilealligator.infinityforreddit.Flair;
import ml.docilealligator.infinityforreddit.Infinity;
@@ -50,6 +52,8 @@ public class FlairBottomSheetFragment extends BottomSheetDialogFragment {
@Inject
@Named("no_oauth")
Retrofit mRetrofit;
+ @Inject
+ CustomThemeWrapper mCustomThemeWrapper;
private String mAccessToken;
private String mSubredditName;
private Activity mActivity;
@@ -66,16 +70,9 @@ public class FlairBottomSheetFragment extends BottomSheetDialogFragment {
ButterKnife.bind(this, rootView);
- mActivity = getActivity();
-
((Infinity) mActivity.getApplication()).getAppComponent().inject(this);
- /*if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
- && (getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) {
- rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
- }*/
-
- mAdapter = new FlairBottomSheetRecyclerViewAdapter(mActivity, flair -> {
+ mAdapter = new FlairBottomSheetRecyclerViewAdapter(mActivity, mCustomThemeWrapper, flair -> {
((FlairSelectionCallback) mActivity).flairSelected(flair);
dismiss();
});
@@ -119,4 +116,10 @@ public class FlairBottomSheetFragment extends BottomSheetDialogFragment {
public interface FlairSelectionCallback {
void flairSelected(Flair flair);
}
+
+ @Override
+ public void onAttach(@NonNull Context context) {
+ super.onAttach(context);
+ mActivity = (Activity) context;
+ }
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/FollowedUsersListingFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/FollowedUsersListingFragment.java
index 9dad2c5e..a57545fa 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/FollowedUsersListingFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/FollowedUsersListingFragment.java
@@ -2,8 +2,8 @@ package ml.docilealligator.infinityforreddit.Fragment;
import android.app.Activity;
+import android.content.Context;
import android.content.SharedPreferences;
-import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Build;
import android.os.Bundle;
@@ -12,7 +12,9 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
+import android.widget.TextView;
+import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager;
@@ -30,13 +32,13 @@ import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.Activity.BaseActivity;
import ml.docilealligator.infinityforreddit.Activity.SubscribedThingListingActivity;
import ml.docilealligator.infinityforreddit.Adapter.FollowedUsersRecyclerViewAdapter;
+import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.FragmentCommunicator;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUserViewModel;
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
-import ml.docilealligator.infinityforreddit.Utils.Utils;
import retrofit2.Retrofit;
@@ -56,6 +58,8 @@ public class FollowedUsersListingFragment extends Fragment implements FragmentCo
LinearLayout mLinearLayout;
@BindView(R.id.no_subscriptions_image_view_followed_users_listing_fragment)
ImageView mImageView;
+ @BindView(R.id.error_text_view_followed_users_listing_fragment)
+ TextView mErrorTextView;
@Inject
@Named("oauth")
Retrofit mOauthRetrofit;
@@ -64,6 +68,8 @@ public class FollowedUsersListingFragment extends Fragment implements FragmentCo
SharedPreferences mSharedPreferences;
@Inject
RedditDataRoomDatabase mRedditDataRoomDatabase;
+ @Inject
+ CustomThemeWrapper customThemeWrapper;
SubscribedUserViewModel mSubscribedUserViewModel;
private Activity mActivity;
private RequestManager mGlide;
@@ -79,10 +85,10 @@ public class FollowedUsersListingFragment extends Fragment implements FragmentCo
ButterKnife.bind(this, rootView);
- mActivity = getActivity();
-
((Infinity) mActivity.getApplication()).getAppComponent().inject(this);
+ applyTheme();
+
Resources resources = getResources();
if ((mActivity instanceof BaseActivity && ((BaseActivity) mActivity).isImmersiveInterface())) {
@@ -97,17 +103,10 @@ public class FollowedUsersListingFragment extends Fragment implements FragmentCo
mGlide = Glide.with(this);
- if (mActivity instanceof SubscribedThingListingActivity) {
- mSwipeRefreshLayout.setOnRefreshListener(() -> ((SubscribedThingListingActivity) mActivity).loadSubscriptions(true));
- mSwipeRefreshLayout.setProgressBackgroundColorSchemeColor(Utils.getAttributeColor(mActivity, R.attr.cardViewBackgroundColor));
- mSwipeRefreshLayout.setColorSchemeColors(Utils.getAttributeColor(mActivity, R.attr.colorAccent));
- } else {
- mSwipeRefreshLayout.setEnabled(false);
- }
-
mRecyclerView.setLayoutManager(new LinearLayoutManager(mActivity));
FollowedUsersRecyclerViewAdapter adapter = new FollowedUsersRecyclerViewAdapter(mActivity,
- mOauthRetrofit, mRedditDataRoomDatabase, getArguments().getString(EXTRA_ACCESS_TOKEN));
+ mOauthRetrofit, mRedditDataRoomDatabase, customThemeWrapper,
+ getArguments().getString(EXTRA_ACCESS_TOKEN));
mRecyclerView.setAdapter(adapter);
mSubscribedUserViewModel = new ViewModelProvider(this,
@@ -142,7 +141,26 @@ public class FollowedUsersListingFragment extends Fragment implements FragmentCo
}
@Override
+ public void onAttach(@NonNull Context context) {
+ super.onAttach(context);
+ mActivity = (Activity) context;
+ }
+
+ @Override
public void stopRefreshProgressbar() {
mSwipeRefreshLayout.setRefreshing(false);
}
+
+ @Override
+ public void applyTheme() {
+ int themeType = customThemeWrapper.getThemeType();
+ if (mActivity instanceof SubscribedThingListingActivity) {
+ mSwipeRefreshLayout.setOnRefreshListener(() -> ((SubscribedThingListingActivity) mActivity).loadSubscriptions(true));
+ mSwipeRefreshLayout.setProgressBackgroundColorSchemeColor(customThemeWrapper.getCardViewBackgroundColor(themeType));
+ mSwipeRefreshLayout.setColorSchemeColors(customThemeWrapper.getColorAccent(themeType));
+ } else {
+ mSwipeRefreshLayout.setEnabled(false);
+ }
+ mErrorTextView.setTextColor(customThemeWrapper.getSecondaryTextColor(themeType));
+ }
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java
index 7b07c9dc..8fdffdd1 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java
@@ -52,6 +52,7 @@ import ml.docilealligator.infinityforreddit.Activity.FilteredThingActivity;
import ml.docilealligator.infinityforreddit.Activity.MainActivity;
import ml.docilealligator.infinityforreddit.Activity.ViewSubredditDetailActivity;
import ml.docilealligator.infinityforreddit.Adapter.PostRecyclerViewAdapter;
+import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.Event.ChangeDefaultPostLayoutEvent;
import ml.docilealligator.infinityforreddit.Event.ChangeNSFWBlurEvent;
import ml.docilealligator.infinityforreddit.Event.ChangePostLayoutEvent;
@@ -114,6 +115,8 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
@Inject
@Named("default")
SharedPreferences mSharedPreferences;
+ @Inject
+ CustomThemeWrapper customThemeWrapper;
private RequestManager mGlide;
private AppCompatActivity activity;
private LinearLayoutManager mLinearLayoutManager;
@@ -183,6 +186,8 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
EventBus.getDefault().register(this);
+ applyTheme();
+
lazyModeHandler = new Handler();
lazyModeInterval = Float.parseFloat(mSharedPreferences.getString(SharedPreferencesUtils.LAZY_MODE_INTERVAL_KEY, "2.5"));
@@ -263,8 +268,6 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
};
mSwipeRefreshLayout.setOnRefreshListener(this::refresh);
- mSwipeRefreshLayout.setProgressBackgroundColorSchemeColor(Utils.getAttributeColor(activity, R.attr.cardViewBackgroundColor));
- mSwipeRefreshLayout.setColorSchemeColors(Utils.getAttributeColor(activity, R.attr.colorAccent));
if (savedInstanceState != null) {
int recyclerViewPosition = savedInstanceState.getInt(RECYCLER_VIEW_POSITION_STATE);
@@ -334,8 +337,9 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
postLayout = mSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_SEARCH_POST, defaultPostLayout);
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mRedditDataRoomDatabase,
- accessToken, postType, postLayout, true, needBlurNsfw, needBlurSpoiler,
- voteButtonsOnTheRight, showElapsedTime, showDividerInCompactLayout, showAbsoluteNumberOfVotes,
+ customThemeWrapper, accessToken, postType, postLayout, true,
+ needBlurNsfw, needBlurSpoiler, voteButtonsOnTheRight, showElapsedTime,
+ showDividerInCompactLayout, showAbsoluteNumberOfVotes,
new PostRecyclerViewAdapter.Callback() {
@Override
public void retryLoadingMore() {
@@ -398,8 +402,9 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
}
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mRedditDataRoomDatabase,
- accessToken, postType, postLayout, displaySubredditName, needBlurNsfw, needBlurSpoiler,
- voteButtonsOnTheRight, showElapsedTime, showDividerInCompactLayout, showAbsoluteNumberOfVotes,
+ customThemeWrapper, accessToken, postType, postLayout, displaySubredditName,
+ needBlurNsfw, needBlurSpoiler, voteButtonsOnTheRight, showElapsedTime,
+ showDividerInCompactLayout, showAbsoluteNumberOfVotes,
new PostRecyclerViewAdapter.Callback() {
@Override
public void retryLoadingMore() {
@@ -447,8 +452,9 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
}
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mRedditDataRoomDatabase,
- accessToken, postType, postLayout, true, needBlurNsfw, needBlurSpoiler,
- voteButtonsOnTheRight, showElapsedTime, showDividerInCompactLayout, showAbsoluteNumberOfVotes,
+ customThemeWrapper, accessToken, postType, postLayout, true,
+ needBlurNsfw, needBlurSpoiler, voteButtonsOnTheRight, showElapsedTime,
+ showDividerInCompactLayout, showAbsoluteNumberOfVotes,
new PostRecyclerViewAdapter.Callback() {
@Override
public void retryLoadingMore() {
@@ -494,8 +500,9 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
postLayout = mSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_USER_POST_BASE + username, defaultPostLayout);
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mRedditDataRoomDatabase,
- accessToken, postType, postLayout, true, needBlurNsfw, needBlurSpoiler,
- voteButtonsOnTheRight, showElapsedTime, showDividerInCompactLayout, showAbsoluteNumberOfVotes,
+ customThemeWrapper, accessToken, postType, postLayout, true,
+ needBlurNsfw, needBlurSpoiler, voteButtonsOnTheRight, showElapsedTime,
+ showDividerInCompactLayout, showAbsoluteNumberOfVotes,
new PostRecyclerViewAdapter.Callback() {
@Override
public void retryLoadingMore() {
@@ -534,8 +541,9 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
postLayout = mSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_FRONT_PAGE_POST, defaultPostLayout);
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mRedditDataRoomDatabase,
- accessToken, postType, postLayout, true, needBlurNsfw, needBlurSpoiler,
- voteButtonsOnTheRight, showElapsedTime, showDividerInCompactLayout, showAbsoluteNumberOfVotes,
+ customThemeWrapper, accessToken, postType, postLayout, true,
+ needBlurNsfw, needBlurSpoiler, voteButtonsOnTheRight, showElapsedTime,
+ showDividerInCompactLayout, showAbsoluteNumberOfVotes,
new PostRecyclerViewAdapter.Callback() {
@Override
public void retryLoadingMore() {
@@ -721,6 +729,14 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
}
}
+ @Override
+ public void applyTheme() {
+ int themeType = customThemeWrapper.getThemeType();
+ mSwipeRefreshLayout.setProgressBackgroundColorSchemeColor(customThemeWrapper.getCardViewBackgroundColor(themeType));
+ mSwipeRefreshLayout.setColorSchemeColors(customThemeWrapper.getColorAccent(themeType));
+ mFetchPostInfoTextView.setTextColor(customThemeWrapper.getSecondaryTextColor(themeType));
+ }
+
@Subscribe
public void onPostUpdateEvent(PostUpdateEventToPostList event) {
PagedList<Post> posts = mAdapter.getCurrentList();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SubredditListingFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SubredditListingFragment.java
index c6a413dc..21842828 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SubredditListingFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SubredditListingFragment.java
@@ -34,6 +34,7 @@ import ml.docilealligator.infinityforreddit.Activity.BaseActivity;
import ml.docilealligator.infinityforreddit.Activity.SearchSubredditsResultActivity;
import ml.docilealligator.infinityforreddit.Activity.ViewSubredditDetailActivity;
import ml.docilealligator.infinityforreddit.Adapter.SubredditListingRecyclerViewAdapter;
+import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.FragmentCommunicator;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.NetworkState;
@@ -80,6 +81,8 @@ public class SubredditListingFragment extends Fragment implements FragmentCommun
@Inject
@Named("default")
SharedPreferences mSharedPreferences;
+ @Inject
+ CustomThemeWrapper customThemeWrapper;
private LinearLayoutManager mLinearLayoutManager;
private SubredditListingRecyclerViewAdapter mAdapter;
private Activity mActivity;
@@ -99,6 +102,8 @@ public class SubredditListingFragment extends Fragment implements FragmentCommun
ButterKnife.bind(this, rootView);
+ applyTheme();
+
Resources resources = getResources();
if ((mActivity instanceof BaseActivity && ((BaseActivity) mActivity).isImmersiveInterface())) {
@@ -123,7 +128,7 @@ public class SubredditListingFragment extends Fragment implements FragmentCommun
SortType sortType = new SortType(SortType.Type.valueOf(sort.toUpperCase()));
mAdapter = new SubredditListingRecyclerViewAdapter(mActivity, mOauthRetrofit, mRetrofit,
- accessToken, accountName, mRedditDataRoomDatabase,
+ customThemeWrapper, accessToken, accountName, mRedditDataRoomDatabase,
new SubredditListingRecyclerViewAdapter.Callback() {
@Override
public void retryLoadingMore() {
@@ -177,8 +182,6 @@ public class SubredditListingFragment extends Fragment implements FragmentCommun
});
mSwipeRefreshLayout.setOnRefreshListener(() -> mSubredditListingViewModel.refresh());
- mSwipeRefreshLayout.setProgressBackgroundColorSchemeColor(Utils.getAttributeColor(mActivity, R.attr.cardViewBackgroundColor));
- mSwipeRefreshLayout.setColorSchemeColors(Utils.getAttributeColor(mActivity, R.attr.colorAccent));
return rootView;
}
@@ -208,4 +211,12 @@ public class SubredditListingFragment extends Fragment implements FragmentCommun
mSubredditListingViewModel.refresh();
mAdapter.setNetworkState(null);
}
+
+ @Override
+ public void applyTheme() {
+ int themeType = customThemeWrapper.getThemeType();
+ mSwipeRefreshLayout.setProgressBackgroundColorSchemeColor(customThemeWrapper.getCardViewBackgroundColor(themeType));
+ mSwipeRefreshLayout.setColorSchemeColors(customThemeWrapper.getColorAccent(themeType));
+ mFetchSubredditListingInfoTextView.setTextColor(customThemeWrapper.getSecondaryTextColor(themeType));
+ }
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SubscribedSubredditsListingFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SubscribedSubredditsListingFragment.java
index 852590b7..d5ca7545 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SubscribedSubredditsListingFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/SubscribedSubredditsListingFragment.java
@@ -12,6 +12,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
+import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
@@ -32,13 +33,13 @@ import ml.docilealligator.infinityforreddit.Activity.BaseActivity;
import ml.docilealligator.infinityforreddit.Activity.SubredditSelectionActivity;
import ml.docilealligator.infinityforreddit.Activity.SubscribedThingListingActivity;
import ml.docilealligator.infinityforreddit.Adapter.SubscribedSubredditsRecyclerViewAdapter;
+import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.FragmentCommunicator;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase.SubscribedSubredditViewModel;
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
-import ml.docilealligator.infinityforreddit.Utils.Utils;
import retrofit2.Retrofit;
@@ -61,6 +62,8 @@ public class SubscribedSubredditsListingFragment extends Fragment implements Fra
LinearLayout mLinearLayout;
@BindView(R.id.no_subscriptions_image_view_subreddits_listing_fragment)
ImageView mImageView;
+ @BindView(R.id.error_text_view_subscribed_subreddits_listing_fragment)
+ TextView mErrorTextView;
@Inject
@Named("oauth")
Retrofit mOauthRetrofit;
@@ -69,6 +72,8 @@ public class SubscribedSubredditsListingFragment extends Fragment implements Fra
SharedPreferences mSharedPreferences;
@Inject
RedditDataRoomDatabase mRedditDataRoomDatabase;
+ @Inject
+ CustomThemeWrapper customThemeWrapper;
private Activity mActivity;
private RequestManager mGlide;
private SubscribedSubredditViewModel mSubscribedSubredditViewModel;
@@ -86,6 +91,8 @@ public class SubscribedSubredditsListingFragment extends Fragment implements Fra
((Infinity) mActivity.getApplication()).getAppComponent().inject(this);
+ applyTheme();
+
if ((mActivity instanceof BaseActivity && ((BaseActivity) mActivity).isImmersiveInterface())) {
mRecyclerView.setPadding(0, 0, 0, ((BaseActivity) mActivity).getNavBarHeight());
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
@@ -102,23 +109,16 @@ public class SubscribedSubredditsListingFragment extends Fragment implements Fra
mGlide = Glide.with(this);
- if (mActivity instanceof SubscribedThingListingActivity) {
- mSwipeRefreshLayout.setOnRefreshListener(() -> ((SubscribedThingListingActivity) mActivity).loadSubscriptions(true));
- mSwipeRefreshLayout.setProgressBackgroundColorSchemeColor(Utils.getAttributeColor(mActivity, R.attr.cardViewBackgroundColor));
- mSwipeRefreshLayout.setColorSchemeColors(Utils.getAttributeColor(mActivity, R.attr.colorAccent));
- } else {
- mSwipeRefreshLayout.setEnabled(false);
- }
-
mRecyclerView.setLayoutManager(new LinearLayoutManager(mActivity));
SubscribedSubredditsRecyclerViewAdapter adapter;
if (getArguments().getBoolean(EXTRA_IS_SUBREDDIT_SELECTION)) {
adapter = new SubscribedSubredditsRecyclerViewAdapter(mActivity, mOauthRetrofit, mRedditDataRoomDatabase,
- accessToken, getArguments().getBoolean(EXTRA_EXTRA_CLEAR_SELECTION),
+ customThemeWrapper, accessToken, getArguments().getBoolean(EXTRA_EXTRA_CLEAR_SELECTION),
(name, iconUrl, subredditIsUser) -> ((SubredditSelectionActivity) mActivity).getSelectedSubreddit(name, iconUrl, subredditIsUser));
} else {
- adapter = new SubscribedSubredditsRecyclerViewAdapter(mActivity, mOauthRetrofit, mRedditDataRoomDatabase, accessToken);
+ adapter = new SubscribedSubredditsRecyclerViewAdapter(mActivity, mOauthRetrofit, mRedditDataRoomDatabase,
+ customThemeWrapper, accessToken);
}
mRecyclerView.setAdapter(adapter);
@@ -166,4 +166,17 @@ public class SubscribedSubredditsListingFragment extends Fragment implements Fra
public void stopRefreshProgressbar() {
mSwipeRefreshLayout.setRefreshing(false);
}
+
+ @Override
+ public void applyTheme() {
+ if (mActivity instanceof SubscribedThingListingActivity) {
+ mSwipeRefreshLayout.setOnRefreshListener(() -> ((SubscribedThingListingActivity) mActivity).loadSubscriptions(true));
+ int themeType = customThemeWrapper.getThemeType();
+ mSwipeRefreshLayout.setProgressBackgroundColorSchemeColor(customThemeWrapper.getCardViewBackgroundColor(themeType));
+ mSwipeRefreshLayout.setColorSchemeColors(customThemeWrapper.getColorAccent(themeType));
+ mErrorTextView.setTextColor(customThemeWrapper.getSecondaryTextColor(themeType));
+ } else {
+ mSwipeRefreshLayout.setEnabled(false);
+ }
+ }
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/UserListingFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/UserListingFragment.java
index 4167c483..311a7e56 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/UserListingFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/UserListingFragment.java
@@ -31,6 +31,7 @@ import butterknife.BindView;
import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.Activity.BaseActivity;
import ml.docilealligator.infinityforreddit.Adapter.UserListingRecyclerViewAdapter;
+import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.FragmentCommunicator;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.NetworkState;
@@ -76,6 +77,8 @@ public class UserListingFragment extends Fragment implements FragmentCommunicato
@Inject
@Named("default")
SharedPreferences mSharedPreferences;
+ @Inject
+ CustomThemeWrapper customThemeWrapper;
private LinearLayoutManager mLinearLayoutManager;
private String mQuery;
private UserListingRecyclerViewAdapter mAdapter;
@@ -96,6 +99,8 @@ public class UserListingFragment extends Fragment implements FragmentCommunicato
ButterKnife.bind(this, rootView);
+ applyTheme();
+
Resources resources = getResources();
if ((mActivity instanceof BaseActivity && ((BaseActivity) mActivity).isImmersiveInterface())) {
@@ -118,7 +123,7 @@ public class UserListingFragment extends Fragment implements FragmentCommunicato
SortType sortType = new SortType(SortType.Type.valueOf(sort.toUpperCase()));
mAdapter = new UserListingRecyclerViewAdapter(getActivity(), mOauthRetrofit, mRetrofit,
- accessToken, accountName, mRedditDataRoomDatabase.subscribedUserDao(),
+ customThemeWrapper, accessToken, accountName, mRedditDataRoomDatabase.subscribedUserDao(),
() -> mUserListingViewModel.retryLoadingMore());
mUserListingRecyclerView.setAdapter(mAdapter);
@@ -157,8 +162,6 @@ public class UserListingFragment extends Fragment implements FragmentCommunicato
});
mSwipeRefreshLayout.setOnRefreshListener(() -> mUserListingViewModel.refresh());
- mSwipeRefreshLayout.setProgressBackgroundColorSchemeColor(Utils.getAttributeColor(mActivity, R.attr.cardViewBackgroundColor));
- mSwipeRefreshLayout.setColorSchemeColors(Utils.getAttributeColor(mActivity, R.attr.colorAccent));
return rootView;
}
@@ -188,4 +191,12 @@ public class UserListingFragment extends Fragment implements FragmentCommunicato
mUserListingViewModel.refresh();
mAdapter.setNetworkState(null);
}
+
+ @Override
+ public void applyTheme() {
+ int themeType = customThemeWrapper.getThemeType();
+ mSwipeRefreshLayout.setProgressBackgroundColorSchemeColor(customThemeWrapper.getCardViewBackgroundColor(themeType));
+ mSwipeRefreshLayout.setColorSchemeColors(customThemeWrapper.getColorAccent(themeType));
+ mFetchUserListingInfoTextView.setTextColor(customThemeWrapper.getSecondaryTextColor(themeType));
+ }
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/FragmentCommunicator.java b/app/src/main/java/ml/docilealligator/infinityforreddit/FragmentCommunicator.java
index e67ae8ca..07a18a72 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/FragmentCommunicator.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/FragmentCommunicator.java
@@ -33,4 +33,6 @@ public interface FragmentCommunicator {
default void stopRefreshProgressbar() {
}
+
+ void applyTheme();
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/NotificationUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/NotificationUtils.java
index 2e04377d..36160d0c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/NotificationUtils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/NotificationUtils.java
@@ -7,8 +7,6 @@ import android.content.Context;
import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationManagerCompat;
-import ml.docilealligator.infinityforreddit.Utils.Utils;
-
public class NotificationUtils {
public static final String CHANNEL_SUBMIT_POST = "Submit Post";
static final String CHANNEL_ID_NEW_MESSAGES = "new_messages";
@@ -23,7 +21,7 @@ public class NotificationUtils {
static NotificationCompat.Builder buildNotification(NotificationManagerCompat notificationManager,
Context context, String title, String content,
String summary, String channelId, String channelName,
- String group) {
+ String group, int color) {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
NotificationChannel channel = new NotificationChannel(channelId, channelName, NotificationManager.IMPORTANCE_DEFAULT);
notificationManager.createNotificationChannel(channel);
@@ -33,7 +31,7 @@ public class NotificationUtils {
.setContentTitle(title)
.setContentText(content)
.setSmallIcon(R.drawable.ic_notification)
- .setColor(context.getResources().getColor(Utils.getAttributeColor(context, R.attr.notificationIconColor)))
+ .setColor(color)
.setStyle(new NotificationCompat.BigTextStyle()
.setSummaryText(summary)
.bigText(content))
@@ -43,7 +41,7 @@ public class NotificationUtils {
static NotificationCompat.Builder buildSummaryNotification(Context context, NotificationManagerCompat notificationManager,
String title, String content, String channelId,
- String channelName, String group) {
+ String channelName, String group, int color) {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
NotificationChannel channel = new NotificationChannel(channelId, channelName, NotificationManager.IMPORTANCE_DEFAULT);
notificationManager.createNotificationChannel(channel);
@@ -54,7 +52,7 @@ public class NotificationUtils {
//set content text to support devices running API level < 24
.setContentText(content)
.setSmallIcon(R.drawable.ic_notification)
- .setColor(Utils.getAttributeColor(context, R.attr.notificationIconColor))
+ .setColor(color)
.setGroup(group)
.setGroupSummary(true)
.setAutoCancel(true);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Okhttp3DebugInterceptor.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Okhttp3DebugInterceptor.java
deleted file mode 100644
index 0392415b..00000000
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Okhttp3DebugInterceptor.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package ml.docilealligator.infinityforreddit;
-
-import android.content.Context;
-
-import androidx.annotation.NonNull;
-import androidx.core.app.NotificationCompat;
-import androidx.core.app.NotificationManagerCompat;
-
-import java.io.IOException;
-
-import okhttp3.Interceptor;
-import okhttp3.Response;
-
-public class Okhttp3DebugInterceptor implements Interceptor {
- private Context context;
-
- public Okhttp3DebugInterceptor(Context context) {
- this.context = context;
- }
-
- @NonNull
- @Override
- public Response intercept(Chain chain) throws IOException {
- Response response = chain.proceed(chain.request());
- if (!response.isSuccessful()) {
- String message = "No body";
- if (response.code() == 401) {
- message = "Not authorized";
- } else if (response.body() != null) {
- message = response.body().string();
- }
- NotificationManagerCompat notificationManager = NotificationUtils.getNotificationManager(context);
- NotificationCompat.Builder builder = NotificationUtils.buildNotification(notificationManager,
- context, "debug", message, Integer.toString(response.code()),
- NotificationUtils.CHANNEL_ID_NEW_MESSAGES,
- NotificationUtils.CHANNEL_NEW_MESSAGES,
- NotificationUtils.getAccountGroupName("Debug"));
- notificationManager.notify(9765, builder.build());
- }
- return response;
- }
-}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PullNotificationWorker.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PullNotificationWorker.java
index 31da44dc..97bd4bfa 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/PullNotificationWorker.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PullNotificationWorker.java
@@ -28,6 +28,7 @@ import javax.inject.Named;
import ml.docilealligator.infinityforreddit.Account.Account;
import ml.docilealligator.infinityforreddit.Activity.LinkResolverActivity;
import ml.docilealligator.infinityforreddit.Activity.ViewMessageActivity;
+import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import retrofit2.Call;
@@ -47,6 +48,8 @@ public class PullNotificationWorker extends Worker {
@Inject
@Named("default")
SharedPreferences mSharedPreferences;
+ @Inject
+ CustomThemeWrapper mCustomThemeWrapper;
private Context context;
public PullNotificationWorker(@NonNull Context context, @NonNull WorkerParameters workerParams) {
@@ -60,6 +63,7 @@ public class PullNotificationWorker extends Worker {
public Result doWork() {
try {
List<Account> accounts = mRedditDataRoomDatabase.accountDao().getAllAccounts();
+ int color = mCustomThemeWrapper.getNotificationIconColor(mCustomThemeWrapper.getThemeType());
for (int accountIndex = 0; accountIndex < accounts.size(); accountIndex++) {
Account account = accounts.get(accountIndex);
@@ -78,11 +82,11 @@ public class PullNotificationWorker extends Worker {
notificationManager, accountName,
context.getString(R.string.notification_new_messages, messages.size()),
NotificationUtils.CHANNEL_ID_NEW_MESSAGES, NotificationUtils.CHANNEL_NEW_MESSAGES,
- NotificationUtils.getAccountGroupName(accountName));
+ NotificationUtils.getAccountGroupName(accountName), color);
NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
- int messageSize = messages.size() >= 5 ? 5 : messages.size();
+ int messageSize = Math.min(messages.size(), 5);
long lastNotificationTime = mSharedPreferences.getLong(SharedPreferencesUtils.PULL_NOTIFICATION_TIME, -1L);
boolean hasValidMessage = false;
@@ -122,7 +126,7 @@ public class PullNotificationWorker extends Worker {
context, title, message.getBody(), summary,
NotificationUtils.CHANNEL_ID_NEW_MESSAGES,
NotificationUtils.CHANNEL_NEW_MESSAGES,
- NotificationUtils.getAccountGroupName(accountName));
+ NotificationUtils.getAccountGroupName(accountName), color);
if (kind.equals(Message.TYPE_COMMENT)) {
Intent intent = new Intent(context, LinkResolverActivity.class);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Service/SubmitPostService.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Service/SubmitPostService.java
index d73ab466..88798143 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Service/SubmitPostService.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Service/SubmitPostService.java
@@ -31,6 +31,7 @@ import java.io.IOException;
import javax.inject.Inject;
import javax.inject.Named;
+import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.Event.SubmitImagePostEvent;
import ml.docilealligator.infinityforreddit.Event.SubmitTextOrLinkPostEvent;
import ml.docilealligator.infinityforreddit.Event.SubmitVideoPostEvent;
@@ -39,7 +40,6 @@ import ml.docilealligator.infinityforreddit.NotificationUtils;
import ml.docilealligator.infinityforreddit.Post.Post;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.SubmitPost;
-import ml.docilealligator.infinityforreddit.Utils.Utils;
import retrofit2.Retrofit;
public class SubmitPostService extends Service {
@@ -64,6 +64,8 @@ public class SubmitPostService extends Service {
@Inject
@Named("upload_video")
Retrofit mUploadVideoRetrofit;
+ @Inject
+ CustomThemeWrapper mCustomThemeWrapper;
private String mAccessToken;
private String subredditName;
private String title;
@@ -128,7 +130,7 @@ public class SubmitPostService extends Service {
.setContentTitle(getString(stringResId))
.setContentText(getString(R.string.please_wait))
.setSmallIcon(R.drawable.ic_notification)
- .setColor(Utils.getAttributeColor(context, R.attr.notificationIconColor))
+ .setColor(mCustomThemeWrapper.getNotificationIconColor(mCustomThemeWrapper.getThemeType()))
.build();
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/CustomThemeSharedPreferencesUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/CustomThemeSharedPreferencesUtils.java
new file mode 100644
index 00000000..6bca6a51
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/CustomThemeSharedPreferencesUtils.java
@@ -0,0 +1,66 @@
+package ml.docilealligator.infinityforreddit.Utils;
+
+public class CustomThemeSharedPreferencesUtils {
+ public static final int NORMAL = 0;
+ public static final int DARK = 1;
+ public static final int AMOLED_DARK = 2;
+ public static final String THEME_TYPE_KEY = "theme_type";
+ public static final String THEME_SHARED_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit.theme";
+ public static final String COLOR_PRIMARY = "colorPrimary";
+ public static final String COLOR_PRIMARY_DARK = "colorPrimaryDark";
+ public static final String COLOR_ACCENT = "colorAccent";
+ public static final String COLOR_PRIMARY_LIGHT_THEME = "colorPrimaryLightTheme";
+ public static final String POST_TITLE_COLOR = "postTitleColor";
+ public static final String POST_CONTENT_COLOR = "postContentColor";
+ public static final String COMMENT_COLOR = "commentColor";
+ public static final String PRIMARY_TEXT_COLOR = "primaryTextColor";
+ public static final String SECONDARY_TEXT_COLOR = "secondaryTextColor";
+ public static final String BUTTON_TEXT_COLOR = "buttonTextColor";
+ public static final String BUTTON_BACKGROUND_TINT = "buttonBackgroundTint";
+ public static final String BACKGROUND_COLOR = "backgroundColor";
+ public static final String ROUNDED_BOTTOM_SHEET_PRIMARY_BACKGROUND = "roundedBottomSheetPrimaryBackground";
+ public static final String CARD_VIEW_BACKGROUND_COLOR = "cardViewBackgroundColor";
+ public static final String COMMENT_BACKGROUND_COLOR = "commentBackgroundColor";
+ public static final String TOOLBAR_PRIMARY_TEXT_AND_ICON_COLOR = "toolbarPrimaryTextAndIconColor";
+ public static final String TOOLBAR_AND_TAB_BACKGROUND_COLOR = "toolbarAndTabBackgroundColor";
+ public static final String CIRCULAR_PROGRESS_BAR_BACKGROUND = "circularProgressBarBackground";
+ public static final String TAB_LAYOUT_WITH_EXPANDED_COLLAPSING_TOOLBAR_TAB_BACKGROUND = "tabLayoutWithExpandedCollapsingToolbarTabBackground";
+ public static final String TAB_LAYOUT_WITH_EXPANDED_COLLAPSING_TOOLBAR_TEXT_COLOR = "tabLayoutWithExpandedCollapsingToolbarTextColor";
+ public static final String TAB_LAYOUT_WITH_EXPANDED_COLLAPSING_TOOLBAR_TAB_INDICATOR = "tabLayoutWithExpandedCollapsingToolbarTabIndicator";
+ public static final String TAB_LAYOUT_WITH_COLLAPSED_COLLAPSING_TOOLBAR_TAB_BACKGROUND = "tabLayoutWithCollapsedCollapsingToolbarTabBackground";
+ public static final String TAB_LAYOUT_WITH_COLLAPSED_COLLAPSING_TOOLBAR_TEXT_COLOR = "tabLayoutWithCollapsedCollapsingToolbarTextColor";
+ public static final String TAB_LAYOUT_WITH_COLLAPSED_COLLAPSING_TOOLBAR_TAB_INDICATOR = "tabLayoutWithCollapsedCollapsingToolbarTabIndicator";
+ public static final String NAV_BAR_COLOR = "navBarColor";
+ public static final String UPVOTED = "upvoted";
+ public static final String DOWNVOTED = "downvoted";
+ public static final String POST_TYPE = "postType";
+ public static final String SPOILER_COLOR = "spoilerColor";
+ public static final String NSFW_COLOR = "nsfwColor";
+ public static final String FLAIR_COLOR = "flairColor";
+ public static final String ARCHIVED_TINT = "archivedTint";
+ public static final String LOCKED_ICON_TINT = "lockedIconTint";
+ public static final String CROSSPOST = "crosspost";
+ public static final String STICKIED_POST = "stickiedPost";
+ public static final String SUBSCRIBED = "subscribed";
+ public static final String UNSUBSCRIBED = "unsubscribed";
+ public static final String USERNAME = "username";
+ public static final String SUBREDDIT = "subreddit";
+ public static final String AUTHOR_FLAIR_TEXT_COLOR = "authorFlairTextColor";
+ public static final String SUBMITTER = "submitter";
+ public static final String MODERATOR = "moderator";
+ public static final String NOTIFICATION_ICON_COLOR = "notificationIconColor";
+ public static final String SINGLE_COMMENT_THREAD_BACKGROUND = "singleCommentThreadBackgroundColor";
+ public static final String UNREAD_MESSAGE_BACKGROUND_COLOR = "unreadMessageBackgroundColor";
+ public static final String DIVIDER_COLOR = "dividerColor";
+ public static final String NO_PREVIEW_LINK_BACKGROUND_COLOR = "noPreviewLinkBackgroundColor";
+ public static final String VOTE_AND_REPLY_UNAVAILABLE_VOTE_BUTTON_COLOR = "voteAndReplyUnavailableVoteButtonColor";
+ public static final String COMMENT_VERTICAL_BAR_COLOR_1 = "commentVerticalBarColor1";
+ public static final String COMMENT_VERTICAL_BAR_COLOR_2 = "commentVerticalBarColor2";
+ public static final String COMMENT_VERTICAL_BAR_COLOR_3 = "commentVerticalBarColor3";
+ public static final String COMMENT_VERTICAL_BAR_COLOR_4 = "commentVerticalBarColor4";
+ public static final String COMMENT_VERTICAL_BAR_COLOR_5 = "commentVerticalBarColor5";
+ public static final String COMMENT_VERTICAL_BAR_COLOR_6 = "commentVerticalBarColor6";
+ public static final String COMMENT_VERTICAL_BAR_COLOR_7 = "commentVerticalBarColor7";
+ public static final String FAB_ICON_COLOR = "fabIconColor";
+ public static final String CHIP_TEXT_COLOR = "chipTextColor";
+}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java
index 6d0ba6c6..0ff474bd 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java
@@ -77,56 +77,4 @@ public class SharedPreferencesUtils {
public static final String LOCK_BOTTOM_APP_BAR = "lock_bottom_app_bar";
public static final String SHOW_COMMENT_DIVIDER = "show_comment_divider";
public static final String SHOW_ABSOLUTE_NUMBER_OF_VOTES = "show_absolute_number_of_votes";
-
- //Theme
- public static final String THEME_SHARED_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit.theme";
- public static final String COLOR_PRIMARY = "colorPrimary";
- public static final String COLOR_PRIMARY_DARK = "colorPrimaryDark";
- public static final String COLOR_ACCENT = "colorAccent";
- public static final String COLOR_PRIMARY_LIGHT_THEME = "colorPrimaryLightTheme";
- public static final String PRIMARY_TEXT_COLOR = "primaryTextColor";
- public static final String SECONDARY_TEXT_COLOR = "secondaryTextColor";
- public static final String BACKGROUND_COLOR = "backgroundColor";
- public static final String ROUNDED_BOTTOM_SHEET_PRIMARY_BACKGROUND = "roundedBottomSheetPrimaryBackground";
- public static final String CARD_VIEW_BACKGROUND_COLOR = "cardViewBackgroundColor";
- public static final String TOOLBAR_PRIMARY_TEXT_AND_ICON_COLOR = "toolbarPrimaryTextAndIconColor";
- public static final String TOOLBAR_AND_TAB_BACKGROUND_COLOR = "toolbarAndTabBackgroundColor";
- public static final String CIRCULAR_PROGRESS_BAR_BACKGROUND = "circularProgressBarBackground";
- public static final String TAB_LAYOUT_WITH_EXPANDED_COLLAPSING_TOOLBAR_TAB_BACKGROUND = "tabLayoutWithExpandedCollapsingToolbarTabBackground";
- public static final String TAB_LAYOUT_WITH_EXPANDED_COLLAPSING_TOOLBAR_TEXT_COLOR = "tabLayoutWithExpandedCollapsingToolbarTextColor";
- public static final String TAB_LAYOUT_WITH_EXPANDED_COLLAPSING_TOOLBAR_TAB_INDICATOR = "tabLayoutWithExpandedCollapsingToolbarTabIndicator";
- public static final String TAB_LAYOUT_WITH_COLLAPSED_COLLAPSING_TOOLBAR_TAB_BACKGROUND = "tabLayoutWithCollapsedCollapsingToolbarTabBackground";
- public static final String TAB_LAYOUT_WITH_COLLAPSED_COLLAPSING_TOOLBAR_TEXT_COLOR = "tabLayoutWithCollapsedCollapsingToolbarTextColor";
- public static final String TAB_LAYOUT_WITH_COLLAPSED_COLLAPSING_TOOLBAR_TAB_INDICATOR = "tabLayoutWithCollapsedCollapsingToolbarTabIndicator";
- public static final String NAV_BAR_COLOR = "navBarColor";
- public static final String UPVOTED = "upvoted";
- public static final String DOWNVOTED = "downvoted";
- public static final String POST_TYPE = "postType";
- public static final String SPOILER_COLOR = "spoilerColor";
- public static final String NSFW_COLOR = "nsfwColor";
- public static final String FLAIR_COLOR = "flairColor";
- public static final String ARCHIVED_TINT = "archivedTint";
- public static final String LOCKED_ICON_TINT = "lockedIconTint";
- public static final String CROSSPOST = "crosspost";
- public static final String STICKIED_POST = "stickiedPost";
- public static final String SUBSCRIBED = "subscribed";
- public static final String UNSUBSCRIBED = "unsubscribed";
- public static final String USERNAME = "username";
- public static final String SUBREDDIT = "subreddit";
- public static final String AUTHOR_FLAIR_TEXT_COLOR = "authorFlairTextColor";
- public static final String SUBMITTER = "submitter";
- public static final String MODERATOR = "moderator";
- public static final String NOTIFICATION_ICON_COLOR = "notificationIconColor";
- public static final String SINGLE_COMMENT_THREAD_BACKGROUND = "singleCommentThreadBackgroundColor";
- public static final String UNREAD_MESSAGE_BACKGROUND_COLOR = "unreadMessageBackgroundColor";
- public static final String DIVIDER_COLOR = "dividerColor";
- public static final String NO_PREVIEW_LINK_BACKGROUND_COLOR = "noPreviewLinkBackgroundColor";
- public static final String VOTE_AND_REPLY_UNAVAILABLE_VOTE_BUTTON_COLOR = "voteAndReplyUnavailableVoteButtonColor";
- public static final String COMMENT_VERTICAL_BAR_COLOR_1 = "commentVerticalBarColor1";
- public static final String COMMENT_VERTICAL_BAR_COLOR_2 = "commentVerticalBarColor2";
- public static final String COMMENT_VERTICAL_BAR_COLOR_3 = "commentVerticalBarColor3";
- public static final String COMMENT_VERTICAL_BAR_COLOR_4 = "commentVerticalBarColor4";
- public static final String COMMENT_VERTICAL_BAR_COLOR_5 = "commentVerticalBarColor5";
- public static final String COMMENT_VERTICAL_BAR_COLOR_6 = "commentVerticalBarColor6";
- public static final String COMMENT_VERTICAL_BAR_COLOR_7 = "commentVerticalBarColor7";
}
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 fc71392f..1a40911b 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/Utils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/Utils.java
@@ -1,7 +1,6 @@
package ml.docilealligator.infinityforreddit.Utils;
import android.content.Context;
-import android.util.TypedValue;
import java.util.Locale;
@@ -75,9 +74,9 @@ public class Utils {
}
}
- public static int getAttributeColor(Context context, int attrId) {
+ /*public static int getAttributeColor(Context context, int attrId) {
TypedValue typedValue = new TypedValue();
context.getTheme().resolveAttribute(attrId, typedValue, true);
return typedValue.data;
- }
+ }*/
}