]> git.ktnx.net Git - mobile-ledger.git/commitdiff
rename Patterns to Templates
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Tue, 2 Feb 2021 17:23:35 +0000 (19:23 +0200)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Tue, 2 Feb 2021 20:22:00 +0000 (22:22 +0200)
better reflects the purpose and function

also drop unnecessary unique index on a primary key and explicit
foreign key constraint names

21 files changed:
app/schemas/net.ktnx.mobileledger.db.DB/54.json [new file with mode: 0644]
app/src/main/java/net/ktnx/mobileledger/dao/PatternAccountDAO.java [deleted file]
app/src/main/java/net/ktnx/mobileledger/dao/PatternHeaderDAO.java [deleted file]
app/src/main/java/net/ktnx/mobileledger/dao/TemplateAccountDAO.java [new file with mode: 0644]
app/src/main/java/net/ktnx/mobileledger/dao/TemplateHeaderDAO.java [new file with mode: 0644]
app/src/main/java/net/ktnx/mobileledger/db/DB.java
app/src/main/java/net/ktnx/mobileledger/db/PatternWithAccounts.java [deleted file]
app/src/main/java/net/ktnx/mobileledger/db/TemplateAccount.java
app/src/main/java/net/ktnx/mobileledger/db/TemplateHeader.java
app/src/main/java/net/ktnx/mobileledger/db/TemplateWithAccounts.java [new file with mode: 0644]
app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionFragment.java
app/src/main/java/net/ktnx/mobileledger/ui/templates/TemplateDetailsFragment.java
app/src/main/java/net/ktnx/mobileledger/ui/templates/TemplateDetailsViewModel.java
app/src/main/java/net/ktnx/mobileledger/ui/templates/TemplateListFragment.java
app/src/main/java/net/ktnx/mobileledger/utils/MobileLedgerDatabase.java
app/src/main/res/layout/activity_main.xml
app/src/main/res/layout/template_details_account.xml
app/src/main/res/layout/template_details_header.xml
app/src/main/res/raw/sql_54.sql [new file with mode: 0644]
app/src/main/res/values-bg/strings.xml
app/src/main/res/values/strings.xml

diff --git a/app/schemas/net.ktnx.mobileledger.db.DB/54.json b/app/schemas/net.ktnx.mobileledger.db.DB/54.json
new file mode 100644 (file)
index 0000000..fcaec8c
--- /dev/null
@@ -0,0 +1,276 @@
+{
+  "formatVersion": 1,
+  "database": {
+    "version": 54,
+    "identityHash": "c5ddfa995546d7931ec2655613654949",
+    "entities": [
+      {
+        "tableName": "templates",
+        "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `name` TEXT NOT NULL, `regular_expression` TEXT NOT NULL, `test_text` TEXT, `transaction_description` TEXT, `transaction_description_match_group` INTEGER, `transaction_comment` TEXT, `transaction_comment_match_group` INTEGER, `date_year` INTEGER, `date_year_match_group` INTEGER, `date_month` INTEGER, `date_month_match_group` INTEGER, `date_day` INTEGER, `date_day_match_group` INTEGER)",
+        "fields": [
+          {
+            "fieldPath": "id",
+            "columnName": "id",
+            "affinity": "INTEGER",
+            "notNull": true
+          },
+          {
+            "fieldPath": "name",
+            "columnName": "name",
+            "affinity": "TEXT",
+            "notNull": true
+          },
+          {
+            "fieldPath": "regularExpression",
+            "columnName": "regular_expression",
+            "affinity": "TEXT",
+            "notNull": true
+          },
+          {
+            "fieldPath": "testText",
+            "columnName": "test_text",
+            "affinity": "TEXT",
+            "notNull": false
+          },
+          {
+            "fieldPath": "transactionDescription",
+            "columnName": "transaction_description",
+            "affinity": "TEXT",
+            "notNull": false
+          },
+          {
+            "fieldPath": "transactionDescriptionMatchGroup",
+            "columnName": "transaction_description_match_group",
+            "affinity": "INTEGER",
+            "notNull": false
+          },
+          {
+            "fieldPath": "transactionComment",
+            "columnName": "transaction_comment",
+            "affinity": "TEXT",
+            "notNull": false
+          },
+          {
+            "fieldPath": "transactionCommentMatchGroup",
+            "columnName": "transaction_comment_match_group",
+            "affinity": "INTEGER",
+            "notNull": false
+          },
+          {
+            "fieldPath": "dateYear",
+            "columnName": "date_year",
+            "affinity": "INTEGER",
+            "notNull": false
+          },
+          {
+            "fieldPath": "dateYearMatchGroup",
+            "columnName": "date_year_match_group",
+            "affinity": "INTEGER",
+            "notNull": false
+          },
+          {
+            "fieldPath": "dateMonth",
+            "columnName": "date_month",
+            "affinity": "INTEGER",
+            "notNull": false
+          },
+          {
+            "fieldPath": "dateMonthMatchGroup",
+            "columnName": "date_month_match_group",
+            "affinity": "INTEGER",
+            "notNull": false
+          },
+          {
+            "fieldPath": "dateDay",
+            "columnName": "date_day",
+            "affinity": "INTEGER",
+            "notNull": false
+          },
+          {
+            "fieldPath": "dateDayMatchGroup",
+            "columnName": "date_day_match_group",
+            "affinity": "INTEGER",
+            "notNull": false
+          }
+        ],
+        "primaryKey": {
+          "columnNames": [
+            "id"
+          ],
+          "autoGenerate": true
+        },
+        "indices": [],
+        "foreignKeys": []
+      },
+      {
+        "tableName": "template_accounts",
+        "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `template_id` INTEGER NOT NULL, `acc` TEXT, `position` INTEGER NOT NULL, `acc_match_group` INTEGER, `currency` INTEGER, `currency_match_group` INTEGER, `amount` REAL, `amount_match_group` INTEGER, `comment` TEXT, `comment_match_group` INTEGER, `negate_amount` INTEGER, FOREIGN KEY(`template_id`) REFERENCES `templates`(`id`) ON UPDATE NO ACTION ON DELETE NO ACTION , FOREIGN KEY(`currency`) REFERENCES `currencies`(`id`) ON UPDATE NO ACTION ON DELETE NO ACTION )",
+        "fields": [
+          {
+            "fieldPath": "id",
+            "columnName": "id",
+            "affinity": "INTEGER",
+            "notNull": true
+          },
+          {
+            "fieldPath": "templateId",
+            "columnName": "template_id",
+            "affinity": "INTEGER",
+            "notNull": true
+          },
+          {
+            "fieldPath": "accountName",
+            "columnName": "acc",
+            "affinity": "TEXT",
+            "notNull": false
+          },
+          {
+            "fieldPath": "position",
+            "columnName": "position",
+            "affinity": "INTEGER",
+            "notNull": true
+          },
+          {
+            "fieldPath": "accountNameMatchGroup",
+            "columnName": "acc_match_group",
+            "affinity": "INTEGER",
+            "notNull": false
+          },
+          {
+            "fieldPath": "currency",
+            "columnName": "currency",
+            "affinity": "INTEGER",
+            "notNull": false
+          },
+          {
+            "fieldPath": "currencyMatchGroup",
+            "columnName": "currency_match_group",
+            "affinity": "INTEGER",
+            "notNull": false
+          },
+          {
+            "fieldPath": "amount",
+            "columnName": "amount",
+            "affinity": "REAL",
+            "notNull": false
+          },
+          {
+            "fieldPath": "amountMatchGroup",
+            "columnName": "amount_match_group",
+            "affinity": "INTEGER",
+            "notNull": false
+          },
+          {
+            "fieldPath": "accountComment",
+            "columnName": "comment",
+            "affinity": "TEXT",
+            "notNull": false
+          },
+          {
+            "fieldPath": "accountCommentMatchGroup",
+            "columnName": "comment_match_group",
+            "affinity": "INTEGER",
+            "notNull": false
+          },
+          {
+            "fieldPath": "negateAmount",
+            "columnName": "negate_amount",
+            "affinity": "INTEGER",
+            "notNull": false
+          }
+        ],
+        "primaryKey": {
+          "columnNames": [
+            "id"
+          ],
+          "autoGenerate": true
+        },
+        "indices": [
+          {
+            "name": "fk_template_accounts_template",
+            "unique": false,
+            "columnNames": [
+              "template_id"
+            ],
+            "createSql": "CREATE INDEX IF NOT EXISTS `fk_template_accounts_template` ON `${TABLE_NAME}` (`template_id`)"
+          },
+          {
+            "name": "fk_template_accounts_currency",
+            "unique": false,
+            "columnNames": [
+              "currency"
+            ],
+            "createSql": "CREATE INDEX IF NOT EXISTS `fk_template_accounts_currency` ON `${TABLE_NAME}` (`currency`)"
+          }
+        ],
+        "foreignKeys": [
+          {
+            "table": "templates",
+            "onDelete": "NO ACTION",
+            "onUpdate": "NO ACTION",
+            "columns": [
+              "template_id"
+            ],
+            "referencedColumns": [
+              "id"
+            ]
+          },
+          {
+            "table": "currencies",
+            "onDelete": "NO ACTION",
+            "onUpdate": "NO ACTION",
+            "columns": [
+              "currency"
+            ],
+            "referencedColumns": [
+              "id"
+            ]
+          }
+        ]
+      },
+      {
+        "tableName": "currencies",
+        "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `name` TEXT NOT NULL, `position` TEXT NOT NULL, `has_gap` INTEGER NOT NULL)",
+        "fields": [
+          {
+            "fieldPath": "id",
+            "columnName": "id",
+            "affinity": "INTEGER",
+            "notNull": true
+          },
+          {
+            "fieldPath": "name",
+            "columnName": "name",
+            "affinity": "TEXT",
+            "notNull": true
+          },
+          {
+            "fieldPath": "position",
+            "columnName": "position",
+            "affinity": "TEXT",
+            "notNull": true
+          },
+          {
+            "fieldPath": "hasGap",
+            "columnName": "has_gap",
+            "affinity": "INTEGER",
+            "notNull": true
+          }
+        ],
+        "primaryKey": {
+          "columnNames": [
+            "id"
+          ],
+          "autoGenerate": true
+        },
+        "indices": [],
+        "foreignKeys": []
+      }
+    ],
+    "views": [],
+    "setupQueries": [
+      "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
+      "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'c5ddfa995546d7931ec2655613654949')"
+    ]
+  }
+}
\ No newline at end of file
diff --git a/app/src/main/java/net/ktnx/mobileledger/dao/PatternAccountDAO.java b/app/src/main/java/net/ktnx/mobileledger/dao/PatternAccountDAO.java
deleted file mode 100644 (file)
index 1ee0cd0..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright © 2021 Damyan Ivanov.
- * This file is part of MoLe.
- * MoLe is free software: you can distribute it and/or modify it
- * under the term of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your opinion), any later version.
- *
- * MoLe is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License terms for details.
- *
- * You should have received a copy of the GNU General Public License
- * along with MoLe. If not, see <https://www.gnu.org/licenses/>.
- */
-
-package net.ktnx.mobileledger.dao;
-
-import androidx.lifecycle.LiveData;
-import androidx.room.Dao;
-import androidx.room.Delete;
-import androidx.room.Insert;
-import androidx.room.Query;
-import androidx.room.Update;
-
-import net.ktnx.mobileledger.db.TemplateAccount;
-
-import java.util.List;
-
-@Dao
-public interface PatternAccountDAO {
-    @Insert
-    Long insert(TemplateAccount item);
-
-    @Update
-    void update(TemplateAccount... items);
-
-    @Delete
-    void delete(TemplateAccount item);
-
-    @Query("SELECT * FROM pattern_accounts WHERE pattern_id=:pattern_id")
-    LiveData<List<TemplateAccount>> getPatternAccounts(Long pattern_id);
-
-    @Query("SELECT * FROM pattern_accounts WHERE id = :id")
-    LiveData<TemplateAccount> getPatternAccountById(Long id);
-
-//    not useful for now
-//    @Transaction
-//    @Query("SELECT * FROM patterns")
-//    List<PatternWithAccounts> getPatternsWithAccounts();
-}
diff --git a/app/src/main/java/net/ktnx/mobileledger/dao/PatternHeaderDAO.java b/app/src/main/java/net/ktnx/mobileledger/dao/PatternHeaderDAO.java
deleted file mode 100644 (file)
index b4713d3..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright © 2021 Damyan Ivanov.
- * This file is part of MoLe.
- * MoLe is free software: you can distribute it and/or modify it
- * under the term of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your opinion), any later version.
- *
- * MoLe is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License terms for details.
- *
- * You should have received a copy of the GNU General Public License
- * along with MoLe. If not, see <https://www.gnu.org/licenses/>.
- */
-
-package net.ktnx.mobileledger.dao;
-
-import androidx.lifecycle.LiveData;
-import androidx.room.Dao;
-import androidx.room.Delete;
-import androidx.room.Insert;
-import androidx.room.Query;
-import androidx.room.Transaction;
-import androidx.room.Update;
-
-import net.ktnx.mobileledger.db.PatternWithAccounts;
-import net.ktnx.mobileledger.db.TemplateHeader;
-
-import java.util.List;
-
-@Dao
-public interface PatternHeaderDAO {
-    @Insert()
-    long insert(TemplateHeader item);
-
-    @Update
-    void update(TemplateHeader... items);
-
-    @Delete
-    void delete(TemplateHeader item);
-
-    @Query("SELECT * FROM patterns ORDER BY UPPER(name)")
-    LiveData<List<TemplateHeader>> getPatterns();
-
-    @Query("SELECT * FROM patterns WHERE id = :id")
-    LiveData<TemplateHeader> getPattern(Long id);
-
-    @Transaction
-    @Query("SELECT * FROM patterns WHERE id = :id")
-    LiveData<PatternWithAccounts> getPatternWithAccounts(Long id);
-}
diff --git a/app/src/main/java/net/ktnx/mobileledger/dao/TemplateAccountDAO.java b/app/src/main/java/net/ktnx/mobileledger/dao/TemplateAccountDAO.java
new file mode 100644 (file)
index 0000000..4fd1d20
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright © 2021 Damyan Ivanov.
+ * This file is part of MoLe.
+ * MoLe is free software: you can distribute it and/or modify it
+ * under the term of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your opinion), any later version.
+ *
+ * MoLe is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License terms for details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with MoLe. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package net.ktnx.mobileledger.dao;
+
+import androidx.lifecycle.LiveData;
+import androidx.room.Dao;
+import androidx.room.Delete;
+import androidx.room.Insert;
+import androidx.room.Query;
+import androidx.room.Update;
+
+import net.ktnx.mobileledger.db.TemplateAccount;
+
+import java.util.List;
+
+@Dao
+public interface TemplateAccountDAO {
+    @Insert
+    Long insert(TemplateAccount item);
+
+    @Update
+    void update(TemplateAccount... items);
+
+    @Delete
+    void delete(TemplateAccount item);
+
+    @Query("SELECT * FROM template_accounts WHERE template_id=:template_id")
+    LiveData<List<TemplateAccount>> getTemplateAccounts(Long template_id);
+
+    @Query("SELECT * FROM template_accounts WHERE id = :id")
+    LiveData<TemplateAccount> getPatternAccountById(Long id);
+
+//    not useful for now
+//    @Transaction
+//    @Query("SELECT * FROM patterns")
+//    List<PatternWithAccounts> getPatternsWithAccounts();
+}
diff --git a/app/src/main/java/net/ktnx/mobileledger/dao/TemplateHeaderDAO.java b/app/src/main/java/net/ktnx/mobileledger/dao/TemplateHeaderDAO.java
new file mode 100644 (file)
index 0000000..faef98f
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright © 2021 Damyan Ivanov.
+ * This file is part of MoLe.
+ * MoLe is free software: you can distribute it and/or modify it
+ * under the term of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your opinion), any later version.
+ *
+ * MoLe is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License terms for details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with MoLe. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package net.ktnx.mobileledger.dao;
+
+import androidx.lifecycle.LiveData;
+import androidx.room.Dao;
+import androidx.room.Delete;
+import androidx.room.Insert;
+import androidx.room.Query;
+import androidx.room.Transaction;
+import androidx.room.Update;
+
+import net.ktnx.mobileledger.db.TemplateHeader;
+import net.ktnx.mobileledger.db.TemplateWithAccounts;
+
+import java.util.List;
+
+@Dao
+public interface TemplateHeaderDAO {
+    @Insert()
+    long insert(TemplateHeader item);
+
+    @Update
+    void update(TemplateHeader... items);
+
+    @Delete
+    void delete(TemplateHeader item);
+
+    @Query("SELECT * FROM templates ORDER BY UPPER(name)")
+    LiveData<List<TemplateHeader>> getTemplates();
+
+    @Query("SELECT * FROM templates WHERE id = :id")
+    LiveData<TemplateHeader> getTemplate(Long id);
+
+    @Transaction
+    @Query("SELECT * FROM templates WHERE id = :id")
+    LiveData<TemplateWithAccounts> getTemplateWithAccounts(Long id);
+}
index 80652ed1ecb8cf6642b79ff579e73345805dabe6..f65f503fccfc49583690d1a864c4a28575e7ce59 100644 (file)
@@ -26,11 +26,11 @@ import androidx.sqlite.db.SupportSQLiteDatabase;
 
 import net.ktnx.mobileledger.App;
 import net.ktnx.mobileledger.dao.CurrencyDAO;
-import net.ktnx.mobileledger.dao.PatternAccountDAO;
-import net.ktnx.mobileledger.dao.PatternHeaderDAO;
+import net.ktnx.mobileledger.dao.TemplateAccountDAO;
+import net.ktnx.mobileledger.dao.TemplateHeaderDAO;
 import net.ktnx.mobileledger.utils.MobileLedgerDatabase;
 
-@Database(version = 53, entities = {TemplateHeader.class, TemplateAccount.class, Currency.class})
+@Database(version = 54, entities = {TemplateHeader.class, TemplateAccount.class, Currency.class})
 abstract public class DB extends RoomDatabase {
     private static DB instance;
     public static DB get() {
@@ -63,14 +63,70 @@ abstract public class DB extends RoomDatabase {
                                 db.execSQL(
                                         "alter table pattern_accounts add negate_amount boolean;");
                             }
+                        }, new Migration(53, 54) {
+                            @Override
+                            public void migrate(@NonNull SupportSQLiteDatabase db) {
+                                db.execSQL("CREATE TABLE templates (id INTEGER PRIMARY KEY " +
+                                           "AUTOINCREMENT NOT NULL, name TEXT NOT NULL, " +
+                                           "regular_expression TEXT NOT NULL, test_text TEXT, " +
+                                           "transaction_description TEXT, " +
+                                           "transaction_description_match_group INTEGER, " +
+                                           "transaction_comment TEXT, " +
+                                           "transaction_comment_match_group INTEGER, date_year " +
+                                           "INTEGER, date_year_match_group INTEGER, date_month " +
+                                           "INTEGER, date_month_match_group INTEGER, date_day " +
+                                           "INTEGER, date_day_match_group INTEGER)");
+                                db.execSQL(
+                                        "CREATE TABLE template_accounts (id INTEGER PRIMARY KEY " +
+                                        "AUTOINCREMENT NOT NULL, template_id INTEGER NOT NULL, " +
+                                        "acc TEXT, position INTEGER NOT NULL, acc_match_group " +
+                                        "INTEGER, currency INTEGER, currency_match_group INTEGER," +
+                                        " amount REAL, amount_match_group INTEGER, comment TEXT, " +
+                                        "comment_match_group INTEGER, negate_amount INTEGER, " +
+                                        "FOREIGN KEY(template_id) REFERENCES templates(id) ON " +
+                                        "UPDATE NO ACTION ON DELETE NO ACTION , FOREIGN KEY" +
+                                        "(currency) REFERENCES currencies(id) ON UPDATE NO ACTION" +
+                                        " ON DELETE NO ACTION )");
+                                db.execSQL("insert into templates(id, name, regular_expression, " +
+                                           "test_text, transaction_description, " +
+                                           "transaction_description_match_group, " +
+                                           "transaction_comment, transaction_comment_match_group," +
+                                           " date_year, date_year_match_group, date_month, " +
+                                           "date_month_match_group, date_day, " +
+                                           "date_day_match_group)" +
+                                           " select id, name, regular_expression, test_text, " +
+                                           "transaction_description, " +
+                                           "transaction_description_match_group, " +
+                                           "transaction_comment, transaction_comment_match_group," +
+                                           " date_year, date_year_match_group, date_month, " +
+                                           "date_month_match_group, date_day, " +
+                                           "date_day_match_group from patterns");
+                                db.execSQL("insert into template_accounts(id, template_id, acc, " +
+                                           "position, acc_match_group, currency, " +
+                                           "currency_match_group, amount, amount_match_group, " +
+                                           "amount, amount_match_group, comment, " +
+                                           "comment_match_group, negate_amount) select id, " +
+                                           "pattern_id, acc, position, acc_match_group, " +
+                                           "currency, " +
+                                           "currency_match_group, amount, amount_match_group, " +
+                                           "amount, amount_match_group, comment, " +
+                                           "comment_match_group, negate_amount from " +
+                                           "pattern_accounts");
+                                db.execSQL("create index fk_template_accounts_template on " +
+                                           "template_accounts(template_id)");
+                                db.execSQL("create index fk_template_accounts_currency on " +
+                                           "template_accounts(currency)");
+                                db.execSQL("drop table pattern_accounts");
+                                db.execSQL("drop table patterns");
+                            }
                         }
                         })
                         .build();
         }
     }
-    public abstract PatternHeaderDAO getPatternDAO();
+    public abstract TemplateHeaderDAO getPatternDAO();
 
-    public abstract PatternAccountDAO getPatternAccountDAO();
+    public abstract TemplateAccountDAO getPatternAccountDAO();
 
     public abstract CurrencyDAO getCurrencyDAO();
 }
diff --git a/app/src/main/java/net/ktnx/mobileledger/db/PatternWithAccounts.java b/app/src/main/java/net/ktnx/mobileledger/db/PatternWithAccounts.java
deleted file mode 100644 (file)
index 9f171b1..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright © 2021 Damyan Ivanov.
- * This file is part of MoLe.
- * MoLe is free software: you can distribute it and/or modify it
- * under the term of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your opinion), any later version.
- *
- * MoLe is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License terms for details.
- *
- * You should have received a copy of the GNU General Public License
- * along with MoLe. If not, see <https://www.gnu.org/licenses/>.
- */
-
-package net.ktnx.mobileledger.db;
-
-import androidx.room.Embedded;
-import androidx.room.Relation;
-
-import java.util.List;
-
-public class PatternWithAccounts {
-    @Embedded
-    public TemplateHeader header;
-    @Relation(parentColumn = "id", entityColumn = "pattern_id")
-    public List<TemplateAccount> accounts;
-
-    public Long getId() {
-        return header.getId();
-    }
-}
index 92b290805ba3866689971846082e2dccbb046df0..c662ff1c18092121ebf6f6b74bbffe1ec98be595 100644 (file)
@@ -26,22 +26,21 @@ import androidx.room.PrimaryKey;
 
 import org.jetbrains.annotations.NotNull;
 
-@Entity(tableName = "pattern_accounts",
-        indices = {@Index(name = "un_pattern_accounts", unique = true, value = "id"),
-                   @Index(name = "fk_pattern_accounts_pattern", value = "pattern_id"),
-                   @Index(name = "fk_pattern_accounts_currency", value = "currency")
-        }, foreignKeys = {@ForeignKey(childColumns = "pattern_id", parentColumns = "id",
+@Entity(tableName = "template_accounts",
+        indices = {@Index(name = "fk_template_accounts_template", value = "template_id"),
+                   @Index(name = "fk_template_accounts_currency", value = "currency")
+        }, foreignKeys = {@ForeignKey(childColumns = "template_id", parentColumns = "id",
                                       entity = TemplateHeader.class),
                           @ForeignKey(childColumns = "currency", parentColumns = "id",
                                       entity = Currency.class)
 })
 public class TemplateAccount extends TemplateBase {
-    @NonNull
-    @ColumnInfo(name = "pattern_id")
-    private Long patternId;
     @PrimaryKey(autoGenerate = true)
     @NotNull
     private Long id;
+    @NonNull
+    @ColumnInfo(name = "template_id")
+    private Long templateId;
     @ColumnInfo(name = "acc")
     private String accountName;
     @ColumnInfo(name = "position")
@@ -63,9 +62,9 @@ public class TemplateAccount extends TemplateBase {
     private Integer accountCommentMatchGroup;
     @ColumnInfo(name = "negate_amount")
     private Boolean negateAmount;
-    public TemplateAccount(@NotNull Long id, @NonNull Long patternId, @NonNull Long position) {
+    public TemplateAccount(@NotNull Long id, @NonNull Long templateId, @NonNull Long position) {
         this.id = id;
-        this.patternId = patternId;
+        this.templateId = templateId;
         this.position = position;
     }
     public Long getId() {
@@ -80,11 +79,11 @@ public class TemplateAccount extends TemplateBase {
     public void setNegateAmount(Boolean negateAmount) {
         this.negateAmount = negateAmount;
     }
-    public @NotNull Long getPatternId() {
-        return patternId;
+    public @NotNull Long getTemplateId() {
+        return templateId;
     }
-    public void setPatternId(@NonNull Long patternId) {
-        this.patternId = patternId;
+    public void setTemplateId(@NonNull Long templateId) {
+        this.templateId = templateId;
     }
     @NonNull
     public String getAccountName() {
index 301b100c19dab93fb8080817669e25dd7c3cf11a..5422767f9e74d01ffbedb63059263692da8f66c7 100644 (file)
@@ -21,15 +21,13 @@ import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
 import androidx.room.ColumnInfo;
 import androidx.room.Entity;
-import androidx.room.Index;
 import androidx.room.PrimaryKey;
 
 import net.ktnx.mobileledger.utils.Misc;
 
 import org.jetbrains.annotations.NotNull;
 
-@Entity(tableName = "patterns",
-        indices = {@Index(name = "un_patterns_id", value = "id", unique = true)})
+@Entity(tableName = "templates")
 public class TemplateHeader extends TemplateBase {
     @PrimaryKey(autoGenerate = true)
     @NonNull
diff --git a/app/src/main/java/net/ktnx/mobileledger/db/TemplateWithAccounts.java b/app/src/main/java/net/ktnx/mobileledger/db/TemplateWithAccounts.java
new file mode 100644 (file)
index 0000000..a40ecae
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright © 2021 Damyan Ivanov.
+ * This file is part of MoLe.
+ * MoLe is free software: you can distribute it and/or modify it
+ * under the term of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your opinion), any later version.
+ *
+ * MoLe is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License terms for details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with MoLe. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package net.ktnx.mobileledger.db;
+
+import androidx.room.Embedded;
+import androidx.room.Relation;
+
+import java.util.List;
+
+public class TemplateWithAccounts {
+    @Embedded
+    public TemplateHeader header;
+    @Relation(parentColumn = "id", entityColumn = "template_id")
+    public List<TemplateAccount> accounts;
+
+    public Long getId() {
+        return header.getId();
+    }
+}
index e708c5fe3f2d7a37e88e684fdede50b52f57d3b3..8499d6f02f6ce886af876d7c3d7c14dd307f158a 100644 (file)
@@ -98,7 +98,7 @@ public class NewTransactionFragment extends QRScanCapableFragment {
     private void alertNoPatternMatch(String scanned) {
         MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(requireContext());
         builder.setCancelable(true)
-               .setMessage(R.string.no_pattern_matches)
+               .setMessage(R.string.no_template_matches)
                .setPositiveButton(R.string.add_button,
                        (dialog, which) -> startNewPatternActivity(scanned))
                .create()
@@ -112,7 +112,7 @@ public class NewTransactionFragment extends QRScanCapableFragment {
 
         LiveData<List<TemplateHeader>> allPatterns = DB.get()
                                                        .getPatternDAO()
-                                                       .getPatterns();
+                                                       .getTemplates();
         allPatterns.observe(getViewLifecycleOwner(), patternHeaders -> {
             ArrayList<TemplateHeader> matchingPatterns = new ArrayList<>();
 
@@ -199,7 +199,7 @@ public class NewTransactionFragment extends QRScanCapableFragment {
 
         MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(requireContext());
         builder.setCancelable(true)
-               .setTitle(R.string.choose_pattern_to_apply)
+               .setTitle(R.string.choose_template_to_apply)
                .setSingleChoiceItems(cursor, -1, patternNameColumn, (dialog, which) -> {
                    applyPattern(matchingPatterns.get(which), matchedText);
                    dialog.dismiss();
@@ -258,7 +258,7 @@ public class NewTransactionFragment extends QRScanCapableFragment {
 
         DB.get()
           .getPatternDAO()
-          .getPatternWithAccounts(patternHeader.getId())
+          .getTemplateWithAccounts(patternHeader.getId())
           .observe(getViewLifecycleOwner(), entry -> {
               int rowIndex = 0;
               final boolean accountsInInitialState = viewModel.accountsInInitialState();
index 94e6989e6227bbdc3494fbfcea5ec4ab31b31df9..b95ae29bcead60b38bdac0af004f2a718f1a9663 100644 (file)
@@ -75,7 +75,7 @@ public class TemplateDetailsFragment extends QRScanCapableFragment {
         final ViewModelStoreOwner viewModelStoreOwner =
                 controller.getViewModelStoreOwner(R.id.template_list_navigation);
         mViewModel = new ViewModelProvider(viewModelStoreOwner).get(TemplateDetailsViewModel.class);
-        mViewModel.setDefaultPatternName(getString(R.string.unnamed_pattern));
+        mViewModel.setDefaultPatternName(getString(R.string.unnamed_template));
         Logger.debug("flow", "PatternDetailsFragment.onCreateView(): model=" + mViewModel);
 
         b = TemplateDetailsFragmentBinding.inflate(inflater);
index 088b1b77c9100b6f5203a27e8a6bed2caa728208..a24b97670a54b05e1d8bc3c7d9b56083e4677a48 100644 (file)
@@ -24,12 +24,12 @@ import androidx.lifecycle.MutableLiveData;
 import androidx.lifecycle.Observer;
 import androidx.lifecycle.ViewModel;
 
-import net.ktnx.mobileledger.dao.PatternAccountDAO;
-import net.ktnx.mobileledger.dao.PatternHeaderDAO;
+import net.ktnx.mobileledger.dao.TemplateAccountDAO;
+import net.ktnx.mobileledger.dao.TemplateHeaderDAO;
 import net.ktnx.mobileledger.db.DB;
-import net.ktnx.mobileledger.db.PatternWithAccounts;
 import net.ktnx.mobileledger.db.TemplateAccount;
 import net.ktnx.mobileledger.db.TemplateHeader;
+import net.ktnx.mobileledger.db.TemplateWithAccounts;
 import net.ktnx.mobileledger.model.TemplateDetailsItem;
 import net.ktnx.mobileledger.utils.Logger;
 
@@ -96,11 +96,11 @@ public class TemplateDetailsViewModel extends ViewModel {
         }
 
         DB db = DB.get();
-        LiveData<PatternWithAccounts> dbList = db.getPatternDAO()
-                                                 .getPatternWithAccounts(mPatternId);
-        Observer<PatternWithAccounts> observer = new Observer<PatternWithAccounts>() {
+        LiveData<TemplateWithAccounts> dbList = db.getPatternDAO()
+                                                  .getTemplateWithAccounts(mPatternId);
+        Observer<TemplateWithAccounts> observer = new Observer<TemplateWithAccounts>() {
             @Override
-            public void onChanged(PatternWithAccounts src) {
+            public void onChanged(TemplateWithAccounts src) {
                 ArrayList<TemplateDetailsItem> l = new ArrayList<>();
 
                 TemplateDetailsItem header = TemplateDetailsItem.fromRoomObject(src.header);
@@ -139,8 +139,8 @@ public class TemplateDetailsViewModel extends ViewModel {
 
             TemplateDetailsItem.Header modelHeader = list.get(0)
                                                          .asHeaderItem();
-            PatternHeaderDAO headerDAO = DB.get()
-                                           .getPatternDAO();
+            TemplateHeaderDAO headerDAO = DB.get()
+                                            .getPatternDAO();
             TemplateHeader dbHeader = modelHeader.toDBO();
             if (newPattern) {
                 dbHeader.setId(null);
@@ -154,13 +154,13 @@ public class TemplateDetailsViewModel extends ViewModel {
                             modelHeader));
 
 
-            PatternAccountDAO paDAO = DB.get()
-                                        .getPatternAccountDAO();
+            TemplateAccountDAO paDAO = DB.get()
+                                         .getPatternAccountDAO();
             for (int i = 1; i < list.size(); i++) {
                 final TemplateDetailsItem.AccountRow accRowItem = list.get(i)
                                                                       .asAccountRowItem();
                 TemplateAccount dbAccount = accRowItem.toDBO(dbHeader.getId());
-                dbAccount.setPatternId(mPatternId);
+                dbAccount.setTemplateId(mPatternId);
                 dbAccount.setPosition(i);
                 if (newPattern) {
                     dbAccount.setId(null);
index cc5c79888cb0ba1433098af475dea1617d783c39..53564278fb140eefb91aa0c2d0ff49f341eea71b 100644 (file)
@@ -32,7 +32,7 @@ import androidx.lifecycle.LiveData;
 import androidx.recyclerview.widget.LinearLayoutManager;
 import androidx.recyclerview.widget.RecyclerView;
 
-import net.ktnx.mobileledger.dao.PatternHeaderDAO;
+import net.ktnx.mobileledger.dao.TemplateHeaderDAO;
 import net.ktnx.mobileledger.databinding.FragmentTemplateListBinding;
 import net.ktnx.mobileledger.db.DB;
 import net.ktnx.mobileledger.db.TemplateHeader;
@@ -85,9 +85,9 @@ public class TemplateListFragment extends Fragment {
         TemplatesRecyclerViewAdapter modelAdapter = new TemplatesRecyclerViewAdapter();
 
         b.templateList.setAdapter(modelAdapter);
-        PatternHeaderDAO pDao = DB.get()
-                                  .getPatternDAO();
-        LiveData<List<TemplateHeader>> templates = pDao.getPatterns();
+        TemplateHeaderDAO pDao = DB.get()
+                                   .getPatternDAO();
+        LiveData<List<TemplateHeader>> templates = pDao.getTemplates();
         templates.observe(getViewLifecycleOwner(), modelAdapter::setTemplates);
         LinearLayoutManager llm = new LinearLayoutManager(getContext());
         llm.setOrientation(RecyclerView.VERTICAL);
index f08f73028d4e3c369fb3c335113edbd45b9e8084..3785ddd3324ad57c9aa3d9b2d1eac3494c03b3de 100644 (file)
@@ -39,7 +39,7 @@ import static net.ktnx.mobileledger.utils.Logger.debug;
 public class MobileLedgerDatabase extends SQLiteOpenHelper {
     public static final MutableLiveData<Boolean> initComplete = new MutableLiveData<>(false);
     public static final String DB_NAME = "MoLe.db";
-    private static final int LATEST_REVISION = 53;
+    private static final int LATEST_REVISION = 54;
     private static final String CREATE_DB_SQL = "create_db";
     private final Application mContext;
 
index ede0f620caea7d06b558f391f861a5a1bbc22e04..02c51e06fed69f6ba36f6c061ce1a09baa1d7c84 100644 (file)
                             <TextView
                                 android:id="@+id/nav_patterns"
                                 style="@style/nav_button"
-                                android:text="@string/nav_patterns"
+                                android:text="@string/nav_templates"
                                 app:drawableStartCompat="@drawable/ic_baseline_auto_graph_24"
                                 />
 
index 0eeb78b97c723d0690dc447828bb6cfc6a098707..93372b7a2492721982a2e124fa5056f4396fb786 100644 (file)
@@ -28,7 +28,7 @@
         android:layout_height="match_parent"
         android:gravity="end"
         android:paddingTop="@dimen/text_margin"
-        android:text="@string/pattern_details_account_row_label"
+        android:text="@string/template_details_account_row_label"
         app:drawableBottomCompat="@drawable/dashed_border_8dp"
         />
     <TextView
@@ -66,7 +66,7 @@
             android:id="@+id/template_details_account_name"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:hint="@string/pattern_details_account_name_label"
+            android:hint="@string/template_details_account_name_label"
             android:inputType="text"
             />
     </com.google.android.material.textfield.TextInputLayout>
             android:id="@+id/template_details_account_comment"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:hint="@string/pattern_details_account_comment_label"
+            android:hint="@string/template_details_account_comment_label"
             android:inputType="text"
             />
     </com.google.android.material.textfield.TextInputLayout>
             android:id="@+id/template_details_account_amount"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:hint="@string/pattern_details_account_amount_label"
+            android:hint="@string/template_details_account_amount_label"
             android:inputType="number|numberDecimal|numberSigned"
             />
     </com.google.android.material.textfield.TextInputLayout>
index bc5b851ef5680a0b05192779db5b6118c9bf9066..d16ce4ebc58d4032659e64e70d201c6c792cdfe4 100644 (file)
@@ -34,7 +34,7 @@
             android:id="@+id/template_name"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:hint="@string/pattern_name_label"
+            android:hint="@string/template_name_label"
             android:inputType="text"
             />
     </com.google.android.material.textfield.TextInputLayout>
@@ -51,7 +51,7 @@
             android:id="@+id/pattern"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:hint="@string/pattern_details_pattern_label"
+            android:hint="@string/template_details_pattern_label"
             android:inputType="text"
             />
     </com.google.android.material.textfield.TextInputLayout>
@@ -68,7 +68,7 @@
             android:id="@+id/test_text"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:hint="@string/pattern_details_test_text_label"
+            android:hint="@string/template_details_test_text_label"
             android:inputType="text"
             />
     </com.google.android.material.textfield.TextInputLayout>
         android:layout_height="wrap_content"
         android:gravity="end"
         android:paddingTop="@dimen/text_margin"
-        android:text="@string/pattern_transaction_parameters_label"
+        android:text="@string/template_transaction_parameters_label"
         app:layout_constraintTop_toBottomOf="@id/test_text_layout"
         />
     <TextView
         android:id="@+id/pattern_transaction_date_label"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:text="@string/pattern_details_date_label"
+        android:text="@string/template_details_date_label"
         app:layout_constraintTop_toBottomOf="@id/transaction_parameters_label"
         />
     <TextView
         android:id="@+id/template_details_year_source_label"
         android:layout_width="0dp"
         android:layout_height="wrap_content"
-        android:text="@string/pattern_details_date_year_source_label"
+        android:text="@string/template_details_date_year_source_label"
         android:textAlignment="center"
         app:layout_constraintEnd_toStartOf="@id/template_details_month_source_label"
         app:layout_constraintStart_toStartOf="parent"
         android:id="@+id/template_details_month_source_label"
         android:layout_width="0dp"
         android:layout_height="wrap_content"
-        android:text="@string/pattern_details_date_month_source_label"
+        android:text="@string/template_details_date_month_source_label"
         android:textAlignment="center"
         app:layout_constraintEnd_toStartOf="@id/template_details_day_source_label"
         app:layout_constraintStart_toEndOf="@id/template_details_year_source_label"
         android:id="@+id/template_details_day_source_label"
         android:layout_width="0dp"
         android:layout_height="wrap_content"
-        android:text="@string/pattern_details_date_day_source_label"
+        android:text="@string/template_details_date_day_source_label"
         android:textAlignment="center"
         app:layout_constraintEnd_toEndOf="parent"
         app:layout_constraintStart_toEndOf="@id/template_details_month_source_label"
diff --git a/app/src/main/res/raw/sql_54.sql b/app/src/main/res/raw/sql_54.sql
new file mode 100644 (file)
index 0000000..1d6565f
--- /dev/null
@@ -0,0 +1,16 @@
+-- Copyright © 2020 Damyan Ivanov.
+-- This file is part of MoLe.
+-- MoLe is free software: you can distribute it and/or modify it
+-- under the term of the GNU General Public License as published by
+-- the Free Software Foundation, either version 3 of the License, or
+-- (at your opinion), any later version.
+--
+-- MoLe is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU General Public License terms for details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with MoLe. If not, see <https://www.gnu.org/licenses/>.
+
+-- this is handled in a Room migration
\ No newline at end of file
index 0b97052c3710e55c78ffa24416219767e2382ccf..75ffb64d67e0d7bd226f4566da350e123795a0e2 100644 (file)
     <string name="err_json_send_error_tail">Вероятно настроената версия на протокола не се поддържа.</string>
     <string name="err_json_send_error_unsupported">Възможно е програмния интерфейс на сървъра да не се поддържа от MoLe</string>
     <string name="scan_qr">Сканиране на QR код</string>
-    <string name="nav_patterns">Макети</string>
+    <string name="nav_templates">Макети</string>
     <string name="title_activity_templates">Макети</string>
     <string name="pattern_regex_hint">Шаблон (regex)</string>
     <string name="help_menu_item_title">Помощ</string>
     <string name="edit_button_description">Бутон за промяна</string>
-    <string name="pattern_details_account_comment_label">Бележка към сметката</string>
-    <string name="pattern_details_account_amount_label">Сума</string>
+    <string name="template_details_account_comment_label">Бележка към сметката</string>
+    <string name="template_details_account_amount_label">Сума</string>
     <string name="choose_template_detail_source_label">Прихващане от шаблона</string>
     <string name="missing_pattern_error">Липсва шаблон</string>
     <string name="missing_test_text">Липсва примерен текст</string>
     <string name="pattern_without_groups">Шаблонът няма прихващания</string>
     <string name="pattern_does_not_match">Шаблонът не съвпада с примерния текст</string>
-    <string name="pattern_transaction_parameters_label">Данни за движението</string>
+    <string name="template_transaction_parameters_label">Данни за движението</string>
     <string name="template_transaction_description_hint">Описание на движението</string>
     <string name="template_transaction_comment_hint">Бележка към движението</string>
     <string name="transaction_description_source_label">Източник на описанието на движението</string>
     <string name="transaction_comment_source_label">Източник на бележката към движението</string>
-    <string name="pattern_details_date_label">Дата на движението</string>
+    <string name="template_details_date_label">Дата на движението</string>
     <string name="date_year_hint">година</string>
     <string name="date_month_hint">месец</string>
     <string name="date_day_hint">ден</string>
-    <string name="pattern_details_date_year_source_label">година</string>
-    <string name="pattern_details_date_day_source_label">ден</string>
-    <string name="pattern_details_date_month_source_label">месец</string>
-    <string name="unnamed_pattern">Макет без име</string>
+    <string name="template_details_date_year_source_label">година</string>
+    <string name="template_details_date_day_source_label">ден</string>
+    <string name="template_details_date_month_source_label">месец</string>
+    <string name="unnamed_template">Макет без име</string>
     <string name="add_button_description">Добавяне на макет</string>
     <string name="save_button_description">Запазване на макета</string>
-    <string name="no_pattern_matches">Няма съвпадение с нито един макет</string>
-    <string name="choose_pattern_to_apply">Избор на макет</string>
-    <string name="pattern_name">Име на макет</string>
+    <string name="no_template_matches">Няма съвпадение с нито един макет</string>
+    <string name="choose_template_to_apply">Избор на макет</string>
+    <string name="template_name">Име на макет</string>
     <string name="implementation_pending">Функцията още не е готова</string>
     <string name="title_edit_template">Промяна на макет</string>
     <string name="title_new_template">Създаване на макет</string>
     <string name="account_name_is_empty">Липсва сметка</string>
     <string name="pattern_is_empty">Липсва шаблон</string>
     <string name="invalid_matching_group_number">Невалиден номер на прихващане</string>
-    <string name="pattern_name_label">Име на макет</string>
-    <string name="pattern_details_pattern_label">Шаблон</string>
-    <string name="pattern_details_amount_label">Сума</string>
-    <string name="pattern_details_test_text_label">Примерен текст</string>
-    <string name="pattern_details_account_name_label">Сметка</string>
-    <string name="pattern_details_account_row_label">Данни за сметката</string>
+    <string name="template_name_label">Име на макет</string>
+    <string name="template_details_pattern_label">Шаблон</string>
+    <string name="template_details_amount_label">Сума</string>
+    <string name="template_details_test_text_label">Примерен текст</string>
+    <string name="template_details_account_name_label">Сметка</string>
+    <string name="template_details_account_row_label">Данни за сметката</string>
     <string name="account_name_source_label">Източник на името на сметката</string>
     <string name="template_details_source_literal">ръчно въвеждане</string>
     <string name="account_comment_source_label">Източник на бележка към сметката</string>
index 8b77d38225afb2a4e75294471336bed4479d7e78..d9d1ab3b223e02632e322359a709f3ba2d83b5d1 100644 (file)
     <string name="err_json_send_error_tail">A mismatch in the configured API version could be causing this</string>
     <string name="err_json_send_error_unsupported">Perhaps the API of the backend server is not supported by MoLe</string>
     <string name="scan_qr">Scan QR code</string>
-    <string name="nav_patterns">Patterns</string>
-    <string name="title_activity_templates">Patterns</string>
+    <string name="nav_templates">Templates</string>
+    <string name="title_activity_templates">Templates</string>
     <string name="pattern_regex_hint">Pattern (regular expression)</string>
     <string name="help_menu_item_title">Help</string>
     <string name="edit_button_description">Edit button</string>
     <string name="account_name_is_empty">Account name missing</string>
     <string name="pattern_is_empty">Pattern missing</string>
     <string name="invalid_matching_group_number">Invalid matching group number</string>
-    <string name="pattern_name_label">Pattern name</string>
-    <string name="pattern_details_pattern_label">Pattern</string>
-    <string name="pattern_details_amount_label">Amount</string>
-    <string name="pattern_details_test_text_label">Test text</string>
-    <string name="pattern_details_account_name_label">Account name</string>
-    <string name="pattern_details_account_row_label">Transaction account details</string>
+    <string name="template_name_label">Template name</string>
+    <string name="template_details_pattern_label">Pattern</string>
+    <string name="template_details_amount_label">Amount</string>
+    <string name="template_details_test_text_label">Test text</string>
+    <string name="template_details_account_name_label">Account name</string>
+    <string name="template_details_account_row_label">Transaction account details</string>
     <string name="account_name_source_label">Account name source</string>
     <string name="template_details_source_literal">literal</string>
     <string name="account_comment_source_label">Account comment source</string>
     <string name="account_amount_source_label">Amount source</string>
-    <string name="pattern_details_account_comment_label">Account comment</string>
-    <string name="pattern_details_account_amount_label">Amount</string>
+    <string name="template_details_account_comment_label">Account comment</string>
+    <string name="template_details_account_amount_label">Amount</string>
     <string name="choose_template_detail_source_label">Pattern match group</string>
     <string name="missing_pattern_error">Missing pattern</string>
     <string name="missing_test_text">Missing test text</string>
     <string name="pattern_without_groups">Pattern has no capturing groups</string>
     <string name="pattern_does_not_match">Pattern doesn\'t match the test text</string>
-    <string name="pattern_transaction_parameters_label">Transaction parameters</string>
+    <string name="template_transaction_parameters_label">Transaction parameters</string>
     <string name="template_transaction_description_hint">Transaction description</string>
     <string name="template_transaction_comment_hint">Transaction comment</string>
     <string name="transaction_description_source_label">Transaction description source</string>
     <string name="transaction_comment_source_label">Transaction comment source</string>
-    <string name="pattern_details_date_label">Transaction date</string>
+    <string name="template_details_date_label">Transaction date</string>
     <string name="date_year_hint">year</string>
     <string name="date_month_hint">month</string>
     <string name="date_day_hint">date</string>
-    <string name="pattern_details_date_year_source_label">year</string>
-    <string name="pattern_details_date_day_source_label">date</string>
-    <string name="pattern_details_date_month_source_label">month</string>
-    <string name="unnamed_pattern">Pattern with no name</string>
-    <string name="add_button_description">Add pattern</string>
-    <string name="save_button_description">Save pattern</string>
-    <string name="no_pattern_matches">No pattern matches</string>
-    <string name="choose_pattern_to_apply">Choose pattern to apply</string>
-    <string name="pattern_name">Pattern name</string>
+    <string name="template_details_date_year_source_label">year</string>
+    <string name="template_details_date_day_source_label">date</string>
+    <string name="template_details_date_month_source_label">month</string>
+    <string name="unnamed_template">Template with no name</string>
+    <string name="add_button_description">Add template</string>
+    <string name="save_button_description">Save template</string>
+    <string name="no_template_matches">No template matches</string>
+    <string name="choose_template_to_apply">Choose template to apply</string>
+    <string name="template_name">Template name</string>
     <string name="implementation_pending">Not implemented yet</string>
-    <string name="title_edit_template">Edit pattern</string>
-    <string name="title_new_template">New pattern</string>
+    <string name="title_edit_template">Edit template</string>
+    <string name="title_new_template">New template</string>
 </resources>