From 6b740c280c79b0170321f533747cdbfc3e179a29 Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Fri, 14 Dec 2018 20:56:35 +0000 Subject: [PATCH] separate packages for the different aspects of the application --- .../net/ktnx/mobileledger/AccountSummary.java | 6 +- .../mobileledger/AccountSummaryViewModel.java | 3 + .../mobileledger/NewTransactionActivity.java | 9 ++- .../{ => async}/RetrieveAccountsTask.java | 14 ++-- .../{ => async}/RetrieveTransactionsTask.java | 66 ++++++++++--------- .../{ => async}/SaveTransactionTask.java | 13 ++-- .../{ => async}/TaskCallback.java | 4 +- .../{ => model}/LedgerAccount.java | 16 ++--- .../{ => model}/LedgerAmount.java | 4 +- .../{ => model}/LedgerTransaction.java | 14 ++-- .../{ => model}/LedgerTransactionItem.java | 8 +-- .../{ => ui}/DatePickerFragment.java | 4 +- .../{ => utils}/DimensionUtils.java | 2 +- .../{ => utils}/MobileLedgerDatabase.java | 28 ++++---- .../mobileledger/{ => utils}/NetworkUtil.java | 7 +- .../{ => utils}/UrlEncodedFormData.java | 8 +-- 16 files changed, 119 insertions(+), 87 deletions(-) rename app/src/main/java/net/ktnx/mobileledger/{ => async}/RetrieveAccountsTask.java (94%) rename app/src/main/java/net/ktnx/mobileledger/{ => async}/RetrieveTransactionsTask.java (87%) rename app/src/main/java/net/ktnx/mobileledger/{ => async}/SaveTransactionTask.java (93%) rename app/src/main/java/net/ktnx/mobileledger/{ => async}/TaskCallback.java (91%) rename app/src/main/java/net/ktnx/mobileledger/{ => model}/LedgerAccount.java (90%) rename app/src/main/java/net/ktnx/mobileledger/{ => model}/LedgerAmount.java (95%) rename app/src/main/java/net/ktnx/mobileledger/{ => model}/LedgerTransaction.java (86%) rename app/src/main/java/net/ktnx/mobileledger/{ => model}/LedgerTransactionItem.java (88%) rename app/src/main/java/net/ktnx/mobileledger/{ => ui}/DatePickerFragment.java (98%) rename app/src/main/java/net/ktnx/mobileledger/{ => utils}/DimensionUtils.java (96%) rename app/src/main/java/net/ktnx/mobileledger/{ => utils}/MobileLedgerDatabase.java (83%) rename app/src/main/java/net/ktnx/mobileledger/{ => utils}/NetworkUtil.java (90%) rename app/src/main/java/net/ktnx/mobileledger/{ => utils}/UrlEncodedFormData.java (91%) diff --git a/app/src/main/java/net/ktnx/mobileledger/AccountSummary.java b/app/src/main/java/net/ktnx/mobileledger/AccountSummary.java index b6b2b3b7..91829498 100644 --- a/app/src/main/java/net/ktnx/mobileledger/AccountSummary.java +++ b/app/src/main/java/net/ktnx/mobileledger/AccountSummary.java @@ -41,6 +41,10 @@ import android.view.MenuItem; import android.view.View; import android.widget.LinearLayout; +import net.ktnx.mobileledger.async.RetrieveAccountsTask; +import net.ktnx.mobileledger.model.LedgerAccount; +import net.ktnx.mobileledger.utils.MobileLedgerDatabase; + import java.lang.ref.WeakReference; import java.util.Date; import java.util.List; @@ -259,7 +263,7 @@ public class AccountSummary extends AppCompatActivity { task.execute(); } - void onAccountRefreshDone(int error) { + public void onAccountRefreshDone(int error) { SwipeRefreshLayout srl = findViewById(R.id.account_swiper); srl.setRefreshing(false); if (error != 0) { diff --git a/app/src/main/java/net/ktnx/mobileledger/AccountSummaryViewModel.java b/app/src/main/java/net/ktnx/mobileledger/AccountSummaryViewModel.java index 0a523c7f..f01907b3 100644 --- a/app/src/main/java/net/ktnx/mobileledger/AccountSummaryViewModel.java +++ b/app/src/main/java/net/ktnx/mobileledger/AccountSummaryViewModel.java @@ -36,6 +36,9 @@ import android.widget.CheckBox; import android.widget.LinearLayout; import android.widget.TextView; +import net.ktnx.mobileledger.model.LedgerAccount; +import net.ktnx.mobileledger.utils.MobileLedgerDatabase; + import java.util.ArrayList; import java.util.List; diff --git a/app/src/main/java/net/ktnx/mobileledger/NewTransactionActivity.java b/app/src/main/java/net/ktnx/mobileledger/NewTransactionActivity.java index 85c51209..4950a1ef 100644 --- a/app/src/main/java/net/ktnx/mobileledger/NewTransactionActivity.java +++ b/app/src/main/java/net/ktnx/mobileledger/NewTransactionActivity.java @@ -51,12 +51,17 @@ import android.widget.TableLayout; import android.widget.TableRow; import android.widget.TextView; +import net.ktnx.mobileledger.async.SaveTransactionTask; +import net.ktnx.mobileledger.async.TaskCallback; +import net.ktnx.mobileledger.model.LedgerTransaction; +import net.ktnx.mobileledger.model.LedgerTransactionItem; +import net.ktnx.mobileledger.ui.DatePickerFragment; +import net.ktnx.mobileledger.utils.MobileLedgerDatabase; + import java.util.Date; import java.util.Objects; /* - * TODO: auto-fill of transaction description - * if Android O's implementation won't work, add a custom one * TODO: nicer progress while transaction is submitted * TODO: latest transactions, maybe with browsing further in the past? * TODO: reports diff --git a/app/src/main/java/net/ktnx/mobileledger/RetrieveAccountsTask.java b/app/src/main/java/net/ktnx/mobileledger/async/RetrieveAccountsTask.java similarity index 94% rename from app/src/main/java/net/ktnx/mobileledger/RetrieveAccountsTask.java rename to app/src/main/java/net/ktnx/mobileledger/async/RetrieveAccountsTask.java index 6e66453b..8117a198 100644 --- a/app/src/main/java/net/ktnx/mobileledger/RetrieveAccountsTask.java +++ b/app/src/main/java/net/ktnx/mobileledger/async/RetrieveAccountsTask.java @@ -15,12 +15,18 @@ * along with Mobile-Ledger. If not, see . */ -package net.ktnx.mobileledger; +package net.ktnx.mobileledger.async; import android.content.SharedPreferences; import android.database.sqlite.SQLiteDatabase; import android.util.Log; +import net.ktnx.mobileledger.AccountSummary; +import net.ktnx.mobileledger.R; +import net.ktnx.mobileledger.model.LedgerAccount; +import net.ktnx.mobileledger.utils.MobileLedgerDatabase; +import net.ktnx.mobileledger.utils.NetworkUtil; + import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.IOException; @@ -33,18 +39,18 @@ import java.net.URLDecoder; import java.util.regex.Matcher; import java.util.regex.Pattern; -class RetrieveAccountsTask extends android.os.AsyncTask { +public class RetrieveAccountsTask extends android.os.AsyncTask { int error; private SharedPreferences pref; WeakReference mContext; - RetrieveAccountsTask(WeakReference context) { + public RetrieveAccountsTask(WeakReference context) { mContext = context; error = 0; } - void setPref(SharedPreferences pref) { + public void setPref(SharedPreferences pref) { this.pref = pref; } diff --git a/app/src/main/java/net/ktnx/mobileledger/RetrieveTransactionsTask.java b/app/src/main/java/net/ktnx/mobileledger/async/RetrieveTransactionsTask.java similarity index 87% rename from app/src/main/java/net/ktnx/mobileledger/RetrieveTransactionsTask.java rename to app/src/main/java/net/ktnx/mobileledger/async/RetrieveTransactionsTask.java index 4131a213..aeb49a5f 100644 --- a/app/src/main/java/net/ktnx/mobileledger/RetrieveTransactionsTask.java +++ b/app/src/main/java/net/ktnx/mobileledger/async/RetrieveTransactionsTask.java @@ -15,13 +15,19 @@ * along with Mobile-Ledger. If not, see . */ -package net.ktnx.mobileledger; +package net.ktnx.mobileledger.async; import android.content.Context; import android.content.SharedPreferences; import android.database.sqlite.SQLiteDatabase; import android.os.AsyncTask; +import net.ktnx.mobileledger.R; +import net.ktnx.mobileledger.model.LedgerTransaction; +import net.ktnx.mobileledger.model.LedgerTransactionItem; +import net.ktnx.mobileledger.utils.MobileLedgerDatabase; +import net.ktnx.mobileledger.utils.NetworkUtil; + import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.IOException; @@ -33,37 +39,37 @@ import java.net.MalformedURLException; import java.util.regex.Matcher; import java.util.regex.Pattern; -class Params { - static final int DEFAULT_LIMIT = 100; - private SharedPreferences backendPref; - private String accountsRoot; - private int limit; - Params(SharedPreferences backendPref) { - this.backendPref = backendPref; - this.accountsRoot = null; - this.limit = DEFAULT_LIMIT; - } - Params(SharedPreferences backendPref, String accountsRoot) { - this(backendPref, accountsRoot, DEFAULT_LIMIT); - } - Params(SharedPreferences backendPref, String accountsRoot, int limit) { - this.backendPref = backendPref; - this.accountsRoot = accountsRoot; - this.limit = limit; - } - String getAccountsRoot() { - return accountsRoot; - } - SharedPreferences getBackendPref() { - return backendPref; - } - int getLimit() { - return limit; - } -} +class RetrieveTransactionsTask extends AsyncTask { + class Params { + static final int DEFAULT_LIMIT = 100; + private SharedPreferences backendPref; + private String accountsRoot; + private int limit; -class RetrieveTransactionsTask extends AsyncTask { + Params(SharedPreferences backendPref) { + this.backendPref = backendPref; + this.accountsRoot = null; + this.limit = DEFAULT_LIMIT; + } + Params(SharedPreferences backendPref, String accountsRoot) { + this(backendPref, accountsRoot, DEFAULT_LIMIT); + } + Params(SharedPreferences backendPref, String accountsRoot, int limit) { + this.backendPref = backendPref; + this.accountsRoot = accountsRoot; + this.limit = limit; + } + String getAccountsRoot() { + return accountsRoot; + } + SharedPreferences getBackendPref() { + return backendPref; + } + int getLimit() { + return limit; + } + } private static final Pattern transactionStartPattern = Pattern.compile("([\\d.-]+)"); private static final Pattern transactionDescriptionPattern = diff --git a/app/src/main/java/net/ktnx/mobileledger/SaveTransactionTask.java b/app/src/main/java/net/ktnx/mobileledger/async/SaveTransactionTask.java similarity index 93% rename from app/src/main/java/net/ktnx/mobileledger/SaveTransactionTask.java rename to app/src/main/java/net/ktnx/mobileledger/async/SaveTransactionTask.java index 2e95a7d4..ac9c7c91 100644 --- a/app/src/main/java/net/ktnx/mobileledger/SaveTransactionTask.java +++ b/app/src/main/java/net/ktnx/mobileledger/async/SaveTransactionTask.java @@ -15,12 +15,17 @@ * along with Mobile-Ledger. If not, see . */ -package net.ktnx.mobileledger; +package net.ktnx.mobileledger.async; import android.content.SharedPreferences; import android.os.AsyncTask; import android.util.Log; +import net.ktnx.mobileledger.model.LedgerTransaction; +import net.ktnx.mobileledger.model.LedgerTransactionItem; +import net.ktnx.mobileledger.utils.NetworkUtil; +import net.ktnx.mobileledger.utils.UrlEncodedFormData; + import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; @@ -36,7 +41,7 @@ import java.util.regex.Pattern; import static java.lang.Thread.sleep; -class SaveTransactionTask extends AsyncTask { +public class SaveTransactionTask extends AsyncTask { private final TaskCallback task_callback; private String token; private String session; @@ -45,11 +50,11 @@ class SaveTransactionTask extends AsyncTask { protected String error; private SharedPreferences pref; - void setPref(SharedPreferences pref) { + public void setPref(SharedPreferences pref) { this.pref = pref; } - SaveTransactionTask(TaskCallback callback) { + public SaveTransactionTask(TaskCallback callback) { task_callback = callback; } private boolean send_ok() throws IOException { diff --git a/app/src/main/java/net/ktnx/mobileledger/TaskCallback.java b/app/src/main/java/net/ktnx/mobileledger/async/TaskCallback.java similarity index 91% rename from app/src/main/java/net/ktnx/mobileledger/TaskCallback.java rename to app/src/main/java/net/ktnx/mobileledger/async/TaskCallback.java index 5a6bacd6..31cdc8d2 100644 --- a/app/src/main/java/net/ktnx/mobileledger/TaskCallback.java +++ b/app/src/main/java/net/ktnx/mobileledger/async/TaskCallback.java @@ -15,8 +15,8 @@ * along with Mobile-Ledger. If not, see . */ -package net.ktnx.mobileledger; +package net.ktnx.mobileledger.async; -interface TaskCallback { +public interface TaskCallback { void done(String error); } diff --git a/app/src/main/java/net/ktnx/mobileledger/LedgerAccount.java b/app/src/main/java/net/ktnx/mobileledger/model/LedgerAccount.java similarity index 90% rename from app/src/main/java/net/ktnx/mobileledger/LedgerAccount.java rename to app/src/main/java/net/ktnx/mobileledger/model/LedgerAccount.java index 0c0c3ac0..4cf08f9e 100644 --- a/app/src/main/java/net/ktnx/mobileledger/LedgerAccount.java +++ b/app/src/main/java/net/ktnx/mobileledger/model/LedgerAccount.java @@ -15,7 +15,7 @@ * along with Mobile-Ledger. If not, see . */ -package net.ktnx.mobileledger; +package net.ktnx.mobileledger.model; import android.support.annotation.NonNull; @@ -24,7 +24,7 @@ import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; -class LedgerAccount { +public class LedgerAccount { private String name; private String shortName; private int level; @@ -34,7 +34,7 @@ class LedgerAccount { private List amounts; static Pattern higher_account = Pattern.compile("^[^:]+:"); - LedgerAccount(String name) { + public LedgerAccount(String name) { this.setName(name); hidden = false; } @@ -47,7 +47,7 @@ class LedgerAccount { this.hidden = hidden; } - LedgerAccount(String name, float amount) { + public LedgerAccount(String name, float amount) { this.setName(name); this.hidden = false; this.amounts = new ArrayList(); @@ -77,19 +77,19 @@ class LedgerAccount { else parentName = null; } - String getName() { + public String getName() { return name; } - void addAmount(float amount, String currency) { + public void addAmount(float amount, String currency) { if (amounts == null ) amounts = new ArrayList<>(); amounts.add(new LedgerAmount(amount, currency)); } - void addAmount(float amount) { + public void addAmount(float amount) { this.addAmount(amount, null); } - String getAmountsString() { + public String getAmountsString() { if ((amounts == null) || amounts.isEmpty()) return ""; StringBuilder builder = new StringBuilder(); diff --git a/app/src/main/java/net/ktnx/mobileledger/LedgerAmount.java b/app/src/main/java/net/ktnx/mobileledger/model/LedgerAmount.java similarity index 95% rename from app/src/main/java/net/ktnx/mobileledger/LedgerAmount.java rename to app/src/main/java/net/ktnx/mobileledger/model/LedgerAmount.java index a59b8913..6eb4ffba 100644 --- a/app/src/main/java/net/ktnx/mobileledger/LedgerAmount.java +++ b/app/src/main/java/net/ktnx/mobileledger/model/LedgerAmount.java @@ -15,12 +15,12 @@ * along with Mobile-Ledger. If not, see . */ -package net.ktnx.mobileledger; +package net.ktnx.mobileledger.model; import android.annotation.SuppressLint; import android.support.annotation.NonNull; -class LedgerAmount { +public class LedgerAmount { private String currency; private float amount; diff --git a/app/src/main/java/net/ktnx/mobileledger/LedgerTransaction.java b/app/src/main/java/net/ktnx/mobileledger/model/LedgerTransaction.java similarity index 86% rename from app/src/main/java/net/ktnx/mobileledger/LedgerTransaction.java rename to app/src/main/java/net/ktnx/mobileledger/model/LedgerTransaction.java index ad456cef..a103ab39 100644 --- a/app/src/main/java/net/ktnx/mobileledger/LedgerTransaction.java +++ b/app/src/main/java/net/ktnx/mobileledger/model/LedgerTransaction.java @@ -15,7 +15,7 @@ * along with Mobile-Ledger. If not, see . */ -package net.ktnx.mobileledger; +package net.ktnx.mobileledger.model; import android.database.sqlite.SQLiteDatabase; @@ -23,22 +23,22 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; -class LedgerTransaction { +public class LedgerTransaction { private String id; private String date; private String description; private List items; - LedgerTransaction(String id, String date, String description) { + public LedgerTransaction(String id, String date, String description) { this.id = id; this.date = date; this.description = description; this.items = new ArrayList<>(); } - LedgerTransaction(String date, String description) { + public LedgerTransaction(String date, String description) { this(null, date, description); } - void add_item(LedgerTransactionItem item) { + public void add_item(LedgerTransactionItem item) { items.add(item); } @@ -58,7 +58,7 @@ class LedgerTransaction { this.description = description; } - Iterator getItemsIterator() { + public Iterator getItemsIterator() { return new Iterator() { private int pointer = 0; @Override @@ -76,7 +76,7 @@ class LedgerTransaction { return id; } - void insertInto(SQLiteDatabase db) { + public void insertInto(SQLiteDatabase db) { db.execSQL("INSERT INTO transactions(id, date, " + "description) values(?, ?, ?)", new String[]{id, date, description}); diff --git a/app/src/main/java/net/ktnx/mobileledger/LedgerTransactionItem.java b/app/src/main/java/net/ktnx/mobileledger/model/LedgerTransactionItem.java similarity index 88% rename from app/src/main/java/net/ktnx/mobileledger/LedgerTransactionItem.java rename to app/src/main/java/net/ktnx/mobileledger/model/LedgerTransactionItem.java index 3453a617..ff19a450 100644 --- a/app/src/main/java/net/ktnx/mobileledger/LedgerTransactionItem.java +++ b/app/src/main/java/net/ktnx/mobileledger/model/LedgerTransactionItem.java @@ -15,18 +15,18 @@ * along with Mobile-Ledger. If not, see . */ -package net.ktnx.mobileledger; +package net.ktnx.mobileledger.model; -class LedgerTransactionItem { +public class LedgerTransactionItem { private String accountName; private float amount; private boolean amountSet; private String currency; - LedgerTransactionItem(String accountName, float amount) { + public LedgerTransactionItem(String accountName, float amount) { this(accountName, amount, null); } - LedgerTransactionItem(String accountName, float amount, String currency) { + public LedgerTransactionItem(String accountName, float amount, String currency) { this.accountName = accountName; this.amount = amount; this.amountSet = true; diff --git a/app/src/main/java/net/ktnx/mobileledger/DatePickerFragment.java b/app/src/main/java/net/ktnx/mobileledger/ui/DatePickerFragment.java similarity index 98% rename from app/src/main/java/net/ktnx/mobileledger/DatePickerFragment.java rename to app/src/main/java/net/ktnx/mobileledger/ui/DatePickerFragment.java index ebee0580..f801bdaa 100644 --- a/app/src/main/java/net/ktnx/mobileledger/DatePickerFragment.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/DatePickerFragment.java @@ -15,7 +15,7 @@ * along with Mobile-Ledger. If not, see . */ -package net.ktnx.mobileledger; +package net.ktnx.mobileledger.ui; import android.annotation.TargetApi; import android.app.DatePickerDialog; @@ -27,6 +27,8 @@ import android.support.v7.app.AppCompatDialogFragment; import android.widget.DatePicker; import android.widget.TextView; +import net.ktnx.mobileledger.R; + import java.util.Calendar; import java.util.GregorianCalendar; import java.util.Locale; diff --git a/app/src/main/java/net/ktnx/mobileledger/DimensionUtils.java b/app/src/main/java/net/ktnx/mobileledger/utils/DimensionUtils.java similarity index 96% rename from app/src/main/java/net/ktnx/mobileledger/DimensionUtils.java rename to app/src/main/java/net/ktnx/mobileledger/utils/DimensionUtils.java index 836d7b7b..14c8979d 100644 --- a/app/src/main/java/net/ktnx/mobileledger/DimensionUtils.java +++ b/app/src/main/java/net/ktnx/mobileledger/utils/DimensionUtils.java @@ -15,7 +15,7 @@ * along with Mobile-Ledger. If not, see . */ -package net.ktnx.mobileledger; +package net.ktnx.mobileledger.utils; import android.content.Context; import android.util.TypedValue; diff --git a/app/src/main/java/net/ktnx/mobileledger/MobileLedgerDatabase.java b/app/src/main/java/net/ktnx/mobileledger/utils/MobileLedgerDatabase.java similarity index 83% rename from app/src/main/java/net/ktnx/mobileledger/MobileLedgerDatabase.java rename to app/src/main/java/net/ktnx/mobileledger/utils/MobileLedgerDatabase.java index c7f4c5ee..cae65b0f 100644 --- a/app/src/main/java/net/ktnx/mobileledger/MobileLedgerDatabase.java +++ b/app/src/main/java/net/ktnx/mobileledger/utils/MobileLedgerDatabase.java @@ -15,7 +15,7 @@ * along with Mobile-Ledger. If not, see . */ -package net.ktnx.mobileledger; +package net.ktnx.mobileledger.utils; import android.content.Context; import android.content.res.Resources; @@ -31,13 +31,13 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.util.Locale; -class MobileLedgerDatabase extends SQLiteOpenHelper implements AutoCloseable { - static final String DB_NAME = "mobile-ledger.db"; - static final String ACCOUNTS_TABLE = "accounts"; - static final String DESCRIPTION_HISTORY_TABLE = "description_history"; - static final int LATEST_REVISION = 7; +public class MobileLedgerDatabase extends SQLiteOpenHelper implements AutoCloseable { + public static final String DB_NAME = "mobile-ledger.db"; + public static final String ACCOUNTS_TABLE = "accounts"; + public static final String DESCRIPTION_HISTORY_TABLE = "description_history"; + public static final int LATEST_REVISION = 7; - final Context mContext; + private final Context mContext; public MobileLedgerDatabase(Context context) { @@ -89,7 +89,7 @@ class MobileLedgerDatabase extends SQLiteOpenHelper implements AutoCloseable { db.endTransaction(); } } - int get_option_value(String name, int default_value) { + 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); @@ -99,7 +99,7 @@ class MobileLedgerDatabase extends SQLiteOpenHelper implements AutoCloseable { } } - long get_option_value(String name, long default_value) { + 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); @@ -110,7 +110,7 @@ class MobileLedgerDatabase extends SQLiteOpenHelper implements AutoCloseable { } } - String get_option_value(String name, String default_value) { + 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 @@ -133,7 +133,7 @@ class MobileLedgerDatabase extends SQLiteOpenHelper implements AutoCloseable { } } - void set_option_value(String name, String value) { + public void set_option_value(String name, String value) { Log.d("db", "setting option "+name+"="+value); try(SQLiteDatabase db = getWritableDatabase()) { db.execSQL("insert or replace into options(name, value) values(?, ?);", @@ -141,15 +141,15 @@ class MobileLedgerDatabase extends SQLiteOpenHelper implements AutoCloseable { } } - void set_option_value(String name, long value) { + public void set_option_value(String name, long value) { set_option_value(name, String.valueOf(value)); } - static long get_option_value(Context context, String name, long default_value) { + public static long get_option_value(Context context, String name, long default_value) { try(MobileLedgerDatabase db = new MobileLedgerDatabase(context)) { return db.get_option_value(name, default_value); } } - static void set_option_value(Context context, String name, String value) { + public static void set_option_value(Context context, String name, String value) { try(MobileLedgerDatabase db = new MobileLedgerDatabase(context)) { db.set_option_value(name, value); } diff --git a/app/src/main/java/net/ktnx/mobileledger/NetworkUtil.java b/app/src/main/java/net/ktnx/mobileledger/utils/NetworkUtil.java similarity index 90% rename from app/src/main/java/net/ktnx/mobileledger/NetworkUtil.java rename to app/src/main/java/net/ktnx/mobileledger/utils/NetworkUtil.java index e311fcf9..8386bbff 100644 --- a/app/src/main/java/net/ktnx/mobileledger/NetworkUtil.java +++ b/app/src/main/java/net/ktnx/mobileledger/utils/NetworkUtil.java @@ -15,7 +15,7 @@ * along with Mobile-Ledger. If not, see . */ -package net.ktnx.mobileledger; +package net.ktnx.mobileledger.utils; import android.content.SharedPreferences; import android.util.Base64; @@ -25,8 +25,9 @@ import java.io.IOException; import java.net.HttpURLConnection; import java.net.URL; -final class NetworkUtil { - static HttpURLConnection prepare_connection(SharedPreferences pref, String path) throws IOException { +public final class NetworkUtil { + public static HttpURLConnection prepare_connection(SharedPreferences pref, String path) throws + IOException { final String backend_url = pref.getString("backend_url", ""); final boolean use_auth = pref.getBoolean("backend_use_http_auth", false); Log.d("network", "Connecting to "+backend_url + "/" + path); diff --git a/app/src/main/java/net/ktnx/mobileledger/UrlEncodedFormData.java b/app/src/main/java/net/ktnx/mobileledger/utils/UrlEncodedFormData.java similarity index 91% rename from app/src/main/java/net/ktnx/mobileledger/UrlEncodedFormData.java rename to app/src/main/java/net/ktnx/mobileledger/utils/UrlEncodedFormData.java index 1928b3c1..5d69da21 100644 --- a/app/src/main/java/net/ktnx/mobileledger/UrlEncodedFormData.java +++ b/app/src/main/java/net/ktnx/mobileledger/utils/UrlEncodedFormData.java @@ -15,7 +15,7 @@ * along with Mobile-Ledger. If not, see . */ -package net.ktnx.mobileledger; +package net.ktnx.mobileledger.utils; import android.support.annotation.NonNull; @@ -25,14 +25,14 @@ import java.util.AbstractMap; import java.util.ArrayList; import java.util.List; -class UrlEncodedFormData { +public class UrlEncodedFormData { private List> pairs; - UrlEncodedFormData() { + public UrlEncodedFormData() { pairs = new ArrayList<>(); } - void add_pair(String name, String value) { + public void add_pair(String name, String value) { pairs.add(new AbstractMap.SimpleEntry(name, value)); } -- 2.39.5