aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--build.gradle1
-rw-r--r--src/main/java/eu/siacs/conversations/ui/XmppActivity.java11
-rw-r--r--src/main/java/eu/siacs/conversations/ui/adapter/AccountAdapter.java9
-rw-r--r--src/main/java/eu/siacs/conversations/ui/widget/Switch.java68
-rw-r--r--src/main/res/drawable/switch_back_off.xml15
-rw-r--r--src/main/res/drawable/switch_back_on.xml16
-rw-r--r--src/main/res/drawable/switch_thumb.xml12
-rw-r--r--src/main/res/layout/account_row.xml3
-rw-r--r--src/main/res/layout/contact_key.xml6
-rw-r--r--src/main/res/values/styles.xml13
10 files changed, 14 insertions, 140 deletions
diff --git a/build.gradle b/build.gradle
index 209cf450..60379a50 100644
--- a/build.gradle
+++ b/build.gradle
@@ -45,7 +45,6 @@ dependencies {
compile name: 'protobuf-java-2.5.0' // axolotl, loaded from maven
compile name: 'android-crop-1.0.1', ext: 'aar'
compile name: 'roundedimageview-2.2.0', ext: 'aar'
- compile name: 'switchbutton-1.2.8', ext: 'aar' // loaded from jcenter
compile name: 'openpgp-api-10.0', ext: 'aar' // loaded from jcenter
// Local modules
diff --git a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
index c709d842..0677fbd2 100644
--- a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
@@ -49,6 +49,7 @@ import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
+import android.widget.Switch;
import android.widget.TextView;
import android.widget.Toast;
@@ -71,6 +72,7 @@ import java.util.concurrent.RejectedExecutionException;
import de.thedevstack.android.logcat.Logging;
import de.thedevstack.conversationsplus.ConversationsPlusPreferences;
import de.thedevstack.conversationsplus.utils.ImageUtil;
+
import eu.siacs.conversations.Config;
import eu.siacs.conversations.R;
import eu.siacs.conversations.crypto.axolotl.XmppAxolotlSession;
@@ -82,7 +84,6 @@ import eu.siacs.conversations.entities.MucOptions;
import eu.siacs.conversations.entities.Presences;
import eu.siacs.conversations.services.XmppConnectionService;
import eu.siacs.conversations.services.XmppConnectionService.XmppConnectionBinder;
-import eu.siacs.conversations.ui.widget.Switch;
import eu.siacs.conversations.utils.CryptoHelper;
import eu.siacs.conversations.utils.ExceptionHelper;
import eu.siacs.conversations.xmpp.OnKeyStatusUpdated;
@@ -743,7 +744,7 @@ public abstract class XmppActivity extends Activity {
case UNTRUSTED:
case TRUSTED:
case TRUSTED_X509:
- trustToggle.setChecked(trust.trusted(), false);
+ trustToggle.setChecked(trust.trusted());
trustToggle.setEnabled(trust != XmppAxolotlSession.Trust.TRUSTED_X509);
if (trust == XmppAxolotlSession.Trust.TRUSTED_X509) {
trustToggle.setOnClickListener(null);
@@ -752,7 +753,7 @@ public abstract class XmppActivity extends Activity {
keyType.setTextColor(getSecondaryTextColor());
break;
case UNDECIDED:
- trustToggle.setChecked(false, false);
+ trustToggle.setChecked(false);
trustToggle.setEnabled(false);
key.setTextColor(getPrimaryTextColor());
keyType.setTextColor(getSecondaryTextColor());
@@ -760,7 +761,7 @@ public abstract class XmppActivity extends Activity {
case INACTIVE_UNTRUSTED:
case INACTIVE_UNDECIDED:
trustToggle.setOnClickListener(null);
- trustToggle.setChecked(false, false);
+ trustToggle.setChecked(false);
trustToggle.setEnabled(false);
key.setTextColor(getTertiaryTextColor());
keyType.setTextColor(getTertiaryTextColor());
@@ -768,7 +769,7 @@ public abstract class XmppActivity extends Activity {
case INACTIVE_TRUSTED:
case INACTIVE_TRUSTED_X509:
trustToggle.setOnClickListener(null);
- trustToggle.setChecked(true, false);
+ trustToggle.setChecked(true);
trustToggle.setEnabled(false);
key.setTextColor(getTertiaryTextColor());
keyType.setTextColor(getTertiaryTextColor());
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 4ab47b37..b8f15e0e 100644
--- a/src/main/java/eu/siacs/conversations/ui/adapter/AccountAdapter.java
+++ b/src/main/java/eu/siacs/conversations/ui/adapter/AccountAdapter.java
@@ -7,6 +7,7 @@ import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.CompoundButton;
import android.widget.ImageView;
+import android.widget.Switch;
import android.widget.TextView;
import java.util.List;
@@ -17,7 +18,6 @@ import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.services.AvatarService;
import eu.siacs.conversations.ui.ManageAccountActivity;
import eu.siacs.conversations.ui.XmppActivity;
-import eu.siacs.conversations.ui.widget.Switch;
public class AccountAdapter extends ArrayAdapter<Account> {
@@ -60,12 +60,13 @@ public class AccountAdapter extends ArrayAdapter<Account> {
}
final Switch tglAccountState = (Switch) view.findViewById(R.id.tgl_account_status);
final boolean isDisabled = (account.getStatus() == Account.State.DISABLED);
- tglAccountState.setChecked(!isDisabled,false);
+ tglAccountState.setChecked(!isDisabled);
tglAccountState.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
- if (b == isDisabled && activity instanceof ManageAccountActivity) {
- ((ManageAccountActivity) activity).onClickTglAccountState(account,b);
+ // Condition compoundButton.isPressed() added because of http://stackoverflow.com/a/28219410
+ if (compoundButton.isPressed() && b == isDisabled && activity instanceof ManageAccountActivity) {
+ ((ManageAccountActivity) activity).onClickTglAccountState(account, b);
}
}
});
diff --git a/src/main/java/eu/siacs/conversations/ui/widget/Switch.java b/src/main/java/eu/siacs/conversations/ui/widget/Switch.java
deleted file mode 100644
index fd3b5553..00000000
--- a/src/main/java/eu/siacs/conversations/ui/widget/Switch.java
+++ /dev/null
@@ -1,68 +0,0 @@
-package eu.siacs.conversations.ui.widget;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.view.MotionEvent;
-import android.view.ViewConfiguration;
-
-import com.kyleduo.switchbutton.SwitchButton;
-
-public class Switch extends SwitchButton {
-
- private int mTouchSlop;
- private int mClickTimeout;
- private float mStartX;
- private float mStartY;
- private OnClickListener mOnClickListener;
-
- public Switch(Context context) {
- super(context);
- mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
- mClickTimeout = ViewConfiguration.getPressedStateDuration() + ViewConfiguration.getTapTimeout();
- }
-
- public Switch(Context context, AttributeSet attrs) {
- super(context, attrs);
- mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
- mClickTimeout = ViewConfiguration.getPressedStateDuration() + ViewConfiguration.getTapTimeout();
- }
-
- public Switch(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
- mClickTimeout = ViewConfiguration.getPressedStateDuration() + ViewConfiguration.getTapTimeout();
- }
-
- @Override
- public void setOnClickListener(OnClickListener onClickListener) {
- this.mOnClickListener = onClickListener;
- }
-
- @Override
- public boolean onTouchEvent(MotionEvent event) {
- if (!isEnabled()) {
- float deltaX = event.getX() - mStartX;
- float deltaY = event.getY() - mStartY;
- int action = event.getAction();
- switch (action) {
- case MotionEvent.ACTION_DOWN:
- mStartX = event.getX();
- mStartY = event.getY();
- break;
- case MotionEvent.ACTION_CANCEL:
- case MotionEvent.ACTION_UP:
- float time = event.getEventTime() - event.getDownTime();
- if (deltaX < mTouchSlop && deltaY < mTouchSlop && time < mClickTimeout) {
- if (mOnClickListener != null) {
- this.mOnClickListener.onClick(this);
- }
- }
- break;
- default:
- break;
- }
- return true;
- }
- return super.onTouchEvent(event);
- }
-}
diff --git a/src/main/res/drawable/switch_back_off.xml b/src/main/res/drawable/switch_back_off.xml
deleted file mode 100644
index 20d2fb14..00000000
--- a/src/main/res/drawable/switch_back_off.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
-
- <item android:state_enabled="false"><shape android:shape="rectangle">
- <solid android:color="#D5D5D5" />
-
- <corners android:radius="99dp" />
- </shape></item>
- <item android:state_enabled="true"><shape android:shape="rectangle">
- <solid android:color="#939393" />
-
- <corners android:radius="99dp" />
- </shape></item>
-
-</selector> \ No newline at end of file
diff --git a/src/main/res/drawable/switch_back_on.xml b/src/main/res/drawable/switch_back_on.xml
deleted file mode 100644
index 45117a98..00000000
--- a/src/main/res/drawable/switch_back_on.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:state_enabled="false">
- <shape android:shape="rectangle">
- <solid android:color="#D5D5D5"/>
- <corners android:radius="99dp"/>
- </shape>
- </item>
- <item android:state_enabled="true">
- <shape android:shape="rectangle">
- <!-- 30% accent on white -->
- <solid android:color="#b3ddf7"/>
- <corners android:radius="99dp"/>
- </shape>
- </item>
-</selector> \ No newline at end of file
diff --git a/src/main/res/drawable/switch_thumb.xml b/src/main/res/drawable/switch_thumb.xml
deleted file mode 100644
index ba3d1c45..00000000
--- a/src/main/res/drawable/switch_thumb.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
-
- <item android:drawable="@drawable/switch_thumb_disable" android:state_enabled="false"/>
- <item android:drawable="@drawable/switch_thumb_on_pressed" android:state_checked="true" android:state_pressed="true"/>
- <item android:drawable="@drawable/switch_thumb_on_pressed" android:state_checked="true" android:state_focused="true"/>
- <item android:drawable="@drawable/switch_thumb_on_normal" android:state_checked="true"/>
- <item android:drawable="@drawable/switch_thumb_off_pressed" android:state_checked="false" android:state_pressed="true"/>
- <item android:drawable="@drawable/switch_thumb_off_pressed" android:state_checked="false" android:state_focused="true"/>
- <item android:drawable="@drawable/switch_thumb_off_normal" android:state_checked="false"/>
-
-</selector> \ No newline at end of file
diff --git a/src/main/res/layout/account_row.xml b/src/main/res/layout/account_row.xml
index c6569d5a..d1ec92af 100644
--- a/src/main/res/layout/account_row.xml
+++ b/src/main/res/layout/account_row.xml
@@ -46,8 +46,7 @@
android:textStyle="bold" />
</LinearLayout>
- <eu.siacs.conversations.ui.widget.Switch
- style="@style/MD"
+ <Switch
android:id="@+id/tgl_account_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
diff --git a/src/main/res/layout/contact_key.xml b/src/main/res/layout/contact_key.xml
index 6d61026d..03246ccb 100644
--- a/src/main/res/layout/contact_key.xml
+++ b/src/main/res/layout/contact_key.xml
@@ -55,15 +55,13 @@
android:src="?attr/icon_remove"
android:visibility="gone" />
-
- <eu.siacs.conversations.ui.widget.Switch
+ <Switch
android:id="@+id/tgl_trust"
android:visibility="invisible"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
- android:layout_centerVertical="true"
- style="@style/MD"/>
+ android:layout_centerVertical="true"/>
</RelativeLayout>
</RelativeLayout> \ No newline at end of file
diff --git a/src/main/res/values/styles.xml b/src/main/res/values/styles.xml
index e8572d9d..450cf183 100644
--- a/src/main/res/values/styles.xml
+++ b/src/main/res/values/styles.xml
@@ -4,18 +4,5 @@
<item name="android:layout_height">1.5dp</item>
<item name="android:background">@color/black12</item>
</style>
- <style name="MD">
- <item name="animationVelocity">6</item>
- <item name="insetBottom">16dp</item>
- <item name="insetTop">16dp</item>
- <item name="insetLeft">16dp</item>
- <item name="insetRight">16dp</item>
- <item name="measureFactor">1.4</item>
- <item name="offDrawable">@drawable/switch_back_off</item>
- <item name="onDrawable">@drawable/switch_back_on</item>
- <item name="thumbDrawable">@drawable/switch_thumb</item>
- <item name="thumb_margin">-17dp</item>
- <item name="android:padding">16dp</item>
- </style>
</resources> \ No newline at end of file