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();
}
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();
}
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();
}
}
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();
}
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();
}
Aggregations