Fixed issue#31 concerning profile edit without password
This commit is contained in:
parent
1d8925c53e
commit
f7ad4460db
|
@ -51,7 +51,7 @@ import static android.view.View.VISIBLE;
|
||||||
|
|
||||||
public abstract class BaseActivity extends AppCompatActivity implements
|
public abstract class BaseActivity extends AppCompatActivity implements
|
||||||
OnClickListener, OnDAppClickListener, OnProfileClickListener, OnLongClickListener, ProfilesChangeListener {
|
OnClickListener, OnDAppClickListener, OnProfileClickListener, OnLongClickListener, ProfilesChangeListener {
|
||||||
|
|
||||||
private static final int DRAWER_CLOSE_DELAY_SHORT = 200;
|
private static final int DRAWER_CLOSE_DELAY_SHORT = 200;
|
||||||
private static final int DRAWER_CLOSE_DELAY_LONG = 400;
|
private static final int DRAWER_CLOSE_DELAY_LONG = 400;
|
||||||
|
|
||||||
|
@ -283,9 +283,6 @@ public abstract class BaseActivity extends AppCompatActivity implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("ConstantConditions")
|
|
||||||
|
|
||||||
|
|
||||||
private void flipDrawer() {
|
private void flipDrawer() {
|
||||||
ImageView imageView = (ImageView) findViewById(R.id.drawer_indicator);
|
ImageView imageView = (ImageView) findViewById(R.id.drawer_indicator);
|
||||||
if (isDrawerFrontViewActive()) {
|
if (isDrawerFrontViewActive()) {
|
||||||
|
@ -320,10 +317,9 @@ public abstract class BaseActivity extends AppCompatActivity implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onProfileClick(Profile profile) {
|
public void onProfileClick(Profile profile) {
|
||||||
if (ProfileManager.getCurrentProfile().getId().equals(profile.getId())) {
|
if (!ProfileManager.getCurrentProfile().getId().equals(profile.getId())) {
|
||||||
return;
|
requestChangeProfile(profile);
|
||||||
}
|
}
|
||||||
requestChangeProfile(profile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -339,8 +335,34 @@ public abstract class BaseActivity extends AppCompatActivity implements
|
||||||
@SuppressWarnings("ConstantConditions")
|
@SuppressWarnings("ConstantConditions")
|
||||||
@Override
|
@Override
|
||||||
public void onProfilePress(final Profile profile) {
|
public void onProfilePress(final Profile profile) {
|
||||||
ProfileDialogFragment dialogFragment = ProfileDialogFragment.newInstance(profile);
|
if (ProfileManager.getCurrentProfile().getId().equals(profile.getId())) {
|
||||||
dialogFragment.show(getSupportFragmentManager(), "profile_dialog");
|
ProfileDialogFragment dialogFragment = ProfileDialogFragment.newInstance(profile);
|
||||||
|
dialogFragment.show(getSupportFragmentManager(), "profile_dialog");
|
||||||
|
} else {
|
||||||
|
Dialog dialog = new MaterialDialog.Builder(BaseActivity.this)
|
||||||
|
.title(R.string.request_profile_password)
|
||||||
|
.customView(R.layout.profile_password, true)
|
||||||
|
.positiveText(R.string.ok)
|
||||||
|
.negativeText(R.string.cancel)
|
||||||
|
.callback(new MaterialDialog.ButtonCallback() {
|
||||||
|
@SuppressWarnings("ConstantConditions")
|
||||||
|
@Override
|
||||||
|
public void onPositive(MaterialDialog dialog) {
|
||||||
|
View view = dialog.getCustomView();
|
||||||
|
EditText password = (EditText) view.findViewById(R.id.et_pass);
|
||||||
|
if (profile.checkPassword(password.getText().toString())) {
|
||||||
|
ProfileDialogFragment dialogFragment = ProfileDialogFragment.newInstance(profile);
|
||||||
|
dialogFragment.show(getSupportFragmentManager(), "profile_dialog");
|
||||||
|
} else {
|
||||||
|
Toast.makeText(BaseActivity.this, "Password is not correct", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.show();
|
||||||
|
EditText name = (EditText) dialog.findViewById(R.id.et_pass);
|
||||||
|
GeneralUtil.showKeyBoard(name, this);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue