]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/model/MobileLedgerProfile.java
add functional currency selector when entering new transactions
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / model / MobileLedgerProfile.java
index 5fbb5ba04c69061d7999fde0936a6215b61f4855..831dc63f0a04a558b12a15be71bc79e9cac44b9c 100644 (file)
@@ -488,9 +488,26 @@ public final class MobileLedgerProfile {
             db.endTransaction();
         }
     }
+    public List<Currency> getCurrencies() {
+        SQLiteDatabase db = App.getDatabase();
+
+        ArrayList<Currency> result = new ArrayList<>();
+
+        try (Cursor c = db.rawQuery("SELECT c.id, c.name, c.position, c.has_gap FROM currencies c",
+                new String[]{}))
+        {
+            while (c.moveToNext()) {
+                Currency currency = new Currency(c.getInt(0), c.getString(1),
+                        Currency.Position.valueOf(c.getInt(2)), c.getInt(3) == 1);
+                result.add(currency);
+            }
+        }
+
+        return result;
+    }
     public enum FutureDates {
-        None(0), OneMonth(30), TwoMonths(60), ThreeMonths(90), SixMonths(180), OneYear(365),
-        All(-1);
+        None(0), OneWeek(7), TwoWeeks(14), OneMonth(30), TwoMonths(60), ThreeMonths(90),
+        SixMonths(180), OneYear(365), All(-1);
         private static SparseArray<FutureDates> map = new SparseArray<>();
 
         static {
@@ -511,6 +528,10 @@ public final class MobileLedgerProfile {
         }
         public String getText(Resources resources) {
             switch (value) {
+                case 7:
+                    return resources.getString(R.string.future_dates_7);
+                case 14:
+                    return resources.getString(R.string.future_dates_14);
                 case 30:
                     return resources.getString(R.string.future_dates_30);
                 case 60: