Search in sources :

Example 1 with AppCompatEditText

use of android.support.v7.widget.AppCompatEditText in project Rashr by DsLNeXuS.

the class BackupRestoreFragment method createBackup.

public void createBackup(final boolean RecoveryBackup) {
    String prefix;
    String CurrentName;
    String EXT;
    if (RecoveryBackup) {
        prefix = "recovery";
        EXT = RashrApp.DEVICE.getRecoveryExt();
        CurrentName = RashrApp.DEVICE.getRecoveryVersion();
    } else {
        prefix = "kernel";
        EXT = RashrApp.DEVICE.getKernelExt();
        CurrentName = RashrApp.DEVICE.getKernelVersion();
    }
    final AppCompatDialog dialog = new AppCompatDialog(mContext);
    dialog.setTitle(R.string.setname);
    dialog.setContentView(R.layout.dialog_input);
    final AppCompatButton bGoBackup = (AppCompatButton) dialog.findViewById(R.id.bGoBackup);
    final AppCompatEditText etFileName = (AppCompatEditText) dialog.findViewById(R.id.etFileName);
    final AppCompatCheckBox optName = (AppCompatCheckBox) dialog.findViewById(R.id.cbOptInput);
    if (bGoBackup == null || etFileName == null || optName == null)
        return;
    final String NameHint = prefix + "-from-" + Calendar.getInstance().get(Calendar.DATE) + "-" + Calendar.getInstance().get(Calendar.MONTH) + "-" + Calendar.getInstance().get(Calendar.YEAR) + "-" + Calendar.getInstance().get(Calendar.HOUR) + "-" + Calendar.getInstance().get(Calendar.MINUTE) + EXT;
    optName.setText(CurrentName);
    optName.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            etFileName.setEnabled(!optName.isChecked());
        }
    });
    etFileName.setHint(NameHint);
    bGoBackup.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            String EXT;
            File Path;
            final int JOB;
            if (RecoveryBackup) {
                EXT = RashrApp.DEVICE.getRecoveryExt();
                Path = Const.PathToRecoveryBackups;
                JOB = FlashUtil.JOB_BACKUP_RECOVERY;
            } else {
                EXT = RashrApp.DEVICE.getKernelExt();
                Path = Const.PathToKernelBackups;
                JOB = FlashUtil.JOB_BACKUP_KERNEL;
            }
            CharSequence Name = "";
            if (optName.isChecked()) {
                Name = optName.getText() + EXT;
            } else {
                if (etFileName.getText() != null && !etFileName.getText().toString().equals("")) {
                    Name = etFileName.getText().toString();
                }
                if (Name.equals("")) {
                    Name = String.valueOf(etFileName.getHint());
                }
                if (!Name.toString().endsWith(EXT)) {
                    Name = Name + EXT;
                }
            }
            final File fBACKUP = new File(Path, Name.toString());
            if (fBACKUP.exists()) {
                Toast.makeText(mActivity, R.string.backupalready, Toast.LENGTH_SHORT).show();
            } else {
                final FlashUtil BackupCreator = new FlashUtil(mActivity, fBACKUP, JOB);
                BackupCreator.setOnTaskDoneListener(new FlashUtil.OnTaskDoneListener() {

                    @Override
                    public void onSuccess() {
                        mAdapter.reload();
                    }

                    @Override
                    public void onFail(Exception e) {
                        String msg;
                        if (e != null) {
                            msg = e.toString();
                        } else {
                            msg = getString(R.string.bak_error);
                        }
                        Toast.makeText(mContext, msg, Toast.LENGTH_SHORT).show();
                    }
                });
                BackupCreator.execute();
            }
            dialog.dismiss();
        }
    });
    dialog.show();
}
Also used : View(android.view.View) AdapterView(android.widget.AdapterView) AppCompatTextView(android.support.v7.widget.AppCompatTextView) ListView(android.widget.ListView) AppCompatButton(android.support.v7.widget.AppCompatButton) AppCompatCheckBox(android.support.v7.widget.AppCompatCheckBox) AppCompatEditText(android.support.v7.widget.AppCompatEditText) AppCompatDialog(android.support.v7.app.AppCompatDialog) File(java.io.File)

Example 2 with AppCompatEditText

use of android.support.v7.widget.AppCompatEditText in project Rashr by DsLNeXuS.

the class SettingsFragment method onCreateView.

@Override
public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View root = inflater.inflate(R.layout.fragment_settings, container, false);
    final AppCompatButton bSetDevName = (AppCompatButton) root.findViewById(R.id.bSetDevName);
    final AppCompatCheckBox cbShowAds = (AppCompatCheckBox) root.findViewById(R.id.cbShowAds);
    final AppCompatCheckBox cbLog = (AppCompatCheckBox) root.findViewById(R.id.cbLog);
    //        final AppCompatCheckBox cbDarkUI = (AppCompatCheckBox) root.findViewById(R.id.cbDarkUI);
    final AppCompatCheckBox cbCheckUpdates = (AppCompatCheckBox) root.findViewById(R.id.cbCheckUpdates);
    final AppCompatCheckBox cbHideUpToDateHint = (AppCompatCheckBox) root.findViewById(R.id.cbShowUpToDateHints);
    final AppCompatCheckBox cbSkipSizeCheck = (AppCompatCheckBox) root.findViewById(R.id.cbSkipSizeChecking);
    final AppCompatCheckBox cbSkipValidate = (AppCompatCheckBox) root.findViewById(R.id.cbSkipValidateImages);
    final AppCompatButton bShowLogs = (AppCompatButton) root.findViewById(R.id.bShowLogs);
    final AppCompatButton bReport = (AppCompatButton) root.findViewById(R.id.bReport);
    final AppCompatButton bShowChangelog = (AppCompatButton) root.findViewById(R.id.bShowChangelog);
    final AppCompatButton bReset = (AppCompatButton) root.findViewById(R.id.bReset);
    final AppCompatButton bClearCache = (AppCompatButton) root.findViewById(R.id.bClearCache);
    final AppCompatButton bShowLicences = (AppCompatButton) root.findViewById(R.id.bShowLicenses);
    //        cbDarkUI.setChecked(Common.getBooleanPref(root.getContext(), Const.PREF_NAME,
    //                Const.PREF_KEY_DARK_UI));
    cbShowAds.setChecked(Common.getBooleanPref(root.getContext(), Const.PREF_NAME, Const.PREF_KEY_ADS));
    cbLog.setChecked(Common.getBooleanPref(root.getContext(), Const.PREF_NAME, Const.PREF_KEY_LOG));
    cbCheckUpdates.setChecked(Common.getBooleanPref(root.getContext(), Const.PREF_NAME, Const.PREF_KEY_CHECK_UPDATES));
    cbShowAds.setChecked(Common.getBooleanPref(root.getContext(), Const.PREF_NAME, Const.PREF_KEY_ADS));
    cbHideUpToDateHint.setChecked(Common.getBooleanPref(root.getContext(), Const.PREF_NAME, Const.PREF_KEY_HIDE_UPDATE_HINTS));
    cbSkipSizeCheck.setChecked(Common.getBooleanPref(root.getContext(), Const.PREF_NAME, Const.PREF_KEY_SKIP_SIZE_CHECK));
    cbSkipValidate.setChecked(Common.getBooleanPref(root.getContext(), Const.PREF_NAME, Const.PREF_KEY_SKIP_IMAGE_CHECK));
    //        cbDarkUI.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
    //            @Override
    //            public void onCheckedChanged(CompoundButton view, boolean isChecked) {
    //                Common.setBooleanPref(view.getContext(), Const.PREF_NAME,
    //                        Const.PREF_KEY_DARK_UI, isChecked);
    //                RashrActivity.isDark = isChecked;
    //            }
    //        });
    cbLog.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton view, boolean isChecked) {
            Common.setBooleanPref(view.getContext(), Const.PREF_NAME, Const.PREF_KEY_LOG, isChecked);
            root.findViewById(R.id.bShowLogs).setVisibility(isChecked ? View.VISIBLE : View.INVISIBLE);
        }
    });
    cbCheckUpdates.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton view, boolean isChecked) {
            Common.setBooleanPref(view.getContext(), Const.PREF_NAME, Const.PREF_KEY_CHECK_UPDATES, isChecked);
        }
    });
    cbShowAds.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton view, boolean isChecked) {
            Common.setBooleanPref(view.getContext(), Const.PREF_NAME, Const.PREF_KEY_ADS, isChecked);
        }
    });
    cbHideUpToDateHint.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton view, boolean isChecked) {
            Common.setBooleanPref(view.getContext(), Const.PREF_NAME, Const.PREF_KEY_HIDE_UPDATE_HINTS, isChecked);
        }
    });
    cbSkipSizeCheck.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            Common.setBooleanPref(buttonView.getContext(), Const.PREF_NAME, Const.PREF_KEY_SKIP_SIZE_CHECK, isChecked);
        }
    });
    cbSkipValidate.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            Common.setBooleanPref(buttonView.getContext(), Const.PREF_NAME, Const.PREF_KEY_SKIP_IMAGE_CHECK, isChecked);
        }
    });
    final RashrActivity activity = (RashrActivity) getActivity();
    bReport.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            ReportDialog dialog = new ReportDialog(activity, "");
            dialog.show();
        }
    });
    bShowLogs.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            showLogs();
        }
    });
    bShowLogs.setVisibility(cbLog.isChecked() ? View.VISIBLE : View.INVISIBLE);
    bReset.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            AppCompatActivity activity = (AppCompatActivity) getActivity();
            SharedPreferences.Editor editor = activity.getSharedPreferences(Const.PREF_NAME, Context.MODE_PRIVATE).edit();
            editor.clear().apply();
            editor = activity.getSharedPreferences(Const.PREF_NAME, Context.MODE_PRIVATE).edit();
            editor.clear().apply();
            RashrActivity.firstSetup(v.getContext());
        }
    });
    bClearCache.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            final AlertDialog.Builder ConfirmationDialog = new AlertDialog.Builder(v.getContext());
            ConfirmationDialog.setTitle(R.string.warning);
            ConfirmationDialog.setMessage(R.string.delete_confirmation);
            ConfirmationDialog.setPositiveButton(R.string.positive, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    if (!Common.deleteFolder(Const.PathToCWM, false) || !Common.deleteFolder(Const.PathToTWRP, false) || !Common.deleteFolder(Const.PathToPhilz, false) || !Common.deleteFolder(Const.PathToStockRecovery, false) || !Common.deleteFolder(Const.PathToStockKernel, false)) {
                        Toast.makeText(getActivity(), R.string.delete_failed, Toast.LENGTH_SHORT).show();
                    } else {
                        Toast.makeText(getActivity(), R.string.files_deleted, Toast.LENGTH_SHORT).show();
                    }
                }
            });
            ConfirmationDialog.setNegativeButton(R.string.negative, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                }
            });
            ConfirmationDialog.show();
        }
    });
    bShowChangelog.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            SettingsFragment.showChangelog(v.getContext());
        }
    });
    bShowLicences.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            new LicensesDialog.Builder(v.getContext()).setNotices(R.raw.licenses_notice).setIncludeOwnLicense(true).build().show();
        }
    });
    bSetDevName.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            final AppCompatEditText et = new AppCompatEditText(v.getContext());
            AlertDialog.Builder inputDialog = new AlertDialog.Builder(v.getContext());
            String dev_name = Common.getStringPref(v.getContext(), Const.PREF_NAME, Const.PREF_KEY_DEVICE_NAME);
            if (dev_name.equals(""))
                dev_name = RashrApp.DEVICE.getName();
            et.setText(dev_name);
            inputDialog.setTitle(R.string.device_name);
            inputDialog.setView(et);
            inputDialog.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    String name = et.getText().toString();
                    if (!name.equals("")) {
                        Common.setStringPref(getContext(), Const.PREF_NAME, Const.PREF_KEY_DEVICE_NAME, et.getText().toString());
                        Snackbar.make(bSetDevName, R.string.please_restart, Snackbar.LENGTH_SHORT).show();
                    }
                }
            });
            inputDialog.setNeutralButton(R.string.reset, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    Common.setStringPref(getContext(), Const.PREF_NAME, Const.PREF_KEY_DEVICE_NAME, Build.DEVICE.toLowerCase());
                }
            });
            inputDialog.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                }
            });
            inputDialog.show();
        }
    });
    return root;
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) AppCompatActivity(android.support.v7.app.AppCompatActivity) LicensesDialog(de.psdev.licensesdialog.LicensesDialog) View(android.view.View) WebView(android.webkit.WebView) AppCompatButton(android.support.v7.widget.AppCompatButton) AppCompatCheckBox(android.support.v7.widget.AppCompatCheckBox) AppCompatEditText(android.support.v7.widget.AppCompatEditText) CompoundButton(android.widget.CompoundButton)

Example 3 with AppCompatEditText

use of android.support.v7.widget.AppCompatEditText in project instructure-android by instructure.

the class AskInstructorDialogStyled method onCreateDialog.

@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()).setTitle(getActivity().getString(R.string.instructor_question)).setPositiveButton(getActivity().getString(R.string.send), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (canClickSend) {
                if (message == null || message.getText().toString().trim().equals("")) {
                    Toast.makeText(getActivity(), getString(R.string.emptyMessage), Toast.LENGTH_SHORT).show();
                } else {
                    progressDialog = ProgressDialog.show(getActivity(), "", getActivity().getString(R.string.sending));
                    loadTeacherData();
                }
            }
        }
    });
    // Suppress lint warning about null parent when inflating layout
    @SuppressLint("InflateParams") final View view = LayoutInflater.from(getActivity()).inflate(R.layout.ask_instructor, null);
    courseSpinner = view.findViewById(R.id.courseSpinner);
    ArrayList<Course> loadingIndicator = new ArrayList<Course>();
    Course loading = new Course();
    loading.setName(getActivity().getString(R.string.loading));
    loadingIndicator.add(loading);
    courseAdapter = new CourseSpinnerAdapter(getActivity(), android.R.layout.simple_spinner_dropdown_item, loadingIndicator);
    // we haven't set an onItemSelectedListener, so selecting the item shouldn't do anything
    courseSpinner.setAdapter(courseAdapter);
    message = view.findViewById(R.id.message);
    builder.setView(view);
    final AlertDialog dialog = builder.create();
    dialog.setOnShowListener(new DialogInterface.OnShowListener() {

        @Override
        public void onShow(DialogInterface worthless) {
            dialog.getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(ThemePrefs.getBrandColor());
            ViewStyler.themeEditText(getContext(), (AppCompatEditText) message, ThemePrefs.getBrandColor());
        }
    });
    dialog.setCanceledOnTouchOutside(true);
    return dialog;
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) ArrayList(java.util.ArrayList) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) SuppressLint(android.annotation.SuppressLint) AppCompatEditText(android.support.v7.widget.AppCompatEditText) SuppressLint(android.annotation.SuppressLint) Course(com.instructure.canvasapi2.models.Course) NonNull(android.support.annotation.NonNull)

Example 4 with AppCompatEditText

use of android.support.v7.widget.AppCompatEditText in project instructure-android by instructure.

the class RCEInsertDialog method onCreateDialog.

@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    View root = LayoutInflater.from(getContext()).inflate(R.layout.rce_dialog_insert, null);
    AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
    builder.setView(root);
    builder.setTitle(getArguments().getString(TITLE));
    builder.setPositiveButton(R.string.rce_dialogDone, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (mCallback != null) {
                mCallback.onResults(mUrlEditText.getText().toString(), mAltEditText.getText().toString());
            }
            dismiss();
        }
    });
    builder.setNegativeButton(R.string.rce_dialogCancel, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dismiss();
        }
    });
    final int themeColor = getArguments().getInt(THEME_COLOR, Color.BLACK);
    final int highlightColor = RCEUtils.increaseAlpha(themeColor);
    final ColorStateList colorStateList = RCEUtils.makeEditTextColorStateList(Color.BLACK, themeColor);
    mAltEditText = (AppCompatEditText) root.findViewById(R.id.altEditText);
    mUrlEditText = (AppCompatEditText) root.findViewById(R.id.urlEditText);
    mAltEditText.setHighlightColor(highlightColor);
    mUrlEditText.setHighlightColor(highlightColor);
    mAltEditText.setSupportBackgroundTintList(colorStateList);
    mUrlEditText.setSupportBackgroundTintList(colorStateList);
    final AlertDialog dialog = builder.create();
    dialog.setOnShowListener(new DialogInterface.OnShowListener() {

        @Override
        public void onShow(DialogInterface dialogInterface) {
            final int buttonColor = getArguments().getInt(BUTTON_COLOR, Color.BLACK);
            dialog.getButton(DialogInterface.BUTTON_POSITIVE).setTextColor(buttonColor);
            dialog.getButton(DialogInterface.BUTTON_NEGATIVE).setTextColor(buttonColor);
        }
    });
    return dialog;
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) ColorStateList(android.content.res.ColorStateList) View(android.view.View) NonNull(android.support.annotation.NonNull)

Example 5 with AppCompatEditText

use of android.support.v7.widget.AppCompatEditText in project instructure-android by instructure.

the class CanvasEditTextView method initEditText.

// //////////////////////////////////////////////////////////////////////////////////////////////
// region View Layout Helpers
// //////////////////////////////////////////////////////////////////////////////////////////////
public static EditText initEditText(Context context, String hint, int hintColor, float textSize, int maxLines) {
    final AppCompatEditText editText = new AppCompatEditText(context);
    editText.setId(R.id.canvasEditText);
    editText.setEnabled(true);
    editText.setHint(hint);
    editText.setHintTextColor(hintColor);
    editText.setSingleLine(false);
    editText.setMaxLines(maxLines);
    editText.setVerticalScrollBarEnabled(true);
    editText.setTextColor(context.getResources().getColor(R.color.canvasTextDark));
    editText.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
    editText.setRawInputType(editText.getInputType() | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
    final int padding = context.getResources().getDimensionPixelOffset(R.dimen.canvas_edit_text_view_padding);
    editText.setPadding(padding, 0, padding, 0);
    ColorDrawable colorDrawable = new ColorDrawable(Color.TRANSPARENT);
    editText.setBackgroundDrawable(colorDrawable);
    RelativeLayout.LayoutParams editTextParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    editTextParams.addRule(RelativeLayout.END_OF, R.id.leftLayout);
    editTextParams.addRule(RelativeLayout.START_OF, R.id.rightLayout);
    editTextParams.addRule(RelativeLayout.CENTER_VERTICAL);
    editText.setLayoutParams(editTextParams);
    return editText;
}
Also used : AppCompatEditText(android.support.v7.widget.AppCompatEditText) ColorDrawable(android.graphics.drawable.ColorDrawable) RelativeLayout(android.widget.RelativeLayout) Paint(android.graphics.Paint)

Aggregations

AppCompatEditText (android.support.v7.widget.AppCompatEditText)37 View (android.view.View)20 DialogInterface (android.content.DialogInterface)16 AlertDialog (android.support.v7.app.AlertDialog)13 TextView (android.widget.TextView)11 Editable (android.text.Editable)10 AppCompatButton (android.support.v7.widget.AppCompatButton)8 TextWatcher (android.text.TextWatcher)7 LinearLayout (android.widget.LinearLayout)7 File (java.io.File)7 Context (android.content.Context)6 TextInputLayout (android.support.design.widget.TextInputLayout)6 AppCompatCheckBox (android.support.v7.widget.AppCompatCheckBox)6 AppCompatTextView (android.support.v7.widget.AppCompatTextView)6 ColorDrawable (android.graphics.drawable.ColorDrawable)5 AdapterView (android.widget.AdapterView)5 SuppressLint (android.annotation.SuppressLint)4 AppCompatDialog (android.support.v7.app.AppCompatDialog)4 RelativeLayout (android.widget.RelativeLayout)4 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)4