summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFabrice Di Meglio <fdimeglio@google.com>2014-07-16 01:55:21 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-07-15 20:35:01 +0000
commitfd1415d204e4a11a26fe2d550709c0fe42df46ab (patch)
treea31b9a987567e0fabeadbb29909ad02aca2f47f6 /src
parenteda4acbb499c7e310bcf5e5465a0f0cd1c773204 (diff)
parent1b18665dbc49663f290859ce9cdf3237b8a30b7c (diff)
downloadpackages_apps_Settings-fd1415d204e4a11a26fe2d550709c0fe42df46ab.tar.gz
packages_apps_Settings-fd1415d204e4a11a26fe2d550709c0fe42df46ab.tar.bz2
packages_apps_Settings-fd1415d204e4a11a26fe2d550709c0fe42df46ab.zip
Merge "Fix bug #16319697 ACTION_DEVICE_INFO_SETTINGS intent causes Settings app to crash" into lmp-dev
Diffstat (limited to 'src')
-rw-r--r--src/com/android/settings/widget/SwitchBar.java27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/com/android/settings/widget/SwitchBar.java b/src/com/android/settings/widget/SwitchBar.java
index c8afa1c76..d974a9d62 100644
--- a/src/com/android/settings/widget/SwitchBar.java
+++ b/src/com/android/settings/widget/SwitchBar.java
@@ -17,11 +17,14 @@
package com.android.settings.widget;
import android.content.Context;
+import android.content.res.TypedArray;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.AttributeSet;
+import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
+import android.view.ViewGroup;
import android.widget.CompoundButton;
import android.widget.LinearLayout;
@@ -34,12 +37,6 @@ import java.util.ArrayList;
public class SwitchBar extends LinearLayout implements CompoundButton.OnCheckedChangeListener,
View.OnClickListener {
- private ToggleSwitch mSwitch;
- private TextView mTextView;
-
- private ArrayList<OnSwitchChangeListener> mSwitchChangeListeners =
- new ArrayList<OnSwitchChangeListener>();
-
public static interface OnSwitchChangeListener {
/**
* Called when the checked state of the Switch has changed.
@@ -50,6 +47,15 @@ public class SwitchBar extends LinearLayout implements CompoundButton.OnCheckedC
void onSwitchChanged(Switch switchView, boolean isChecked);
}
+ private ToggleSwitch mSwitch;
+ private TextView mTextView;
+
+ private ArrayList<OnSwitchChangeListener> mSwitchChangeListeners =
+ new ArrayList<OnSwitchChangeListener>();
+
+ private static int[] MARGIN_ATTRIBUTES = {
+ R.attr.switchBarMarginStart, R.attr.switchBarMarginEnd};
+
public SwitchBar(Context context) {
this(context, null);
}
@@ -67,13 +73,22 @@ public class SwitchBar extends LinearLayout implements CompoundButton.OnCheckedC
LayoutInflater.from(context).inflate(R.layout.switch_bar, this);
+ final TypedArray a = context.obtainStyledAttributes(attrs, MARGIN_ATTRIBUTES);
+ int switchBarMarginStart = (int) a.getDimension(0, 0);
+ int switchBarMarginEnd = (int) a.getDimension(1, 0);
+ a.recycle();
+
mTextView = (TextView) findViewById(R.id.switch_text);
mTextView.setText(R.string.switch_off_text);
+ ViewGroup.MarginLayoutParams lp = (MarginLayoutParams) mTextView.getLayoutParams();
+ lp.setMarginStart(switchBarMarginStart);
mSwitch = (ToggleSwitch) findViewById(R.id.switch_widget);
// Prevent onSaveInstanceState() to be called as we are managing the state of the Switch
// on our own
mSwitch.setSaveEnabled(false);
+ lp = (MarginLayoutParams) mSwitch.getLayoutParams();
+ lp.setMarginEnd(switchBarMarginEnd);
addOnSwitchChangeListener(new OnSwitchChangeListener() {
@Override