Search in sources :

Example 1 with Dialog

use of com.moro.mtweaks.views.dialog.Dialog in project MTweaks-KernelAdiutorMOD by morogoku.

the class SettingsFragment method editPasswordDialog.

private void editPasswordDialog(final String oldPass) {
    mOldPassword = oldPass;
    LinearLayout linearLayout = new LinearLayout(getActivity());
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    linearLayout.setGravity(Gravity.CENTER);
    int padding = Math.round(getResources().getDimension(R.dimen.dialog_padding));
    linearLayout.setPadding(padding, padding, padding, padding);
    final AppCompatEditText oldPassword = new AppCompatEditText(getActivity());
    if (!oldPass.isEmpty()) {
        oldPassword.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
        oldPassword.setHint(getString(R.string.old_password));
        linearLayout.addView(oldPassword);
    }
    final AppCompatEditText newPassword = new AppCompatEditText(getActivity());
    newPassword.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
    newPassword.setHint(getString(R.string.new_password));
    linearLayout.addView(newPassword);
    final AppCompatEditText confirmNewPassword = new AppCompatEditText(getActivity());
    confirmNewPassword.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
    confirmNewPassword.setHint(getString(R.string.confirm_new_password));
    linearLayout.addView(confirmNewPassword);
    new Dialog(getActivity()).setView(linearLayout).setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
        }
    }).setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
            if (!oldPass.isEmpty() && !oldPassword.getText().toString().equals(Utils.decodeString(oldPass))) {
                Utils.toast(getString(R.string.old_password_wrong), getActivity());
                return;
            }
            if (newPassword.getText().toString().isEmpty()) {
                Utils.toast(getString(R.string.password_empty), getActivity());
                return;
            }
            if (!newPassword.getText().toString().equals(confirmNewPassword.getText().toString())) {
                Utils.toast(getString(R.string.password_not_match), getActivity());
                return;
            }
            if (newPassword.getText().toString().length() > 32) {
                Utils.toast(getString(R.string.password_too_long), getActivity());
                return;
            }
            Prefs.saveString("password", Utils.encodeString(newPassword.getText().toString()), getActivity());
            if (mFingerprint != null) {
                mFingerprint.setEnabled(true);
            }
        }
    }).setOnDismissListener(new DialogInterface.OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface dialogInterface) {
            mOldPassword = null;
        }
    }).show();
}
Also used : AppCompatEditText(android.support.v7.widget.AppCompatEditText) DialogInterface(android.content.DialogInterface) Dialog(com.moro.mtweaks.views.dialog.Dialog) ProgressDialog(android.app.ProgressDialog) AlertDialog(android.support.v7.app.AlertDialog) LinearLayout(android.widget.LinearLayout)

Example 2 with Dialog

use of com.moro.mtweaks.views.dialog.Dialog in project MTweaks-KernelAdiutorMOD by morogoku.

the class SettingsFragment method deletePasswordDialog.

private void deletePasswordDialog(final String password) {
    if (password.isEmpty()) {
        Utils.toast(getString(R.string.set_password_first), getActivity());
        return;
    }
    mDeletePassword = password;
    LinearLayout linearLayout = new LinearLayout(getActivity());
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    linearLayout.setGravity(Gravity.CENTER);
    int padding = Math.round(getResources().getDimension(R.dimen.dialog_padding));
    linearLayout.setPadding(padding, padding, padding, padding);
    final AppCompatEditText mPassword = new AppCompatEditText(getActivity());
    mPassword.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
    mPassword.setHint(getString(R.string.password));
    linearLayout.addView(mPassword);
    new Dialog(getActivity()).setView(linearLayout).setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
            if (!mPassword.getText().toString().equals(Utils.decodeString(password))) {
                Utils.toast(getString(R.string.password_wrong), getActivity());
                return;
            }
            Prefs.saveString("password", "", getActivity());
            if (mFingerprint != null) {
                mFingerprint.setEnabled(false);
            }
        }
    }).setOnDismissListener(new DialogInterface.OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface dialogInterface) {
            mDeletePassword = null;
        }
    }).show();
}
Also used : AppCompatEditText(android.support.v7.widget.AppCompatEditText) DialogInterface(android.content.DialogInterface) Dialog(com.moro.mtweaks.views.dialog.Dialog) ProgressDialog(android.app.ProgressDialog) AlertDialog(android.support.v7.app.AlertDialog) LinearLayout(android.widget.LinearLayout)

Example 3 with Dialog

use of com.moro.mtweaks.views.dialog.Dialog in project MTweaks-KernelAdiutorMOD by morogoku.

the class ProfileActivity method onCreate.

@Override
protected void onCreate(@Nullable final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mItems.clear();
    boolean add = false;
    for (int id : NavigationActivity.sActualFragments.keySet()) {
        if (id == R.string.kernel) {
            add = true;
        } else if (add && NavigationActivity.sActualFragments.get(id) != null) {
            Fragment fragment = getSupportFragmentManager().findFragmentByTag(id + "_key");
            mItems.put(getString(id), fragment == null ? NavigationActivity.sActualFragments.get(id) : fragment);
        } else if (id == R.string.tools) {
            break;
        }
    }
    mItems.remove("Spectrum");
    if (mItems.size() < 1) {
        Utils.toast(R.string.sections_disabled, this);
        finish();
        return;
    }
    mProfilePosition = getIntent().getIntExtra(POSITION_INTENT, -1);
    if (savedInstanceState != null && (mMode = savedInstanceState.getInt("mode")) != 0) {
        if (mMode == 1) {
            initNewMode(savedInstanceState);
        } else {
            currentSettings();
        }
    } else {
        new Dialog(this).setItems(getResources().getStringArray(R.array.profile_modes), new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                switch(which) {
                    case 0:
                        initNewMode(savedInstanceState);
                        break;
                    case 1:
                        currentSettings();
                        break;
                }
            }
        }).setCancelable(false).show();
    }
}
Also used : DialogInterface(android.content.DialogInterface) Dialog(com.moro.mtweaks.views.dialog.Dialog) ApplyOnBootFragment(com.moro.mtweaks.fragments.ApplyOnBootFragment) DialogFragment(android.support.v4.app.DialogFragment) BaseFragment(com.moro.mtweaks.fragments.BaseFragment) Fragment(android.support.v4.app.Fragment)

Example 4 with Dialog

use of com.moro.mtweaks.views.dialog.Dialog in project MTweaks-KernelAdiutorMOD by morogoku.

the class BackupFragment method showBackupFlashingDialog.

private void showBackupFlashingDialog(final File file) {
    final LinkedHashMap<String, Backup.PARTITION> menu = getPartitionMenu();
    mBackupFlashingDialog = new Dialog(getActivity()).setItems(menu.keySet().toArray(new String[menu.size()]), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
            Backup.PARTITION partition = menu.values().toArray(new Backup.PARTITION[menu.size()])[i];
            if (file != null) {
                restore(partition, file, true);
            } else {
                backup(partition);
            }
        }
    }).setOnDismissListener(new DialogInterface.OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface dialogInterface) {
            mBackupFlashingDialog = null;
        }
    });
    mBackupFlashingDialog.show();
}
Also used : DialogInterface(android.content.DialogInterface) Dialog(com.moro.mtweaks.views.dialog.Dialog) ProgressDialog(android.app.ProgressDialog) Backup(com.moro.mtweaks.utils.tools.Backup)

Example 5 with Dialog

use of com.moro.mtweaks.views.dialog.Dialog in project MTweaks-KernelAdiutorMOD by morogoku.

the class BackupFragment method onTopFabClick.

@Override
protected void onTopFabClick() {
    super.onTopFabClick();
    if (mPermissionDenied) {
        Utils.toast(R.string.permission_denied_write_storage, getActivity());
        return;
    }
    mOptionsDialog = new Dialog(getActivity()).setItems(getResources().getStringArray(R.array.backup_options), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
            switch(i) {
                case 0:
                    showBackupFlashingDialog(null);
                    break;
                case 1:
                    Intent intent = new Intent(getActivity(), FilePickerActivity.class);
                    intent.putExtra(FilePickerActivity.PATH_INTENT, "/sdcard");
                    intent.putExtra(FilePickerActivity.EXTENSION_INTENT, ".img");
                    startActivityForResult(intent, 0);
                    break;
            }
        }
    }).setOnDismissListener(new DialogInterface.OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface dialogInterface) {
            mOptionsDialog = null;
        }
    });
    mOptionsDialog.show();
}
Also used : FilePickerActivity(com.moro.mtweaks.activities.FilePickerActivity) DialogInterface(android.content.DialogInterface) Dialog(com.moro.mtweaks.views.dialog.Dialog) ProgressDialog(android.app.ProgressDialog) Intent(android.content.Intent)

Aggregations

Dialog (com.moro.mtweaks.views.dialog.Dialog)20 DialogInterface (android.content.DialogInterface)19 ProgressDialog (android.app.ProgressDialog)6 Intent (android.content.Intent)6 LinearLayout (android.widget.LinearLayout)5 AppCompatEditText (android.support.v7.widget.AppCompatEditText)4 View (android.view.View)4 FilePickerActivity (com.moro.mtweaks.activities.FilePickerActivity)4 AlertDialog (android.support.v7.app.AlertDialog)3 ViewGroup (android.view.ViewGroup)2 TextView (android.widget.TextView)2 DescriptionView (com.moro.mtweaks.views.recyclerview.DescriptionView)2 RecyclerViewItem (com.moro.mtweaks.views.recyclerview.RecyclerViewItem)2 File (java.io.File)2 Activity (android.app.Activity)1 Bitmap (android.graphics.Bitmap)1 Drawable (android.graphics.drawable.Drawable)1 DialogFragment (android.support.v4.app.DialogFragment)1 Fragment (android.support.v4.app.Fragment)1 AppCompatImageView (android.support.v7.widget.AppCompatImageView)1