@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.commons.R的实例源码
ColorChooserDialog.java 文件源码
项目:GitHub
阅读 32
收藏 0
点赞 0
评论 0
PrefUtil.java 文件源码
项目:GitHub
阅读 33
收藏 0
点赞 0
评论 0
static void setLayoutResource(@NonNull Context context, @NonNull Preference preference, @Nullable AttributeSet attrs) {
boolean foundLayout = false;
if (attrs != null) {
for (int i = 0; i < attrs.getAttributeCount(); i++) {
final String namespace = ((XmlResourceParser) attrs).getAttributeNamespace(0);
if (namespace.equals("http://schemas.android.com/apk/res/android") &&
attrs.getAttributeName(i).equals("layout")) {
foundLayout = true;
break;
}
}
}
boolean useStockLayout = false;
if (attrs != null) {
TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.Preference, 0, 0);
try {
useStockLayout = a.getBoolean(R.styleable.Preference_useStockLayout, false);
} finally {
a.recycle();
}
}
if (!foundLayout && !useStockLayout)
preference.setLayoutResource(R.layout.md_preference_custom);
}
ColorChooserDialog.java 文件源码
项目:OpenHub
阅读 32
收藏 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;
}
MaterialEditTextPreference.java 文件源码
项目:material-dialogs
阅读 21
收藏 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
阅读 27
收藏 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;
}
MaterialEditTextPreference.java 文件源码
项目:GitHub
阅读 27
收藏 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);
}
MaterialSimpleListAdapter.java 文件源码
项目:GitHub
阅读 19
收藏 0
点赞 0
评论 0
SimpleListVH(View itemView, MaterialSimpleListAdapter adapter) {
super(itemView);
icon = (ImageView) itemView.findViewById(android.R.id.icon);
title = (TextView) itemView.findViewById(android.R.id.title);
this.adapter = adapter;
itemView.setOnClickListener(this);
}
ColorChooserDialog.java 文件源码
项目:GitHub
阅读 32
收藏 0
点赞 0
评论 0
private void invalidate() {
if (grid.getAdapter() == null) {
grid.setAdapter(new ColorGridAdapter());
grid.setSelector(ResourcesCompat.getDrawable(getResources(), R.drawable.md_transparent, null));
} else ((BaseAdapter) grid.getAdapter()).notifyDataSetChanged();
if (getDialog() != null)
getDialog().setTitle(getTitle());
}
FileChooserDialog.java 文件源码
项目:GitHub
阅读 23
收藏 0
点赞 0
评论 0
@SuppressWarnings("ConstantConditions")
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M &&
ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.READ_EXTERNAL_STORAGE) !=
PackageManager.PERMISSION_GRANTED) {
return new MaterialDialog.Builder(getActivity())
.title(R.string.md_error_label)
.content(R.string.md_storage_perm_error)
.positiveText(android.R.string.ok)
.build();
}
if (getArguments() == null || !getArguments().containsKey("builder"))
throw new IllegalStateException("You must create a FileChooserDialog using the Builder.");
if (!getArguments().containsKey("current_path"))
getArguments().putString("current_path", getBuilder().initialPath);
parentFolder = new File(getArguments().getString("current_path"));
checkIfCanGoUp();
parentContents = listFiles(getBuilder().mimeType, getBuilder().extensions);
return new MaterialDialog.Builder(getActivity())
.title(parentFolder.getAbsolutePath())
.items(getContentsArray())
.itemsCallback(this)
.onNegative(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
dialog.dismiss();
}
})
.autoDismiss(false)
.negativeText(getBuilder().cancelButton)
.build();
}
FileChooserDialog.java 文件源码
项目:GitHub
阅读 27
收藏 0
点赞 0
评论 0
public <ActivityType extends AppCompatActivity & FileCallback> Builder(@NonNull ActivityType context) {
this.context = context;
cancelButton = android.R.string.cancel;
initialPath = Environment.getExternalStorageDirectory().getAbsolutePath();
mimeType = null;
goUpLabel = "...";
}
FolderChooserDialog.java 文件源码
项目:GitHub
阅读 33
收藏 0
点赞 0
评论 0
public <ActivityType extends AppCompatActivity & FolderCallback> Builder(@NonNull ActivityType context) {
this.context = context;
chooseButton = R.string.md_choose_label;
cancelButton = android.R.string.cancel;
goUpLabel = "...";
initialPath = Environment.getExternalStorageDirectory().getAbsolutePath();
}
FolderChooserDialog.java 文件源码
项目:GitHub
阅读 30
收藏 0
点赞 0
评论 0
@NonNull public Builder allowNewFolder(boolean allow, @StringRes int buttonLabel) {
allowNewFolder = allow;
if (buttonLabel == 0)
buttonLabel = R.string.new_folder;
newFolderButton = buttonLabel;
return this;
}
ColorChooserDialog.java 文件源码
项目:OpenHub
阅读 28
收藏 0
点赞 0
评论 0
private void invalidate() {
if (grid.getAdapter() == null) {
grid.setAdapter(new ColorGridAdapter());
grid.setSelector(
ResourcesCompat.getDrawable(getResources(), R.drawable.md_transparent, null));
} else {
((BaseAdapter) grid.getAdapter()).notifyDataSetChanged();
}
if (getDialog() != null) {
getDialog().setTitle(getTitle());
}
}
RootFileChooserDialog.java 文件源码
项目:android_app_efidroidmanager
阅读 17
收藏 0
点赞 0
评论 0
public <ActivityType extends AppCompatActivity> Builder(@NonNull ActivityType context) {
mContext = context;
mCancelButton = android.R.string.cancel;
mInitialPath = Environment.getExternalStorageDirectory().getAbsolutePath();
mMimeType = null;
mProtectRoot = false;
mHideDirectories = false;
}
PrefUtil.java 文件源码
项目:material-dialogs
阅读 27
收藏 0
点赞 0
评论 0
static void setLayoutResource(
Context context, Preference preference, @Nullable AttributeSet attrs) {
boolean foundLayout = false;
if (attrs != null) {
for (int i = 0; i < attrs.getAttributeCount(); i++) {
final String namespace = ((XmlResourceParser) attrs).getAttributeNamespace(0);
if (namespace.equals("http://schemas.android.com/apk/res/android")
&& attrs.getAttributeName(i).equals("layout")) {
foundLayout = true;
break;
}
}
}
boolean useStockLayout = false;
if (attrs != null) {
TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.Preference, 0, 0);
try {
useStockLayout = a.getBoolean(R.styleable.Preference_useStockLayout, false);
} finally {
a.recycle();
}
}
if (!foundLayout && !useStockLayout) {
preference.setLayoutResource(R.layout.md_preference_custom);
}
}
MaterialSimpleListAdapter.java 文件源码
项目:material-dialogs
阅读 20
收藏 0
点赞 0
评论 0
@Override
public SimpleListVH onCreateViewHolder(ViewGroup parent, int viewType) {
final View view =
LayoutInflater.from(parent.getContext())
.inflate(R.layout.md_simplelist_item, parent, false);
return new SimpleListVH(view, this);
}
MaterialSimpleListAdapter.java 文件源码
项目:material-dialogs
阅读 18
收藏 0
点赞 0
评论 0
SimpleListVH(View itemView, MaterialSimpleListAdapter adapter) {
super(itemView);
icon = (ImageView) itemView.findViewById(android.R.id.icon);
title = (TextView) itemView.findViewById(android.R.id.title);
this.adapter = adapter;
itemView.setOnClickListener(this);
}
ColorChooserDialog.java 文件源码
项目:material-dialogs
阅读 29
收藏 0
点赞 0
评论 0
private void invalidate() {
if (grid.getAdapter() == null) {
grid.setAdapter(new ColorGridAdapter());
grid.setSelector(
ResourcesCompat.getDrawable(getResources(), R.drawable.md_transparent, null));
} else {
((BaseAdapter) grid.getAdapter()).notifyDataSetChanged();
}
if (getDialog() != null) {
getDialog().setTitle(getTitle());
}
}
FileChooserDialog.java 文件源码
项目:material-dialogs
阅读 25
收藏 0
点赞 0
评论 0
@SuppressWarnings("ConstantConditions")
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
&& ContextCompat.checkSelfPermission(
getActivity(), Manifest.permission.READ_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED) {
return new MaterialDialog.Builder(getActivity())
.title(R.string.md_error_label)
.content(R.string.md_storage_perm_error)
.positiveText(android.R.string.ok)
.build();
}
if (getArguments() == null || !getArguments().containsKey("builder")) {
throw new IllegalStateException("You must create a FileChooserDialog using the Builder.");
}
if (!getArguments().containsKey("current_path")) {
getArguments().putString("current_path", getBuilder().initialPath);
}
parentFolder = new File(getArguments().getString("current_path"));
checkIfCanGoUp();
parentContents = listFiles(getBuilder().mimeType, getBuilder().extensions);
return new MaterialDialog.Builder(getActivity())
.title(parentFolder.getAbsolutePath())
.typeface(getBuilder().mediumFont, getBuilder().regularFont)
.items(getContentsArray())
.itemsCallback(this)
.onNegative(
new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(MaterialDialog dialog, DialogAction which) {
dialog.dismiss();
}
})
.autoDismiss(false)
.negativeText(getBuilder().cancelButton)
.build();
}
FolderChooserDialog.java 文件源码
项目:material-dialogs
阅读 29
收藏 0
点赞 0
评论 0
public Builder allowNewFolder(boolean allow, @StringRes int buttonLabel) {
allowNewFolder = allow;
if (buttonLabel == 0) {
buttonLabel = R.string.new_folder;
}
newFolderButton = buttonLabel;
return this;
}
MaterialEditTextPreference.java 文件源码
项目:GitHub
阅读 26
收藏 0
点赞 0
评论 0
@Override protected void showDialog(Bundle state) {
Builder mBuilder = new MaterialDialog.Builder(getContext())
.title(getDialogTitle())
.icon(getDialogIcon())
.positiveText(getPositiveButtonText())
.negativeText(getNegativeButtonText())
.dismissListener(this)
.onAny(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
switch (which) {
default:
MaterialEditTextPreference.this.onClick(dialog, DialogInterface.BUTTON_POSITIVE);
break;
case NEUTRAL:
MaterialEditTextPreference.this.onClick(dialog, DialogInterface.BUTTON_NEUTRAL);
break;
case NEGATIVE:
MaterialEditTextPreference.this.onClick(dialog, DialogInterface.BUTTON_NEGATIVE);
break;
}
}
})
.dismissListener(this);
@SuppressLint("InflateParams")
View layout = LayoutInflater.from(getContext()).inflate(R.layout.md_stub_inputpref, null);
onBindDialogView(layout);
MDTintHelper.setTint(editText, color);
TextView message = (TextView) layout.findViewById(android.R.id.message);
if (getDialogMessage() != null && getDialogMessage().toString().length() > 0) {
message.setVisibility(View.VISIBLE);
message.setText(getDialogMessage());
} else {
message.setVisibility(View.GONE);
}
mBuilder.customView(layout, false);
PrefUtil.registerOnActivityDestroyListener(this, this);
dialog = mBuilder.build();
if (state != null)
dialog.onRestoreInstanceState(state);
requestInputMethod(dialog);
dialog.show();
}
MaterialSimpleListAdapter.java 文件源码
项目:GitHub
阅读 21
收藏 0
点赞 0
评论 0
@Override public SimpleListVH onCreateViewHolder(ViewGroup parent, int viewType) {
final View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.md_simplelist_item, parent, false);
return new SimpleListVH(view, this);
}
RootFileChooserDialog.java 文件源码
项目:android_app_efidroidmanager
阅读 17
收藏 0
点赞 0
评论 0
@SuppressWarnings("ConstantConditions")
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M &&
ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.READ_EXTERNAL_STORAGE) !=
PackageManager.PERMISSION_GRANTED) {
return new MaterialDialog.Builder(getActivity())
.title(R.string.md_error_label)
.content(R.string.md_storage_perm_error)
.positiveText(android.R.string.ok)
.build();
}
if (getArguments() == null || !getArguments().containsKey("builder"))
throw new IllegalStateException("You must create a FileChooserDialog using the Builder.");
if (!getArguments().containsKey("current_path"))
getArguments().putString("current_path", getBuilder().mInitialPath);
mHideDirectories = getBuilder().mHideDirectories;
parentFolder = new RootToolsEx.RootFile(getArguments().getString("current_path"));
parentContents = listFiles(getBuilder().mMimeType);
mProtectRoot = getBuilder().mProtectRoot;
mInitialPath = getBuilder().mInitialPath;
if (mProtectRoot)
canGoUp = false;
return new MaterialDialog.Builder(getActivity())
.title(parentFolder.getAbsolutePath())
.items(getContentsArray())
.itemsCallback(this)
.onNegative(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
dialog.dismiss();
}
})
.autoDismiss(false)
.negativeText(getBuilder().mCancelButton)
.build();
}
MaterialEditTextPreference.java 文件源码
项目:material-dialogs
阅读 25
收藏 0
点赞 0
评论 0
@Override
protected void showDialog(Bundle state) {
Builder mBuilder =
new MaterialDialog.Builder(getContext())
.title(getDialogTitle())
.icon(getDialogIcon())
.positiveText(getPositiveButtonText())
.negativeText(getNegativeButtonText())
.dismissListener(this)
.onAny(
new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(MaterialDialog dialog, DialogAction which) {
switch (which) {
default:
MaterialEditTextPreference.this.onClick(
dialog, DialogInterface.BUTTON_POSITIVE);
break;
case NEUTRAL:
MaterialEditTextPreference.this.onClick(
dialog, DialogInterface.BUTTON_NEUTRAL);
break;
case NEGATIVE:
MaterialEditTextPreference.this.onClick(
dialog, DialogInterface.BUTTON_NEGATIVE);
break;
}
}
})
.dismissListener(this);
@SuppressLint("InflateParams")
View layout = LayoutInflater.from(getContext()).inflate(R.layout.md_stub_inputpref, null);
onBindDialogView(layout);
MDTintHelper.setTint(editText, color);
TextView message = (TextView) layout.findViewById(android.R.id.message);
if (getDialogMessage() != null && getDialogMessage().toString().length() > 0) {
message.setVisibility(View.VISIBLE);
message.setText(getDialogMessage());
} else {
message.setVisibility(View.GONE);
}
mBuilder.customView(layout, false);
PrefUtil.registerOnActivityDestroyListener(this, this);
dialog = mBuilder.build();
if (state != null) {
dialog.onRestoreInstanceState(state);
}
requestInputMethod(dialog);
dialog.show();
}
FileChooserDialog.java 文件源码
项目:material-dialogs
阅读 26
收藏 0
点赞 0
评论 0
private Builder() {
cancelButton = android.R.string.cancel;
initialPath = Environment.getExternalStorageDirectory().getAbsolutePath();
mimeType = null;
goUpLabel = "...";
}
FolderChooserDialog.java 文件源码
项目:material-dialogs
阅读 31
收藏 0
点赞 0
评论 0
private Builder() {
chooseButton = R.string.md_choose_label;
cancelButton = android.R.string.cancel;
goUpLabel = "...";
initialPath = Environment.getExternalStorageDirectory().getAbsolutePath();
}