随机主题配色

This commit is contained in:
seven332 committed 2014-06-13 18:14:41 +08:00
1 parent 5bc166d3da
commit f39cfc7875
16 files changed
+275 -46

No files matched your search

+1
View File
@@ -20,6 +20,7 @@
android:orientation="vertical" >
<LinearLayout
android:id="@+id/title_layout"
android:layout_width="fill_parent"
android:layout_height="64dp"
android:background="@android:color/holo_blue_dark"
+1
View File
@@ -104,6 +104,7 @@
</RelativeLayout>
<View
android:id="@+id/crude_divider"
android:layout_width="fill_parent"
android:layout_height="2.0dp"
android:background="@android:color/holo_blue_light" />
+1
View File
@@ -20,6 +20,7 @@
android:orientation="vertical" >
<LinearLayout
android:id="@+id/title_layout"
android:layout_width="fill_parent"
android:layout_height="64.0dp"
android:orientation="horizontal"
+1
View File
@@ -14,6 +14,7 @@
limitations under the License.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/list_menu_left"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/holo_blue_dark"
+8 -10
View File
@@ -18,28 +18,26 @@
android:layout_height="wrap_content"
android:gravity="center" >
<ImageView
<View
android:id="@+id/back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/back" />
android:layout_width="24.0dp"
android:layout_height="48.0dp" />
<TextView
android:id="@+id/preview_num"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="48dp"
android:layout_marginRight="48dp"
android:layout_marginLeft="48.0dp"
android:layout_marginRight="48.0dp"
android:padding="12dp"
android:textSize="14sp"
android:textColor="@android:color/white"
android:background="@drawable/clickable_bg_blue"
android:clickable="true" />
<ImageView
<View
android:id="@+id/front"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/front" />
android:layout_width="24.0dp"
android:layout_height="48.0dp" />
</LinearLayout>
+36
View File
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2014 Hippo Seven
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<resources>
<style name="AppTheme.Normal">
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
</style>
<style name="AppTheme.Main.ListActivity">
<item name="android:windowBackground">@color/list_main_bg</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
</style>
<!-- For activity whose main view is list, make background darker to match white list -->
<style name="AppTheme.ListActivity">
<item name="android:windowBackground">@color/list_main_bg</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
</style>
</resources>
@@ -35,6 +35,7 @@ import com.hippo.ehviewer.ehclient.DetailParser;
import com.hippo.ehviewer.ehclient.EhClient;
import com.hippo.ehviewer.util.Cache;
import com.hippo.ehviewer.util.Log;
import com.hippo.ehviewer.util.Theme;
import com.hippo.ehviewer.util.Ui;
import com.hippo.ehviewer.util.Util;
import com.hippo.ehviewer.widget.AlertButton;
@@ -57,8 +58,12 @@ import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.Path;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.StateListDrawable;
import android.graphics.drawable.shapes.PathShape;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.TypedValue;
@@ -119,6 +124,40 @@ public class DetailSectionFragment extends Fragment
private int mCurPage;
private boolean mShowPreview = false;
private ShapeDrawable getArrowShapeDrawable(int color, boolean isToLeft) {
Path path = new Path();
if (isToLeft) {
path.moveTo(50, 0);
path.lineTo(50, 100);
path.lineTo(0, 50);
path.close();
} else {
path.moveTo(0, 0);
path.lineTo(0, 100);
path.lineTo(50, 50);
path.close();
}
ShapeDrawable d = new ShapeDrawable(new PathShape(path, 50, 100));
d.getPaint().setColor(color);
//d.setBounds(0, 0, Ui.dp2pix(24), Ui.dp2pix(48));
return d;
}
private StateListDrawable getArrowClickDrawable(int color, boolean isToLeft) {
StateListDrawable sld = new StateListDrawable();
ShapeDrawable normal = getArrowShapeDrawable(color, isToLeft);
ShapeDrawable grey = getArrowShapeDrawable(Theme.GREY_COLOR, isToLeft);
ShapeDrawable dark = getArrowShapeDrawable(Theme.getDarkerColor(color), isToLeft);
sld.addState(new int[]{-android.R.attr.state_enabled}, grey);
sld.addState(new int[]{android.R.attr.state_enabled, android.R.attr.state_selected}, dark);
sld.addState(new int[]{android.R.attr.state_enabled, android.R.attr.state_focused}, dark);
sld.addState(new int[]{android.R.attr.state_enabled, android.R.attr.state_pressed}, dark);
sld.addState(new int[]{}, normal);
//sld.setBounds(0, 0, Ui.dp2pix(24), Ui.dp2pix(48));
return sld;
}
@SuppressWarnings("deprecation")
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
@@ -162,6 +201,24 @@ public class DetailSectionFragment extends Fragment
mFrontButton = mPreviewListMain.findViewById(R.id.front);
mDivider = mNormalView.findViewById(R.id.divider);
int color;
// Set random color
color = Theme.getRandomDeepColor();
mReadButton.setBackgroundDrawable(Theme.getClickDrawable(mActivity, color));
mRateButton.setBackgroundDrawable(Theme.getClickDrawable(mActivity, color));
color = Theme.getRandomDeepColor();
mRootView.findViewById(R.id.crude_divider).setBackgroundColor(Theme.getRandomDeepColor());
color = Theme.getRandomDeepColor();
mRefreshButton.setBackgroundDrawable(Theme.getClickDrawable(mActivity, color));
mCancelButton.setBackgroundDrawable(Theme.getClickDrawable(mActivity, color));
mOnceButton.setBackgroundDrawable(Theme.getClickDrawable(mActivity, color));
mEveryButton.setBackgroundDrawable(Theme.getClickDrawable(mActivity, color));
mKnownButton.setBackgroundDrawable(Theme.getClickDrawable(mActivity, color));
color = Theme.getRandomDeepColor();
mPreviewNumText.setBackgroundDrawable(Theme.getClickDrawable(mActivity, color));
mBackButton.setBackgroundDrawable(getArrowClickDrawable(color, true));
mFrontButton.setBackgroundDrawable(getArrowClickDrawable(color, false));
mRefreshButton.setOnClickListener(this);
FswView align = (FswView)mActivity.findViewById(R.id.alignment);
@@ -193,8 +250,6 @@ public class DetailSectionFragment extends Fragment
}
});
LoadImageView thumb = (LoadImageView)mRootView.findViewById(R.id.detail_cover);
Bitmap bmp = null;
if (Cache.memoryCache != null &&
@@ -398,6 +453,7 @@ public class DetailSectionFragment extends Fragment
}).create();
}
@SuppressWarnings("deprecation")
private void addTags() {
LinearLayout tagsLayout = (LinearLayout)mRootView.findViewById(R.id.tags_layout);
LinkedHashMap<String, LinkedList<SimpleEntry<String, Integer>>> tagGroups =
@@ -406,6 +462,7 @@ public class DetailSectionFragment extends Fragment
int x = Ui.dp2pix(4);
int y = Ui.dp2pix(4);
Resources resources = getResources();
// Get tag view resources
int tagTextSize = resources.getDimensionPixelOffset(R.dimen.button_small_size);
ColorStateList tagTextColor = resources.getColorStateList(R.color.blue_bn_text);
@@ -425,13 +482,15 @@ public class DetailSectionFragment extends Fragment
tagGroupLayout.addView(groupNameView, lp);
// tags
// get random color
int tagColor = Theme.getRandomDeepColor();
for (SimpleEntry<String, Integer> tag : tagGroup.getValue()) {
final String tagText = tag.getKey();
Button tagView = new Button(mActivity);
tagView.setTextSize(TypedValue.COMPLEX_UNIT_PX, tagTextSize);
tagView.setText(String.format("%s (%d)", tagText, tag.getValue()));
tagView.setTextColor(tagTextColor);
tagView.setBackgroundResource(R.drawable.clickable_bg_blue);
tagView.setBackgroundDrawable(Theme.getClickDrawable(mActivity, tagColor));
tagView.setPadding(tagPaddingX, tagPaddingY, tagPaddingX, tagPaddingY);
tagView.setOnClickListener(new OnClickListener() {
@Override
@@ -476,7 +535,7 @@ public class DetailSectionFragment extends Fragment
addtagView.setTextSize(TypedValue.COMPLEX_UNIT_PX, tagTextSize);
addtagView.setText("+");
addtagView.setTextColor(tagTextColor);
addtagView.setBackgroundResource(R.drawable.clickable_bg_blue);
addtagView.setBackgroundDrawable(Theme.getClickDrawable(mActivity, Theme.getRandomDeepColor()));
addtagView.setPadding(tagPaddingX, tagPaddingY, tagPaddingX, tagPaddingY);
addtagView.setOnClickListener(new View.OnClickListener() {
@Override
@@ -23,7 +23,6 @@ import java.util.Set;
import android.app.ActionBar;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.Resources;
@@ -55,6 +54,7 @@ import com.hippo.ehviewer.data.GalleryInfo;
import com.hippo.ehviewer.ehclient.EhClient;
import com.hippo.ehviewer.service.DownloadService;
import com.hippo.ehviewer.service.DownloadServiceConnection;
import com.hippo.ehviewer.util.Theme;
import com.hippo.ehviewer.util.Ui;
import com.hippo.ehviewer.widget.ActionableToastBar;
import com.hippo.ehviewer.widget.DialogBuilder;
@@ -139,12 +139,7 @@ public class FavouriteActivity extends AbstractGalleryActivity
mImageGeterManager = mAppContext.getImageGeterManager();
mClient = mAppContext.getEhClient();
int color = getResources().getColor(android.R.color.holo_blue_dark)
& 0x00ffffff | 0xdd000000;
Drawable drawable = new ColorDrawable(color);
Ui.translucent(this, drawable);
final ActionBar actionBar = getActionBar();
actionBar.setBackgroundDrawable(drawable);
getActionBar().setDisplayHomeAsUpEnabled(true);
// Download service
@@ -283,6 +278,13 @@ public class FavouriteActivity extends AbstractGalleryActivity
}
});
// Set random color
int color = Theme.getRandomDeepColor() & 0x00ffffff | 0xdd000000;
Drawable drawable = new ColorDrawable(color);
actionBar.setBackgroundDrawable(drawable);
Ui.translucent(this, color);
mMenuList.setBackgroundColor(color);
// Check login
if (!mClient.isLogin()) {
SuperToast superToast = new SuperToast(this, "未检测到登陆状态,仅可使用本地收藏。由于开发者的问题,本地收藏不可靠,请尽快登陆,将本地收藏转移至账户中的收藏。");
@@ -366,7 +368,7 @@ public class FavouriteActivity extends AbstractGalleryActivity
private void startMoveFromLocal2Cloud() {
mPdb = new ProgressDialogBulider(FavouriteActivity.this);
mPdb.setCancelable(true).setTitle("正在移动...");
mPdb.setCancelable(false).setTitle("正在移动...");
mPdb.setMax(mChoiceGiSetCopy.size()).setProgress(0);
mProgressDialog = mPdb.create();
mProgressDialog.show();
@@ -519,8 +521,7 @@ public class FavouriteActivity extends AbstractGalleryActivity
@Override
public void onSuccess(ArrayList<GalleryInfo> gis, int indexPerPage,
int maxPage) {
if (mTargetCat == mMenuIndex - 1)
setGalleryInfos(gis, maxPage);
setGalleryInfos(gis, maxPage);
mHlv.setRefreshing(false);
new SuperToast(FavouriteActivity.this, mSuccStr).show();
@@ -27,6 +27,7 @@ import com.hippo.ehviewer.ehclient.DetailUrlParser;
import com.hippo.ehviewer.ehclient.EhClient;
import com.hippo.ehviewer.service.DownloadService;
import com.hippo.ehviewer.service.DownloadServiceConnection;
import com.hippo.ehviewer.util.Theme;
import com.hippo.ehviewer.util.Ui;
import com.hippo.ehviewer.widget.AlertButton;
import com.hippo.ehviewer.widget.DialogBuilder;
@@ -126,15 +127,15 @@ public class MangaDetailActivity extends AbstractFragmentActivity
handleIntent(getIntent());
int color = getResources().getColor(android.R.color.holo_blue_dark)
& 0x00ffffff | 0xdd000000;
Drawable drawable = new ColorDrawable(color);
Ui.translucent(this, drawable);
final ActionBar actionBar = getActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
// Set random color
int color = Theme.getRandomDeepColor() & 0x00ffffff | 0xdd000000;
Drawable drawable = new ColorDrawable(color);
actionBar.setBackgroundDrawable(drawable);
Ui.translucent(this, color);
SectionsPagerAdapter adapter =
new SectionsPagerAdapter(getSupportFragmentManager());
@@ -38,6 +38,7 @@ import com.hippo.ehviewer.service.DownloadService;
import com.hippo.ehviewer.service.DownloadServiceConnection;
import com.hippo.ehviewer.util.Config;
import com.hippo.ehviewer.util.Log;
import com.hippo.ehviewer.util.Theme;
import com.hippo.ehviewer.util.Ui;
import com.hippo.ehviewer.util.Util;
import com.hippo.ehviewer.widget.AlertButton;
@@ -74,6 +75,7 @@ import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
@@ -137,7 +139,7 @@ public class MangaListActivity extends AbstractGalleryActivity
private Resources mResources;
private SlidingMenu mSlidingMenu;
private View mMenuLeft;
private LinearLayout mUserPanel;
private SearchView mSearchView;
private ListView itemListMenu;
@@ -926,13 +928,6 @@ public class MangaListActivity extends AbstractGalleryActivity
}
});
int color = getResources().getColor(android.R.color.holo_blue_dark)
& 0x00ffffff | 0xdd000000;
Drawable drawable = new ColorDrawable(color);
final ActionBar actionBar = getActionBar();
actionBar.setBackgroundDrawable(drawable);
Ui.translucent(this, drawable);
// Download service
Intent it = new Intent(MangaListActivity.this, DownloadService.class);
bindService(it, mServiceConn, BIND_AUTO_CREATE);
@@ -951,6 +946,7 @@ public class MangaListActivity extends AbstractGalleryActivity
// Get View
mMenuLeft = findViewById(R.id.list_menu_left);
mUserPanel = (LinearLayout)findViewById(R.id.user_panel);
itemListMenu = (ListView) findViewById(R.id.list_menu_item_list);
tagListMenu = (TagListView) findViewById(R.id.list_menu_tag_list);
@@ -1144,6 +1140,14 @@ public class MangaListActivity extends AbstractGalleryActivity
}
});
// Set random color
int color = Theme.getRandomDeepColor() & 0x00ffffff | 0xdd000000;
Drawable drawable = new ColorDrawable(color);
final ActionBar actionBar = getActionBar();
actionBar.setBackgroundDrawable(drawable);
Ui.translucent(this, color);
mMenuLeft.setBackgroundColor(color);
tagListMenu.setBackgroundColor(color);
// Check update
if (Config.isAutoCheckForUpdate())
@@ -29,6 +29,7 @@ import com.hippo.ehviewer.R;
import com.hippo.ehviewer.UpdateHelper;
import com.hippo.ehviewer.util.Cache;
import com.hippo.ehviewer.util.Config;
import com.hippo.ehviewer.util.Theme;
import com.hippo.ehviewer.util.Ui;
import com.hippo.ehviewer.util.Util;
import com.hippo.ehviewer.widget.AlertButton;
@@ -40,9 +41,12 @@ import com.hippo.ehviewer.network.Downloader;
import com.hippo.ehviewer.preference.AutoListPreference;
import com.readystatesoftware.systembartint.SystemBarTintManager.SystemBarConfig;
import android.app.ActionBar;
import android.app.AlertDialog;
import android.content.Intent;
import android.content.res.Configuration;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
@@ -112,9 +116,15 @@ public class SettingsActivity extends AbstractPreferenceActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getActionBar().setDisplayHomeAsUpEnabled(true);
// Set random color
int color = Theme.getRandomDeepColor() & 0x00ffffff | 0xdd000000;
Drawable drawable = new ColorDrawable(color);
final ActionBar actionBar = getActionBar();
actionBar.setBackgroundDrawable(drawable);
mSystemBarConfig = Ui.translucent(this, color);
actionBar.setDisplayHomeAsUpEnabled(true);
mSystemBarConfig = Ui.translucent(this);
mFragments = new LinkedList<TranslucentPreferenceFragment>();
mListView = getListView();
+89
View File
@@ -0,0 +1,89 @@
/*
* Copyright (C) 2014 Hippo Seven
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.hippo.ehviewer.util;
import java.util.Random;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.StateListDrawable;
public class Theme {
private static final Random random =
new Random(System.currentTimeMillis());
public static final int GREY_COLOR = 0xffaaaaaa;
public static final ColorDrawable GREY_DRAWABLE =
new ColorDrawable(0xffaaaaaa);
/**
* Ignore alpha
* @param color
* @return
*/
public static boolean isDeepColor(int color) {
int grayLevel = (int)(((color >> 16) & 0xff) * 0.299
+ ((color >> 8) & 0xff) * 0.587 + (color & 0xff) * 0.114);
if (grayLevel < 128) // I think 128 is better than 192
return true;
else
return false;
}
/**
* Get random color, alpha is 0xff
* @return
*/
public static int getRandomColor() {
return random.nextInt() | 0xff000000;
}
/**
* Get random deep color, alpha is 0xff
* @return
*/
public static int getRandomDeepColor() {
int deepColor;
while(!isDeepColor(deepColor = getRandomColor()));
return deepColor;
}
/**
* get darker color of target color, alpha not change
* @param color
* @return
*/
public static int getDarkerColor(int color) {
return (((color & 0xff0000) >> 1) & 0xff0000)
| (((color & 0xff00) >> 1) & 0xff00)
| (((color & 0xff) >> 1) & 0xff)
| (color & 0xff000000);
}
public static StateListDrawable getClickDrawable(Context context, int color) {
StateListDrawable sld = new StateListDrawable();
ColorDrawable normal = new ColorDrawable(color);
ColorDrawable dark = new ColorDrawable(getDarkerColor(color));
sld.addState(new int[]{-android.R.attr.state_enabled}, GREY_DRAWABLE);
sld.addState(new int[]{android.R.attr.state_enabled, android.R.attr.state_selected}, dark);
sld.addState(new int[]{android.R.attr.state_enabled, android.R.attr.state_focused}, dark);
sld.addState(new int[]{android.R.attr.state_enabled, android.R.attr.state_pressed}, dark);
sld.addState(new int[]{}, normal);
return sld;
}
}
+3 -3
View File
@@ -280,14 +280,14 @@ public class Ui {
public static SystemBarConfig translucentColor(
Activity activity, int color) {
return translucent(activity, new ColorDrawable(color));
return translucent(activity, color);
}
public static SystemBarConfig translucent(
Activity activity, Drawable drawable) {
Activity activity, int color) {
SystemBarTintManager tintManager = new SystemBarTintManager(activity);
tintManager.setStatusBarTintEnabled(true);
tintManager.setStatusBarTintDrawable(drawable);
tintManager.setStatusBarTintColor(color);
tintManager.setNavigationBarTintEnabled(true);
tintManager.setNavigationBarAlpha(0.0f);
return tintManager.getConfig();
@@ -20,6 +20,7 @@ import java.util.LinkedList;
import java.util.List;
import com.hippo.ehviewer.R;
import com.hippo.ehviewer.util.Theme;
import android.app.AlertDialog;
import android.content.Context;
@@ -39,6 +40,7 @@ public class ButtonsDialogBuilder extends AlertDialog.Builder {
private LinearLayout mContainer;
private List<AlertButton> mButtonList;
private int mThemeColor;
public ButtonsDialogBuilder(Context context) {
super(context);
@@ -54,6 +56,8 @@ public class ButtonsDialogBuilder extends AlertDialog.Builder {
LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
mRootView.addView(mContainer, lp);
super.setView(mView);
mThemeColor = Theme.getRandomDeepColor();
}
/**
@@ -77,6 +81,8 @@ public class ButtonsDialogBuilder extends AlertDialog.Builder {
TextView titleView = (TextView)mView.findViewById(R.id.title);
titleView.setVisibility(View.VISIBLE);
titleView.setText(title);
// Set random color
mView.findViewById(R.id.title_layout).setBackgroundColor(mThemeColor);
return this;
}
@@ -19,6 +19,7 @@ package com.hippo.ehviewer.widget;
import java.util.List;
import com.hippo.ehviewer.R;
import com.hippo.ehviewer.util.Theme;
import android.app.AlertDialog;
import android.content.Context;
@@ -38,8 +39,12 @@ import android.widget.ScrollView;
import android.widget.TextView;
public class DialogBuilder extends AlertDialog.Builder {
private View mView;
private Context mContext;
private int mThemeColor;
public DialogBuilder(Context context) {
super(context);
mContext = context;
@@ -47,6 +52,8 @@ public class DialogBuilder extends AlertDialog.Builder {
Context.LAYOUT_INFLATER_SERVICE);
mView = inflater.inflate(R.layout.dialog, null);
super.setView(mView);
mThemeColor = Theme.getRandomDeepColor();
}
/**
@@ -70,6 +77,8 @@ public class DialogBuilder extends AlertDialog.Builder {
TextView titleView = (TextView)mView.findViewById(R.id.title);
titleView.setVisibility(View.VISIBLE);
titleView.setText(title);
// Set random color
mView.findViewById(R.id.title_layout).setBackgroundColor(mThemeColor);
return this;
}
@@ -135,7 +144,7 @@ public class DialogBuilder extends AlertDialog.Builder {
lp.gravity = Gravity.CENTER;
} else {
lp = new LinearLayout.LayoutParams(
LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
}
setView(view, lp);
return this;
@@ -180,11 +189,14 @@ public class DialogBuilder extends AlertDialog.Builder {
*
* @return This Builder object to allow for chaining of calls to set methods
*/
@SuppressWarnings("deprecation")
public DialogBuilder setPositiveButton(CharSequence text, final View.OnClickListener listener) {
Button button = (Button)mView.findViewById(R.id.positive_button);
button.setVisibility(View.VISIBLE);
button.setText(text);
button.setOnClickListener(listener);
// Set random color
button.setBackgroundDrawable(Theme.getClickDrawable(mContext, mThemeColor));
return this;
}
@@ -207,19 +219,19 @@ public class DialogBuilder extends AlertDialog.Builder {
*
* @return This Builder object to allow for chaining of calls to set methods
*/
@SuppressWarnings("deprecation")
public DialogBuilder setNegativeButton(CharSequence text, final View.OnClickListener listener) {
Button button = (Button)mView.findViewById(R.id.negative_button);
button.setVisibility(View.VISIBLE);
button.setText(text);
button.setOnClickListener(listener);
// Set random color
button.setBackgroundDrawable(Theme.getClickDrawable(mContext, mThemeColor));
return this;
}
public DialogBuilder setSimpleNegativeButton() {
Button button = (Button)mView.findViewById(R.id.negative_button);
button.setVisibility(View.VISIBLE);
button.setText(android.R.string.cancel);
button.setOnClickListener(new View.OnClickListener() {
setNegativeButton(android.R.string.cancel, new View.OnClickListener() {
@Override
public void onClick(View v) {
((AlertButton)v).dialog.dismiss();
@@ -247,11 +259,14 @@ public class DialogBuilder extends AlertDialog.Builder {
*
* @return This Builder object to allow for chaining of calls to set methods
*/
@SuppressWarnings("deprecation")
public DialogBuilder setNeutralButton(CharSequence text, final View.OnClickListener listener) {
Button button = (Button)mView.findViewById(R.id.neutral_button);
button.setVisibility(View.VISIBLE);
button.setText(text);
button.setOnClickListener(listener);
// Set random color
button.setBackgroundDrawable(Theme.getClickDrawable(mContext, mThemeColor));
return this;
}
@@ -329,12 +344,15 @@ public class DialogBuilder extends AlertDialog.Builder {
return this;
}
@SuppressWarnings("deprecation")
public DialogBuilder setAction(Drawable drawable, View.OnClickListener listener) {
ImageView actionView = (ImageView)mView.findViewById(R.id.action);
actionView.setVisibility(View.VISIBLE);
if (drawable != null)
actionView.setImageDrawable(drawable);
actionView.setOnClickListener(listener);
// Set random color
actionView.setBackgroundDrawable(Theme.getClickDrawable(mContext, mThemeColor));
return this;
}
@@ -17,6 +17,7 @@
package com.hippo.ehviewer.widget;
import com.hippo.ehviewer.R;
import com.hippo.ehviewer.util.Theme;
import android.content.Context;
import android.graphics.drawable.Drawable;
@@ -72,6 +73,8 @@ public class SuperToast extends Toast {
mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
FrameLayout view = (FrameLayout)inflate.inflate(R.layout.super_toast, null);
mMainView = (LinearLayout)view.getChildAt(0);
// Set random color
mMainView.setBackgroundColor(Theme.getRandomDeepColor());
mIcon = (ImageView)mMainView.findViewById(R.id.icon);
mMessage = (TextView)mMainView.findViewById(R.id.message);