更改主题色(包括一些按钮的调整)

This commit is contained in:
kehaoyuan
2018-03-16 18:24:02 +08:00
parent fb28a49537
commit 21d06d97ef
21 changed files with 96 additions and 119 deletions

View File

@ -151,28 +151,27 @@ public class LibaoUtils {
});
}
public static void initLibaoBtn(final Context context, final TextView libaoBtn, final LibaoEntity libaoEntity,
final boolean isInstallRequired, final LibaoDetailAdapter adapter, final String entrance) {
public static void setLiBaoBtnStatus(final TextView libaoBtn, String status, Context context) {
libaoBtn.setTextColor(Color.WHITE);
final String status = libaoEntity.getStatus();
if (TextUtils.isEmpty(status)) return;
switch (status) {
case "coming":
libaoBtn.setText(R.string.libao_coming);
libaoBtn.setBackgroundResource(R.drawable.textview_blue_style);
break;
case "ling":
libaoBtn.setText(R.string.libao_ling);
libaoBtn.setBackgroundResource(R.drawable.textview_green_style);
libaoBtn.setBackgroundResource(R.drawable.button_normal_style);
break;
case "tao":
libaoBtn.setText(R.string.libao_tao);
libaoBtn.setBackgroundResource(R.drawable.textview_orange_style);
libaoBtn.setBackgroundResource(R.drawable.button_normal_style);
break;
case "coming":
libaoBtn.setText(R.string.libao_coming);
libaoBtn.setBackgroundResource(R.drawable.button_normal_border);
libaoBtn.setTextColor(context.getResources().getColor(R.color.theme));
break;
case "used_up":
libaoBtn.setText(R.string.libao_used_up);
libaoBtn.setBackgroundResource(R.drawable.textview_cancel_up);
libaoBtn.setBackgroundResource(R.drawable.button_normal_border);
libaoBtn.setTextColor(context.getResources().getColor(R.color.theme));
break;
case "finish":
libaoBtn.setText(R.string.libao_finish);
@ -180,44 +179,51 @@ public class LibaoUtils {
break;
case "linged":
libaoBtn.setText(R.string.libao_linged);
libaoBtn.setBackgroundResource(R.drawable.libao_linged_style);
libaoBtn.setTextColor(ContextCompat.getColorStateList(context, R.color.libao_linged_selector));
libaoBtn.setBackgroundResource(R.drawable.button_normal_border);
libaoBtn.setTextColor(context.getResources().getColor(R.color.theme));
break;
case "taoed":
libaoBtn.setText(R.string.libao_taoed);
libaoBtn.setBackgroundResource(R.drawable.libao_taoed_style);
libaoBtn.setTextColor(ContextCompat.getColorStateList(context, R.color.libao_taoed_selector));
libaoBtn.setBackgroundResource(R.drawable.button_normal_border);
libaoBtn.setTextColor(context.getResources().getColor(R.color.theme));
break;
case "copy":
libaoBtn.setText(R.string.libao_copy);
libaoBtn.setBackgroundResource(R.drawable.textview_blue_style);
libaoBtn.setBackgroundResource(R.drawable.button_normal_style);
break;
case "repeatLing":
libaoBtn.setText(R.string.libao_repeat_ling);
libaoBtn.setBackgroundResource(R.drawable.textview_cancel_up);
libaoBtn.setBackgroundResource(R.drawable.button_normal_border);
libaoBtn.setTextColor(context.getResources().getColor(R.color.theme));
break;
case "repeatLinged":
libaoBtn.setText(R.string.libao_repeat_ling);
libaoBtn.setBackgroundResource(R.drawable.textview_green_style);
libaoBtn.setBackgroundResource(R.drawable.button_normal_style);
break;
case "repeatTao":
libaoBtn.setText(R.string.libao_repeat_tao);
libaoBtn.setBackgroundResource(R.drawable.textview_cancel_up);
libaoBtn.setBackgroundResource(R.drawable.button_normal_border);
libaoBtn.setTextColor(context.getResources().getColor(R.color.theme));
break;
case "repeatTaoed":
libaoBtn.setText(R.string.libao_repeat_tao);
libaoBtn.setBackgroundResource(R.drawable.textview_orange_style);
libaoBtn.setBackgroundResource(R.drawable.button_normal_style);
break;
case "unshelve":
libaoBtn.setBackgroundResource(R.drawable.textview_cancel_style);
libaoBtn.setBackgroundResource(R.drawable.button_border_gray);
libaoBtn.setText(R.string.libao_unshelve);
break;
default:
libaoBtn.setBackgroundResource(R.drawable.textview_cancel_style);
libaoBtn.setBackgroundResource(R.drawable.button_border_gray);
libaoBtn.setText("异常");
break;
}
}
public static void initLibaoBtn(final Context context, final TextView libaoBtn, final LibaoEntity libaoEntity,
final boolean isInstallRequired, final LibaoDetailAdapter adapter, final String entrance) {
String status = libaoEntity.getStatus();
setLiBaoBtnStatus(libaoBtn, status, context);
libaoBtn.setOnClickListener(new View.OnClickListener() {
@Override

View File

@ -4,6 +4,7 @@ import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Handler;
import android.support.v4.content.ContextCompat;
import android.support.v4.util.ArrayMap;
import android.text.TextUtils;
@ -207,7 +208,9 @@ public class PlatformUtils {
if (color != null) {
return color;
}
return "#00B7FA";
int themeColor = ContextCompat.getColor(HaloApp.getInstance().getApplication(), R.color.theme);
return String.format("#%06X", 0xFFFFFF & themeColor);
}
public int getPlatformPic(String platform) {

View File

@ -14,6 +14,7 @@ import android.text.TextUtils;
import android.util.AttributeSet;
import android.widget.ProgressBar;
import com.gh.common.util.DisplayUtils;
import com.gh.gamecenter.R;
public class DownloadProgressBar extends ProgressBar {
@ -65,17 +66,16 @@ public class DownloadProgressBar extends ProgressBar {
if (TextUtils.isEmpty(mText)) return;
mPaint.setColor(mDefaultColor == 0 ? ContextCompat.getColor(getContext(), R.color.theme) : mDefaultColor); // 初始化颜色
mPaint.setTextSize(40f);
mPaint.setTextSize(DisplayUtils.sp2px(getContext(), 14));
mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
mPaint.setXfermode(null);
create();
Paint.FontMetrics fontMetrics = mPaint.getFontMetrics();
float mTextHeight = fontMetrics.bottom - fontMetrics.descent - fontMetrics.ascent;
float mTextWidth = mPaint.measureText(mText);
Paint.FontMetricsInt fontMetrics = mPaint.getFontMetricsInt();
int baseline = (getHeight() - fontMetrics.bottom - fontMetrics.top) / 2;
// todo 文字有点不居中
srcCanvas.drawText(mText, (getWidth() - mTextWidth) / 2, (getHeight() + mTextHeight) / 2, mPaint);
mPaint.setTextAlign(Paint.Align.CENTER);
srcCanvas.drawText(mText, getWidth() / 2, baseline, mPaint);
mPaint.setXfermode(mDuffXFerMode);
mPaint.setColor(Color.WHITE); // 反向颜色

View File

@ -202,8 +202,6 @@ public class CleanApkAdapter extends BaseRecyclerAdapter<KcSelectGameViewHolder>
DecimalFormat df = new DecimalFormat("#.00");
String sizeName = df.format(size) + "MB";
// Spanned spanned = Html.fromHtml("大小:" + "<font color=\"#00B7FA\">" + sizeName + "</font>");
// holder.gameSize.setText(spanned);
holder.checkBoxRl.setVisibility(View.VISIBLE);
holder.selectCB.setVisibility(View.VISIBLE);
if (mSelectPosition.get(position)) {

View File

@ -1,6 +1,7 @@
package com.gh.gamecenter.adapter;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.RecyclerView;
@ -134,13 +135,13 @@ public class VoteAdapter extends BaseRecyclerAdapter<ViewHolder> {
VersionVoteEntity versionVoteEntity = mVoteList.get(position);
UserDataEntity userData = versionVoteEntity.getUserData();
if (userData != null && userData.isVersionRequested()) {
viewHolder.voteBtn.setBackgroundResource(R.drawable.border_suggest_bg);
viewHolder.voteBtn.setTextColor(ContextCompat.getColor(mContext, R.color.content));
viewHolder.voteBtn.setBackgroundResource(R.drawable.button_normal_border);
viewHolder.voteBtn.setTextColor(ContextCompat.getColor(mContext, R.color.theme));
viewHolder.voteBtn.setText(R.string.voted);
viewHolder.voteBtn.setEnabled(false);
} else {
viewHolder.voteBtn.setBackgroundResource(R.drawable.comment_border_bg);
viewHolder.voteBtn.setTextColor(ContextCompat.getColor(mContext, R.color.theme));
viewHolder.voteBtn.setBackgroundResource(R.drawable.button_normal_style);
viewHolder.voteBtn.setTextColor(Color.WHITE);
viewHolder.voteBtn.setText(R.string.vote);
viewHolder.voteBtn.setEnabled(true);
}

View File

@ -6,7 +6,6 @@ import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.AppBarLayout;
import android.support.v4.app.Fragment;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.ViewPager;
import android.text.TextUtils;
import android.view.MenuItem;
@ -289,11 +288,11 @@ public class GameDetailFragment extends NormalFragment {
if (mGameDetailEntity.getUserData() != null && mGameDetailEntity.getUserData().isGameConcerned()) {
mGameConcern.setText(getString(R.string.cancel_concern));
mGameConcern.setBackgroundResource(R.drawable.border_red_bg);
mGameConcern.setTextColor(ContextCompat.getColor(getContext(), R.color.red));
mGameConcern.setBackgroundResource(R.drawable.button_normal_border);
mGameConcern.setTextColor(getResources().getColor(R.color.theme));
} else {
mGameConcern.setText(getString(R.string.concern));
mGameConcern.setBackgroundResource(R.drawable.textview_concern_red_style);
mGameConcern.setBackgroundResource(R.drawable.button_normal_style);
mGameConcern.setTextColor(0xffffffff);
}
@ -540,8 +539,8 @@ public class GameDetailFragment extends NormalFragment {
DataCollectionUtils.uploadConcern(getContext(), mGameEntity.getName(), mGameEntity.getId(), "关注");
mGameConcern.setText(R.string.cancel_concern);
mGameConcern.setBackgroundResource(R.drawable.border_red_bg);
mGameConcern.setTextColor(ContextCompat.getColor(getContext(), R.color.red));
mGameConcern.setBackgroundResource(R.drawable.button_normal_border);
mGameConcern.setTextColor(getResources().getColor(R.color.theme));
toast(R.string.concern_success);
mGameConcern.setEnabled(true);
@ -574,7 +573,7 @@ public class GameDetailFragment extends NormalFragment {
mGameEntity.getName(), mGameEntity.getId(), "取消关注");
mGameConcern.setText(getString(R.string.concern));
mGameConcern.setBackgroundResource(R.drawable.textview_concern_red_style);
mGameConcern.setBackgroundResource(R.drawable.button_normal_style);
mGameConcern.setTextColor(0xffffffff);
mGameConcern.setEnabled(true);
}

View File

@ -1,12 +1,11 @@
package com.gh.gamecenter.gamedetail;
import android.content.Context;
import android.graphics.Color;
import android.support.v4.content.ContextCompat;
import android.view.View;
import android.view.ViewGroup;
import com.gh.base.OnListClickListener;
import com.gh.common.util.LibaoUtils;
import com.gh.gamecenter.R;
import com.gh.gamecenter.adapter.viewholder.GameLibaoGalleryViewHolder;
import com.gh.gamecenter.entity.LibaoEntity;
@ -46,51 +45,7 @@ class GameLibaoGalleryAdapter extends BaseRecyclerAdapter<GameLibaoGalleryViewHo
}
holder.libaoDes.setText(content);
if (libaoEntity.getStatus() == null) return;
holder.libaoBtn.setTextColor(Color.WHITE);
switch (libaoEntity.getStatus()) {
case "coming":
holder.libaoBtn.setText(R.string.libao_coming);
holder.libaoBtn.setBackgroundResource(R.drawable.textview_blue_style);
break;
case "ling":
holder.libaoBtn.setText(R.string.libao_ling);
holder.libaoBtn.setBackgroundResource(R.drawable.textview_green_style);
break;
case "tao":
holder.libaoBtn.setText(R.string.libao_tao);
holder.libaoBtn.setBackgroundResource(R.drawable.textview_orange_style);
break;
case "used_up":
holder.libaoBtn.setText(R.string.libao_used_up);
holder.libaoBtn.setBackgroundResource(R.drawable.textview_cancel_up);
break;
case "finish":
holder.libaoBtn.setText(R.string.libao_finish);
holder.libaoBtn.setBackgroundResource(R.drawable.textview_cancel_up);
break;
case "linged":
holder.libaoBtn.setText(R.string.libao_linged);
holder.libaoBtn.setBackgroundResource(R.drawable.libao_linged_style);
holder.libaoBtn.setTextColor(ContextCompat.getColorStateList(mContext, R.color.libao_linged_selector));
break;
case "taoed":
holder.libaoBtn.setText(R.string.libao_taoed);
holder.libaoBtn.setBackgroundResource(R.drawable.libao_taoed_style);
holder.libaoBtn.setTextColor(ContextCompat.getColorStateList(mContext, R.color.libao_taoed_selector));
break;
case "copy":
holder.libaoBtn.setText(R.string.libao_copy);
holder.libaoBtn.setBackgroundResource(R.drawable.textview_blue_style);
break;
case "unshelve":
holder.libaoBtn.setBackgroundResource(R.drawable.textview_cancel_style);
holder.libaoBtn.setText(R.string.libao_unshelve);
break;
default:
holder.libaoBtn.setBackgroundResource(R.drawable.textview_cancel_style);
holder.libaoBtn.setText("异常");
}
LibaoUtils.setLiBaoBtnStatus(holder.libaoBtn, libaoEntity.getStatus(), mContext);
}

View File

@ -322,11 +322,11 @@ public class NewsDetailAdapter extends BaseRecyclerAdapter<ViewHolder> {
}
if (mNewsDetailEntity.getUserData() != null && mNewsDetailEntity.getUserData().isGameConcerned()) {
viewHolder.gamedetailConcern.setText(R.string.cancel_concern);
viewHolder.gamedetailConcern.setBackgroundResource(R.drawable.border_red_bg);
viewHolder.gamedetailConcern.setTextColor(ContextCompat.getColor(mContext, R.color.red));
viewHolder.gamedetailConcern.setBackgroundResource(R.drawable.button_normal_border);
viewHolder.gamedetailConcern.setTextColor(ContextCompat.getColor(mContext, R.color.theme));
} else {
viewHolder.gamedetailConcern.setText(R.string.concern);
viewHolder.gamedetailConcern.setBackgroundResource(R.drawable.textview_concern_red_style);
viewHolder.gamedetailConcern.setBackgroundResource(R.drawable.button_normal_style);
viewHolder.gamedetailConcern.setTextColor(Color.WHITE);
}
viewHolder.gamedetailConcern.setOnClickListener(new View.OnClickListener() {
@ -355,8 +355,8 @@ public class NewsDetailAdapter extends BaseRecyclerAdapter<ViewHolder> {
DataCollectionUtils.uploadConcern(mContext, mGameEntity.getName(), mGameEntity.getId(), mContext.getString(R.string.concern));
concern.setText(R.string.cancel_concern);
concern.setBackgroundResource(R.drawable.border_red_bg);
concern.setTextColor(ContextCompat.getColor(mContext, R.color.red));
concern.setBackgroundResource(R.drawable.button_normal_border);
concern.setTextColor(ContextCompat.getColor(mContext, R.color.theme));
Utils.toast(mContext, R.string.concern_success);
viewHolder.gamedetailConcern.setEnabled(true);
@ -393,7 +393,7 @@ public class NewsDetailAdapter extends BaseRecyclerAdapter<ViewHolder> {
mGameEntity.getName(), mGameEntity.getId(), mContext.getString(R.string.cancel_concern));
concern.setText(mContext.getString(R.string.concern));
concern.setBackgroundResource(R.drawable.textview_concern_red_style);
concern.setBackgroundResource(R.drawable.button_normal_style);
concern.setTextColor(Color.WHITE);
viewHolder.gamedetailConcern.setEnabled(true);
}