Dark theme support.

This commit is contained in:
Alex Ning 2019-05-07 23:55:49 +08:00
parent 297db53aa3
commit c8d1a9e37a
20 changed files with 207 additions and 158 deletions

View File

@ -156,7 +156,7 @@ class CommentMultiLevelRecyclerViewAdapter extends MultiLevelAdapter {
commentItem.setVoteType(1);
newVoteType = RedditUtils.DIR_UPVOTE;
((CommentViewHolder) holder).upvoteButton
.setColorFilter(ContextCompat.getColor(mContext, R.color.colorPrimary), android.graphics.PorterDuff.Mode.SRC_IN);
.setColorFilter(ContextCompat.getColor(mContext, R.color.backgroundColorPrimaryDark), android.graphics.PorterDuff.Mode.SRC_IN);
} else {
//Upvoted before
commentItem.setVoteType(0);
@ -172,7 +172,7 @@ class CommentMultiLevelRecyclerViewAdapter extends MultiLevelAdapter {
if(newVoteType.equals(RedditUtils.DIR_UPVOTE)) {
commentItem.setVoteType(1);
((CommentViewHolder) holder).upvoteButton
.setColorFilter(ContextCompat.getColor(mContext, R.color.colorPrimary), android.graphics.PorterDuff.Mode.SRC_IN);
.setColorFilter(ContextCompat.getColor(mContext, R.color.backgroundColorPrimaryDark), android.graphics.PorterDuff.Mode.SRC_IN);
} else {
commentItem.setVoteType(0);
((CommentViewHolder) holder).upvoteButton.clearColorFilter();

View File

@ -270,7 +270,7 @@ class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHo
switch (voteType) {
case 1:
//Upvote
((DataViewHolder) holder).upvoteButton.setColorFilter(ContextCompat.getColor(mContext, R.color.colorPrimary), android.graphics.PorterDuff.Mode.SRC_IN);
((DataViewHolder) holder).upvoteButton.setColorFilter(ContextCompat.getColor(mContext, R.color.backgroundColorPrimaryDark), android.graphics.PorterDuff.Mode.SRC_IN);
break;
case -1:
//Downvote
@ -389,7 +389,7 @@ class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHo
post.setVoteType(1);
newVoteType = RedditUtils.DIR_UPVOTE;
((DataViewHolder) holder).upvoteButton
.setColorFilter(ContextCompat.getColor(mContext, R.color.colorPrimary), android.graphics.PorterDuff.Mode.SRC_IN);
.setColorFilter(ContextCompat.getColor(mContext, R.color.backgroundColorPrimaryDark), android.graphics.PorterDuff.Mode.SRC_IN);
} else {
//Upvoted before
post.setVoteType(0);
@ -405,7 +405,7 @@ class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHo
if(newVoteType.equals(RedditUtils.DIR_UPVOTE)) {
post.setVoteType(1);
((DataViewHolder) holder).upvoteButton
.setColorFilter(ContextCompat.getColor(mContext, R.color.colorPrimary), android.graphics.PorterDuff.Mode.SRC_IN);
.setColorFilter(ContextCompat.getColor(mContext, R.color.backgroundColorPrimaryDark), android.graphics.PorterDuff.Mode.SRC_IN);
} else {
post.setVoteType(0);
((DataViewHolder) holder).upvoteButton.clearColorFilter();

View File

@ -38,7 +38,7 @@ class SubscribedSubredditRecyclerViewAdapter extends RecyclerView.Adapter<Recycl
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
return new SubredditViewHolder(LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_subscribed_subreddit, viewGroup, false));
return new SubredditViewHolder(LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_subscribed_thing, viewGroup, false));
}
@Override

View File

@ -7,6 +7,9 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestManager;
import com.bumptech.glide.request.RequestOptions;
@ -14,8 +17,6 @@ import com.bumptech.glide.request.RequestOptions;
import java.util.List;
import SubscribedUserDatabase.SubscribedUserData;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import pl.droidsonroids.gif.GifImageView;
@ -38,7 +39,7 @@ public class SubscribedUserRecyclerViewAdapter extends RecyclerView.Adapter<Recy
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
return new UserViewHolder(LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_subscribed_subreddit, viewGroup, false));
return new UserViewHolder(LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_subscribed_thing, viewGroup, false));
}
@Override

View File

@ -20,7 +20,6 @@ import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.browser.customtabs.CustomTabsIntent;
import androidx.cardview.widget.CardView;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.core.content.ContextCompat;
import androidx.core.widget.NestedScrollView;
@ -35,6 +34,7 @@ import com.bumptech.glide.load.engine.GlideException;
import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.RequestOptions;
import com.bumptech.glide.request.target.Target;
import com.google.android.material.card.MaterialCardView;
import com.google.android.material.chip.Chip;
import com.google.android.material.snackbar.Snackbar;
import com.lsjwzh.widget.materialloadingprogressbar.CircleProgressBar;
@ -105,7 +105,7 @@ public class ViewPostDetailActivity extends AppCompatActivity {
@BindView(R.id.share_button_view_post_detail) ImageView mShareButton;
@BindView(R.id.comment_progress_bar_view_post_detail) CircleProgressBar mCommentProgressbar;
@BindView(R.id.comment_card_view_view_post_detail) CardView mCommentCardView;
@BindView(R.id.comment_card_view_view_post_detail) MaterialCardView mCommentCardView;
@BindView(R.id.recycler_view_view_post_detail) MultiLevelRecyclerView mRecyclerView;
@BindView(R.id.no_comment_wrapper_linear_layout_view_post_detail) LinearLayout mNoCommentWrapperLinearLayout;
@ -187,7 +187,7 @@ public class ViewPostDetailActivity extends AppCompatActivity {
switch (mPost.getVoteType()) {
case 1:
//Upvote
mUpvoteButton.setColorFilter(ContextCompat.getColor(this, R.color.colorPrimary), PorterDuff.Mode.SRC_IN);
mUpvoteButton.setColorFilter(ContextCompat.getColor(this, R.color.backgroundColorPrimaryDark), PorterDuff.Mode.SRC_IN);
break;
case -1:
//Downvote
@ -344,7 +344,7 @@ public class ViewPostDetailActivity extends AppCompatActivity {
//Not upvoted before
mPost.setVoteType(1);
newVoteType = RedditUtils.DIR_UPVOTE;
mUpvoteButton.setColorFilter(ContextCompat.getColor(this, R.color.colorPrimary), android.graphics.PorterDuff.Mode.SRC_IN);
mUpvoteButton.setColorFilter(ContextCompat.getColor(this, R.color.backgroundColorPrimaryDark), android.graphics.PorterDuff.Mode.SRC_IN);
} else {
//Upvoted before
mPost.setVoteType(0);
@ -363,7 +363,7 @@ public class ViewPostDetailActivity extends AppCompatActivity {
public void onVoteThingSuccess() {
if(newVoteType.equals(RedditUtils.DIR_UPVOTE)) {
mPost.setVoteType(1);
mUpvoteButton.setColorFilter(ContextCompat.getColor(ViewPostDetailActivity.this, R.color.colorPrimary), android.graphics.PorterDuff.Mode.SRC_IN);
mUpvoteButton.setColorFilter(ContextCompat.getColor(ViewPostDetailActivity.this, R.color.backgroundColorPrimaryDark), android.graphics.PorterDuff.Mode.SRC_IN);
} else {
mPost.setVoteType(0);
mUpvoteButton.clearColorFilter();

View File

@ -182,7 +182,7 @@ public class ViewSubredditDetailActivity extends AppCompatActivity {
@Override
public void onSubredditSubscriptionSuccess() {
subscribeSubredditChip.setText(R.string.subscribe);
subscribeSubredditChip.setChipBackgroundColor(getResources().getColorStateList(R.color.colorPrimaryDark));
subscribeSubredditChip.setChipBackgroundColor(getResources().getColorStateList(R.color.textColorPrimaryDark));
makeSnackbar(R.string.unsubscribed);
subscriptionReady = true;
}
@ -209,7 +209,7 @@ public class ViewSubredditDetailActivity extends AppCompatActivity {
@Override
public void isNotSubscribed() {
subscribeSubredditChip.setText(R.string.subscribe);
subscribeSubredditChip.setChipBackgroundColor(getResources().getColorStateList(R.color.colorPrimaryDark));
subscribeSubredditChip.setChipBackgroundColor(getResources().getColorStateList(R.color.textColorPrimaryDark));
subscriptionReady = true;
}
}).execute();

View File

@ -46,21 +46,22 @@
android:layout_height="24dp"
android:layout_gravity="center_vertical"
android:layout_marginEnd="32dp"
android:src="@drawable/ic_outline_account_circle_24px" />
android:src="@drawable/ic_outline_account_circle_24px"
android:tint="@color/primaryTextColor"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/profile"
android:textColor="@android:color/black" />
android:textColor="@color/primaryTextColor" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#E0E0E0" />
android:background="@color/dividerColor" />
<TextView
android:id="@+id/following_label_main_activity"

View File

@ -78,7 +78,7 @@
android:layout_height="wrap_content"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:textColor="#000000"
android:textColor="@color/primaryTextColor"
android:textSize="18sp" />
<ru.noties.markwon.view.MarkwonView
@ -104,7 +104,7 @@
android:layout_marginEnd="8dp"
android:textColor="@android:color/white"
android:layout_centerVertical="true"
app:chipBackgroundColor="@color/colorPrimaryDark"/>
app:chipBackgroundColor="@color/backgroundColorPrimaryDark"/>
<ImageView
android:id="@+id/gilded_image_view_view_post_detail"
@ -197,9 +197,10 @@
android:layout_width="match_parent"
android:layout_height="150dp"
android:layout_marginTop="16dp"
android:background="#E0E0E0"
android:background="@color/grey"
android:scaleType="center"
android:src="@drawable/ic_link"
android:tint="@android:color/tab_indicator_text"
android:visibility="gone" />
<RelativeLayout
@ -267,9 +268,10 @@
android:layout_marginBottom="16dp"
app:mlpb_progress_stoke_width="3dp"
app:mlpb_progress_color="@color/colorAccent"
app:mlpb_background_color="@color/circularProgressBarBackground"
android:layout_gravity="center_horizontal"/>
<androidx.cardview.widget.CardView
<com.google.android.material.card.MaterialCardView
android:id="@+id/comment_card_view_view_post_detail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -290,7 +292,7 @@
android:paddingStart="16dp"
android:paddingTop="16dp"
android:text="@string/comments"
android:textColor="#000000"
android:textColor="@color/primaryTextColor"
android:textSize="18sp" />
<com.multilevelview.MultiLevelRecyclerView
@ -300,7 +302,7 @@
</LinearLayout>
</androidx.cardview.widget.CardView>
</com.google.android.material.card.MaterialCardView>
<LinearLayout
android:id="@+id/no_comment_wrapper_linear_layout_view_post_detail"

View File

@ -48,7 +48,7 @@
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:layout_below="@id/banner_image_view_view_subreddit_detail_activity"
android:background="@android:color/white">
android:background="@color/backgroundColor">
<TextView
android:id="@+id/subreddit_name_text_view_view_subreddit_detail_activity"
@ -77,7 +77,7 @@
android:id="@+id/subscriber_count_text_view_view_subreddit_detail_activity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/black"
android:textColor="@color/primaryTextColor"
android:layout_alignParentStart="true"
android:layout_toStartOf="@id/online_subscriber_count_text_view_view_subreddit_detail_activity" />
@ -86,7 +86,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:textColor="@android:color/black" />
android:textColor="@color/primaryTextColor" />
</RelativeLayout>
@ -95,7 +95,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:textColor="@android:color/black"
android:textColor="@color/primaryTextColor"
android:visibility="gone"/>
</LinearLayout>

View File

@ -48,7 +48,7 @@
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:layout_below="@id/banner_image_view_view_user_detail_activity"
android:background="@android:color/white">
android:background="@color/backgroundColor">
<TextView
android:id="@+id/user_name_text_view_view_user_detail_activity"
@ -56,7 +56,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:textSize="18sp"
android:textColor="@color/colorPrimaryDark"
android:textColor="@color/textColorPrimaryDark"
android:layout_gravity="center_horizontal"/>
<TextView
@ -65,7 +65,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
android:textColor="@android:color/black"
android:textColor="@color/primaryTextColor"
android:layout_gravity="center_horizontal"/>
<com.google.android.material.chip.Chip

View File

@ -14,6 +14,7 @@
android:layout_marginBottom="16dp"
app:mlpb_progress_stoke_width="3dp"
app:mlpb_progress_color="@color/colorAccent"
app:mlpb_background_color="@color/circularProgressBarBackground"
android:layout_gravity="center_horizontal"/>
<androidx.recyclerview.widget.RecyclerView

View File

@ -1,14 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/linear_layout_item_post_comment">
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<View
android:id="@+id/vertical_block_item_post_comment"
android:layout_width="0dp"
android:layout_height="match_parent"
android:background="@color/colorPrimary"/>
android:background="@color/textColorPrimaryDark"/>
<LinearLayout
android:layout_width="match_parent"
@ -29,7 +32,7 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginEnd="16dp"
android:textColor="@color/colorPrimary"/>
android:textColor="@color/textColorPrimaryDark"/>
<TextView
android:id="@+id/comment_time_text_view_item_post_comment"
@ -48,7 +51,7 @@
android:layout_marginStart="32dp"
android:layout_marginEnd="32dp"
android:layout_marginBottom="8dp"
android:textColor="@android:color/black"/>
android:textColor="@color/primaryTextColor"/>
<RelativeLayout
android:id="@+id/relative_layout_item_post_comment"
@ -126,4 +129,6 @@
</LinearLayout>
</LinearLayout>
</LinearLayout>
</com.google.android.material.card.MaterialCardView>

View File

@ -50,7 +50,7 @@
android:layout_height="24dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:tint="@color/colorPrimary"
android:tint="@color/textColorPrimaryDark"
android:visibility="gone"
app:layout_constraintStart_toEndOf="@id/subreddit_icon_name_linear_layout_view_item_best_post"
app:layout_constraintEnd_toStartOf="@+id/post_time_text_view_best_post_item"
@ -77,7 +77,7 @@
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:textSize="18sp"
android:textColor="#000000"/>
android:textColor="@color/primaryTextColor"/>
<RelativeLayout
android:layout_width="match_parent"
@ -93,7 +93,7 @@
android:layout_marginEnd="16dp"
android:textColor="@android:color/white"
android:layout_centerVertical="true"
app:chipBackgroundColor="@color/colorPrimaryDark" />
app:chipBackgroundColor="@color/backgroundColorPrimaryDark" />
<ImageView
android:id="@+id/gilded_image_view_item_best_post"
@ -187,7 +187,8 @@
android:layout_marginTop="16dp"
android:scaleType="center"
android:src="@drawable/ic_link"
android:background="#E0E0E0"
android:tint="@android:color/tab_indicator_text"
android:background="@color/grey"
android:visibility="gone"/>
<RelativeLayout

View File

@ -24,7 +24,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="32dp"
android:textColor="@android:color/black"
android:textColor="@color/primaryTextColor"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/subreddit_icon_gif_image_view_item_subreddit_listing"
app:layout_constraintTop_toTopOf="parent" />
@ -34,9 +34,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:src="@drawable/baseline_add_white_24"
android:tint="@color/colorPrimary"
android:tint="@color/textColorPrimaryDark"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"

View File

@ -18,7 +18,7 @@
android:id="@+id/subreddit_name_text_view_item_subscribed_subreddit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/black"
android:textColor="@color/primaryTextColor"
android:layout_gravity="center_vertical"/>
</LinearLayout>

View File

@ -24,7 +24,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="32dp"
android:textColor="@android:color/black"
android:textColor="@color/primaryTextColor"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/user_icon_gif_image_view_item_user_listing"
app:layout_constraintTop_toTopOf="parent" />
@ -34,9 +34,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:src="@drawable/baseline_add_white_24"
android:tint="@color/colorPrimary"
android:tint="@color/textColorPrimaryDark"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#242424</color>
<color name="colorPrimaryDark">#141414</color>
<color name="colorAccent">#FF4081</color>
<color name="minusButtonColor">#E91E63</color>
<color name="transparentActionBarColor">#88000000</color>
<color name="gold">#FFC107</color>
<color name="primaryTextColor">#FFFFFF</color>
<color name="textColorPrimaryDark">#1E88E5</color>
<color name="circularProgressBarBackground">#242424</color>
<color name="dividerColor">#69666C</color>
<color name="grey">#424242</color>
<color name="backgroundColor">#181818</color>
<color name="backgroundColorPrimaryDark">#1976D2</color>
</resources>

View File

@ -1,7 +1,7 @@
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.MaterialComponents.Light">
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>

View File

@ -9,4 +9,18 @@
<color name="transparentActionBarColor">#88000000</color>
<color name="gold">#FFC107</color>
<color name="primaryTextColor">#000000</color>
<color name="textColorPrimaryDark">@color/colorPrimaryDark</color>
<color name="circularProgressBarBackground">#242424</color>
<color name="dividerColor">#E0E0E0</color>
<color name="grey">#E0E0E0</color>
<color name="backgroundColor">#FFFFFF</color>
<color name="backgroundColorPrimaryDark">@color/colorPrimaryDark</color>
</resources>

View File

@ -1,7 +1,7 @@
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.MaterialComponents.Light">
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
@ -31,7 +31,7 @@
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.DayNight" />
<style name="Theme.AppCompat.Transparent" parent="AppTheme.ActionBar.Transparent">
<item name="android:windowNoTitle">true</item>