From b296570e4c84379133927f7f35e1220b9b1d6862 Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Sun, 27 Dec 2020 12:41:30 +0200 Subject: [PATCH] Migrate from Switch to SwitchMaterial --- .../ui/profiles/ProfileDetailFragment.java | 10 +++++----- app/src/main/res/layout/profile_detail.xml | 8 ++++---- app/src/main/res/layout/switch_item.xml | 7 ++++--- app/src/main/res/menu/new_transaction_fragment.xml | 3 ++- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailFragment.java b/app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailFragment.java index e4fa95ae..672acf0e 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailFragment.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailFragment.java @@ -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))); diff --git a/app/src/main/res/layout/profile_detail.xml b/app/src/main/res/layout/profile_detail.xml index 9fa89479..83c4f228 100644 --- a/app/src/main/res/layout/profile_detail.xml +++ b/app/src/main/res/layout/profile_detail.xml @@ -68,7 +68,7 @@ android:orientation="vertical" > - - - - - + android:layout_centerVertical="true" + /> diff --git a/app/src/main/res/menu/new_transaction_fragment.xml b/app/src/main/res/menu/new_transaction_fragment.xml index c55428e9..c44acf51 100644 --- a/app/src/main/res/menu/new_transaction_fragment.xml +++ b/app/src/main/res/menu/new_transaction_fragment.xml @@ -1,6 +1,6 @@