@ColorInt private int getSelectedColor() {
if (colorChooserCustomFrame != null &&
colorChooserCustomFrame.getVisibility() == View.VISIBLE) {
return selectedCustomColor;
}
int color = 0;
if (subIndex() > -1)
color = mColorsSub[topIndex()][subIndex()];
else if (topIndex() > -1)
color = mColorsTop[topIndex()];
if (color == 0) {
int fallback = 0;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
fallback = DialogUtils.resolveColor(getActivity(), android.R.attr.colorAccent);
color = DialogUtils.resolveColor(getActivity(), R.attr.colorAccent, fallback);
}
return color;
}
java类com.afollestad.materialdialogs.util.DialogUtils的实例源码
ColorChooserDialog.java 文件源码
项目:GitHub
阅读 28
收藏 0
点赞 0
评论 0
MainActivity.java 文件源码
项目:GitHub
阅读 18
收藏 0
点赞 0
评论 0
@Override
public void onColorSelection(@NonNull ColorChooserDialog dialog, @ColorInt int color) {
if (dialog.isAccentMode()) {
accentPreselect = color;
ThemeSingleton.get().positiveColor = DialogUtils.getActionTextStateList(this, color);
ThemeSingleton.get().neutralColor = DialogUtils.getActionTextStateList(this, color);
ThemeSingleton.get().negativeColor = DialogUtils.getActionTextStateList(this, color);
ThemeSingleton.get().widgetColor = color;
} else {
primaryPreselect = color;
if (getSupportActionBar() != null)
getSupportActionBar().setBackgroundDrawable(new ColorDrawable(color));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().setStatusBarColor(CircleView.shiftColorDown(color));
getWindow().setNavigationBarColor(color);
}
}
}
MDTintHelper.java 文件源码
项目:GitHub
阅读 27
收藏 0
点赞 0
评论 0
public static void setTint(@NonNull RadioButton radioButton,
@ColorInt int color) {
final int disabledColor = DialogUtils.getDisabledColor(radioButton.getContext());
ColorStateList sl = new ColorStateList(new int[][]{
new int[]{android.R.attr.state_enabled, -android.R.attr.state_checked},
new int[]{android.R.attr.state_enabled, android.R.attr.state_checked},
new int[]{-android.R.attr.state_enabled, -android.R.attr.state_checked},
new int[]{-android.R.attr.state_enabled, android.R.attr.state_checked}
}, new int[]{
DialogUtils.resolveColor(radioButton.getContext(), R.attr.colorControlNormal),
color,
disabledColor,
disabledColor
});
setTint(radioButton, sl);
}
MDButton.java 文件源码
项目:GitHub
阅读 22
收藏 0
点赞 0
评论 0
/**
* Set if the button should be displayed in stacked mode.
* This should only be called from MDRootLayout's onMeasure, and we must be measured
* after calling this.
*/
/* package */ void setStacked(boolean stacked, boolean force) {
if (this.stacked != stacked || force) {
setGravity(stacked ? (Gravity.CENTER_VERTICAL | stackedGravity.getGravityInt()) : Gravity.CENTER);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
//noinspection ResourceType
setTextAlignment(stacked ? stackedGravity.getTextAlignment() : TEXT_ALIGNMENT_CENTER);
}
DialogUtils.setBackgroundCompat(this, stacked ? stackedBackground : defaultBackground);
if (stacked) {
setPadding(stackedEndPadding, getPaddingTop(), stackedEndPadding, getPaddingBottom());
} /* Else the padding was properly reset by the drawable */
this.stacked = stacked;
}
}
MDRootLayout.java 文件源码
项目:GitHub
阅读 26
收藏 0
点赞 0
评论 0
private void init(Context context, AttributeSet attrs, int defStyleAttr) {
Resources r = context.getResources();
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MDRootLayout, defStyleAttr, 0);
reducePaddingNoTitleNoButtons = a.getBoolean(R.styleable.MDRootLayout_md_reduce_padding_no_title_no_buttons, true);
a.recycle();
noTitlePaddingFull = r.getDimensionPixelSize(R.dimen.md_notitle_vertical_padding);
buttonPaddingFull = r.getDimensionPixelSize(R.dimen.md_button_frame_vertical_padding);
buttonHorizontalEdgeMargin = r.getDimensionPixelSize(R.dimen.md_button_padding_frame_side);
buttonBarHeight = r.getDimensionPixelSize(R.dimen.md_button_height);
dividerPaint = new Paint();
dividerWidth = r.getDimensionPixelSize(R.dimen.md_divider_height);
dividerPaint.setColor(DialogUtils.resolveColor(context, R.attr.md_divider_color));
setWillNotDraw(false);
}
MaterialDialog.java 文件源码
项目:GitHub
阅读 31
收藏 0
点赞 0
评论 0
/**
* @param errorColor Pass in 0 for the default red error color (as specified in
* guidelines).
*/
public Builder inputRange(@IntRange(from = 0, to = Integer.MAX_VALUE) int minLength,
@IntRange(from = -1, to = Integer.MAX_VALUE) int maxLength,
@ColorInt int errorColor) {
if (minLength < 0)
throw new IllegalArgumentException("Min length for input dialogs cannot be less than 0.");
this.inputMinLength = minLength;
this.inputMaxLength = maxLength;
if (errorColor == 0) {
this.inputRangeErrorColor = DialogUtils.getColor(context, R.color.md_edittext_error);
} else {
this.inputRangeErrorColor = errorColor;
}
if (this.inputMinLength > 0)
this.inputAllowEmpty = false;
return this;
}
ColorChooserDialog.java 文件源码
项目:OpenHub
阅读 28
收藏 0
点赞 0
评论 0
@ColorInt
private int getSelectedColor() {
if (colorChooserCustomFrame != null
&& colorChooserCustomFrame.getVisibility() == View.VISIBLE) {
return selectedCustomColor;
}
int color = 0;
if (subIndex() > -1) {
color = colorsSub[topIndex()][subIndex()];
} else if (topIndex() > -1) {
color = colorsTop[topIndex()];
}
if (color == 0) {
int fallback = 0;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
fallback = DialogUtils.resolveColor(getActivity(), android.R.attr.colorAccent);
}
color = DialogUtils.resolveColor(getActivity(), R.attr.colorAccent, fallback);
}
return color;
}
AttributeActivity.java 文件源码
项目:mesh-core-on-android
阅读 23
收藏 0
点赞 0
评论 0
@Override
public void onColorSelection(@NonNull ColorChooserDialog dialog, @ColorInt int color) {
if (dialog.isAccentMode()) {
accentPreselect = color;
ThemeSingleton.get().positiveColor = DialogUtils.getActionTextStateList(this, color);
ThemeSingleton.get().neutralColor = DialogUtils.getActionTextStateList(this, color);
ThemeSingleton.get().negativeColor = DialogUtils.getActionTextStateList(this, color);
ThemeSingleton.get().widgetColor = color;
Log.i(TAG, "onColorSelection: #"+ Integer.toHexString(color));
setStateItem(ElementAppItem.APP_TYPE_COLOR, "#"+Integer.toHexString(color));
} else {
primaryPreselect = color;
if (getSupportActionBar() != null) {
getSupportActionBar().setBackgroundDrawable(new ColorDrawable(color));
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().setStatusBarColor(CircleView.shiftColorDown(color));
getWindow().setNavigationBarColor(color);
}
}
}
KustomFragment.java 文件源码
项目:polar-dashboard
阅读 20
收藏 0
点赞 0
评论 0
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.kustom, menu);
super.onCreateOptionsMenu(menu, inflater);
MenuItem mSearchItem = menu.findItem(R.id.search);
SearchView mSearchView = (SearchView) MenuItemCompat.getActionView(mSearchItem);
mSearchView.setQueryHint(getString(getSearchHintRes()));
mSearchView.setOnQueryTextListener(this);
mSearchView.setOnCloseListener(this);
mSearchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
if (getActivity() != null) {
final MainActivity act = (MainActivity) getActivity();
TintUtils.themeSearchView(
act.getToolbar(), mSearchView, DialogUtils.resolveColor(act, R.attr.tab_icon_color));
}
}
ZooperFragment.java 文件源码
项目:polar-dashboard
阅读 19
收藏 0
点赞 0
评论 0
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.zooper, menu);
super.onCreateOptionsMenu(menu, inflater);
MenuItem mSearchItem = menu.findItem(R.id.search);
SearchView mSearchView = (SearchView) MenuItemCompat.getActionView(mSearchItem);
mSearchView.setQueryHint(getString(R.string.search_widgets));
mSearchView.setOnQueryTextListener(this);
mSearchView.setOnCloseListener(this);
mSearchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
if (getActivity() != null) {
final MainActivity act = (MainActivity) getActivity();
TintUtils.themeSearchView(
act.getToolbar(), mSearchView, DialogUtils.resolveColor(act, R.attr.tab_icon_color));
}
}
RequestsFragment.java 文件源码
项目:polar-dashboard
阅读 20
收藏 0
点赞 0
评论 0
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.cab_requests, menu);
super.onCreateOptionsMenu(menu, inflater);
synchronized (LOCK) {
MenuItem selectAll = menu.findItem(R.id.selectAll);
try {
final Activity act = getActivity();
final int tintColor = DialogUtils.resolveColor(act, R.attr.toolbar_icons_color);
if (mAdapter == null || mAdapter.getSelectedCount() == 0) {
selectAll.setIcon(
TintUtils.createTintedDrawable(act, R.drawable.ic_action_selectall, tintColor));
} else {
selectAll.setIcon(
TintUtils.createTintedDrawable(act, R.drawable.ic_action_close, tintColor));
}
} catch (Throwable e) {
e.printStackTrace();
selectAll.setVisible(false);
}
selectAll.setVisible(mAppsLoaded);
}
}
IconsFragment.java 文件源码
项目:polar-dashboard
阅读 20
收藏 0
点赞 0
评论 0
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.icons, menu);
super.onCreateOptionsMenu(menu, inflater);
MenuItem mSearchItem = menu.findItem(R.id.search);
SearchView mSearchView = (SearchView) MenuItemCompat.getActionView(mSearchItem);
mSearchView.setQueryHint(getString(R.string.search_icons));
mSearchView.setOnQueryTextListener(this);
mSearchView.setOnCloseListener(this);
mSearchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
if (getActivity() != null) {
final BaseThemedActivity act = (BaseThemedActivity) getActivity();
TintUtils.themeSearchView(
act.getToolbar(), mSearchView, DialogUtils.resolveColor(act, R.attr.tab_icon_color));
}
}
WallpapersFragment.java 文件源码
项目:polar-dashboard
阅读 24
收藏 0
点赞 0
评论 0
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.wallpapers, menu);
super.onCreateOptionsMenu(menu, inflater);
MenuItem mSearchItem = menu.findItem(R.id.search);
SearchView mSearchView = (SearchView) MenuItemCompat.getActionView(mSearchItem);
mSearchView.setQueryHint(getString(R.string.search_wallpapers));
mSearchView.setOnQueryTextListener(this);
mSearchView.setOnCloseListener(this);
mSearchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
if (getActivity() != null) {
final MainActivity act = (MainActivity) getActivity();
TintUtils.themeSearchView(
act.getToolbar(), mSearchView, DialogUtils.resolveColor(act, R.attr.tab_icon_color));
}
}
ApplyAdapter.java 文件源码
项目:polar-dashboard
阅读 22
收藏 0
点赞 0
评论 0
@Override
public void onBindViewHolder(ApplyVH holder, int position) {
if (getItemViewType(position) == 1) {
holder.icon.setColorFilter(
DialogUtils.resolveColor(mContext, android.R.attr.textColorSecondary),
PorterDuff.Mode.SRC_IN);
return;
}
if (mQuickApplyLauncher != null) {
position--;
}
final Launcher launcher = mLaunchers[position];
holder.title.setText(launcher.title);
holder.icon.setBackgroundColor(launcher.color);
holder.title.setBackgroundColor(launcher.colorDark);
holder.icon.setImageResource(launcher.icon);
holder.card.setCardBackgroundColor(launcher.color);
}
BaseThemedActivity.java 文件源码
项目:polar-dashboard
阅读 19
收藏 0
点赞 0
评论 0
@SuppressLint("PrivateResource")
@Override
protected void onStart() {
super.onStart();
final Toolbar toolbar = getToolbar();
if (toolbar != null) {
final int titleColor = DialogUtils.resolveColor(this, R.attr.toolbar_title_color);
final int iconColor = DialogUtils.resolveColor(this, R.attr.toolbar_icons_color);
toolbar.setTitleTextColor(titleColor);
Utils.setOverflowButtonColor(this, iconColor);
if (TintUtils.isColorLight(titleColor)) {
toolbar.setPopupTheme(R.style.ThemeOverlay_AppCompat_Light);
} else {
toolbar.setPopupTheme(R.style.ThemeOverlay_AppCompat);
}
}
}
IconPickerActivity.java 文件源码
项目:polar-dashboard
阅读 21
收藏 0
点赞 0
评论 0
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_picker);
ButterKnife.bind(this);
toolbar.setTitle(R.string.select_icon);
setSupportActionBar(toolbar);
//noinspection ConstantConditions
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_action_close);
if (toolbar.getNavigationIcon() != null) {
toolbar.setNavigationIcon(
TintUtils.createTintedDrawable(
toolbar.getNavigationIcon(), DialogUtils.resolveColor(this, R.attr.tab_icon_color)));
}
getFragmentManager()
.beginTransaction()
.replace(R.id.container, IconsFragment.create(true))
.commit();
}
Utils.java 文件源码
项目:polar-dashboard
阅读 27
收藏 0
点赞 0
评论 0
public static Drawable createCardSelector(Context context) {
final int accentColor = DialogUtils.resolveColor(context, R.attr.colorAccent);
final boolean darkTheme = Config.get().darkTheme();
final int activated = TintUtils.adjustAlpha(accentColor, darkTheme ? 0.5f : 0.3f);
final int pressed = TintUtils.adjustAlpha(accentColor, darkTheme ? 0.75f : 0.6f);
final StateListDrawable baseSelector = new StateListDrawable();
baseSelector.addState(new int[] {android.R.attr.state_activated}, new ColorDrawable(activated));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
return new RippleDrawable(
ColorStateList.valueOf(accentColor), baseSelector, new ColorDrawable(Color.WHITE));
}
baseSelector.addState(new int[] {}, new ColorDrawable(Color.TRANSPARENT));
baseSelector.addState(new int[] {android.R.attr.state_pressed}, new ColorDrawable(pressed));
return baseSelector;
}
DevicesCommandFragment.java 文件源码
项目:bleYan
阅读 21
收藏 0
点赞 0
评论 0
protected void invalidateInputMinMaxIndicator(EditText inputMinMax, int currentLength) {
if (inputMinMax != null) {
int materialBlue = ContextCompat.getColor(getActivity(), com.afollestad.materialdialogs.R.color.md_material_blue_600);
int widgetColor = DialogUtils.resolveColor(getActivity(), com.afollestad.materialdialogs.R.attr.colorAccent, materialBlue);
if (Build.VERSION.SDK_INT >= 21) {
widgetColor = DialogUtils.resolveColor(getActivity(), android.R.attr.colorAccent, widgetColor);
}
final boolean isDisabled = currentLength > 20;
final int colorText = isDisabled ? ContextCompat.getColor(getActivity(), R.color.red)
: -1;
final int colorWidget = isDisabled ? ContextCompat.getColor(getActivity(), R.color.red)
: widgetColor;
inputMinMax.setTextColor(colorText);
MDTintHelper.setTint(inputMinMax, colorWidget);
}
}
BleDeviceActivity.java 文件源码
项目:bleYan
阅读 22
收藏 0
点赞 0
评论 0
protected void invalidateInputMinMaxIndicator(EditText input, int currentLength) {
if (input != null) {
int materialBlue = ContextCompat.getColor(this, com.afollestad.materialdialogs.R.color.md_material_blue_600);
int widgetColor = DialogUtils.resolveColor(this, com.afollestad.materialdialogs.R.attr.colorAccent, materialBlue);
if (Build.VERSION.SDK_INT >= 21) {
widgetColor = DialogUtils.resolveColor(this, android.R.attr.colorAccent, widgetColor);
}
final boolean isDisabled = currentLength > 20;
final int colorText = isDisabled ? ContextCompat.getColor(this, R.color.red)
: -1;
final int colorWidget = isDisabled ? ContextCompat.getColor(this, R.color.red)
: widgetColor;
input.setTextColor(colorText);
MDTintHelper.setTint(input, colorWidget);
}
}
MDTintHelper.java 文件源码
项目:EasyFrame
阅读 27
收藏 0
点赞 0
评论 0
public static void setTint(@NonNull RadioButton radioButton, @ColorInt int color) {
ColorStateList sl = new ColorStateList(new int[][]{
new int[]{-android.R.attr.state_checked},
new int[]{android.R.attr.state_checked}
}, new int[]{
DialogUtils.resolveColor(radioButton.getContext(), R.attr.colorControlNormal),
color
});
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
radioButton.setButtonTintList(sl);
} else {
Drawable d = DrawableCompat.wrap(ContextCompat.getDrawable(radioButton.getContext(), R.drawable.abc_btn_radio_material));
DrawableCompat.setTintList(d, sl);
radioButton.setButtonDrawable(d);
}
}
MDTintHelper.java 文件源码
项目:EasyFrame
阅读 26
收藏 0
点赞 0
评论 0
public static void setTint(@NonNull CheckBox box, @ColorInt int color) {
ColorStateList sl = new ColorStateList(new int[][]{
new int[]{-android.R.attr.state_checked},
new int[]{android.R.attr.state_checked}
}, new int[]{
DialogUtils.resolveColor(box.getContext(), R.attr.colorControlNormal),
color
});
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
box.setButtonTintList(sl);
} else {
Drawable drawable = DrawableCompat.wrap(ContextCompat.getDrawable(box.getContext(), R.drawable.abc_btn_check_material));
DrawableCompat.setTintList(drawable, sl);
box.setButtonDrawable(drawable);
}
}
HorizontalProgressDrawable.java 文件源码
项目:EasyFrame
阅读 20
收藏 0
点赞 0
评论 0
public HorizontalProgressDrawable(Context context) {
super(new Drawable[]{
new SingleHorizontalProgressDrawable(context),
new SingleHorizontalProgressDrawable(context),
new SingleHorizontalProgressDrawable(context)
});
setId(0, android.R.id.background);
mTrackDrawable = (SingleHorizontalProgressDrawable) getDrawable(0);
setId(1, android.R.id.secondaryProgress);
mSecondaryProgressDrawable = (SingleHorizontalProgressDrawable) getDrawable(1);
float disabledAlpha = DialogUtils.resolveFloat(context, android.R.attr.disabledAlpha);
mSecondaryAlpha = Math.round(disabledAlpha * 0xFF);
mSecondaryProgressDrawable.setAlpha(mSecondaryAlpha);
mSecondaryProgressDrawable.setShowTrack(false);
setId(2, android.R.id.progress);
mProgressDrawable = (SingleHorizontalProgressDrawable) getDrawable(2);
mProgressDrawable.setShowTrack(false);
}
MDButton.java 文件源码
项目:EasyFrame
阅读 24
收藏 0
点赞 0
评论 0
/**
* Set if the button should be displayed in stacked mode.
* This should only be called from MDRootLayout's onMeasure, and we must be measured
* after calling this.
*/
/* package */ void setStacked(boolean stacked, boolean force) {
if (mStacked != stacked || force) {
setGravity(stacked ? (Gravity.CENTER_VERTICAL | mStackedGravity.getGravityInt()) : Gravity.CENTER);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
//noinspection ResourceType
setTextAlignment(stacked ? mStackedGravity.getTextAlignment() : TEXT_ALIGNMENT_CENTER);
}
DialogUtils.setBackgroundCompat(this, stacked ? mStackedBackground : mDefaultBackground);
if (stacked) {
setPadding(mStackedEndPadding, getPaddingTop(), mStackedEndPadding, getPaddingBottom());
} /* Else the padding was properly reset by the drawable */
mStacked = stacked;
}
}
MDRootLayout.java 文件源码
项目:EasyFrame
阅读 32
收藏 0
点赞 0
评论 0
private void init(Context context, AttributeSet attrs, int defStyleAttr) {
Resources r = context.getResources();
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MDRootLayout, defStyleAttr, 0);
mReducePaddingNoTitleNoButtons = a.getBoolean(R.styleable.MDRootLayout_md_reduce_padding_no_title_no_buttons, true);
a.recycle();
mNoTitlePaddingFull = r.getDimensionPixelSize(R.dimen.md_notitle_vertical_padding);
mButtonPaddingFull = r.getDimensionPixelSize(R.dimen.md_button_frame_vertical_padding);
mButtonHorizontalEdgeMargin = r.getDimensionPixelSize(R.dimen.md_button_padding_frame_side);
mButtonBarHeight = r.getDimensionPixelSize(R.dimen.md_button_height);
mDividerPaint = new Paint();
mDividerWidth = r.getDimensionPixelSize(R.dimen.md_divider_height);
mDividerPaint.setColor(DialogUtils.resolveColor(context, R.attr.md_divider_color));
setWillNotDraw(false);
}
MaterialDialog.java 文件源码
项目:EasyFrame
阅读 30
收藏 0
点赞 0
评论 0
/**
* @param errorColor Pass in 0 for the default red error color (as specified in guidelines).
*/
public Builder inputRange(@IntRange(from = 0, to = Integer.MAX_VALUE) int minLength,
@IntRange(from = 1, to = Integer.MAX_VALUE) int maxLength,
@ColorInt int errorColor) {
if (minLength < 0)
throw new IllegalArgumentException("Min length for input dialogs cannot be less than 0.");
if (maxLength < 1)
throw new IllegalArgumentException("Max length for input dialogs cannot be less than 1.");
this.inputMinLength = minLength;
this.inputMaxLength = maxLength;
if (errorColor == 0) {
this.inputRangeErrorColor = DialogUtils.getColor(context, R.color.md_edittext_error);
} else {
this.inputRangeErrorColor = errorColor;
}
return this;
}
MaterialEditTextPreference.java 文件源码
项目:material-dialogs
阅读 22
收藏 0
点赞 0
评论 0
private void init(Context context, AttributeSet attrs) {
PrefUtil.setLayoutResource(context, this, attrs);
int fallback;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
fallback = DialogUtils.resolveColor(context, android.R.attr.colorAccent);
} else {
fallback = 0;
}
fallback = DialogUtils.resolveColor(context, R.attr.colorAccent, fallback);
color = DialogUtils.resolveColor(context, R.attr.md_widget_color, fallback);
editText = new AppCompatEditText(context, attrs);
// Give it an ID so it can be saved/restored
editText.setId(android.R.id.edit);
editText.setEnabled(true);
}
ColorChooserDialog.java 文件源码
项目:material-dialogs
阅读 40
收藏 0
点赞 0
评论 0
@ColorInt
private int getSelectedColor() {
if (colorChooserCustomFrame != null
&& colorChooserCustomFrame.getVisibility() == View.VISIBLE) {
return selectedCustomColor;
}
int color = 0;
if (subIndex() > -1) {
color = colorsSub[topIndex()][subIndex()];
} else if (topIndex() > -1) {
color = colorsTop[topIndex()];
}
if (color == 0) {
int fallback = 0;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
fallback = DialogUtils.resolveColor(getActivity(), android.R.attr.colorAccent);
}
color = DialogUtils.resolveColor(getActivity(), R.attr.colorAccent, fallback);
}
return color;
}
MainActivity.java 文件源码
项目:material-dialogs
阅读 20
收藏 0
点赞 0
评论 0
@Override
public void onColorSelection(ColorChooserDialog dialog, @ColorInt int color) {
if (dialog.isAccentMode()) {
accentPreselect = color;
ThemeSingleton.get().positiveColor = DialogUtils.getActionTextStateList(this, color);
ThemeSingleton.get().neutralColor = DialogUtils.getActionTextStateList(this, color);
ThemeSingleton.get().negativeColor = DialogUtils.getActionTextStateList(this, color);
ThemeSingleton.get().widgetColor = color;
} else {
primaryPreselect = color;
if (getSupportActionBar() != null) {
getSupportActionBar().setBackgroundDrawable(new ColorDrawable(color));
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().setStatusBarColor(CircleView.shiftColorDown(color));
getWindow().setNavigationBarColor(color);
}
}
}
MDTintHelper.java 文件源码
项目:material-dialogs
阅读 27
收藏 0
点赞 0
评论 0
public static void setTint(RadioButton radioButton, @ColorInt int color) {
final int disabledColor = DialogUtils.getDisabledColor(radioButton.getContext());
ColorStateList sl =
new ColorStateList(
new int[][] {
new int[] {android.R.attr.state_enabled, -android.R.attr.state_checked},
new int[] {android.R.attr.state_enabled, android.R.attr.state_checked},
new int[] {-android.R.attr.state_enabled, -android.R.attr.state_checked},
new int[] {-android.R.attr.state_enabled, android.R.attr.state_checked}
},
new int[] {
DialogUtils.resolveColor(radioButton.getContext(), R.attr.colorControlNormal),
color,
disabledColor,
disabledColor
});
setTint(radioButton, sl);
}
MDTintHelper.java 文件源码
项目:material-dialogs
阅读 27
收藏 0
点赞 0
评论 0
public static void setTint(CheckBox box, @ColorInt int color) {
final int disabledColor = DialogUtils.getDisabledColor(box.getContext());
ColorStateList sl =
new ColorStateList(
new int[][] {
new int[] {android.R.attr.state_enabled, -android.R.attr.state_checked},
new int[] {android.R.attr.state_enabled, android.R.attr.state_checked},
new int[] {-android.R.attr.state_enabled, -android.R.attr.state_checked},
new int[] {-android.R.attr.state_enabled, android.R.attr.state_checked}
},
new int[] {
DialogUtils.resolveColor(box.getContext(), R.attr.colorControlNormal),
color,
disabledColor,
disabledColor
});
setTint(box, sl);
}