调整主题颜色

This commit is contained in:
seven332 committed 2014-11-30 00:21:14 +08:00
1 parent dcfdd31bc4
commit 178b7c8ee3
14 files changed
+57 -73

No files matched your search

+3 -3
View File
@@ -180,9 +180,9 @@
<!-- Settings -->
<string name="display_settings_title">显示</string>
<string name="theme_display_settings_title">主题</string>
<string name="random_theme_color_title">随机主题颜色</string>
<string name="random_theme_color_summary_on">色彩斑斓!</string>
<string name="random_theme_color_summary_off">在下方指定主题颜色</string>
<string name="custom_theme_color_title">自定义主题颜色</string>
<string name="custom_theme_color_summary_on">在下方指定主题颜色</string>
<string name="custom_theme_color_summary_off">使用默认主题颜色</string>
<string name="theme_color_title">主题颜色</string>
<string name="screen_display_settings_title">屏幕</string>
<string name="screen_orientation_title">屏幕方向</string>
-2
View File
@@ -40,9 +40,7 @@
<color name="holo_purple_light_light">#ffd7a2e6</color>
<color name="ab_bg">@android:color/holo_blue_dark</color>
<color name="tag_bg">#bbffffff</color>
<color name="holo_blue_light_light">#ff81d3f7</color>
<color name="light_gray">#aaa</color>
<color name="lighter_gray">#ddd</color>
+2 -2
View File
@@ -17,9 +17,9 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="ActionBar" parent="@android:style/Widget.Holo.ActionBar">
<item name="@android:background">@android:color/holo_blue_dark</item>
<item name="@android:background">?attr/themeColor</item>
<item name="@android:backgroundStacked">@color/tag_bg</item>
<item name="@android:backgroundSplit">@android:color/holo_blue_dark</item>
<item name="@android:backgroundSplit">?attr/themeColor</item>
<item name="@android:titleTextStyle">@style/ActionBarTitleFont</item>
</style>
+7 -6
View File
@@ -20,15 +20,16 @@
android:title="@string/theme_display_settings_title">
<CheckBoxPreference
android:key="random_theme_color"
android:title="@string/random_theme_color_title"
android:summaryOn="@string/random_theme_color_summary_on"
android:summaryOff="@string/random_theme_color_summary_off"
android:defaultValue="true" />
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" />
<com.hippo.ehviewer.preference.ColorPreference
android:key="theme_color"
android:title="@string/theme_color_title" />
android:title="@string/theme_color_title"
android:dependency="custom_theme_color" />
</PreferenceCategory>
+1 -1
View File
@@ -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);
@@ -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);
}
@@ -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);
@@ -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
@@ -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);
@@ -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);
@@ -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;
+5 -5
View File
@@ -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() {
-9
View File
@@ -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
+4 -3
View File
@@ -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);