Search in sources :

Example 21 with AppCompatEditText

use of android.support.v7.widget.AppCompatEditText in project material-dialogs by afollestad.

the class MaterialEditTextPreference method init.

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);
}
Also used : AppCompatEditText(android.support.v7.widget.AppCompatEditText) SuppressLint(android.annotation.SuppressLint)

Example 22 with AppCompatEditText

use of android.support.v7.widget.AppCompatEditText in project material-dialogs by afollestad.

the class MDTintHelper method setTint.

public static void setTint(@NonNull EditText editText, @ColorInt int color) {
    ColorStateList editTextColorStateList = createEditTextColorStateList(editText.getContext(), color);
    if (editText instanceof AppCompatEditText) {
        ((AppCompatEditText) editText).setSupportBackgroundTintList(editTextColorStateList);
    } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        editText.setBackgroundTintList(editTextColorStateList);
    }
    setCursorTint(editText, color);
}
Also used : AppCompatEditText(android.support.v7.widget.AppCompatEditText) ColorStateList(android.content.res.ColorStateList)

Example 23 with AppCompatEditText

use of android.support.v7.widget.AppCompatEditText in project Shuttle by timusus.

the class ThemeUtils method themeEditText.

public static void themeEditText(EditText editText) {
    int accentColor = ColorUtils.getAccentColor();
    //Not sure if this check is necessary..
    if (editText instanceof AppCompatEditText) {
        //Theme the background
        ((AppCompatEditText) editText).setSupportBackgroundTintList(ColorUtils.createEditTextColorStateList(editText.getContext()));
    }
    //Theme the cursor & handles
    setEditTextDrawablesColor(editText, accentColor);
    //If the parent is a TextInputLayout, theme that too
    if (editText.getParent() != null && editText.getParent() instanceof TextInputLayout) {
        setInputTextLayoutColor((TextInputLayout) editText.getParent(), accentColor);
    }
}
Also used : AppCompatEditText(android.support.v7.widget.AppCompatEditText) TextInputLayout(android.support.design.widget.TextInputLayout) SuppressLint(android.annotation.SuppressLint)

Example 24 with AppCompatEditText

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

the class ScriptManagerFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mRootView = inflater.inflate(R.layout.fragment_script_manager, container, false);
    mFileNameAdapter = new ArrayAdapter<>(mContext, R.layout.custom_list_item);
    mFileList = new ArrayList<>();
    mQueue = (ListView) mRootView.findViewById(R.id.lvQueue);
    mQueue.setAdapter(mFileNameAdapter);
    mQueue.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            mFileList.remove(position);
            mFileNameAdapter.clear();
            for (File i : mFileList) {
                mFileNameAdapter.add(i.getName());
            }
        }
    });
    if (mStartFile != null) {
        if (mStartFile.exists()) {
            if (Common.stringEndsWithArray(mStartFile.getName(), mAllowedEXT)) {
                addFileToQueue(mStartFile);
            } else {
                Toast.makeText(mContext, R.string.wrong_format, Toast.LENGTH_SHORT).show();
            }
        }
    }
    AppCompatButton AddZip = (AppCompatButton) mRootView.findViewById(R.id.addZip);
    AddZip.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            mFileChooser = new FileChooserDialog(mContext);
            File startFolder = Environment.getExternalStorageDirectory();
            if (mFileList.size() > 0) {
                startFolder = mFileList.get(mFileList.size() - 1);
                if (startFolder.isFile()) {
                    startFolder = startFolder.getParentFile();
                }
            }
            mFileChooser.setStartFolder(startFolder);
            mFileChooser.setOnFileChooseListener(new FileChooserDialog.OnFileChooseListener() {

                @Override
                public void OnFileChoose(File file) {
                    addFileToQueue(file);
                }
            });
            mFileChooser.setAllowedEXT(mAllowedEXT);
            mFileChooser.setBrowseUpAllowed(true);
            mFileChooser.setWarn(false);
            mFileChooser.show();
        }
    });
    AppCompatButton FlashZip = (AppCompatButton) mRootView.findViewById(R.id.bFlashZip);
    FlashZip.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            AppCompatCheckBox cbBakSystem = (AppCompatCheckBox) mRootView.findViewById(R.id.cbBackupSystem);
            AppCompatCheckBox cbBakData = (AppCompatCheckBox) mRootView.findViewById(R.id.cbBackupData);
            AppCompatCheckBox cbBakCache = (AppCompatCheckBox) mRootView.findViewById(R.id.cbBackupCache);
            AppCompatCheckBox cbBakRecovery = (AppCompatCheckBox) mRootView.findViewById(R.id.cbBackupRecovery);
            AppCompatCheckBox cbBakBoot = (AppCompatCheckBox) mRootView.findViewById(R.id.cbBackupBoot);
            AppCompatCheckBox cbSkipMD5 = (AppCompatCheckBox) mRootView.findViewById(R.id.cbSkipMD5);
            AppCompatEditText etBakName = (AppCompatEditText) mRootView.findViewById(R.id.etBackupName);
            AppCompatCheckBox cbWipeCache = (AppCompatCheckBox) mRootView.findViewById(R.id.cbWipeCache);
            AppCompatCheckBox cbWipeDalvik = (AppCompatCheckBox) mRootView.findViewById(R.id.cbWipeDalvik);
            AppCompatCheckBox cbWipeData = (AppCompatCheckBox) mRootView.findViewById(R.id.cbWipeData);
            final StringBuilder command = new StringBuilder();
            command.append("echo #####Script created by Rashr#####;");
            if (cbBakBoot.isChecked() || cbBakCache.isChecked() || cbBakData.isChecked() || cbBakRecovery.isChecked() || cbBakSystem.isChecked()) {
                command.append("backup ");
                if (cbBakBoot.isChecked())
                    command.append("B");
                if (cbBakCache.isChecked())
                    command.append("C");
                if (cbBakData.isChecked())
                    command.append("D");
                if (cbBakRecovery.isChecked())
                    command.append("R");
                if (cbBakSystem.isChecked())
                    command.append("S");
                if (cbSkipMD5.isChecked())
                    command.append("M");
                CharSequence BackupName = etBakName.getText();
                if (BackupName != null && !BackupName.equals("")) {
                    command.append(" ");
                    command.append(BackupName);
                }
                command.append(CMD_END);
            }
            if (cbWipeCache.isChecked())
                command.append("wipe cache;");
            if (cbWipeDalvik.isChecked())
                command.append("wipe dalvik;");
            if (cbWipeData.isChecked())
                command.append("wipe data;");
            for (File i : mFileList) {
                command.append("install ");
                command.append(i.getAbsolutePath());
                command.append(CMD_END);
            }
            if (!command.toString().equals("")) {
                String commands = "";
                int index = 0;
                for (String i : command.toString().split(CMD_END)) {
                    if (!i.equals("")) {
                        if (index > 0) {
                            commands += index++ + ". " + i + "\n";
                        } else {
                            index++;
                        }
                    }
                }
                final AlertDialog.Builder CommandsPreview = new AlertDialog.Builder(mContext);
                CommandsPreview.setTitle(R.string.recovery_script_review);
                CommandsPreview.setPositiveButton(R.string.run, new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        try {
                            for (String split : command.toString().split(";")) {
                                if (!split.equals("")) {
                                    RashrApp.SHELL.execCommand("echo " + split + " >> /cache/recovery/openrecoveryscript");
                                }
                            }
                            RashrApp.TOOLBOX.reboot(Toolbox.REBOOT_RECOVERY);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                });
                CommandsPreview.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                    }
                });
                CommandsPreview.setMessage(commands);
                CommandsPreview.show();
            } else {
                Toast.makeText(mContext, "No job to do :)", Toast.LENGTH_LONG).show();
            }
        }
    });
    return mRootView;
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) FileChooserDialog(de.mkrtchyan.utils.FileChooserDialog) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) AppCompatButton(android.support.v7.widget.AppCompatButton) AppCompatCheckBox(android.support.v7.widget.AppCompatCheckBox) AppCompatEditText(android.support.v7.widget.AppCompatEditText) AdapterView(android.widget.AdapterView) File(java.io.File)

Example 25 with AppCompatEditText

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

the class BackupRestoreFragment method showPopup.

public void showPopup(final View v) {
    PopupMenu popup = new PopupMenu(mActivity, v);
    popup.getMenuInflater().inflate(R.menu.bakmgr_menu, popup.getMenu());
    popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {

        @Override
        public boolean onMenuItemClick(final MenuItem menuItem) {
            final CharSequence text = ((AppCompatTextView) v).getText();
            final String FileName = text.toString();
            final AppCompatDialog dialog = new AppCompatDialog(mActivity);
            dialog.setTitle(R.string.setname);
            dialog.setContentView(R.layout.dialog_input);
            final AppCompatButton bGo = (AppCompatButton) dialog.findViewById(R.id.bGoBackup);
            final AppCompatEditText etFileName = (AppCompatEditText) dialog.findViewById(R.id.etFileName);
            if (bGo == null || etFileName == null)
                return false;
            //If current item is 0 (first item) a recovery backup will be edited or created
            final File path = mPager.getCurrentItem() == 0 ? Const.PathToRecoveryBackups : Const.PathToKernelBackups;
            try {
                switch(menuItem.getItemId()) {
                    case R.id.iRestore:
                        File backup = new File(path, FileName);
                        FlashUtil RestoreUtil = new FlashUtil(mActivity, backup, mPager.getCurrentItem() == 0 ? FlashUtil.JOB_RESTORE_RECOVERY : FlashUtil.JOB_RESTORE_KERNEL);
                        RestoreUtil.execute();
                        return true;
                    case R.id.iRename:
                        etFileName.setHint(FileName);
                        bGo.setOnClickListener(new View.OnClickListener() {

                            @Override
                            public void onClick(View v) {
                                String Name;
                                if (etFileName.getText() != null && etFileName.isEnabled() && !etFileName.getText().toString().equals("")) {
                                    //User has defined a name for the backup. Use it.
                                    Name = etFileName.getText().toString();
                                } else {
                                    //Use hint as backup name. Normally the correct version
                                    //and Recovery System (if Rashr could read it out of
                                    //"/cache/recovery/last_log"
                                    Name = String.valueOf(etFileName.getHint());
                                }
                                if (!Name.endsWith(RashrApp.DEVICE.getRecoveryExt())) {
                                    //Append extension
                                    Name += RashrApp.DEVICE.getRecoveryExt();
                                }
                                File renamedBackup = new File(path, Name);
                                if (renamedBackup.exists()) {
                                    Toast.makeText(mActivity, R.string.backupalready, Toast.LENGTH_SHORT).show();
                                    // if backup already exists, let the user chose a new name
                                    onMenuItemClick(menuItem);
                                } else {
                                    File Backup = new File(path, FileName);
                                    if (Backup.renameTo(renamedBackup)) {
                                        mAdapter.reload();
                                    } else {
                                        Toast.makeText(mActivity, R.string.rename_failed, Toast.LENGTH_SHORT).show();
                                    }
                                }
                                dialog.dismiss();
                            }
                        });
                        dialog.show();
                        return true;
                    case R.id.iDeleteBackup:
                        backup = new File(path, text.toString());
                        if (backup.delete()) {
                            Toast.makeText(mActivity, mContext.getString(R.string.bak_deleted), Toast.LENGTH_SHORT).show();
                        }
                        mAdapter.reload();
                        return true;
                    default:
                        return false;
                }
            } catch (Exception e) {
                if (e.getMessage().contains("EINVAL") && text.toString().contains(":")) {
                    AlertDialog.Builder adialog = new AlertDialog.Builder(mContext);
                    adialog.setMessage(R.string.check_name);
                    adialog.setMessage(R.string.ok);
                    adialog.show();
                }
                RashrApp.ERRORS.add(Const.RASHR_TAG + " " + e);
                return false;
            }
        }
    });
    popup.show();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) MenuItem(android.view.MenuItem) View(android.view.View) AdapterView(android.widget.AdapterView) AppCompatTextView(android.support.v7.widget.AppCompatTextView) ListView(android.widget.ListView) AppCompatButton(android.support.v7.widget.AppCompatButton) AppCompatEditText(android.support.v7.widget.AppCompatEditText) AppCompatDialog(android.support.v7.app.AppCompatDialog) File(java.io.File) PopupMenu(android.support.v7.widget.PopupMenu)

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