private String uuid;
private String name;
private boolean permitPosting;
+ private boolean showCommodityByDefault;
private String preferredAccountsFilter;
private String url;
private boolean authEnabled;
uuid = origin.uuid;
name = origin.name;
permitPosting = origin.permitPosting;
+ showCommodityByDefault = origin.showCommodityByDefault;
preferredAccountsFilter = origin.preferredAccountsFilter;
url = origin.url;
authEnabled = origin.authEnabled;
SQLiteDatabase db = App.getDatabase();
try (Cursor cursor = db.rawQuery("SELECT uuid, name, url, use_authentication, auth_user, " +
"auth_password, permit_posting, theme, order_no, " +
- "preferred_accounts_filter, future_dates, api_version " +
- "FROM " + "profiles order by order_no", null))
+ "preferred_accounts_filter, future_dates, api_version, " +
+ "show_commodity_by_default FROM " +
+ "profiles order by order_no", null))
{
while (cursor.moveToNext()) {
MobileLedgerProfile item = new MobileLedgerProfile(cursor.getString(0));
item.setPreferredAccountsFilter(cursor.getString(9));
item.setFutureDates(cursor.getInt(10));
item.setApiVersion(cursor.getInt(11));
+ item.setShowCommodityByDefault(cursor.getInt(12) == 1);
list.add(item);
if (item.getUuid()
.equals(currentProfileUUID))
db.endTransaction();
}
}
+ public boolean getShowCommodityByDefault() {
+ return showCommodityByDefault;
+ }
+ public void setShowCommodityByDefault(boolean showCommodityByDefault) {
+ this.showCommodityByDefault = showCommodityByDefault;
+ }
public SendTransactionTask.API getApiVersion() {
return apiVersion;
}
// "themeHue=%d", uuid, name, url,
// permitPosting ? "TRUE" : "FALSE", authEnabled ? "TRUE" : "FALSE", themeHue));
db.execSQL("REPLACE INTO profiles(uuid, name, permit_posting, url, " +
- "use_authentication, auth_user, " +
- "auth_password, theme, order_no, preferred_accounts_filter, future_dates, " +
- "api_version) " + "VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
+ "use_authentication, auth_user, auth_password, theme, order_no, " +
+ "preferred_accounts_filter, future_dates, api_version, " +
+ "show_commodity_by_default) " +
+ "VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
new Object[]{uuid, name, permitPosting, url, authEnabled,
authEnabled ? authUserName : null,
authEnabled ? authPassword : null, themeHue, orderNo,
- preferredAccountsFilter, futureDates.toInt(), apiVersion.toInt()
+ preferredAccountsFilter, futureDates.toInt(), apiVersion.toInt(),
+ showCommodityByDefault
});
db.setTransactionSuccessful();
}
list = activity.findViewById(R.id.new_transaction_accounts);
viewModel = new ViewModelProvider(activity).get(NewTransactionModel.class);
+ viewModel.observeDataProfile(this);
mProfile = Data.profile.getValue();
listAdapter = new NewTransactionItemsAdapter(viewModel, mProfile);
list.setAdapter(listAdapter);
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
+import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.Observer;
import net.ktnx.mobileledger.BuildConfig;
import net.ktnx.mobileledger.model.Currency;
+import net.ktnx.mobileledger.model.Data;
import net.ktnx.mobileledger.model.LedgerTransactionAccount;
+import net.ktnx.mobileledger.model.MobileLedgerProfile;
import net.ktnx.mobileledger.utils.Logger;
import net.ktnx.mobileledger.utils.Misc;
*/
private final HashMap<String, List<Item>> slots = new HashMap<>();
private int checkHoldCounter = 0;
+ private Observer<MobileLedgerProfile> profileObserver = profile ->showCurrency.postValue(profile.getShowCommodityByDefault());
+ public void observeDataProfile(LifecycleOwner activity) {
+ Data.profile.observe(activity, profileObserver);
+ }
void holdSubmittableChecks() {
checkHoldCounter++;
}
private MobileLedgerProfile mProfile;
private TextView url;
private Switch postingPermitted;
+ private Switch showCommodityByDefault;
private TextInputLayout urlLayout;
private LinearLayout authParams;
private Switch useAuthentication;
url = context.findViewById(R.id.url);
urlLayout = context.findViewById(R.id.url_layout);
postingPermitted = context.findViewById(R.id.profile_permit_posting);
+ showCommodityByDefault = context.findViewById(R.id.profile_show_commodity);
futureDatesLayout = context.findViewById(R.id.future_dates_layout);
futureDatesText = context.findViewById(R.id.future_dates_text);
context.findViewById(R.id.future_dates_layout)
if (mProfile != null) {
profileName.setText(mProfile.getName());
postingPermitted.setChecked(mProfile.isPostingPermitted());
+ showCommodityByDefault.setChecked(mProfile.getShowCommodityByDefault());
futureDates = mProfile.getFutureDates();
futureDatesText.setText(futureDates.getText(getResources()));
apiVersion = mProfile.getApiVersion();
profileName.setText("");
url.setText(HTTPS_URL_START);
postingPermitted.setChecked(true);
+ showCommodityByDefault.setChecked(false);
futureDates = MobileLedgerProfile.FutureDates.None;
futureDatesText.setText(futureDates.getText(getResources()));
apiVersion = SendTransactionTask.API.auto;
mProfile.setName(profileName.getText());
mProfile.setUrl(url.getText());
mProfile.setPostingPermitted(postingPermitted.isChecked());
+ mProfile.setShowCommodityByDefault(showCommodityByDefault.isChecked());
mProfile.setPreferredAccountsFilter(preferredAccountsFilter.getText());
mProfile.setAuthEnabled(useAuthentication.isChecked());
mProfile.setAuthUserName(userName.getText());
public class MobileLedgerDatabase extends SQLiteOpenHelper {
private static final String DB_NAME = "MoLe.db";
- private static final int LATEST_REVISION = 26;
+ private static final int LATEST_REVISION = 27;
private static final String CREATE_DB_SQL = "create_db";
private final Application mContext;
android:text="@string/posting_permitted"
android:textAppearance="?android:textAppearanceListItem" />
+ <Switch
+ android:id="@+id/profile_show_commodity"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="16dp"
+ android:text="@string/currency_input_by_default"
+ android:textAppearance="?android:textAppearanceListItem"/>
+
<LinearLayout
android:id="@+id/future_dates_layout"
android:layout_width="match_parent"
create table account_values(profile varchar not null, account varchar not null, currency varchar not null default '', keep boolean, value decimal not null );
create unique index un_account_values on account_values(profile,account,currency);
create table description_history(description varchar not null primary key, keep boolean, description_upper varchar);
-create table profiles(uuid varchar not null primary key, name not null, url not null, use_authentication boolean not null, auth_user varchar, auth_password varchar, order_no integer, permit_posting boolean default 0, theme integer default -1, preferred_accounts_filter varchar, future_dates integer, api_version integer);
+create table profiles(uuid varchar not null primary key, name not null, url not null, use_authentication boolean not null, auth_user varchar, auth_password varchar, order_no integer, permit_posting boolean default 0, theme integer default -1, preferred_accounts_filter varchar, future_dates integer, api_version integer, show_commodity_by_default boolean default 0);
create table transactions(profile varchar not null, id integer not null, data_hash varchar not null, date varchar not null, description varchar not null, keep boolean not null default 0);
create unique index un_transactions_id on transactions(profile,id);
create unique index un_transactions_data_hash on transactions(profile,data_hash);
--- /dev/null
+alter table profiles add show_commodity_by_default boolean default 0;
\ No newline at end of file
<string name="currency_position_right">Вдясно</string>
<string name="new_currency_name_hint">валута/ценност</string>
<string name="show_currency_input">Валута</string>
+ <string name="currency_input_by_default">Показване по подразбиране на полето за валута</string>
</resources>
<string name="currency_position_right">Right</string>
<string name="currency_has_gap">Offset from the value</string>
<string name="show_currency_input">Currency</string>
+ <string name="currency_input_by_default">Commodity input visible by default</string>
</resources>