Change checkboxes to switches to match system settings
This commit is contained in:
@@ -1,35 +1,37 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
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:orientation="vertical"
|
||||
android:duplicateParentState="false">
|
||||
<include layout="@layout/toolbar_light_dark" />
|
||||
<RelativeLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="6dp"
|
||||
android:layout_marginBottom="8dp">
|
||||
<include layout="@layout/toolbar_light_dark"/>
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="8dp"
|
||||
android:paddingLeft="48dp"
|
||||
android:paddingStart="48dp"
|
||||
android:paddingTop="8dp"
|
||||
android:background="@android:color/white"
|
||||
android:elevation="1dp" tools:ignore="RtlSymmetry">
|
||||
<TextView
|
||||
android:id="@+id/bypassLabel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="3dp"
|
||||
android:gravity="center_vertical"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:textSize="18sp"
|
||||
android:text="@string/bypass_apps"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_centerVertical="true"/>
|
||||
android:text="@string/bypass_apps"/>
|
||||
|
||||
<Switch
|
||||
android:id="@+id/bypassSwitch"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginRight="16dp"/>
|
||||
</RelativeLayout>
|
||||
android:layout_marginEnd="6dp"
|
||||
android:layout_marginRight="6dp"/>
|
||||
</LinearLayout>
|
||||
<ListView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
android:textSize="18sp"
|
||||
android:padding="3dp"/>
|
||||
|
||||
<CheckBox
|
||||
<Switch
|
||||
android:id="@+id/itemcheck"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="fill_parent"
|
||||
|
||||
@@ -58,19 +58,19 @@
|
||||
android:summary="@string/route_list_summary"
|
||||
android:title="@string/route_list">
|
||||
</com.github.shadowsocks.preferences.SummaryListPreference>
|
||||
<CheckBoxPreference
|
||||
<SwitchPreference
|
||||
android:key="isIpv6"
|
||||
android:defaultValue="false"
|
||||
android:summary="@string/ipv6_summary"
|
||||
android:title="@string/ipv6">
|
||||
</CheckBoxPreference>
|
||||
<CheckBoxPreference
|
||||
</SwitchPreference>
|
||||
<SwitchPreference
|
||||
android:defaultValue="true"
|
||||
android:key="isGlobalProxy"
|
||||
android:disableDependentsState="true"
|
||||
android:summary="@string/auto_set_proxy_summary"
|
||||
android:title="@string/auto_set_proxy">
|
||||
</CheckBoxPreference>
|
||||
</SwitchPreference>
|
||||
<Preference
|
||||
android:key="proxyedApps"
|
||||
android:dependency="isGlobalProxy"
|
||||
@@ -78,23 +78,23 @@
|
||||
android:title="@string/proxied_apps">
|
||||
<intent android:action="com.github.shadowsocks.AppManager"/>
|
||||
</Preference>
|
||||
<CheckBoxPreference
|
||||
<SwitchPreference
|
||||
android:key="isUdpDns"
|
||||
android:defaultValue="false"
|
||||
android:summary="@string/udp_dns_summary"
|
||||
android:title="@string/udp_dns">
|
||||
</CheckBoxPreference>
|
||||
<CheckBoxPreference
|
||||
</SwitchPreference>
|
||||
<SwitchPreference
|
||||
android:key="isAuth"
|
||||
android:defaultValue="false"
|
||||
android:summary="@string/onetime_auth_summary"
|
||||
android:title="@string/onetime_auth">
|
||||
</CheckBoxPreference>
|
||||
<CheckBoxPreference
|
||||
</SwitchPreference>
|
||||
<SwitchPreference
|
||||
android:key="isAutoConnect"
|
||||
android:summary="@string/auto_connect_summary"
|
||||
android:title="@string/auto_connect">
|
||||
</CheckBoxPreference>
|
||||
</SwitchPreference>
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -162,13 +162,13 @@ class AppManager extends Activity with OnCheckedChangeListener with OnClickListe
|
||||
if (convertView == null) {
|
||||
convertView = getLayoutInflater.inflate(R.layout.layout_apps_item, parent, false)
|
||||
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]
|
||||
entry = new ListEntry(box, text, icon)
|
||||
entry = new ListEntry(switch, text, icon)
|
||||
entry.text.setOnClickListener(AppManager.this)
|
||||
entry.text.setOnClickListener(AppManager.this)
|
||||
convertView.setTag(entry)
|
||||
entry.box.setOnCheckedChangeListener(AppManager.this)
|
||||
entry.switch.setOnCheckedChangeListener(AppManager.this)
|
||||
} else {
|
||||
entry = convertView.getTag.asInstanceOf[ListEntry]
|
||||
}
|
||||
@@ -187,10 +187,10 @@ class AppManager extends Activity with OnCheckedChangeListener with OnClickListe
|
||||
ImageLoader.getInstance().displayImage(Scheme.APP + app.packageName, entry.icon, options)
|
||||
|
||||
entry.text.setText(app.name)
|
||||
val box: CheckBox = entry.box
|
||||
box.setTag(app)
|
||||
box.setChecked(app.proxied)
|
||||
entry.text.setTag(box)
|
||||
val switch = entry.switch
|
||||
switch.setTag(app)
|
||||
switch.setChecked(app.proxied)
|
||||
entry.text.setTag(switch)
|
||||
convertView
|
||||
}
|
||||
}
|
||||
@@ -207,11 +207,11 @@ class AppManager extends Activity with OnCheckedChangeListener with OnClickListe
|
||||
}
|
||||
|
||||
def onClick(v: View) {
|
||||
val cbox: CheckBox = v.getTag.asInstanceOf[CheckBox]
|
||||
val app: ProxiedApp = cbox.getTag.asInstanceOf[ProxiedApp]
|
||||
val switch = v.getTag.asInstanceOf[Switch]
|
||||
val app: ProxiedApp = switch.getTag.asInstanceOf[ProxiedApp]
|
||||
if (app != null) {
|
||||
app.proxied = !app.proxied
|
||||
cbox.setChecked(app.proxied)
|
||||
switch.setChecked(app.proxied)
|
||||
}
|
||||
saveAppSettings(this)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user