summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorArne Schwabe <arne@openvpn.net>2019-02-22 13:32:56 +0100
committerArne Schwabe <arne@openvpn.net>2019-02-22 13:32:56 +0100
commit82484ed5851dd79fefec1090b9d9fe83608b5dc3 (patch)
tree9bc7b17f1448528232cdba4f45ebbea0b6d57e5a /main
parent10be307704a6d22e9f7344e6b18066626b0040dd (diff)
Change allowed apps to also scroll the general settings
Diffstat (limited to 'main')
-rw-r--r--main/src/main/java/de/blinkt/openvpn/fragments/Settings_Allowed_Apps.kt33
-rw-r--r--main/src/main/res/layout/allowed_application_settings.xml65
-rw-r--r--main/src/main/res/layout/allowed_vpn_apps.xml78
3 files changed, 104 insertions, 72 deletions
diff --git a/main/src/main/java/de/blinkt/openvpn/fragments/Settings_Allowed_Apps.kt b/main/src/main/java/de/blinkt/openvpn/fragments/Settings_Allowed_Apps.kt
index 02f8fd77..dd2aa3b7 100644
--- a/main/src/main/java/de/blinkt/openvpn/fragments/Settings_Allowed_Apps.kt
+++ b/main/src/main/java/de/blinkt/openvpn/fragments/Settings_Allowed_Apps.kt
@@ -46,6 +46,8 @@ class Settings_Allowed_Apps : Fragment(), AdapterView.OnItemClickListener, Compo
private lateinit var mProfile: VpnProfile
private lateinit var mDefaultAllowTextView: TextView
private lateinit var mListAdapter: PackageAdapter
+ private lateinit var mSettingsView: View
+
override fun onItemClick(parent: AdapterView<*>, view: View, position: Int, id: Long) {
val avh = view.tag as AppViewHolder
@@ -109,9 +111,10 @@ class Settings_Allowed_Apps : Fragment(), AdapterView.OnItemClickListener, Compo
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val v = inflater.inflate(R.layout.allowed_vpn_apps, container, false)
- mDefaultAllowTextView = v.findViewById<View>(R.id.default_allow_text) as TextView
+ mSettingsView = inflater.inflate(R.layout.allowed_application_settings, container, false)
+ mDefaultAllowTextView = mSettingsView.findViewById<View>(R.id.default_allow_text) as TextView
- val vpnOnDefaultSwitch = v.findViewById<View>(R.id.default_allow) as Switch
+ val vpnOnDefaultSwitch = mSettingsView.findViewById<View>(R.id.default_allow) as Switch
vpnOnDefaultSwitch.setOnCheckedChangeListener { buttonView, isChecked ->
changeDisallowText(isChecked)
@@ -120,7 +123,7 @@ class Settings_Allowed_Apps : Fragment(), AdapterView.OnItemClickListener, Compo
vpnOnDefaultSwitch.isChecked = mProfile.mAllowedAppsVpnAreDisallowed
- val vpnAllowBypassSwitch = v.findViewById<View>(R.id.allow_bypass) as Switch
+ val vpnAllowBypassSwitch = mSettingsView.findViewById<View>(R.id.allow_bypass) as Switch
vpnAllowBypassSwitch.setOnCheckedChangeListener { buttonView, isChecked -> mProfile.mAllowAppVpnBypass = isChecked }
@@ -225,18 +228,28 @@ class Settings_Allowed_Apps : Fragment(), AdapterView.OnItemClickListener, Compo
}
override fun getCount(): Int {
- return mFilteredData.size
+ return mFilteredData.size + 1
}
override fun getItem(position: Int): Any {
- return mFilteredData[position]
+ return mFilteredData[position - 1]
}
override fun getItemId(position: Int): Long {
- return mFilteredData[position].packageName.hashCode().toLong()
+ if (position == 0)
+ return "settings".hashCode().toLong()
+ return mFilteredData[position - 1].packageName.hashCode().toLong()
}
override fun getView(position: Int, convertView: View?, parent: ViewGroup): View? {
+ if (position == 0) {
+ return mSettingsView
+ } else
+ return getViewApp(position - 1, convertView, parent)
+
+ }
+
+ fun getViewApp(position: Int, convertView: View?, parent: ViewGroup): View? {
val viewHolder = AppViewHolder.createOrRecycle(mInflater, convertView, parent)
viewHolder.mInfo = mFilteredData[position]
val mInfo = mFilteredData[position]
@@ -260,6 +273,14 @@ class Settings_Allowed_Apps : Fragment(), AdapterView.OnItemClickListener, Compo
return mFilter
}
+ override fun getViewTypeCount(): Int {
+ return 2;
+ }
+
+ override fun getItemViewType(position: Int): Int {
+ return if (position == 0) 0 else 1
+ }
+
private inner class ItemFilter : Filter() {
override fun performFiltering(constraint: CharSequence): Filter.FilterResults {
diff --git a/main/src/main/res/layout/allowed_application_settings.xml b/main/src/main/res/layout/allowed_application_settings.xml
new file mode 100644
index 00000000..96170965
--- /dev/null
+++ b/main/src/main/res/layout/allowed_application_settings.xml
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (c) 2012-2019 Arne Schwabe
+ ~ Distributed under the GNU GPL v2 with additional terms. For full terms see the file doc/LICENSE.txt
+ -->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ tools:ignore="RtlCompat"
+ android:layout_marginTop="10dp">
+ <RelativeLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:minHeight="?android:attr/actionBarSize"
+ android:background="@drawable/bg_switchbar"
+ android:paddingStart="@dimen/switchbar_pad"
+ android:elevation="1dp"
+ android:paddingEnd="@dimen/switchbar_pad"
+ >
+
+ <Switch
+ android:id="@+id/default_allow"
+ android:layout_alignParentEnd="true"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="10dp"
+ />
+ <TextView
+ android:id="@+id/default_allow_text"
+ style="@android:style/TextAppearance.Medium.Inverse"
+ tools:text="@string/vpn_disallow_radio"
+ android:layout_toStartOf="@id/default_allow"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"/>
+
+ </RelativeLayout>
+
+ <RelativeLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:minHeight="?android:attr/actionBarSize"
+ android:background="@drawable/bg_switchbar"
+ android:paddingStart="@dimen/switchbar_pad"
+ android:elevation="1dp"
+ android:paddingEnd="@dimen/switchbar_pad"
+ >
+
+ <Switch
+ android:id="@+id/allow_bypass"
+ android:layout_alignParentEnd="true"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="10dp"
+
+ />
+ <TextView
+ style="@android:style/TextAppearance.Medium.Inverse"
+ android:text="@string/vpn_allow_bypass"
+ android:layout_toStartOf="@id/allow_bypass"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"/>
+ </RelativeLayout>
+</LinearLayout> \ No newline at end of file
diff --git a/main/src/main/res/layout/allowed_vpn_apps.xml b/main/src/main/res/layout/allowed_vpn_apps.xml
index 45ff66d6..7f5e7b8b 100644
--- a/main/src/main/res/layout/allowed_vpn_apps.xml
+++ b/main/src/main/res/layout/allowed_vpn_apps.xml
@@ -5,82 +5,28 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
- android:orientation="vertical"
android:layout_width="match_parent"
- tools:ignore="RtlCompat"
- android:layout_height="match_parent">
-
- <RelativeLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:minHeight="?android:attr/actionBarSize"
- android:background="@drawable/bg_switchbar"
- android:paddingStart="@dimen/switchbar_pad"
- android:elevation="1dp"
- android:paddingEnd="@dimen/switchbar_pad"
- >
-
- <Switch
- android:id="@+id/default_allow"
- android:layout_alignParentEnd="true"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:padding="10dp"
- />
- <TextView
- android:id="@+id/default_allow_text"
- style="@android:style/TextAppearance.Medium.Inverse"
- tools:text="@string/vpn_disallow_radio"
- android:layout_toStartOf="@id/default_allow"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
-
- </RelativeLayout>
-
- <RelativeLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:minHeight="?android:attr/actionBarSize"
- android:background="@drawable/bg_switchbar"
- android:paddingStart="@dimen/switchbar_pad"
- android:elevation="1dp"
- android:paddingEnd="@dimen/switchbar_pad"
- >
-
- <Switch
- android:id="@+id/allow_bypass"
- android:layout_alignParentEnd="true"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:padding="10dp"
-
- />
- <TextView
- style="@android:style/TextAppearance.Medium.Inverse"
- android:text="@string/vpn_allow_bypass"
- android:layout_toStartOf="@id/allow_bypass"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
- </RelativeLayout>
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ tools:ignore="RtlCompat">
<ListView
- android:visibility="gone"
android:id="@android:id/list"
- android:drawSelectorOnTop="false"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
- android:scrollbarStyle="outsideOverlay" />
-
+ android:drawSelectorOnTop="false"
+ android:scrollbarStyle="outsideOverlay"
+ android:visibility="gone" />
<LinearLayout
android:id="@+id/loading_container"
- android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:visibility="visible"
- android:gravity="center">
+ android:gravity="center"
+ android:orientation="vertical"
+ android:visibility="visible">
<ProgressBar
style="?android:attr/progressBarStyleLarge"
@@ -90,10 +36,10 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:text="@string/loading"
android:paddingTop="4dip"
- android:singleLine="true" />
+ android:singleLine="true"
+ android:text="@string/loading"
+ android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>