protected void invalidateInputMinMaxIndicator(int currentLength, boolean emptyDisabled) { if (inputMinMax != null) { if (builder.inputMaxLength > 0) { inputMinMax.setText(String.format(Locale.getDefault(), "%d/%d", currentLength, builder.inputMaxLength)); inputMinMax.setVisibility(View.VISIBLE); } else inputMinMax.setVisibility(View.GONE); final boolean isDisabled = (emptyDisabled && currentLength == 0) || (builder.inputMaxLength > 0 && currentLength > builder.inputMaxLength) || currentLength < builder.inputMinLength; final int colorText = isDisabled ? builder.inputRangeErrorColor : builder.contentColor; final int colorWidget = isDisabled ? builder.inputRangeErrorColor : builder.widgetColor; if (builder.inputMaxLength > 0) inputMinMax.setTextColor(colorText); MDTintHelper.setTint(input, colorWidget); final View positiveAb = getActionButton(DialogAction.POSITIVE); positiveAb.setEnabled(!isDisabled); } }
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_donation); ButterKnife.bind(this); setStatusbarColorAuto(); setNavigationbarColorAuto(); setTaskDescriptionColorAuto(); mToolbar.setBackgroundColor(ThemeStore.primaryColor(this)); setSupportActionBar(mToolbar); //noinspection ConstantConditions getSupportActionBar().setDisplayHomeAsUpEnabled(true); mToolbar.setNavigationOnClickListener(view -> onBackPressed()); mBillingProcessor = new BillingProcessor(this, BuildConfig.GOOGLE_PLAY_LICENSE_KEY, this); MDTintHelper.setTint(mProgressBar, ThemeStore.accentColor(this)); ((TextView) findViewById(R.id.donation)).setTextColor(ThemeStore.accentColor(this)); }
public void notifyPasswordValidation(boolean valid) { final MaterialDialog dialog = (MaterialDialog) getDialog(); final View positive = dialog.getActionButton(DialogAction.POSITIVE); final View negative = dialog.getActionButton(DialogAction.NEGATIVE); toggleButtonsEnabled(true); if (valid) { if (mStage == Stage.KEY_INVALIDATED && mUseFingerprintFutureCheckBox.isChecked()) { // Re-create the key so that fingerprints including new ones are validated. mFingerLock.recreateKey(this); mStage = Stage.FINGERPRINT; } mPassword.setText(""); mCallback.onFingerprintDialogAuthenticated(); dismiss(); } else { mPasswordDescriptionTextView.setText(R.string.invalid_password); final int red = ContextCompat.getColor(getActivity(), R.color.material_red_500); MDTintHelper.setTint(mPassword, red); ((TextView) positive).setTextColor(red); ((TextView) negative).setTextColor(red); } }
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); } }
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); } }
void invalidateInputMinMaxIndicator(int currentLength, boolean emptyDisabled) { if (inputMinMax != null) { if (builder.inputMaxLength > 0) { inputMinMax.setText( String.format(Locale.getDefault(), "%d/%d", currentLength, builder.inputMaxLength)); inputMinMax.setVisibility(View.VISIBLE); } else { inputMinMax.setVisibility(View.GONE); } final boolean isDisabled = (emptyDisabled && currentLength == 0) || (builder.inputMaxLength > 0 && currentLength > builder.inputMaxLength) || currentLength < builder.inputMinLength; final int colorText = isDisabled ? builder.inputRangeErrorColor : builder.contentColor; final int colorWidget = isDisabled ? builder.inputRangeErrorColor : builder.widgetColor; if (builder.inputMaxLength > 0) { inputMinMax.setTextColor(colorText); } MDTintHelper.setTint(input, colorWidget); final View positiveAb = getActionButton(DialogAction.POSITIVE); positiveAb.setEnabled(!isDisabled); } }
private void invalidateDynamicButtonColors() { final MaterialDialog dialog = (MaterialDialog) getDialog(); if (dialog == null) return; final Builder builder = getBuilder(); if (builder.mDynamicButtonColor) { int selectedColor = getSelectedColor(); if (Color.alpha(selectedColor) < 64 || (Color.red(selectedColor) > 247 && Color.green(selectedColor) > 247 && Color.blue(selectedColor) > 247)) { // Once we get close to white or transparent, the action buttons and seekbars will be a very light gray selectedColor = Color.parseColor("#DEDEDE"); } if (getBuilder().mDynamicButtonColor) { dialog.getActionButton(DialogAction.POSITIVE).setTextColor(selectedColor); dialog.getActionButton(DialogAction.NEGATIVE).setTextColor(selectedColor); dialog.getActionButton(DialogAction.NEUTRAL).setTextColor(selectedColor); } if (customSeekR != null) { if (customSeekA.getVisibility() == View.VISIBLE) MDTintHelper.setTint(customSeekA, selectedColor); MDTintHelper.setTint(customSeekR, selectedColor); MDTintHelper.setTint(customSeekG, selectedColor); MDTintHelper.setTint(customSeekB, selectedColor); } } }
private static void setupInputDialog(final MaterialDialog dialog) { final MaterialDialog.Builder builder = dialog.builder; dialog.input = (EditText) dialog.view.findViewById(android.R.id.input); if (dialog.input == null) return; dialog.setTypeface(dialog.input, builder.regularFont); if (builder.inputPrefill != null) dialog.input.setText(builder.inputPrefill); dialog.setInternalInputCallback(); dialog.input.setHint(builder.inputHint); dialog.input.setSingleLine(); dialog.input.setTextColor(builder.contentColor); dialog.input.setHintTextColor(DialogUtils.adjustAlpha(builder.contentColor, 0.3f)); MDTintHelper.setTint(dialog.input, dialog.builder.widgetColor); if (builder.inputType != -1) { dialog.input.setInputType(builder.inputType); if (builder.inputType != InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD && (builder.inputType & InputType.TYPE_TEXT_VARIATION_PASSWORD) == InputType.TYPE_TEXT_VARIATION_PASSWORD) { // If the flags contain TYPE_TEXT_VARIATION_PASSWORD, apply the password transformation method automatically dialog.input.setTransformationMethod(PasswordTransformationMethod.getInstance()); } } dialog.inputMinMax = (TextView) dialog.view.findViewById(R.id.md_minMax); if (builder.inputMinLength > 0 || builder.inputMaxLength > -1) { dialog.invalidateInputMinMaxIndicator(dialog.input.getText().toString().length(), !builder.inputAllowEmpty); } else { dialog.inputMinMax.setVisibility(View.GONE); dialog.inputMinMax = null; } }
@NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { billingProcessor = new BillingProcessor(getContext(), App.GOOGLE_PLAY_LICENSE_KEY, this); @SuppressLint("InflateParams") View customView = LayoutInflater.from(getContext()).inflate(R.layout.dialog_donation, null); ProgressBar progressBar = ButterKnife.findById(customView, R.id.progress); MDTintHelper.setTint(progressBar, ThemeSingleton.get().positiveColor.getDefaultColor()); return new MaterialDialog.Builder(getContext()) .title(R.string.support_development) .customView(customView, false) .build(); }
private void invalidateDynamicButtonColors() { final MaterialDialog dialog = (MaterialDialog) getDialog(); if (dialog == null) { return; } final Builder builder = getBuilder(); if (builder.dynamicButtonColor) { int selectedColor = getSelectedColor(); if (Color.alpha(selectedColor) < 64 || (Color.red(selectedColor) > 247 && Color.green(selectedColor) > 247 && Color.blue(selectedColor) > 247)) { // Once we get close to white or transparent, // the action buttons and seekbars will be a very light gray. selectedColor = Color.parseColor("#DEDEDE"); } if (getBuilder().dynamicButtonColor) { dialog.getActionButton(DialogAction.POSITIVE).setTextColor(selectedColor); dialog.getActionButton(DialogAction.NEGATIVE).setTextColor(selectedColor); dialog.getActionButton(DialogAction.NEUTRAL).setTextColor(selectedColor); } if (customSeekR != null) { if (customSeekA.getVisibility() == View.VISIBLE) { MDTintHelper.setTint(customSeekA, selectedColor); } MDTintHelper.setTint(customSeekR, selectedColor); MDTintHelper.setTint(customSeekG, selectedColor); MDTintHelper.setTint(customSeekB, selectedColor); } } }
private static void setupInputDialog(final MaterialDialog dialog) { final MaterialDialog.Builder builder = dialog.mBuilder; dialog.input = (EditText) dialog.view.findViewById(android.R.id.input); if (dialog.input == null) return; dialog.setTypeface(dialog.input, builder.regularFont); if (builder.inputPrefill != null) dialog.input.setText(builder.inputPrefill); dialog.setInternalInputCallback(); dialog.input.setHint(builder.inputHint); dialog.input.setSingleLine(); dialog.input.setTextColor(builder.contentColor); dialog.input.setHintTextColor(DialogUtils.adjustAlpha(builder.contentColor, 0.3f)); MDTintHelper.setTint(dialog.input, dialog.mBuilder.widgetColor); if (builder.inputType != -1) { dialog.input.setInputType(builder.inputType); if ((builder.inputType & InputType.TYPE_TEXT_VARIATION_PASSWORD) == InputType.TYPE_TEXT_VARIATION_PASSWORD) { // If the flags contain TYPE_TEXT_VARIATION_PASSWORD, apply the password transformation method automatically dialog.input.setTransformationMethod(PasswordTransformationMethod.getInstance()); } } dialog.inputMinMax = (TextView) dialog.view.findViewById(R.id.minMax); if (builder.inputMinLength > 0 || builder.inputMaxLength > -1) { dialog.invalidateInputMinMaxIndicator(dialog.input.getText().toString().length(), !builder.inputAllowEmpty); } else { dialog.inputMinMax.setVisibility(View.GONE); dialog.inputMinMax = null; } }
protected void invalidateInputMinMaxIndicator(int currentLength, boolean emptyDisabled) { if (inputMinMax != null) { inputMinMax.setText(String.format("%d/%d", currentLength, mBuilder.inputMaxLength)); final boolean isDisabled = (emptyDisabled && currentLength == 0) || currentLength > mBuilder.inputMaxLength || currentLength < mBuilder.inputMinLength; final int colorText = isDisabled ? mBuilder.inputRangeErrorColor : mBuilder.contentColor; final int colorWidget = isDisabled ? mBuilder.inputRangeErrorColor : mBuilder.widgetColor; inputMinMax.setTextColor(colorText); MDTintHelper.setTint(input, colorWidget); final View positiveAb = getActionButton(DialogAction.POSITIVE); positiveAb.setEnabled(!isDisabled); } }
@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(); }
private void setProgressBarColor(int color) { MDTintHelper.setTint(mProgressBar, color); }
@Override protected View getPendingView(ViewGroup parent) { View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.widget_progess, parent, false); MDTintHelper.setTint((ProgressBar) ((FrameLayout) v).getChildAt(0), parent.getContext().getResources().getColor(((BaseFragmentActivity) parent.getContext()).isEasyRedmine() ? R.color.er_primary : R.color.r_primary)); return v; }
@Override protected void showDialog(Bundle state) { MaterialDialog.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); onPrepareDialogBuilder(mBuilder); @SuppressLint("InflateParams") View layout = LayoutInflater.from(getContext()).inflate(com.afollestad.materialdialogs.commons.R.layout.md_stub_inputpref, null); onBindDialogView(layout); MDTintHelper.setTint(mEditText, mColor); 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); registerOnActivityDestroyListener(this, this); mDialog = mBuilder.build(); if (state != null) mDialog.onRestoreInstanceState(state); requestInputMethod(mDialog); mDialog.show(); }
@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(); }
private static void setupInputDialog(final MaterialDialog dialog) { final MaterialDialog.Builder builder = dialog.builder; dialog.input = dialog.view.findViewById(android.R.id.input); if (dialog.input == null) { return; } dialog.setTypeface(dialog.input, builder.regularFont); if (builder.inputPrefill != null) { dialog.input.setText(builder.inputPrefill); } dialog.setInternalInputCallback(); dialog.input.setHint(builder.inputHint); dialog.input.setSingleLine(); dialog.input.setTextColor(builder.contentColor); dialog.input.setHintTextColor(DialogUtils.adjustAlpha(builder.contentColor, 0.3f)); MDTintHelper.setTint(dialog.input, dialog.builder.widgetColor); if (builder.inputType != -1) { dialog.input.setInputType(builder.inputType); if (builder.inputType != InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD && (builder.inputType & InputType.TYPE_TEXT_VARIATION_PASSWORD) == InputType.TYPE_TEXT_VARIATION_PASSWORD) { // If the flags contain TYPE_TEXT_VARIATION_PASSWORD, apply the password transformation // method automatically dialog.input.setTransformationMethod(PasswordTransformationMethod.getInstance()); } } dialog.inputMinMax = dialog.view.findViewById(R.id.md_minMax); if (builder.inputMinLength > 0 || builder.inputMaxLength > -1) { dialog.invalidateInputMinMaxIndicator( dialog.input.getText().toString().length(), !builder.inputAllowEmpty); } else { dialog.inputMinMax.setVisibility(View.GONE); dialog.inputMinMax = null; } if (builder.inputFilters != null) { dialog.input.setFilters(builder.inputFilters); } }