aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs
diff options
context:
space:
mode:
authoriNPUTmice <daniel@gultsch.de>2015-04-01 23:46:54 +0200
committeriNPUTmice <daniel@gultsch.de>2015-04-01 23:46:54 +0200
commitef680840988f0907a2c1911f82e73644ba92000c (patch)
tree7646f294df063af1519a56908eec67b3a404fc43 /src/main/java/eu/siacs
parent1a376cacaca2ff3199624e791d1f4990196297fd (diff)
parentb7b87e1a8d3c17f49eb9f9d5434224d38afabb24 (diff)
Merge branch 'BrianBlade-account_state_switch' into development
Diffstat (limited to 'src/main/java/eu/siacs')
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ManageAccountActivity.java8
-rw-r--r--src/main/java/eu/siacs/conversations/ui/adapter/AccountAdapter.java45
2 files changed, 37 insertions, 16 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/ManageAccountActivity.java b/src/main/java/eu/siacs/conversations/ui/ManageAccountActivity.java
index b2d5ddfd..c7db94af 100644
--- a/src/main/java/eu/siacs/conversations/ui/ManageAccountActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/ManageAccountActivity.java
@@ -168,6 +168,14 @@ public class ManageAccountActivity extends XmppActivity implements OnAccountUpda
}
}
+ public void onClickTglAccountState(Account account) {
+ if (account.isOptionSet(Account.OPTION_DISABLED)) {
+ enableAccount(account);
+ } else {
+ disableAccount(account);
+ }
+ }
+
private void publishAvatar(Account account) {
Intent intent = new Intent(getApplicationContext(),
PublishProfilePictureActivity.class);
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 29730914..5209aa12 100644
--- a/src/main/java/eu/siacs/conversations/ui/adapter/AccountAdapter.java
+++ b/src/main/java/eu/siacs/conversations/ui/adapter/AccountAdapter.java
@@ -5,6 +5,7 @@ import java.util.List;
import eu.siacs.conversations.R;
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.ui.XmppActivity;
+import eu.siacs.conversations.ui.ManageAccountActivity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
@@ -12,6 +13,7 @@ import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
+import android.widget.Switch;
public class AccountAdapter extends ArrayAdapter<Account> {
@@ -24,7 +26,7 @@ public class AccountAdapter extends ArrayAdapter<Account> {
@Override
public View getView(int position, View view, ViewGroup parent) {
- Account account = getItem(position);
+ final Account account = getItem(position);
if (view == null) {
LayoutInflater inflater = (LayoutInflater) getContext()
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
@@ -34,21 +36,32 @@ public class AccountAdapter extends ArrayAdapter<Account> {
jid.setText(account.getJid().toBareJid().toString());
TextView statusView = (TextView) view.findViewById(R.id.account_status);
ImageView imageView = (ImageView) view.findViewById(R.id.account_image);
- imageView.setImageBitmap(activity.avatarService().get(account,
- activity.getPixel(48)));
- statusView.setText(getContext().getString(account.getStatus().getReadableId()));
- switch (account.getStatus()) {
- case ONLINE:
- statusView.setTextColor(activity.getOnlineColor());
- break;
- case DISABLED:
- case CONNECTING:
- statusView.setTextColor(activity.getSecondaryTextColor());
- break;
- default:
- statusView.setTextColor(activity.getWarningTextColor());
- break;
- }
+ imageView.setImageBitmap(activity.avatarService().get(account, activity.getPixel(48)));
+ statusView.setText(getContext().getString(account.getStatus().getReadableId()));
+ switch (account.getStatus()) {
+ case ONLINE:
+ statusView.setTextColor(activity.getOnlineColor());
+ break;
+ case DISABLED:
+ case CONNECTING:
+ statusView.setTextColor(activity.getSecondaryTextColor());
+ break;
+ default:
+ statusView.setTextColor(activity.getWarningTextColor());
+ break;
+ }
+ final Switch tglAccountState = (Switch) view.findViewById(R.id.tgl_account_status);
+ boolean isDisabled = (account.getStatus() == Account.State.DISABLED) ? true : false;
+ tglAccountState.setChecked(!isDisabled);
+ tglAccountState.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (activity instanceof ManageAccountActivity) {
+ ((ManageAccountActivity) activity).onClickTglAccountState(account);
+ tglAccountState.toggle();
+ }
+ }
+ });
return view;
}
}