diff options
author | iNPUTmice <daniel@gultsch.de> | 2015-04-13 18:19:40 +0200 |
---|---|---|
committer | iNPUTmice <daniel@gultsch.de> | 2015-04-13 18:19:40 +0200 |
commit | 2f24b093093296ca6f4f90fbcf664b050a8b03fc (patch) | |
tree | b03c68708579e4929e999cc7527081a786b78980 /src | |
parent | 62faa163f0d5fc2d8d53067cc328f1905d1df370 (diff) |
fixed disable account when sliding and not clicking the toggle
Diffstat (limited to '')
-rw-r--r-- | src/main/java/eu/siacs/conversations/ui/ManageAccountActivity.java | 4 | ||||
-rw-r--r-- | src/main/java/eu/siacs/conversations/ui/adapter/AccountAdapter.java | 13 |
2 files changed, 9 insertions, 8 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/ManageAccountActivity.java b/src/main/java/eu/siacs/conversations/ui/ManageAccountActivity.java index c7db94af..56dbc55e 100644 --- a/src/main/java/eu/siacs/conversations/ui/ManageAccountActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ManageAccountActivity.java @@ -168,8 +168,8 @@ public class ManageAccountActivity extends XmppActivity implements OnAccountUpda } } - public void onClickTglAccountState(Account account) { - if (account.isOptionSet(Account.OPTION_DISABLED)) { + public void onClickTglAccountState(Account account, boolean enable) { + if (enable) { enableAccount(account); } else { disableAccount(account); 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 5209aa12..95c0524d 100644 --- a/src/main/java/eu/siacs/conversations/ui/adapter/AccountAdapter.java +++ b/src/main/java/eu/siacs/conversations/ui/adapter/AccountAdapter.java @@ -11,6 +11,7 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; +import android.widget.CompoundButton; import android.widget.ImageView; import android.widget.TextView; import android.widget.Switch; @@ -51,14 +52,14 @@ public class AccountAdapter extends ArrayAdapter<Account> { break; } final Switch tglAccountState = (Switch) view.findViewById(R.id.tgl_account_status); - boolean isDisabled = (account.getStatus() == Account.State.DISABLED) ? true : false; + final boolean isDisabled = (account.getStatus() == Account.State.DISABLED) ? true : false; + tglAccountState.setOnCheckedChangeListener(null); tglAccountState.setChecked(!isDisabled); - tglAccountState.setOnClickListener(new View.OnClickListener() { + tglAccountState.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override - public void onClick(View v) { - if (activity instanceof ManageAccountActivity) { - ((ManageAccountActivity) activity).onClickTglAccountState(account); - tglAccountState.toggle(); + public void onCheckedChanged(CompoundButton compoundButton, boolean b) { + if (b == isDisabled && activity instanceof ManageAccountActivity) { + ((ManageAccountActivity) activity).onClickTglAccountState(account,b); } } }); |