]> git.ktnx.net Git - mobile-ledger.git/commitdiff
Migrate from Switch to SwitchMaterial
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Sun, 27 Dec 2020 10:41:30 +0000 (12:41 +0200)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Sun, 27 Dec 2020 10:41:30 +0000 (12:41 +0200)
app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailFragment.java
app/src/main/res/layout/profile_detail.xml
app/src/main/res/layout/switch_item.xml
app/src/main/res/menu/new_transaction_fragment.xml

index e4fa95aebc817576afe68deb37e77e43e3e8559f..672acf0ec4a58cb37d7ba0a897c8065b9433feae 100644 (file)
@@ -29,7 +29,6 @@ import android.view.MenuItem;
 import android.view.View;
 import android.widget.LinearLayout;
 import android.widget.PopupMenu;
-import android.widget.Switch;
 import android.widget.TextView;
 
 import androidx.annotation.NonNull;
@@ -42,6 +41,7 @@ import androidx.lifecycle.ViewModelProvider;
 
 import com.google.android.material.appbar.CollapsingToolbarLayout;
 import com.google.android.material.floatingactionbutton.FloatingActionButton;
+import com.google.android.material.switchmaterial.SwitchMaterial;
 import com.google.android.material.textfield.TextInputLayout;
 
 import net.ktnx.mobileledger.BuildConfig;
@@ -86,7 +86,7 @@ public class ProfileDetailFragment extends Fragment {
     private boolean defaultCommoditySet;
     private TextInputLayout urlLayout;
     private LinearLayout authParams;
-    private Switch useAuthentication;
+    private SwitchMaterial useAuthentication;
     private TextView userName;
     private TextInputLayout userNameLayout;
     private TextView password;
@@ -242,14 +242,14 @@ public class ProfileDetailFragment extends Fragment {
                    cpf.show(activity.getSupportFragmentManager(), "currency-selector");
                });
 
-        Switch showCommodityByDefault = context.findViewById(R.id.profile_show_commodity);
+        SwitchMaterial showCommodityByDefault = context.findViewById(R.id.profile_show_commodity);
         showCommodityByDefault.setOnCheckedChangeListener(
                 (buttonView, isChecked) -> model.setShowCommodityByDefault(isChecked));
         model.observeShowCommodityByDefault(viewLifecycleOwner, showCommodityByDefault::setChecked);
 
         View postingSubItems = context.findViewById(R.id.posting_sub_items);
 
-        Switch postingPermitted = context.findViewById(R.id.profile_permit_posting);
+        SwitchMaterial postingPermitted = context.findViewById(R.id.profile_permit_posting);
         model.observePostingPermitted(viewLifecycleOwner, isChecked -> {
             postingPermitted.setChecked(isChecked);
             postingSubItems.setVisibility(isChecked ? View.VISIBLE : View.GONE);
@@ -257,7 +257,7 @@ public class ProfileDetailFragment extends Fragment {
         postingPermitted.setOnCheckedChangeListener(
                 ((buttonView, isChecked) -> model.setPostingPermitted(isChecked)));
 
-        Switch showCommentsByDefault = context.findViewById(R.id.profile_show_comments);
+        SwitchMaterial showCommentsByDefault = context.findViewById(R.id.profile_show_comments);
         model.observeShowCommentsByDefault(viewLifecycleOwner, showCommentsByDefault::setChecked);
         showCommentsByDefault.setOnCheckedChangeListener(
                 ((buttonView, isChecked) -> model.setShowCommentsByDefault(isChecked)));
index 9fa89479cc2c1ba0ff39ef4f43fa63501a35ef03..83c4f22863a787214358dda2765ab62e52aa03af 100644 (file)
@@ -68,7 +68,7 @@
         android:orientation="vertical"
         >
 
-        <Switch
+        <com.google.android.material.switchmaterial.SwitchMaterial
             android:id="@+id/enable_http_auth"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
                 />
         </androidx.constraintlayout.widget.ConstraintLayout>
 
-        <Switch
+        <com.google.android.material.switchmaterial.SwitchMaterial
             android:id="@+id/profile_permit_posting"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
                     />
             </LinearLayout>
 
-            <Switch
+            <com.google.android.material.switchmaterial.SwitchMaterial
                 android:id="@+id/profile_show_commodity"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
                 android:textAppearance="?android:textAppearanceListItem"
                 />
 
-            <Switch
+            <com.google.android.material.switchmaterial.SwitchMaterial
                 android:id="@+id/profile_show_comments"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
index 5835f1440fa6376db14e3a21ade7be5d9e1dcf25..e11755d03a0d626f3aa1077a35060f19fb83bbc6 100644 (file)
@@ -1,5 +1,5 @@
 <!--
-  ~ Copyright © 2019 Damyan Ivanov.
+  ~ 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
     android:layout_width="match_parent"
     android:layout_height="match_parent">
 
-    <Switch
+    <com.google.android.material.switchmaterial.SwitchMaterial
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_centerHorizontal="true"
-        android:layout_centerVertical="true" />
+        android:layout_centerVertical="true"
+        />
 </RelativeLayout>
index c55428e95440feff2cb8b1a4a912fd0de971cf22..c44acf51d777bafc5dc13b390f963b83dfec82f6 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!--
-  ~ Copyright © 2019 Damyan Ivanov.
+  ~ 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
@@ -23,6 +23,7 @@
         android:title="@string/show_currency_input"
         android:checkable="true"
         android:checked="false"
+        app:actionLayout="@layout/switch_item"
         app:showAsAction="never" />
     <item
         android:id="@+id/toggle_comments"