Add Yotsuba, YotsubaB, Photon and Tomorrow themes

filtering
Floens 10 years ago
parent e2963c1185
commit 5db4915c0c
  1. 40
      Clover/app/src/main/java/org/floens/chan/ui/cell/PostCell.java
  2. 2
      Clover/app/src/main/java/org/floens/chan/ui/controller/ThemeSettingsController.java
  3. 5
      Clover/app/src/main/java/org/floens/chan/ui/theme/DarkTheme.java
  4. 16
      Clover/app/src/main/java/org/floens/chan/ui/theme/Theme.java
  5. 12
      Clover/app/src/main/java/org/floens/chan/ui/theme/ThemeHelper.java
  6. 1
      Clover/app/src/main/res/values/attrs.xml
  7. 59
      Clover/app/src/main/res/values/styles.xml

@ -19,7 +19,6 @@ package org.floens.chan.ui.cell;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Typeface;
import android.graphics.drawable.BitmapDrawable;
import android.os.Build;
@ -53,15 +52,17 @@ import org.floens.chan.core.model.Post;
import org.floens.chan.core.model.PostLinkable;
import org.floens.chan.core.settings.ChanSettings;
import org.floens.chan.ui.helper.PostHelper;
import org.floens.chan.ui.theme.Theme;
import org.floens.chan.ui.theme.ThemeHelper;
import org.floens.chan.ui.view.FloatingMenu;
import org.floens.chan.ui.view.FloatingMenuItem;
import org.floens.chan.ui.view.ThumbnailView;
import org.floens.chan.ui.theme.ThemeHelper;
import org.floens.chan.utils.Time;
import java.util.ArrayList;
import java.util.List;
import static org.floens.chan.ui.theme.ThemeHelper.theme;
import static org.floens.chan.utils.AndroidUtils.dp;
import static org.floens.chan.utils.AndroidUtils.getRes;
import static org.floens.chan.utils.AndroidUtils.setRoundItemBackground;
@ -84,12 +85,9 @@ public class PostCell extends RelativeLayout implements PostLinkable.Callback {
private boolean commentClickable = false;
private CharSequence iconsSpannable;
private int detailsSizePx;
private int detailsColor;
private int iconsTextSize;
private int countrySizePx;
private boolean ignoreNextOnClick;
private int highlightColor;
private int savedColor;
private int paddingPx;
private PostCellCallback callback;
@ -156,18 +154,6 @@ public class PostCell extends RelativeLayout implements PostLinkable.Callback {
dividerParams.rightMargin = paddingPx;
divider.setLayoutParams(dividerParams);
TypedArray ta = getContext().obtainStyledAttributes(new int[]{
R.attr.post_details_color,
R.attr.post_highlighted_color,
R.attr.post_saved_reply_color
});
detailsColor = ta.getColor(0, 0);
highlightColor = ta.getColor(1, 0);
savedColor = ta.getColor(2, 0);
ta.recycle();
thumbnailView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -226,6 +212,10 @@ public class PostCell extends RelativeLayout implements PostLinkable.Callback {
}
public void setPost(final Post post, PostCellCallback callback, boolean highlighted, int markedNo) {
setPost(theme(), post, callback, highlighted, markedNo);
}
public void setPost(Theme theme, final Post post, PostCellCallback callback, boolean highlighted, int markedNo) {
if (this.post != null) {
unbindPost(this.post);
}
@ -235,7 +225,7 @@ public class PostCell extends RelativeLayout implements PostLinkable.Callback {
this.highlighted = highlighted;
this.markedNo = markedNo;
bindPost(post);
bindPost(theme, post);
}
public Post getPost() {
@ -252,7 +242,7 @@ public class PostCell extends RelativeLayout implements PostLinkable.Callback {
return false;
}
private void bindPost(Post post) {
private void bindPost(Theme theme, Post post) {
threadMode = callback.getLoadable().isThreadMode();
setPostLinkableListener(post, this);
@ -264,9 +254,9 @@ public class PostCell extends RelativeLayout implements PostLinkable.Callback {
}
if (highlighted) {
setBackgroundColor(highlightColor);
setBackgroundColor(theme.highlightedColor);
} else if (post.isSavedReply) {
setBackgroundColor(savedColor);
setBackgroundColor(theme.savedReplyColor);
} else if (threadMode) {
setBackgroundResource(0);
} else {
@ -293,7 +283,7 @@ public class PostCell extends RelativeLayout implements PostLinkable.Callback {
CharSequence relativeTime = DateUtils.getRelativeTimeSpanString(post.time * 1000L, Time.get(), DateUtils.SECOND_IN_MILLIS, 0);
SpannableString date = new SpannableString("No." + post.no + " " + relativeTime);
date.setSpan(new ForegroundColorSpan(detailsColor), 0, date.length(), 0);
date.setSpan(new ForegroundColorSpan(theme.detailsColor), 0, date.length(), 0);
date.setSpan(new AbsoluteSizeSpan(detailsSizePx), 0, date.length(), 0);
titleParts[titlePartsCount] = date;
@ -320,7 +310,7 @@ public class PostCell extends RelativeLayout implements PostLinkable.Callback {
boolean waitingForCountry = false;
if (!TextUtils.isEmpty(post.country)) {
loadCountryIcon();
loadCountryIcon(theme);
waitingForCountry = true;
}
@ -393,7 +383,7 @@ public class PostCell extends RelativeLayout implements PostLinkable.Callback {
}
}
private void loadCountryIcon() {
private void loadCountryIcon(final Theme theme) {
final Post requestedPost = post;
Chan.getVolleyImageLoader().get(post.countryUrl, new ImageLoader.ImageListener() {
@Override
@ -403,7 +393,7 @@ public class PostCell extends RelativeLayout implements PostLinkable.Callback {
SpannableString countryText = new SpannableString(post.countryName);
countryText.setSpan(new StyleSpan(Typeface.ITALIC), 0, countryText.length(), 0);
countryText.setSpan(new ForegroundColorSpan(detailsColor), 0, countryText.length(), 0);
countryText.setSpan(new ForegroundColorSpan(theme.detailsColor), 0, countryText.length(), 0);
countryText.setSpan(new AbsoluteSizeSpan(countrySizePx), 0, countryText.length(), 0);
iconsSpannable = TextUtils.concat(iconsSpannable, countryIcon, countryText);

@ -200,7 +200,7 @@ public class ThemeSettingsController extends Controller implements View.OnClickL
themeContext.getResources().getDimensionPixelSize(R.dimen.toolbar_height)));
PostCell postCell = (PostCell) LayoutInflater.from(themeContext).inflate(R.layout.cell_post, null);
postCell.setPost(post, DUMMY_POST_CALLBACK, false, -1);
postCell.setPost(theme, post, DUMMY_POST_CALLBACK, false, -1);
linearLayout.addView(postCell, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
return linearLayout;

@ -3,8 +3,9 @@ package org.floens.chan.ui.theme;
import org.floens.chan.R;
public class DarkTheme extends Theme {
public DarkTheme(String displayName, String name, int resValue, boolean isLightTheme, ThemeHelper.PrimaryColor primaryColor) {
super(displayName, name, resValue, isLightTheme, primaryColor);
public DarkTheme(String displayName, String name, int resValue, ThemeHelper.PrimaryColor primaryColor) {
super(displayName, name, resValue, primaryColor);
isLightTheme = false;
}
public void resolveDrawables() {

@ -35,8 +35,8 @@ public class Theme {
public final String displayName;
public final String name;
public final int resValue;
public final boolean isLightTheme;
public final ThemeHelper.PrimaryColor primaryColor;
public boolean isLightTheme = true;
public int quoteColor;
public int highlightQuoteColor;
@ -48,6 +48,9 @@ public class Theme {
public int idBackgroundLight;
public int idBackgroundDark;
public int capcodeColor;
public int detailsColor;
public int highlightedColor;
public int savedReplyColor;
public ThemeDrawable settingsDrawable;
public ThemeDrawable imageDrawable;
@ -56,11 +59,10 @@ public class Theme {
public ThemeDrawable backDrawable;
public ThemeDrawable doneDrawable;
public Theme(String displayName, String name, int resValue, boolean isLightTheme, ThemeHelper.PrimaryColor primaryColor) {
public Theme(String displayName, String name, int resValue, ThemeHelper.PrimaryColor primaryColor) {
this.displayName = displayName;
this.name = name;
this.resValue = resValue;
this.isLightTheme = isLightTheme;
this.primaryColor = primaryColor;
resolveSpanColors();
@ -91,7 +93,10 @@ public class Theme {
R.attr.post_name_color,
R.attr.post_id_background_light,
R.attr.post_id_background_dark,
R.attr.post_capcode_color
R.attr.post_capcode_color,
R.attr.post_details_color,
R.attr.post_highlighted_color,
R.attr.post_saved_reply_color
});
quoteColor = ta.getColor(0, 0);
@ -104,6 +109,9 @@ public class Theme {
idBackgroundLight = ta.getColor(7, 0);
idBackgroundDark = ta.getColor(8, 0);
capcodeColor = ta.getColor(9, 0);
detailsColor = ta.getColor(10, 0);
highlightedColor = ta.getColor(11, 0);
savedReplyColor = ta.getColor(12, 0);
ta.recycle();
}

@ -46,9 +46,13 @@ public class ThemeHelper {
private Theme theme;
public ThemeHelper() {
themes.add(new Theme("Light", "light", R.style.Chan_Theme, true, PrimaryColor.GREEN));
themes.add(new DarkTheme("Dark", "dark", R.style.Chan_Theme_Dark, false, PrimaryColor.DARK));
themes.add(new DarkTheme("Black", "black", R.style.Chan_Theme_Black, false, PrimaryColor.BLACK));
themes.add(new Theme("Light", "light", R.style.Chan_Theme, PrimaryColor.GREEN));
themes.add(new DarkTheme("Dark", "dark", R.style.Chan_Theme_Dark, PrimaryColor.DARK));
themes.add(new DarkTheme("Black", "black", R.style.Chan_Theme_Black, PrimaryColor.BLACK));
themes.add(new Theme("Yotsuba", "yotsuba", R.style.Chan_Theme_Yotsuba, PrimaryColor.RED));
themes.add(new Theme("Yotsuba B", "yotsuba_b", R.style.Chan_Theme_YotsubaB, PrimaryColor.RED));
themes.add(new Theme("Photon", "photon", R.style.Chan_Theme_Photon, PrimaryColor.ORANGE));
themes.add(new DarkTheme("Tomorrow", "tomorrow", R.style.Chan_Theme_Tomorrow, PrimaryColor.DARK));
updateCurrentTheme();
}
@ -85,7 +89,7 @@ public class ThemeHelper {
}
public enum PrimaryColor {
RED("red", 0xFF44336, 0xFFD32F2F),
RED("red", 0xFFF44336, 0xFFD32F2F),
PINK("pink", 0xFFE91E63, 0xFFC2185B),
PURPLE("purple", 0xFF9C27B0, 0xFF7B1FA2),
DEEP_PURPLE("deep purple", 0xFF673AB7, 0xFF512DA8),

@ -25,7 +25,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<attr name="post_saved_reply_color" format="color" />
<attr name="post_highlighted_color" format="color" />
<attr name="post_reply_color" format="color" />
<attr name="post_name_color" format="color" />
<attr name="post_subject_color" format="color" />
<attr name="post_details_color" format="color" />

@ -40,21 +40,21 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<item name="text_color_secondary">#89000000</item>
<item name="text_color_hint">#42000000</item>
<item name="post_saved_reply_color">#FFBCBCBC</item>
<item name="post_highlighted_color">#FFD6BAD0</item>
<item name="post_reply_color">#FF646464</item>
<item name="post_name_color">#ff117743</item>
<item name="post_subject_color">#ff0F0C5D</item>
<item name="post_details_color">#ff646464</item>
<item name="post_quote_color">#ffDD0000</item>
<item name="post_highlight_quote_color">#ff950000</item>
<item name="post_inline_quote_color">#ff789922</item>
<item name="post_link_color">#ff0000B4</item>
<item name="post_spoiler_color">#ff000000</item>
<item name="post_capcode_color">#ffff0000</item>
<item name="post_id_background_light">#ff636363</item>
<item name="post_id_background_dark">#00000000</item>
<item name="post_inline_quote_color">#ff789922</item>
<item name="post_options_drawable">@drawable/ic_overflow</item>
<item name="post_saved_reply_color">#FFBCBCBC</item>
<item name="post_highlighted_color">#FFD6BAD0</item>
<item name="divider_color">#1e000000</item>
@ -98,6 +98,57 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<item name="post_spoiler_color">#ff2c2c2c</item>
</style>
<style name="Chan.Theme.YotsubaB">
<item name="backcolor">#ffd6daf0</item>
<item name="backcolor_secondary">#ffeef2ff</item>
<item name="post_quote_color">#ff000080</item>
<item name="post_link_color">#ff000080</item>
</style>
<style name="Chan.Theme.Yotsuba">
<item name="backcolor">#fff0e0d6</item>
<item name="backcolor_secondary">#ffffffee</item>
<item name="android:textColor">#ff800000</item>
<item name="text_color_primary">#ff800000</item>
<item name="text_color_secondary">#89800000</item>
<item name="post_quote_color">#ff000080</item>
<item name="post_link_color">#ff000080</item>
<item name="post_subject_color">#ffcc1105</item>
</style>
<style name="Chan.Theme.Photon">
<item name="backcolor">#ffeeeeee</item>
<item name="post_name_color">#ff004A99</item>
<item name="post_quote_color">#ffFF6600</item>
<item name="post_link_color">#ffFF6600</item>
<item name="post_highlight_quote_color">#ffcb6600</item>
<item name="post_subject_color">#ff111111</item>
<item name="post_details_color">#ff333333</item>
<item name="post_inline_quote_color">#ff789922</item>
</style>
<style name="Chan.Theme.Tomorrow" parent="Chan.Theme.Dark">
<item name="backcolor">#ff282a2e</item>
<item name="backcolor_secondary">#ff1d1f21</item>
<item name="android:textColor">#ffc5c8c6</item>
<item name="text_color_primary">#ffc5c8c6</item>
<item name="text_color_secondary">#89c5c8c6</item>
<item name="post_name_color">#ffc5c8c6</item>
<item name="post_quote_color">#ff5F89AC</item>
<item name="post_link_color">#ff5F89AC</item>
<item name="post_highlight_quote_color">#ff416181</item>
<item name="post_subject_color">#ffb294bb</item>
<item name="post_details_color">#ffc5c8c6</item>
<item name="post_inline_quote_color">#ffb5bd68</item>
</style>
<!-- For FloatingMenu -->
<style name="ToolbarDropDownListViewStyle" parent="Widget.AppCompat.ListView.DropDown">
<item name="android:background">#ffffffff</item>

Loading…
Cancel
Save