From a7927d181b33642f139b5c8444733aea55ac7e0c Mon Sep 17 00:00:00 2001 From: Marc Schink Date: Wed, 6 Dec 2017 11:18:05 +0100 Subject: [PATCH] AccountAdapter: Allow hiding of state button --- .../conversations/ui/adapter/AccountAdapter.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/AccountAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/AccountAdapter.java index d7e241798..bbcf51c9d 100644 --- a/src/main/java/eu/siacs/conversations/ui/adapter/AccountAdapter.java +++ b/src/main/java/eu/siacs/conversations/ui/adapter/AccountAdapter.java @@ -29,10 +29,18 @@ import eu.siacs.conversations.utils.UIHelper; public class AccountAdapter extends ArrayAdapter { private XmppActivity activity; + private boolean showStateButton; + + public AccountAdapter(XmppActivity activity, List objects, boolean showStateButton) { + super(activity, 0, objects); + this.activity = activity; + this.showStateButton = showStateButton; + } public AccountAdapter(XmppActivity activity, List objects) { super(activity, 0, objects); this.activity = activity; + this.showStateButton = true; } @Override @@ -68,6 +76,11 @@ public class AccountAdapter extends ArrayAdapter { final Switch tglAccountState = (Switch) view.findViewById(R.id.tgl_account_status); final boolean isDisabled = (account.getStatus() == Account.State.DISABLED); tglAccountState.setChecked(!isDisabled,false); + if (this.showStateButton) { + tglAccountState.setVisibility(View.VISIBLE); + } else { + tglAccountState.setVisibility(View.GONE); + } tglAccountState.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) {