diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml
index 321f38019..60414f990 100644
--- a/res/values-zh-rCN/strings.xml
+++ b/res/values-zh-rCN/strings.xml
@@ -180,9 +180,9 @@
显示
主题
- 随机主题颜色
- 色彩斑斓!
- 在下方指定主题颜色
+ 自定义主题颜色
+ 在下方指定主题颜色
+ 使用默认主题颜色
主题颜色
屏幕
屏幕方向
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 0b4afe281..3c7fd2414 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -40,9 +40,7 @@
#ffd7a2e6
- @android:color/holo_blue_dark
#bbffffff
- #ff81d3f7
#aaa
#ddd
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 0c9c277cf..39f94e1d9 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -17,9 +17,9 @@
diff --git a/res/xml/display_settings.xml b/res/xml/display_settings.xml
index d98ea8bfc..b141fb092 100644
--- a/res/xml/display_settings.xml
+++ b/res/xml/display_settings.xml
@@ -20,15 +20,16 @@
android:title="@string/theme_display_settings_title">
+ android:key="custom_theme_color"
+ android:title="@string/custom_theme_color_title"
+ android:summaryOn="@string/custom_theme_color_summary_on"
+ android:summaryOff="@string/custom_theme_color_summary_off"
+ android:defaultValue="false" />
+ android:title="@string/theme_color_title"
+ android:dependency="custom_theme_color" />
diff --git a/src/com/hippo/ehviewer/AppContext.java b/src/com/hippo/ehviewer/AppContext.java
index b66d7b6a9..8373559b1 100644
--- a/src/com/hippo/ehviewer/AppContext.java
+++ b/src/com/hippo/ehviewer/AppContext.java
@@ -74,9 +74,9 @@ public class AppContext extends Application implements UncaughtExceptionHandler
Context mContextThemeWrapper = new ContextThemeWrapper(this, R.style.AppTheme);
// Init everything
+ Ui.init(mContextThemeWrapper);
Config.init(mContextThemeWrapper);
Log.init(mContextThemeWrapper);
- Ui.init(mContextThemeWrapper);
Crash.init(mContextThemeWrapper);
EhClient.createInstance(mContextThemeWrapper);
Favorite.init(mContextThemeWrapper);
diff --git a/src/com/hippo/ehviewer/ui/DownloadActivity.java b/src/com/hippo/ehviewer/ui/DownloadActivity.java
index 20505b9dc..40c3a4051 100644
--- a/src/com/hippo/ehviewer/ui/DownloadActivity.java
+++ b/src/com/hippo/ehviewer/ui/DownloadActivity.java
@@ -50,7 +50,6 @@ import com.hippo.ehviewer.drawable.MaterialIndicatorDrawable.Stroke;
import com.hippo.ehviewer.service.DownloadService;
import com.hippo.ehviewer.util.Config;
import com.hippo.ehviewer.util.EhUtils;
-import com.hippo.ehviewer.util.Theme;
import com.hippo.ehviewer.util.Ui;
import com.hippo.ehviewer.util.Utils;
import com.hippo.ehviewer.widget.ExpandingListView;
@@ -118,7 +117,7 @@ public class DownloadActivity extends AbsTranslucentActivity implements FitWindo
mList.setSelector(new ColorDrawable(Color.TRANSPARENT));
mList.setExpandingId(R.id.buttons);
- mThemeColor = Config.getRandomThemeColor() ? Theme.getRandomDarkColor() : Config.getThemeColor();
+ mThemeColor = Config.getCustomThemeColor() ? Config.getThemeColor() : Ui.THEME_COLOR;
getActionBar().setBackgroundDrawable(new ColorDrawable(mThemeColor));
Ui.colorStatusBarL(this, mThemeColor);
}
diff --git a/src/com/hippo/ehviewer/ui/FavouriteActivity.java b/src/com/hippo/ehviewer/ui/FavouriteActivity.java
index 0e77c3c7a..405a5cf2e 100644
--- a/src/com/hippo/ehviewer/ui/FavouriteActivity.java
+++ b/src/com/hippo/ehviewer/ui/FavouriteActivity.java
@@ -65,7 +65,6 @@ import com.hippo.ehviewer.drawable.MaterialIndicatorDrawable.Stroke;
import com.hippo.ehviewer.ehclient.EhClient;
import com.hippo.ehviewer.util.Config;
import com.hippo.ehviewer.util.Favorite;
-import com.hippo.ehviewer.util.Theme;
import com.hippo.ehviewer.util.Ui;
import com.hippo.ehviewer.widget.ActionableToastBar;
import com.hippo.ehviewer.widget.ActionableToastBar.ActionClickedListener;
@@ -269,7 +268,7 @@ public class FavouriteActivity extends AbsTranslucentActivity
});
// Set random color
- mThemeColor = Config.getRandomThemeColor() ? Theme.getRandomDarkColor() : Config.getThemeColor();
+ mThemeColor = Config.getCustomThemeColor() ? Config.getThemeColor() : Ui.THEME_COLOR;
mActionBar.setBackgroundDrawable(new ColorDrawable(mThemeColor));
mMenu.setBackgroundColor(mThemeColor);
Ui.colorStatusBarL(this, mThemeColor);
diff --git a/src/com/hippo/ehviewer/ui/GalleryDetailActivity.java b/src/com/hippo/ehviewer/ui/GalleryDetailActivity.java
index 570db6014..3d4b0c29b 100644
--- a/src/com/hippo/ehviewer/ui/GalleryDetailActivity.java
+++ b/src/com/hippo/ehviewer/ui/GalleryDetailActivity.java
@@ -83,7 +83,6 @@ import com.hippo.ehviewer.service.DownloadService;
import com.hippo.ehviewer.util.Config;
import com.hippo.ehviewer.util.Constants;
import com.hippo.ehviewer.util.Favorite;
-import com.hippo.ehviewer.util.Theme;
import com.hippo.ehviewer.util.Ui;
import com.hippo.ehviewer.util.ViewUtils;
import com.hippo.ehviewer.widget.AutoWrapLayout;
@@ -174,6 +173,7 @@ public class GalleryDetailActivity extends AbsTranslucentActivity
private CommentAdapter mCommentAdapter;
+ private int mPaddingTop = -1;
private int mThemeColor;
private int mCurPreviewPage = 0;
private boolean mShowPreview = false;
@@ -369,24 +369,9 @@ public class GalleryDetailActivity extends AbsTranslucentActivity
mPreview.setColumnCountLandscape(
Config.getPreviewColumnsLandscape());
- // Set random color
- mThemeColor = Config.getRandomThemeColor() ? Theme.getRandomDarkColor() : Config.getThemeColor();
- getActionBar().setBackgroundDrawable(new ColorDrawable(mThemeColor));
- mDownloadButton.setRoundBackground(true, false, mResources.getColor(R.color.background_light), mThemeColor);
- mDownloadButton.setTextColor(mThemeColor);
- mReadButton.setRoundBackground(true, mThemeColor, 0);
- ((TextView)findViewById(R.id.detail_more_text)).setTextColor(mThemeColor);
- mCommentMoreText.setTextColor(mThemeColor);
- mPreviewPage.setRoundBackground(true, false, mResources.getColor(R.color.background_light), mThemeColor);
- mPreviewPage.setTextColor(mThemeColor);
- mPreviewBack.setRoundBackground(true, false, mResources.getColor(R.color.background_light), mThemeColor);
- mPreviewBack.setTextColor(mThemeColor);
- mPreviewFront.setRoundBackground(true, false, mResources.getColor(R.color.background_light), mThemeColor);
- mPreviewFront.setTextColor(mThemeColor);
- mPreviewWait.setColor(mThemeColor);
- mPreviewRefresh.setRoundBackground(true, mThemeColor, 0);
- mReply.setColor(mThemeColor);
- Ui.colorStatusBarL(this, mThemeColor);
+ // Set theme color
+ setThemeColor(mThemeColor = Config.getCustomThemeColor() ? Config.getThemeColor() :
+ (mGalleryInfo.title == null ? Ui.THEME_COLOR : Ui.getCategoryColor(mGalleryInfo.category)));
// Set ripple
mWindowsAnimate.addRippleEffect(mDownloadButton, true);
@@ -422,6 +407,28 @@ public class GalleryDetailActivity extends AbsTranslucentActivity
doPreLayout();
}
+ private void setThemeColor(int themeColor) {
+ mThemeColor = themeColor;
+ getActionBar().setBackgroundDrawable(new ColorDrawable(mThemeColor));
+ mDownloadButton.setRoundBackground(true, false, mResources.getColor(R.color.background_light), mThemeColor);
+ mDownloadButton.setTextColor(mThemeColor);
+ mReadButton.setRoundBackground(true, mThemeColor, 0);
+ ((TextView)findViewById(R.id.detail_more_text)).setTextColor(mThemeColor);
+ mCommentMoreText.setTextColor(mThemeColor);
+ mPreviewPage.setRoundBackground(true, false, mResources.getColor(R.color.background_light), mThemeColor);
+ mPreviewPage.setTextColor(mThemeColor);
+ mPreviewBack.setRoundBackground(true, false, mResources.getColor(R.color.background_light), mThemeColor);
+ mPreviewBack.setTextColor(mThemeColor);
+ mPreviewFront.setRoundBackground(true, false, mResources.getColor(R.color.background_light), mThemeColor);
+ mPreviewFront.setTextColor(mThemeColor);
+ mPreviewWait.setColor(mThemeColor);
+ mPreviewRefresh.setRoundBackground(true, mThemeColor, 0);
+ mReply.setColor(mThemeColor);
+ Ui.colorStatusBarL(this, mThemeColor);
+ if (mPaddingTop != -1)
+ Ui.colorStatusBarKK(this, mPaddingTop - Ui.ACTION_BAR_HEIGHT, mThemeColor);
+ }
+
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle item selection
@@ -584,6 +591,8 @@ public class GalleryDetailActivity extends AbsTranslucentActivity
private void doLayout() {
if (mDetailScroll.getVisibility() == View.GONE) {
// If not set header in doPreLayout
+ // Set theme
+ setThemeColor(Ui.getCategoryColor(mGalleryInfo.category));
// Add history first
Data.getInstance().addHistory(mGalleryInfo, Data.BROWSE);
mDetailScroll.setVisibility(View.VISIBLE);
@@ -998,7 +1007,8 @@ public class GalleryDetailActivity extends AbsTranslucentActivity
mCommentList.getPaddingRight(), b + Ui.dp2pix(16 + 56 + 16));
((FrameLayout.LayoutParams)mReply.getLayoutParams()).bottomMargin = Ui.dp2pix(16) + b;
- Ui.colorStatusBarKK(this, mThemeColor, t - Ui.ACTION_BAR_HEIGHT);
+ mPaddingTop = t;
+ Ui.colorStatusBarKK(this, mThemeColor, mPaddingTop - Ui.ACTION_BAR_HEIGHT);
}
@Override
diff --git a/src/com/hippo/ehviewer/ui/GalleryListActivity.java b/src/com/hippo/ehviewer/ui/GalleryListActivity.java
index b17146c2f..6491cc811 100644
--- a/src/com/hippo/ehviewer/ui/GalleryListActivity.java
+++ b/src/com/hippo/ehviewer/ui/GalleryListActivity.java
@@ -87,7 +87,6 @@ import com.hippo.ehviewer.tile.TileSalon;
import com.hippo.ehviewer.util.Config;
import com.hippo.ehviewer.util.DialogUtils;
import com.hippo.ehviewer.util.Favorite;
-import com.hippo.ehviewer.util.Theme;
import com.hippo.ehviewer.util.Ui;
import com.hippo.ehviewer.util.Utils;
import com.hippo.ehviewer.util.ViewUtils;
@@ -1219,7 +1218,7 @@ public class GalleryListActivity extends AbsTranslucentActivity implements View.
});
// Set random color
- mThemeColor = Config.getRandomThemeColor() ? Theme.getRandomDarkColor() : Config.getThemeColor();
+ mThemeColor = Config.getCustomThemeColor() ? Config.getThemeColor() : Ui.THEME_COLOR;
mActionBar.setBackgroundDrawable(new ColorDrawable(mThemeColor));
//mLeftMenu.setBackgroundColor(mThemeColor);
//mRightMenu.setBackgroundColor(mThemeColor);
diff --git a/src/com/hippo/ehviewer/ui/HistoryActivity.java b/src/com/hippo/ehviewer/ui/HistoryActivity.java
index 76fccaac0..c84b673a2 100644
--- a/src/com/hippo/ehviewer/ui/HistoryActivity.java
+++ b/src/com/hippo/ehviewer/ui/HistoryActivity.java
@@ -46,7 +46,6 @@ import com.hippo.ehviewer.data.GalleryInfo;
import com.hippo.ehviewer.drawable.MaterialIndicatorDrawable;
import com.hippo.ehviewer.drawable.MaterialIndicatorDrawable.Stroke;
import com.hippo.ehviewer.util.Config;
-import com.hippo.ehviewer.util.Theme;
import com.hippo.ehviewer.util.Ui;
import com.hippo.ehviewer.widget.FitWindowView;
import com.hippo.ehviewer.widget.GalleryListView;
@@ -171,7 +170,7 @@ public class HistoryActivity extends AbsTranslucentActivity
Ui.setMaterialIndicator(getActionBar(), materialIndicator);
// Theme
- mThemeColor = Config.getRandomThemeColor() ? Theme.getRandomDarkColor() : Config.getThemeColor();
+ mThemeColor = Config.getCustomThemeColor() ? Config.getThemeColor() : Ui.THEME_COLOR;
getActionBar().setBackgroundDrawable(new ColorDrawable(mThemeColor));
Ui.colorStatusBarL(this, mThemeColor);
diff --git a/src/com/hippo/ehviewer/ui/SettingsActivity.java b/src/com/hippo/ehviewer/ui/SettingsActivity.java
index a7b18f509..52c3134a1 100644
--- a/src/com/hippo/ehviewer/ui/SettingsActivity.java
+++ b/src/com/hippo/ehviewer/ui/SettingsActivity.java
@@ -69,7 +69,6 @@ import com.hippo.ehviewer.util.Config;
import com.hippo.ehviewer.util.DialogUtils;
import com.hippo.ehviewer.util.EhUtils;
import com.hippo.ehviewer.util.Favorite;
-import com.hippo.ehviewer.util.Theme;
import com.hippo.ehviewer.util.Ui;
import com.hippo.ehviewer.util.Utils;
import com.hippo.ehviewer.widget.CategoryTable;
@@ -88,7 +87,7 @@ public class SettingsActivity extends AbsPreferenceActivity {
super.onCreate(savedInstanceState);
// Set random color
- mThemeColor = Config.getRandomThemeColor() ? Theme.getRandomDarkColor() : Config.getThemeColor();
+ mThemeColor = Config.getCustomThemeColor() ? Config.getThemeColor() : Ui.THEME_COLOR;
getActionBar().setBackgroundDrawable(new ColorDrawable(mThemeColor));
Ui.colorStatusBarL(this, mThemeColor);
@@ -135,12 +134,8 @@ public class SettingsActivity extends AbsPreferenceActivity {
Preference.OnPreferenceChangeListener {
private static final String KEY_SCREEN_ORIENTATION = "screen_orientation";
- private static final String KEY_RANDOM_THEME_COLOR = "random_theme_color";
- private static final String KEY_THEME_COLOR = "theme_color";
private ListPreference mScreenOrientation;
- private CheckBoxPreference mRandomThemeColor;
- private Preference mThemeColor;
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -149,11 +144,6 @@ public class SettingsActivity extends AbsPreferenceActivity {
mScreenOrientation = (ListPreference) findPreference(KEY_SCREEN_ORIENTATION);
mScreenOrientation.setOnPreferenceChangeListener(this);
- mRandomThemeColor = (CheckBoxPreference) findPreference(KEY_RANDOM_THEME_COLOR);
- mRandomThemeColor.setOnPreferenceChangeListener(this);
- mThemeColor = findPreference(KEY_THEME_COLOR);
-
- mThemeColor.setEnabled(!mRandomThemeColor.isChecked());
}
@Override
@@ -162,9 +152,6 @@ public class SettingsActivity extends AbsPreferenceActivity {
if (KEY_SCREEN_ORIENTATION.equals(key)) {
getActivity().setRequestedOrientation(Config.screenOriPre2Value(Integer.parseInt((String) newValue)));
- } else if (KEY_RANDOM_THEME_COLOR.equals(key)) {
- MaterialToast.showToast(R.string.restart_to_take_effect);
- mThemeColor.setEnabled(!(Boolean) newValue);
}
return true;
diff --git a/src/com/hippo/ehviewer/util/Config.java b/src/com/hippo/ehviewer/util/Config.java
index b259c15de..0183caa0f 100644
--- a/src/com/hippo/ehviewer/util/Config.java
+++ b/src/com/hippo/ehviewer/util/Config.java
@@ -132,11 +132,11 @@ public final class Config {
/****** Display ******/
- private static final String KEY_RANDOM_THEME_COLOR = "random_theme_color";
- private static final boolean DEFAULT_RANDOM_THEME_COLOR = true;
+ private static final String KEY_CUSTOM_THEME_COLOR = "custom_theme_color";
+ private static final boolean DEFAULT_CUSTOM_THEME_COLOR = false;
private static final String KEY_THEME_COLOR = "theme_color";
- private static final int DEFAULT_THEME_COLOR = 0xff0099cc;
+ private static final int DEFAULT_THEME_COLOR = Ui.THEME_COLOR;
private static final String KEY_SCREEN_ORIENTATION = "screen_orientation";
private static final int DEFAULT_SCREEN_ORIENTATION = 0;
@@ -159,8 +159,8 @@ public final class Config {
private static final String KEY_SHOW_POPULAR_UPDATE_TIME = "show_popular_update_time";
private static final boolean DEFAULT_SHOW_POPULAR_UPDATE_TIME = false;
- public static boolean getRandomThemeColor() {
- return getBoolean(KEY_RANDOM_THEME_COLOR, DEFAULT_RANDOM_THEME_COLOR);
+ public static boolean getCustomThemeColor() {
+ return getBoolean(KEY_CUSTOM_THEME_COLOR, DEFAULT_CUSTOM_THEME_COLOR);
}
public static int getThemeColor() {
diff --git a/src/com/hippo/ehviewer/util/Theme.java b/src/com/hippo/ehviewer/util/Theme.java
index 40b416a87..3e4035b63 100644
--- a/src/com/hippo/ehviewer/util/Theme.java
+++ b/src/com/hippo/ehviewer/util/Theme.java
@@ -34,15 +34,6 @@ public final class Theme {
0xff259b24
};
- /**
- * Get random deep color, alpha is 0xff
- * @return
- */
- public static int getRandomDarkColor() {
- // return DARK_COLOR_TABLE[Math.abs(MathUtils.random(DARK_COLOR_TABLE.length))];
- return 0xff009688;
- }
-
/**
* get darker color of target color, alpha not change
* @param color
diff --git a/src/com/hippo/ehviewer/util/Ui.java b/src/com/hippo/ehviewer/util/Ui.java
index 40d023854..052960547 100644
--- a/src/com/hippo/ehviewer/util/Ui.java
+++ b/src/com/hippo/ehviewer/util/Ui.java
@@ -55,8 +55,6 @@ public class Ui {
public static float mDensity;
public static float mScaledDensity;
- public static int HOLO_BLUE_DARK;
-
public static int DOUJINSHI_BG_COLOR;
public static int MANGA_BG_COLOR;
public static int ARTIST_CG_BG_COLOR;
@@ -69,6 +67,8 @@ public class Ui {
public static int MISC_BG_COLOR;
public static int UNKNOWN_BG_COLOR;
+ public static int THEME_COLOR;
+
public static Drawable transparentDrawable;
public static int ACTION_BAR_HEIGHT;
@@ -91,7 +91,6 @@ public class Ui {
mScaledDensity = mResources.getDisplayMetrics().scaledDensity;
// init color
- HOLO_BLUE_DARK = mResources.getColor(android.R.color.holo_blue_dark);
DOUJINSHI_BG_COLOR = mResources.getColor(R.color.doujinshi_bg);
MANGA_BG_COLOR = mResources.getColor(R.color.manga_bg);
@@ -105,6 +104,8 @@ public class Ui {
MISC_BG_COLOR = mResources.getColor(R.color.misc_bg);
UNKNOWN_BG_COLOR = mResources.getColor(R.color.unknown_bg);
+ THEME_COLOR = mResources.getColor(R.color.theme);
+
// init drawable
transparentDrawable = new ColorDrawable(Color.TRANSPARENT);