/** * Theme for media selecting Activity. * <p> * There are two built-in themes: * 1. com.zhihu.matisse.R.style.Matisse_Zhihu; * 2. com.zhihu.matisse.R.style.Matisse_Dracula * you can define a custom theme derived from the above ones or other themes. * * @param themeId theme resource id. Default value is com.zhihu.matisse.R.style.Matisse_Zhihu. * @return {@link SelectionCreator} for fluent API. */ public SelectionCreator theme(@StyleRes int themeId) { mSelectionSpec.themeId = themeId; return this; }
/** * 设置动画效果 * @param animStyle * @return */ public CityPicker setAnimationStyle(@StyleRes int animStyle) { this.mAnimStyle = animStyle; return this; }
public Builder theme(@StyleRes int theme) { this.theme = theme; return this; }
TextViewFactory(@StyleRes int styleId, boolean center) { this.styleId = styleId; this.center = center; }
@StyleRes protected abstract int getThemeResId(int theme);
@StyleRes protected abstract int getThemeResId(int theme);
@StyleRes @Override public int getActivityTheme() { return PreferenceManager.getDefaultSharedPreferences(this).getBoolean("dark_theme", false) ? R.style.AppTheme_FullScreen_Dark : R.style.AppTheme_FullScreen_Light; }
@StyleRes @Override public int getActivityTheme() { return PreferenceManager.getDefaultSharedPreferences(this).getBoolean("dark_theme", false) ? R.style.AppThemeDark : R.style.AppThemeLight; }
@StyleRes @Override public int getActivityTheme() { return PreferenceManager.getDefaultSharedPreferences(this).getBoolean("dark_theme", false) ? R.style.AppTheme_FullScreen_Dark : R.style.AppTheme_FullScreen_Light; }
@SuppressLint("ResourceType") public void setAnimationStyle(@StyleRes int resId){ this.mAnimStyle = resId <= 0 ? mAnimStyle : resId; }
/** * Return a dialog theme styled according to the (default) selected theme. * * @param context context to get the selected theme * @return the dialog style (the default one) */ @StyleRes public static int getDialogTheme(Context context) { return isLightThemeSelected(context) ? R.style.LightDialogTheme : R.style.DarkDialogTheme; }
/** * Return the selected theme without being styled to any service (see {@link #getThemeForService(Context, int)}). * * @param context context to get the selected theme * @return the selected style (the default one) */ @StyleRes public static int getDefaultTheme(Context context) { return getThemeForService(context, -1); }
@StyleRes public static int getSettingsThemeStyle(Context context) { String lightTheme = context.getResources().getString(R.string.light_theme_key); String darkTheme = context.getResources().getString(R.string.dark_theme_key); String blackTheme = context.getResources().getString(R.string.black_theme_key); String selectedTheme = getSelectedThemeString(context); if (selectedTheme.equals(lightTheme)) return R.style.LightSettingsTheme; else if (selectedTheme.equals(blackTheme)) return R.style.BlackSettingsTheme; else if (selectedTheme.equals(darkTheme)) return R.style.DarkSettingsTheme; // Fallback else return R.style.DarkSettingsTheme; }
public void setAnimationStyle(@StyleRes int animRes) { Window window = dialog.getWindow(); if (window != null) { window.setWindowAnimations(animRes); } }
void setStyle(@AttrRes int defStyleAttr, @StyleRes int defStyleRes) { mDefStyleAttr = defStyleAttr; mDefStyleRes = defStyleRes; }
void setDefStyle(@AttrRes int defStyleAttr, @StyleRes int defStyleRes) { mDefStyleAttr = defStyleAttr; mDefStyleRes = defStyleRes; }
public static ContextWrapper getWrapperContext(Context context, @StyleRes int themeId) { if (context == null) return null; return new ContextThemeWrapper(context, themeId); }
public static float getDimension(Context context, @StyleRes int styleResId, @AttrRes int attr) { TypedArray a = context.getTheme().obtainStyledAttributes(styleResId, new int[]{attr}); float size = a.getDimension(0, 0); a.recycle(); return size; }
/** * A convenience method for setting text appearance. * * @param textView a TextView which textAppearance to modify. * @param resId a style resource for the text appearance. */ @SuppressWarnings("deprecation") protected static void setTextAppearance(@NonNull TextView textView, @StyleRes int resId) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { textView.setTextAppearance(resId); } else { textView.setTextAppearance(textView.getContext(), resId); } }