]> git.ktnx.net Git - mobile-ledger.git/commitdiff
handle preferred accounts filter setting in the profile detail UI
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Thu, 28 Mar 2019 22:19:17 +0000 (00:19 +0200)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Thu, 28 Mar 2019 22:19:17 +0000 (00:19 +0200)
app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailFragment.java
app/src/main/res/layout/profile_detail.xml

index 299ec42ba900a47071346fbc47eb52bd98056886..607c6b698d003e87ac71460c009312dcf08669e7 100644 (file)
@@ -78,6 +78,8 @@ public class ProfileDetailFragment extends Fragment implements HueRingDialog.Hue
     private TextInputLayout passwordLayout;
     private TextView profileName;
     private TextInputLayout profileNameLayout;
+    private TextView preferredAccountsFilter;
+    private TextInputLayout preferredAccountsFilterLayout;
     private View huePickerView;
 
     /**
@@ -175,10 +177,12 @@ public class ProfileDetailFragment extends Fragment implements HueRingDialog.Hue
         mProfile.setName(profileName.getText());
         mProfile.setUrl(url.getText());
         mProfile.setPostingPermitted(postingPermitted.isChecked());
+        mProfile.setPreferredAccountsFilter(preferredAccountsFilter.getText());
         mProfile.setAuthEnabled(useAuthentication.isChecked());
         mProfile.setAuthUserName(userName.getText());
         mProfile.setAuthPassword(password.getText());
         mProfile.setThemeId(huePickerView.getTag());
+    }
     @Override
     public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
                              Bundle savedInstanceState) {
@@ -196,6 +200,9 @@ public class ProfileDetailFragment extends Fragment implements HueRingDialog.Hue
         password = rootView.findViewById(R.id.password);
         passwordLayout = rootView.findViewById(R.id.password_layout);
         huePickerView = rootView.findViewById(R.id.btn_pick_ring_color);
+        preferredAccountsFilter = rootView.findViewById(R.id.preferred_accounts_filter_filter);
+        preferredAccountsFilterLayout =
+                rootView.findViewById(R.id.preferred_accounts_accounts_filter_layout);
 
         useAuthentication.setOnCheckedChangeListener((buttonView, isChecked) -> {
             Log.d("profiles", isChecked ? "auth enabled " : "auth disabled");
@@ -203,6 +210,11 @@ public class ProfileDetailFragment extends Fragment implements HueRingDialog.Hue
             if (isChecked) userName.requestFocus();
         });
 
+        preferredAccountsFilter.setText(mProfile.getPreferredAccountsFilter());
+        postingPermitted.setOnCheckedChangeListener(((buttonView, isChecked) -> {
+            preferredAccountsFilterLayout.setVisibility(isChecked ? View.VISIBLE : View.GONE);
+        }));
+
         hookClearErrorOnFocusListener(profileName, profileNameLayout);
         hookClearErrorOnFocusListener(url, urlLayout);
         hookClearErrorOnFocusListener(userName, userNameLayout);
index 6b55c2830af39c7343ccfe309b7e16c0bc686a5a..e7b9c6c8c6432f8b20c707216bb9f546401033f0 100644 (file)
@@ -61,6 +61,7 @@
     <LinearLayout
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
+        android:animateLayoutChanges="true"
         android:orientation="vertical">
 
         <Switch
 
         </LinearLayout>
 
+        <com.google.android.material.textfield.TextInputLayout
+            android:id="@+id/preferred_accounts_accounts_filter_layout"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginBottom="16dp"
+            android:orientation="vertical">
+
+            <com.google.android.material.textfield.TextInputEditText
+                android:id="@+id/preferred_accounts_filter_filter"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:ems="10"
+                android:fontFamily="monospace"
+                android:hint="@string/pref_preferred_autocompletion_account_filter_hint"
+                android:inputType="text" />
+        </com.google.android.material.textfield.TextInputLayout>
+
         <LinearLayout
             android:layout_width="match_parent"
             android:layout_height="match_parent"