public final class MobileLedgerProfile {
private String uuid;
private String name;
+ private boolean permitPosting;
private String url;
private boolean authEnabled;
private String authUserName;
private String authPassword;
- public MobileLedgerProfile(String uuid, String name, String url, boolean authEnabled,
- String authUserName, String authPassword) {
+ public MobileLedgerProfile(String uuid, String name, boolean permitPosting, String url,
+ boolean authEnabled, String authUserName, String authPassword) {
this.uuid = uuid;
this.name = name;
+ this.permitPosting = permitPosting;
this.url = url;
this.authEnabled = authEnabled;
this.authUserName = authUserName;
this.authPassword = authPassword;
}
- public MobileLedgerProfile(CharSequence name, CharSequence url, boolean authEnabled,
- CharSequence authUserName, CharSequence authPassword) {
+ public MobileLedgerProfile(CharSequence name, boolean permitPosting, CharSequence url,
+ boolean authEnabled, CharSequence authUserName,
+ CharSequence authPassword) {
this.uuid = String.valueOf(UUID.randomUUID());
this.name = String.valueOf(name);
+ this.permitPosting = permitPosting;
this.url = String.valueOf(url);
this.authEnabled = authEnabled;
this.authUserName = String.valueOf(authUserName);
List<MobileLedgerProfile> list = new ArrayList<>();
SQLiteDatabase db = MLDB.getReadableDatabase();
try (Cursor cursor = db.rawQuery("SELECT uuid, name, url, use_authentication, auth_user, " +
- "auth_password FROM profiles order by order_no", null))
+ "auth_password, permit_posting FROM profiles order by " +
+ "order_no", null))
{
while (cursor.moveToNext()) {
MobileLedgerProfile item =
new MobileLedgerProfile(cursor.getString(0), cursor.getString(1),
- cursor.getString(2), cursor.getInt(3) == 1, cursor.getString(4),
- cursor.getString(5));
+ cursor.getInt(6) == 1, cursor.getString(2), cursor.getInt(3) == 1,
+ cursor.getString(4), cursor.getString(5));
list.add(item);
if (item.getUuid().equals(currentProfileUUID)) result = item;
}
}
}
+ public boolean isPostingPermitted() {
+ return permitPosting;
+ }
public String getUuid() {
return uuid;
}
SQLiteDatabase db = MLDB.getWritableDatabase();
db.beginTransaction();
try {
- db.execSQL("REPLACE INTO profiles(uuid, name, url, use_authentication, auth_user, " +
- "auth_password) VALUES(?, ?, ?, ?, ?, ?)",
- new Object[]{uuid, name, url, authEnabled, authEnabled ? authUserName : null,
+ db.execSQL("REPLACE INTO profiles(uuid, name, permit_posting, url, " +
+ "use_authentication, auth_user, " +
+ "auth_password) VALUES(?, ?, ?, ?, ?, ?, ?)",
+ new Object[]{uuid, name, permitPosting, url, authEnabled,
+ authEnabled ? authUserName : null,
authEnabled ? authPassword : null
});
db.setTransactionSuccessful();
*/
private MobileLedgerProfile mProfile;
private TextView url;
+ private Switch postingPermitted;
private TextInputLayout urlLayout;
private LinearLayout authParams;
private Switch useAuthentication;
}
}
else {
- mProfile = new MobileLedgerProfile(profileName.getText(), url.getText(),
- useAuthentication.isChecked(), userName.getText(), password.getText());
+ mProfile = new MobileLedgerProfile(profileName.getText(), postingPermitted.isChecked(),
+ url.getText(), useAuthentication.isChecked(), userName.getText(),
+ password.getText());
mProfile.storeInDB();
Data.profiles.add(mProfile);
MobileLedgerProfile.storeProfilesOrder();
profileNameLayout = rootView.findViewById(R.id.profile_name_layout);
url = rootView.findViewById(R.id.url);
urlLayout = rootView.findViewById(R.id.url_layout);
+ postingPermitted = rootView.findViewById(R.id.profile_permit_posting);
authParams = rootView.findViewById(R.id.auth_params);
useAuthentication = rootView.findViewById(R.id.enable_http_auth);
userName = rootView.findViewById(R.id.auth_user_name);
if (mProfile != null) {
profileName.setText(mProfile.getName());
+ postingPermitted.setChecked(mProfile.isPostingPermitted());
url.setText(mProfile.getUrl());
useAuthentication.setChecked(mProfile.isAuthEnabled());
authParams.setVisibility(mProfile.isAuthEnabled() ? View.VISIBLE : View.GONE);
else {
profileName.setText("");
url.setText("");
+ postingPermitted.setChecked(true);
useAuthentication.setChecked(false);
authParams.setVisibility(View.GONE);
userName.setText("");