From: Damyan Ivanov Date: Wed, 6 May 2020 07:45:48 +0000 (+0300) Subject: profile editor: streamlined handling of authentication switch X-Git-Tag: v0.12.0~4 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=8ee42b51c43efbd0ff6fa0fec257132d4421f53d;p=mobile-ledger.git profile editor: streamlined handling of authentication switch focus moves only when responding to the UI, hook to the LiveData, not to the UI element --- 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 61d0d519..aba3b0f2 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 @@ -321,12 +321,14 @@ public class ProfileDetailFragment extends Fragment { useAuthentication = context.findViewById(R.id.enable_http_auth); useAuthentication.setOnCheckedChangeListener((buttonView, isChecked) -> { model.setUseAuthentication(isChecked); - authParams.setVisibility(isChecked ? View.VISIBLE : View.GONE); if (isChecked) userName.requestFocus(); + }); + model.observeUseAuthentication(viewLifecycleOwner, isChecked -> { + useAuthentication.setChecked(isChecked); + authParams.setVisibility(isChecked ? View.VISIBLE : View.GONE); checkInsecureSchemeWithAuth(); }); - model.observeUseAuthentication(viewLifecycleOwner, useAuthentication::setChecked); userName = context.findViewById(R.id.auth_user_name); model.observeUserName(viewLifecycleOwner, text -> {