]> git.ktnx.net Git - mobile-ledger.git/commitdiff
fix account name auto-completion in new transaction screen started via shortcut
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Mon, 8 Apr 2019 18:10:40 +0000 (21:10 +0300)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Mon, 8 Apr 2019 18:11:26 +0000 (21:11 +0300)
app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionActivity.java
app/src/main/java/net/ktnx/mobileledger/utils/MLDB.java

index 310232d2057a6fc9585d5f29ec0118adfce629b9..b2ce8ef220880f31219f77f26b628fba4ba862d6 100644 (file)
@@ -100,7 +100,7 @@ public class NewTransactionActivity extends ProfileThemedActivity
         });
         tvDescription = findViewById(R.id.new_transaction_description);
         MLDB.hookAutocompletionAdapter(this, tvDescription, MLDB.DESCRIPTION_HISTORY_TABLE,
-                "description", false, findViewById(R.id.new_transaction_acc_1), this);
+                "description", false, findViewById(R.id.new_transaction_acc_1), this, mProfile);
         hookTextChangeListener(tvDescription);
 
         progress = findViewById(R.id.save_transaction_progress);
@@ -115,7 +115,7 @@ public class NewTransactionActivity extends ProfileThemedActivity
             TextView tvAmount = (TextView) row.getChildAt(1);
             hookSwipeListener(row);
             MLDB.hookAutocompletionAdapter(this, tvAccountName, MLDB.ACCOUNTS_TABLE, "name", true,
-                    tvAmount, null);
+                    tvAmount, null, mProfile);
             hookTextChangeListener(tvAccountName);
             hookTextChangeListener(tvAmount);
 //            Log.d("swipe", "hooked to row "+i);
@@ -361,7 +361,8 @@ public class NewTransactionActivity extends ProfileThemedActivity
         if (focus) acc.requestFocus();
 
         hookSwipeListener(row);
-        MLDB.hookAutocompletionAdapter(this, acc, MLDB.ACCOUNTS_TABLE, "name", true, amt, null);
+        MLDB.hookAutocompletionAdapter(this, acc, MLDB.ACCOUNTS_TABLE, "name", true, amt, null,
+                mProfile);
         hookTextChangeListener(acc);
         hookTextChangeListener(amt);
 
index 5075b9aee1730e3ec0ac5bd077fde94f3343d3d9..c59273b13eeaa70df04514054fb3bcebec13a8db 100644 (file)
@@ -36,6 +36,7 @@ import android.widget.SimpleCursorAdapter;
 
 import net.ktnx.mobileledger.async.DescriptionSelectedCallback;
 import net.ktnx.mobileledger.model.Data;
+import net.ktnx.mobileledger.model.MobileLedgerProfile;
 
 import org.jetbrains.annotations.NonNls;
 
@@ -123,14 +124,15 @@ public final class MLDB {
                                                  final AutoCompleteTextView view,
                                                  final String table, final String field,
                                                  final boolean profileSpecific) {
-        hookAutocompletionAdapter(context, view, table, field, profileSpecific, null, null);
+        hookAutocompletionAdapter(context, view, table, field, profileSpecific, null, null, Data.profile.get());
     }
     @TargetApi(Build.VERSION_CODES.N)
     public static void hookAutocompletionAdapter(final Context context,
                                                  final AutoCompleteTextView view,
                                                  final String table, final String field,
                                                  final boolean profileSpecific, final View nextView,
-                                                 final DescriptionSelectedCallback callback) {
+                                                 final DescriptionSelectedCallback callback,
+                                                 final MobileLedgerProfile profile) {
         String[] from = {field};
         int[] to = {android.R.id.text1};
         SimpleCursorAdapter adapter =
@@ -155,7 +157,7 @@ public final class MLDB {
                                     "FROM %s " +
                                     "WHERE profile=? AND %s_upper LIKE '%%'||?||'%%' " +
                                     "ORDER BY 2, 1;", field, field, field, field, table, field);
-                params = new String[]{str, str, str, Data.profile.get().getUuid(), str};
+                params = new String[]{str, str, str, profile.getUuid(), str};
             }
             else {
                 sql = String.format("SELECT %s as a, case when %s_upper LIKE ?||'%%' then 1 " +