import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.textfield.TextInputLayout;
+import net.ktnx.mobileledger.BuildConfig;
import net.ktnx.mobileledger.R;
import net.ktnx.mobileledger.model.Data;
import net.ktnx.mobileledger.model.MobileLedgerProfile;
builder.setPositiveButton(R.string.Remove, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
- Log.d("profiles", String.format("[fragment] removing profile %s", mProfile.getUuid()));
+ Log.d("profiles",
+ String.format("[fragment] removing profile %s", mProfile.getUuid()));
mProfile.removeFromDB();
Data.profiles.remove(mProfile);
if (Data.profile.get().equals(mProfile)) {
return false;
});
menuDeleteProfile.setVisible((mProfile != null) && (Data.profiles.size() > 1));
+
+ if (BuildConfig.DEBUG) {
+ final MenuItem menuWipeProfileData = menu.findItem(R.id.menuWipeData);
+ menuWipeProfileData.setOnMenuItemClickListener(this::onWipeDataMenuClicked);
+ menuWipeProfileData.setVisible(mProfile != null);
+ }
+ }
+ private boolean onWipeDataMenuClicked(MenuItem item) {
+ // this is a development option, so no confirmation
+ mProfile.wipeAllData();
+ Data.profile.forceNotifyObservers();
+ return true;
}
@Override
public void onCreate(Bundle savedInstanceState) {
if (mProfile.getUuid().equals(Data.profile.get().getUuid())) {
// dummy update to notify the observers of the possibly new name/URL
- Data.profile.set(mProfile);
+ Data.profile.forceNotifyObservers();
}
}
else {
if (isChecked) userName.requestFocus();
});
- preferredAccountsFilter.setText(mProfile.getPreferredAccountsFilter());
postingPermitted.setOnCheckedChangeListener(((buttonView, isChecked) -> {
preferredAccountsFilterLayout.setVisibility(isChecked ? View.VISIBLE : View.GONE);
}));
authParams.setVisibility(mProfile.isAuthEnabled() ? View.VISIBLE : View.GONE);
userName.setText(mProfile.isAuthEnabled() ? mProfile.getAuthUserName() : "");
password.setText(mProfile.isAuthEnabled() ? mProfile.getAuthPassword() : "");
+ preferredAccountsFilter.setText(mProfile.getPreferredAccountsFilter());
profileThemeId = mProfile.getThemeId();
}
else {
authParams.setVisibility(View.GONE);
userName.setText("");
password.setText("");
+ preferredAccountsFilter.setText(null);
profileThemeId = -1;
}
huePickerView.setTag(profileThemeId);
huePickerView.setOnClickListener(v -> {
HueRingDialog d = new HueRingDialog(
- Objects.requireNonNull(ProfileDetailFragment.this.getContext()), hue);
+ Objects.requireNonNull(ProfileDetailFragment.this.getContext()),
+ profileThemeId, (Integer) v.getTag());
d.show();
d.setColorSelectedListener(this);
});