List<MobileLedgerProfile> list = new ArrayList<>();
SQLiteDatabase db = MLDB.getDatabase();
try (Cursor cursor = db.rawQuery("SELECT uuid, name, url, use_authentication, auth_user, " +
List<MobileLedgerProfile> list = new ArrayList<>();
SQLiteDatabase db = MLDB.getDatabase();
try (Cursor cursor = db.rawQuery("SELECT uuid, name, url, use_authentication, auth_user, " +
- "auth_password, permit_posting, theme, order_no FROM " +
+ "auth_password, permit_posting, theme, order_no, " +
+ "preferred_accounts_filter FROM " +
"profiles order by order_no", null))
{
while (cursor.moveToNext()) {
"profiles order by order_no", null))
{
while (cursor.moveToNext()) {
item.setPostingPermitted(cursor.getInt(6) == 1);
item.setThemeId(cursor.getInt(7));
item.orderNo = cursor.getInt(8);
item.setPostingPermitted(cursor.getInt(6) == 1);
item.setThemeId(cursor.getInt(7));
item.orderNo = cursor.getInt(8);
+ public String getPreferredAccountsFilter() {
+ return preferredAccountsFilter;
+ }
+ public void setPreferredAccountsFilter(String preferredAccountsFilter) {
+ this.preferredAccountsFilter = preferredAccountsFilter;
+ }
+ public void setPreferredAccountsFilter(CharSequence preferredAccountsFilter) {
+ setPreferredAccountsFilter(String.valueOf(preferredAccountsFilter));
+ }
-// Log.d("profiles", String.format("Storing profile in DB: uuid=%s, name=%s, " +
+// debug("profiles", String.format("Storing profile in DB: uuid=%s, name=%s, " +
// "url=%s, permit_posting=%s, authEnabled=%s, " +
// "themeId=%d", uuid, name, url,
// permitPosting ? "TRUE" : "FALSE", authEnabled ? "TRUE" : "FALSE", themeId));
db.execSQL("REPLACE INTO profiles(uuid, name, permit_posting, url, " +
"use_authentication, auth_user, " +
// "url=%s, permit_posting=%s, authEnabled=%s, " +
// "themeId=%d", uuid, name, url,
// permitPosting ? "TRUE" : "FALSE", authEnabled ? "TRUE" : "FALSE", themeId));
db.execSQL("REPLACE INTO profiles(uuid, name, permit_posting, url, " +
"use_authentication, auth_user, " +
- "auth_password, theme, order_no) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)",
+ "auth_password, theme, order_no, preferred_accounts_filter) " +
+ "VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
new Object[]{uuid, name, permitPosting, url, authEnabled,
authEnabled ? authUserName : null,
new Object[]{uuid, name, permitPosting, url, authEnabled,
authEnabled ? authUserName : null,
- authEnabled ? authPassword : null, themeId, orderNo
+ authEnabled ? authPassword : null, themeId, orderNo,
+ preferredAccountsFilter
new Object[]{uuid, acc.getName(), acc.getName().toUpperCase(), acc.getParentName(),
acc.getLevel(), acc.isHiddenByStar(), acc.isExpanded()
});
new Object[]{uuid, acc.getName(), acc.getName().toUpperCase(), acc.getParentName(),
acc.getLevel(), acc.isHiddenByStar(), acc.isExpanded()
});
-// Log.d("accounts", String.format("Stored account '%s' in DB [%s]", acc.getName(), uuid));
+// debug("accounts", String.format("Stored account '%s' in DB [%s]", acc.getName(), uuid));
}
public void storeAccountValue(SQLiteDatabase db, String name, String currency, Float amount) {
db.execSQL("replace into account_values(profile, account, " +
}
public void storeAccountValue(SQLiteDatabase db, String name, String currency, Float amount) {
db.execSQL("replace into account_values(profile, account, " +
}
public String getOption(String name, String default_value) {
SQLiteDatabase db = MLDB.getDatabase();
}
public String getOption(String name, String default_value) {
SQLiteDatabase db = MLDB.getDatabase();
- else Log.d("profile", String.format("option %s=%s", name, result));
+ else debug("profile", String.format("option %s=%s", name, result));
long longResult;
String result = getOption(name, "");
if ((result == null) || result.isEmpty()) {
long longResult;
String result = getOption(name, "");
if ((result == null) || result.isEmpty()) {
- Log.d("profile", String.format("option %s=%s", name, result));
+ debug("profile", String.format("option %s=%s", name, result));
- Log.d("profile", String.format("Returning default value for option %s", name), e);
+ debug("profile", String.format("Returning default value for option %s", name), e);
- Log.d("profile", String.format("setting option %s=%s", name, value));
+ debug("profile", String.format("setting option %s=%s", name, value));
DbOpQueue.add("insert or replace into options(profile, name, value) values(?, ?, ?);",
new String[]{uuid, name, value});
}
DbOpQueue.add("insert or replace into options(profile, name, value) values(?, ?, ?);",
new String[]{uuid, name, value});
}
return this.themeId;
}
public void setThemeId(Object o) {
setThemeId(Integer.valueOf(String.valueOf(o)).intValue());
}
public void setThemeId(int themeId) {
return this.themeId;
}
public void setThemeId(Object o) {
setThemeId(Integer.valueOf(String.valueOf(o)).intValue());
}
public void setThemeId(int themeId) {
db.execSQL("DELETE FROM transactions WHERE profile=? AND keep = 0", new String[]{uuid});
}
public void setLastUpdateStamp() {
db.execSQL("DELETE FROM transactions WHERE profile=? AND keep = 0", new String[]{uuid});
}
public void setLastUpdateStamp() {
}
public List<LedgerAccount> loadChildAccountsOf(LedgerAccount acc) {
List<LedgerAccount> result = new ArrayList<>();
}
public List<LedgerAccount> loadChildAccountsOf(LedgerAccount acc) {
List<LedgerAccount> result = new ArrayList<>();
+ public void wipeAllData() {
+ SQLiteDatabase db = MLDB.getDatabase();
+ db.beginTransaction();
+ try {
+ String[] pUuid = new String[]{uuid};
+ db.execSQL("delete from options where profile=?", pUuid);
+ db.execSQL("delete from accounts where profile=?", pUuid);
+ db.execSQL("delete from account_values where profile=?", pUuid);
+ db.execSQL("delete from transactions where profile=?", pUuid);
+ db.execSQL("delete from transaction_accounts where profile=?", pUuid);
+ db.setTransactionSuccessful();
+ }
+ finally {
+ db.endTransaction();
+ }
+ }