<?xml version="1.0" encoding="utf-8"?>
<!--
- ~ Copyright © 2018 Damyan Ivanov.
+ ~ Copyright © 2019 Damyan Ivanov.
~ This file is part of Mobile-Ledger.
~ Mobile-Ledger is free software: you can distribute it and/or modify it
~ under the term of the GNU General Public License as published by
android:theme="@style/AppTheme">
<activity
android:name=".ui.activity.MainActivity"
- android:label="@string/account_summary_title"
+ android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
/*
- * Copyright © 2018 Damyan Ivanov.
+ * Copyright © 2019 Damyan Ivanov.
* This file is part of Mobile-Ledger.
* Mobile-Ledger is free software: you can distribute it and/or modify it
* under the term of the GNU General Public License as published by
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;
-import net.ktnx.mobileledger.ui.account_summary.AccountSummaryFragment;
import net.ktnx.mobileledger.R;
import net.ktnx.mobileledger.model.LedgerAccount;
+import net.ktnx.mobileledger.ui.account_summary.AccountSummaryFragment;
import net.ktnx.mobileledger.utils.MLDB;
import net.ktnx.mobileledger.utils.NetworkUtil;
try {
HttpURLConnection http = NetworkUtil.prepare_connection(pref, "add");
publishProgress(0);
- try (SQLiteDatabase db = MLDB.getWritableDatabase(mContext.get().getActivity())) {
+ try (SQLiteDatabase db = MLDB.getWritableDatabase()) {
try (InputStream resp = http.getInputStream()) {
Log.d("update_accounts", String.valueOf(http.getResponseCode()));
if (http.getResponseCode() != 200) {
/*
- * Copyright © 2018 Damyan Ivanov.
+ * Copyright © 2019 Damyan Ivanov.
* This file is part of Mobile-Ledger.
* Mobile-Ledger is free software: you can distribute it and/or modify it
* under the term of the GNU General Public License as published by
publishProgress(progress);
TransactionListFragment ctx = getContext();
if (ctx == null) return null;
- try (SQLiteDatabase db = MLDB.getWritableDatabase(ctx.getActivity())) {
+ try (SQLiteDatabase db = MLDB.getWritableDatabase()) {
try (InputStream resp = http.getInputStream()) {
if (http.getResponseCode() != 200) throw new IOException(
String.format("HTTP error %d", http.getResponseCode()));
if (success && !isCancelled()) {
Log.d("db", "Updating transaction list stamp");
- MLDB.set_option_value(ctx.getActivity(), MLDB.OPT_TRANSACTION_LIST_STAMP,
+ MLDB.set_option_value(MLDB.OPT_TRANSACTION_LIST_STAMP,
new Date().getTime());
ctx.model.reloadTransactions(ctx);
}
/*
- * Copyright © 2018 Damyan Ivanov.
+ * Copyright © 2019 Damyan Ivanov.
* This file is part of Mobile-Ledger.
* Mobile-Ledger is free software: you can distribute it and/or modify it
* under the term of the GNU General Public License as published by
import android.view.ViewGroup;
import net.ktnx.mobileledger.R;
-import net.ktnx.mobileledger.ui.RecyclerItemListener;
import net.ktnx.mobileledger.async.RetrieveAccountsTask;
import net.ktnx.mobileledger.model.LedgerAccount;
+import net.ktnx.mobileledger.ui.RecyclerItemListener;
import net.ktnx.mobileledger.ui.activity.MainActivity;
import net.ktnx.mobileledger.utils.MLDB;
}
private void prepare_db() {
- account_list_last_updated = MLDB.get_option_value(mActivity, "last_refresh", (long) 0);
+ account_list_last_updated = MLDB.get_option_value("last_refresh", (long) 0);
}
private void update_accounts(boolean force) {
Snackbar.make(swiper, err_text, Snackbar.LENGTH_LONG).show();
}
else {
- MLDB.set_option_value(mActivity, "last_refresh", new Date().getTime());
+ MLDB.set_option_value("last_refresh", new Date().getTime());
update_account_table();
}
}
/*
- * Copyright © 2018 Damyan Ivanov.
+ * Copyright © 2019 Damyan Ivanov.
* This file is part of Mobile-Ledger.
* Mobile-Ledger is free software: you can distribute it and/or modify it
* under the term of the GNU General Public License as published by
public static SQLiteDatabase getReadableDatabase() {
return getDatabase(READ);
}
- public static SQLiteDatabase getWritableDatabase(Context context) {
+ public static SQLiteDatabase getWritableDatabase() {
return getDatabase(WRITE);
}
- static public int get_option_value(Context context, String name, int default_value) {
- String s = get_option_value(context, name, String.valueOf(default_value));
+ static public int get_option_value(String name, int default_value) {
+ String s = get_option_value(name, String.valueOf(default_value));
try {
return Integer.parseInt(s);
}
return default_value;
}
}
- static public long get_option_value(Context context, String name, long default_value) {
- String s = get_option_value(context, name, String.valueOf(default_value));
+ static public long get_option_value(String name, long default_value) {
+ String s = get_option_value(name, String.valueOf(default_value));
try {
return Long.parseLong(s);
}
return default_value;
}
}
- static public String get_option_value(Context context, String name, String default_value) {
+ static public String get_option_value(String name, String default_value) {
Log.d("db", "about to fetch option " + name);
try (SQLiteDatabase db = getReadableDatabase()) {
try (Cursor cursor = db
}
}
}
- static public void set_option_value(Context context, String name, String value) {
+ static public void set_option_value(String name, String value) {
Log.d("db", "setting option " + name + "=" + value);
- try (SQLiteDatabase db = getWritableDatabase(context)) {
+ try (SQLiteDatabase db = getWritableDatabase()) {
db.execSQL("insert or replace into options(name, value) values(?, ?);",
new String[]{name, value});
}
}
- static public void set_option_value(Context context, String name, long value) {
- set_option_value(context, name, String.valueOf(value));
+ static public void set_option_value(String name, long value) {
+ set_option_value(name, String.valueOf(value));
}
@TargetApi(Build.VERSION_CODES.N)
public static void hook_autocompletion_adapter(final Context context,