Commit 46fd69db authored by Mygod's avatar Mygod

Change checkboxes to switches to match system settings

parent 136a1535
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical" android:orientation="vertical"
android:duplicateParentState="false"> android:duplicateParentState="false">
<include layout="@layout/toolbar_light_dark" /> <include layout="@layout/toolbar_light_dark"/>
<RelativeLayout <LinearLayout
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="6dp" android:paddingBottom="8dp"
android:layout_marginBottom="8dp"> android:paddingLeft="48dp"
android:paddingStart="48dp"
android:paddingTop="8dp"
android:background="@android:color/white"
android:elevation="1dp" tools:ignore="RtlSymmetry">
<TextView <TextView
android:id="@+id/bypassLabel" android:id="@+id/bypassLabel"
android:layout_width="wrap_content" android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="3dp"
android:gravity="center_vertical" android:gravity="center_vertical"
android:layout_marginLeft="16dp"
android:textSize="18sp" android:textSize="18sp"
android:text="@string/bypass_apps" android:text="@string/bypass_apps"/>
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"/>
<Switch <Switch
android:id="@+id/bypassSwitch" android:id="@+id/bypassSwitch"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentRight="true" android:layout_marginEnd="6dp"
android:layout_centerVertical="true" android:layout_marginRight="6dp"/>
android:layout_marginRight="16dp"/> </LinearLayout>
</RelativeLayout>
<ListView <ListView
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
android:textSize="18sp" android:textSize="18sp"
android:padding="3dp"/> android:padding="3dp"/>
<CheckBox <Switch
android:id="@+id/itemcheck" android:id="@+id/itemcheck"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="fill_parent" android:layout_height="fill_parent"
......
...@@ -58,19 +58,19 @@ ...@@ -58,19 +58,19 @@
android:summary="@string/route_list_summary" android:summary="@string/route_list_summary"
android:title="@string/route_list"> android:title="@string/route_list">
</com.github.shadowsocks.preferences.SummaryListPreference> </com.github.shadowsocks.preferences.SummaryListPreference>
<CheckBoxPreference <SwitchPreference
android:key="isIpv6" android:key="isIpv6"
android:defaultValue="false" android:defaultValue="false"
android:summary="@string/ipv6_summary" android:summary="@string/ipv6_summary"
android:title="@string/ipv6"> android:title="@string/ipv6">
</CheckBoxPreference> </SwitchPreference>
<CheckBoxPreference <SwitchPreference
android:defaultValue="true" android:defaultValue="true"
android:key="isGlobalProxy" android:key="isGlobalProxy"
android:disableDependentsState="true" android:disableDependentsState="true"
android:summary="@string/auto_set_proxy_summary" android:summary="@string/auto_set_proxy_summary"
android:title="@string/auto_set_proxy"> android:title="@string/auto_set_proxy">
</CheckBoxPreference> </SwitchPreference>
<Preference <Preference
android:key="proxyedApps" android:key="proxyedApps"
android:dependency="isGlobalProxy" android:dependency="isGlobalProxy"
...@@ -78,23 +78,23 @@ ...@@ -78,23 +78,23 @@
android:title="@string/proxied_apps"> android:title="@string/proxied_apps">
<intent android:action="com.github.shadowsocks.AppManager"/> <intent android:action="com.github.shadowsocks.AppManager"/>
</Preference> </Preference>
<CheckBoxPreference <SwitchPreference
android:key="isUdpDns" android:key="isUdpDns"
android:defaultValue="false" android:defaultValue="false"
android:summary="@string/udp_dns_summary" android:summary="@string/udp_dns_summary"
android:title="@string/udp_dns"> android:title="@string/udp_dns">
</CheckBoxPreference> </SwitchPreference>
<CheckBoxPreference <SwitchPreference
android:key="isAuth" android:key="isAuth"
android:defaultValue="false" android:defaultValue="false"
android:summary="@string/onetime_auth_summary" android:summary="@string/onetime_auth_summary"
android:title="@string/onetime_auth"> android:title="@string/onetime_auth">
</CheckBoxPreference> </SwitchPreference>
<CheckBoxPreference <SwitchPreference
android:key="isAutoConnect" android:key="isAutoConnect"
android:summary="@string/auto_connect_summary" android:summary="@string/auto_connect_summary"
android:title="@string/auto_connect"> android:title="@string/auto_connect">
</CheckBoxPreference> </SwitchPreference>
</PreferenceCategory> </PreferenceCategory>
......
...@@ -78,7 +78,7 @@ class ObjectArrayTools[T <: AnyRef](a: Array[T]) { ...@@ -78,7 +78,7 @@ class ObjectArrayTools[T <: AnyRef](a: Array[T]) {
} }
} }
case class ListEntry(box: CheckBox, text: TextView, icon: ImageView) case class ListEntry(switch: Switch, text: TextView, icon: ImageView)
object AppManager { object AppManager {
...@@ -162,13 +162,13 @@ class AppManager extends Activity with OnCheckedChangeListener with OnClickListe ...@@ -162,13 +162,13 @@ class AppManager extends Activity with OnCheckedChangeListener with OnClickListe
if (convertView == null) { if (convertView == null) {
convertView = getLayoutInflater.inflate(R.layout.layout_apps_item, parent, false) convertView = getLayoutInflater.inflate(R.layout.layout_apps_item, parent, false)
val icon = convertView.findViewById(R.id.itemicon).asInstanceOf[ImageView] val icon = convertView.findViewById(R.id.itemicon).asInstanceOf[ImageView]
val box = convertView.findViewById(R.id.itemcheck).asInstanceOf[CheckBox] val switch = convertView.findViewById(R.id.itemcheck).asInstanceOf[Switch]
val text = convertView.findViewById(R.id.itemtext).asInstanceOf[TextView] val text = convertView.findViewById(R.id.itemtext).asInstanceOf[TextView]
entry = new ListEntry(box, text, icon) entry = new ListEntry(switch, text, icon)
entry.text.setOnClickListener(AppManager.this) entry.text.setOnClickListener(AppManager.this)
entry.text.setOnClickListener(AppManager.this) entry.text.setOnClickListener(AppManager.this)
convertView.setTag(entry) convertView.setTag(entry)
entry.box.setOnCheckedChangeListener(AppManager.this) entry.switch.setOnCheckedChangeListener(AppManager.this)
} else { } else {
entry = convertView.getTag.asInstanceOf[ListEntry] entry = convertView.getTag.asInstanceOf[ListEntry]
} }
...@@ -187,10 +187,10 @@ class AppManager extends Activity with OnCheckedChangeListener with OnClickListe ...@@ -187,10 +187,10 @@ class AppManager extends Activity with OnCheckedChangeListener with OnClickListe
ImageLoader.getInstance().displayImage(Scheme.APP + app.packageName, entry.icon, options) ImageLoader.getInstance().displayImage(Scheme.APP + app.packageName, entry.icon, options)
entry.text.setText(app.name) entry.text.setText(app.name)
val box: CheckBox = entry.box val switch = entry.switch
box.setTag(app) switch.setTag(app)
box.setChecked(app.proxied) switch.setChecked(app.proxied)
entry.text.setTag(box) entry.text.setTag(switch)
convertView convertView
} }
} }
...@@ -207,11 +207,11 @@ class AppManager extends Activity with OnCheckedChangeListener with OnClickListe ...@@ -207,11 +207,11 @@ class AppManager extends Activity with OnCheckedChangeListener with OnClickListe
} }
def onClick(v: View) { def onClick(v: View) {
val cbox: CheckBox = v.getTag.asInstanceOf[CheckBox] val switch = v.getTag.asInstanceOf[Switch]
val app: ProxiedApp = cbox.getTag.asInstanceOf[ProxiedApp] val app: ProxiedApp = switch.getTag.asInstanceOf[ProxiedApp]
if (app != null) { if (app != null) {
app.proxied = !app.proxied app.proxied = !app.proxied
cbox.setChecked(app.proxied) switch.setChecked(app.proxied)
} }
saveAppSettings(this) saveAppSettings(this)
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment