diff options
author | Pacien TRAN-GIRARD | 2017-07-15 11:53:43 +0200 |
---|---|---|
committer | Pacien TRAN-GIRARD | 2017-07-15 11:53:43 +0200 |
commit | 75fb7ba17f5977b146f166412eaf39705a5f4e73 (patch) | |
tree | b7e06d28e3215e152a6018861bbf72a619a89d16 /app/src/main | |
parent | a2f166f907b7c7ac6f1e0ed6ff8c0637800f6b91 (diff) | |
download | tincapp-75fb7ba17f5977b146f166412eaf39705a5f4e73.tar.gz |
Refactor common list views
Diffstat (limited to 'app/src/main')
-rw-r--r-- | app/src/main/java/org/pacien/tincapp/activities/StartActivity.kt | 16 | ||||
-rw-r--r-- | app/src/main/java/org/pacien/tincapp/activities/StatusActivity.kt | 16 | ||||
-rw-r--r-- | app/src/main/res/layout/fragment_list_item.xml | 1 | ||||
-rw-r--r-- | app/src/main/res/layout/fragment_list_view.xml (renamed from app/src/main/res/layout/page_status.xml) | 8 | ||||
-rw-r--r-- | app/src/main/res/layout/page_start.xml | 18 |
5 files changed, 19 insertions, 40 deletions
diff --git a/app/src/main/java/org/pacien/tincapp/activities/StartActivity.kt b/app/src/main/java/org/pacien/tincapp/activities/StartActivity.kt index 05f8904..6e8ad37 100644 --- a/app/src/main/java/org/pacien/tincapp/activities/StartActivity.kt +++ b/app/src/main/java/org/pacien/tincapp/activities/StartActivity.kt | |||
@@ -10,8 +10,8 @@ import android.widget.AdapterView | |||
10 | import android.widget.ArrayAdapter | 10 | import android.widget.ArrayAdapter |
11 | import android.widget.TextView | 11 | import android.widget.TextView |
12 | import kotlinx.android.synthetic.main.base.* | 12 | import kotlinx.android.synthetic.main.base.* |
13 | import kotlinx.android.synthetic.main.fragment_list_view.* | ||
13 | import kotlinx.android.synthetic.main.fragment_network_list_header.* | 14 | import kotlinx.android.synthetic.main.fragment_network_list_header.* |
14 | import kotlinx.android.synthetic.main.page_start.* | ||
15 | import org.pacien.tincapp.R | 15 | import org.pacien.tincapp.R |
16 | import org.pacien.tincapp.context.AppPaths | 16 | import org.pacien.tincapp.context.AppPaths |
17 | import org.pacien.tincapp.extensions.Android.setElements | 17 | import org.pacien.tincapp.extensions.Android.setElements |
@@ -32,12 +32,12 @@ class StartActivity : BaseActivity(), AdapterView.OnItemClickListener, SwipeRefr | |||
32 | networkListAdapter = ArrayAdapter<String>(this, R.layout.fragment_list_item) | 32 | networkListAdapter = ArrayAdapter<String>(this, R.layout.fragment_list_item) |
33 | confChangeObserver = FileObserver(AppPaths.confDir().absolutePath, FileObserver.CHANGE, { _, _ -> onRefresh() }) | 33 | confChangeObserver = FileObserver(AppPaths.confDir().absolutePath, FileObserver.CHANGE, { _, _ -> onRefresh() }) |
34 | 34 | ||
35 | layoutInflater.inflate(R.layout.page_start, main_content) | 35 | layoutInflater.inflate(R.layout.fragment_list_view, main_content) |
36 | network_list_wrapper.setOnRefreshListener(this) | 36 | list_wrapper.setOnRefreshListener(this) |
37 | network_list.addHeaderView(layoutInflater.inflate(R.layout.fragment_network_list_header, network_list, false), null, false) | 37 | list.addHeaderView(layoutInflater.inflate(R.layout.fragment_network_list_header, list, false), null, false) |
38 | network_list.addFooterView(View(this), null, false) | 38 | list.addFooterView(View(this), null, false) |
39 | network_list.adapter = networkListAdapter | 39 | list.adapter = networkListAdapter |
40 | network_list.onItemClickListener = this | 40 | list.onItemClickListener = this |
41 | } | 41 | } |
42 | 42 | ||
43 | override fun onCreateOptionsMenu(m: Menu): Boolean { | 43 | override fun onCreateOptionsMenu(m: Menu): Boolean { |
@@ -72,7 +72,7 @@ class StartActivity : BaseActivity(), AdapterView.OnItemClickListener, SwipeRefr | |||
72 | runOnUiThread { | 72 | runOnUiThread { |
73 | networkListAdapter?.setElements(networks) | 73 | networkListAdapter?.setElements(networks) |
74 | network_list_placeholder.visibility = if (networkListAdapter?.isEmpty ?: true) View.VISIBLE else View.GONE | 74 | network_list_placeholder.visibility = if (networkListAdapter?.isEmpty ?: true) View.VISIBLE else View.GONE |
75 | network_list_wrapper.isRefreshing = false | 75 | list_wrapper.isRefreshing = false |
76 | } | 76 | } |
77 | } | 77 | } |
78 | 78 | ||
diff --git a/app/src/main/java/org/pacien/tincapp/activities/StatusActivity.kt b/app/src/main/java/org/pacien/tincapp/activities/StatusActivity.kt index 0d7af6e..6d97dca 100644 --- a/app/src/main/java/org/pacien/tincapp/activities/StatusActivity.kt +++ b/app/src/main/java/org/pacien/tincapp/activities/StatusActivity.kt | |||
@@ -13,8 +13,8 @@ import android.widget.TextView | |||
13 | import java8.util.concurrent.CompletableFuture | 13 | import java8.util.concurrent.CompletableFuture |
14 | import kotlinx.android.synthetic.main.base.* | 14 | import kotlinx.android.synthetic.main.base.* |
15 | import kotlinx.android.synthetic.main.dialog_text_monopsace.view.* | 15 | import kotlinx.android.synthetic.main.dialog_text_monopsace.view.* |
16 | import kotlinx.android.synthetic.main.fragment_list_view.* | ||
16 | import kotlinx.android.synthetic.main.fragment_network_status_header.* | 17 | import kotlinx.android.synthetic.main.fragment_network_status_header.* |
17 | import kotlinx.android.synthetic.main.page_status.* | ||
18 | import org.pacien.tincapp.R | 18 | import org.pacien.tincapp.R |
19 | import org.pacien.tincapp.commands.Tinc | 19 | import org.pacien.tincapp.commands.Tinc |
20 | import org.pacien.tincapp.data.VpnInterfaceConfiguration | 20 | import org.pacien.tincapp.data.VpnInterfaceConfiguration |
@@ -39,12 +39,12 @@ class StatusActivity : BaseActivity(), AdapterView.OnItemClickListener, SwipeRef | |||
39 | nodeListAdapter = ArrayAdapter<String>(this, R.layout.fragment_list_item) | 39 | nodeListAdapter = ArrayAdapter<String>(this, R.layout.fragment_list_item) |
40 | refreshTimer = Timer(true) | 40 | refreshTimer = Timer(true) |
41 | 41 | ||
42 | layoutInflater.inflate(R.layout.page_status, main_content) | 42 | layoutInflater.inflate(R.layout.fragment_list_view, main_content) |
43 | node_list_wrapper.setOnRefreshListener(this) | 43 | list_wrapper.setOnRefreshListener(this) |
44 | node_list.addHeaderView(layoutInflater.inflate(R.layout.fragment_network_status_header, node_list, false), null, false) | 44 | list.addHeaderView(layoutInflater.inflate(R.layout.fragment_network_status_header, list, false), null, false) |
45 | node_list.addFooterView(View(this), null, false) | 45 | list.addFooterView(View(this), null, false) |
46 | node_list.onItemClickListener = this | 46 | list.onItemClickListener = this |
47 | node_list.adapter = nodeListAdapter | 47 | list.adapter = nodeListAdapter |
48 | } | 48 | } |
49 | 49 | ||
50 | override fun onCreateOptionsMenu(m: Menu): Boolean { | 50 | override fun onCreateOptionsMenu(m: Menu): Boolean { |
@@ -82,7 +82,7 @@ class StatusActivity : BaseActivity(), AdapterView.OnItemClickListener, SwipeRef | |||
82 | runOnUiThread { | 82 | runOnUiThread { |
83 | nodeListAdapter?.setElements(it) | 83 | nodeListAdapter?.setElements(it) |
84 | node_list_placeholder.visibility = if (nodeListAdapter?.isEmpty ?: true) View.VISIBLE else View.GONE | 84 | node_list_placeholder.visibility = if (nodeListAdapter?.isEmpty ?: true) View.VISIBLE else View.GONE |
85 | node_list_wrapper.isRefreshing = false | 85 | list_wrapper.isRefreshing = false |
86 | if (!TincVpnService.isConnected()) openStartActivity() | 86 | if (!TincVpnService.isConnected()) openStartActivity() |
87 | } | 87 | } |
88 | } | 88 | } |
diff --git a/app/src/main/res/layout/fragment_list_item.xml b/app/src/main/res/layout/fragment_list_item.xml index c6049f5..f872573 100644 --- a/app/src/main/res/layout/fragment_list_item.xml +++ b/app/src/main/res/layout/fragment_list_item.xml | |||
@@ -5,5 +5,4 @@ | |||
5 | android:paddingLeft="@dimen/activity_horizontal_margin" | 5 | android:paddingLeft="@dimen/activity_horizontal_margin" |
6 | android:paddingRight="@dimen/activity_horizontal_margin" | 6 | android:paddingRight="@dimen/activity_horizontal_margin" |
7 | android:paddingTop="@dimen/activity_vertical_margin"> | 7 | android:paddingTop="@dimen/activity_vertical_margin"> |
8 | |||
9 | </TextView> | 8 | </TextView> |
diff --git a/app/src/main/res/layout/page_status.xml b/app/src/main/res/layout/fragment_list_view.xml index bc68ea1..32e951e 100644 --- a/app/src/main/res/layout/page_status.xml +++ b/app/src/main/res/layout/fragment_list_view.xml | |||
@@ -1,14 +1,12 @@ | |||
1 | <android.support.v4.widget.SwipeRefreshLayout | 1 | <android.support.v4.widget.SwipeRefreshLayout |
2 | xmlns:android="http://schemas.android.com/apk/res/android" | 2 | xmlns:android="http://schemas.android.com/apk/res/android" |
3 | xmlns:tools="http://schemas.android.com/tools" | 3 | android:id="@+id/list_wrapper" |
4 | android:id="@+id/node_list_wrapper" | ||
5 | android:layout_width="match_parent" | 4 | android:layout_width="match_parent" |
6 | android:layout_height="match_parent" | 5 | android:layout_height="match_parent" |
7 | android:orientation="vertical" | 6 | android:orientation="vertical"> |
8 | tools:context="org.pacien.tincapp.activities.StatusActivity"> | ||
9 | 7 | ||
10 | <ListView | 8 | <ListView |
11 | android:id="@+id/node_list" | 9 | android:id="@+id/list" |
12 | android:layout_width="match_parent" | 10 | android:layout_width="match_parent" |
13 | android:layout_height="match_parent" | 11 | android:layout_height="match_parent" |
14 | android:divider="@drawable/horizontal_line" | 12 | android:divider="@drawable/horizontal_line" |
diff --git a/app/src/main/res/layout/page_start.xml b/app/src/main/res/layout/page_start.xml deleted file mode 100644 index b1bf2a4..0000000 --- a/app/src/main/res/layout/page_start.xml +++ /dev/null | |||
@@ -1,18 +0,0 @@ | |||
1 | <android.support.v4.widget.SwipeRefreshLayout | ||
2 | xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | xmlns:tools="http://schemas.android.com/tools" | ||
4 | android:id="@+id/network_list_wrapper" | ||
5 | android:layout_width="match_parent" | ||
6 | android:layout_height="match_parent" | ||
7 | android:orientation="vertical" | ||
8 | tools:context="org.pacien.tincapp.activities.StartActivity"> | ||
9 | |||
10 | <ListView | ||
11 | android:id="@+id/network_list" | ||
12 | android:layout_width="match_parent" | ||
13 | android:layout_height="match_parent" | ||
14 | android:divider="@drawable/horizontal_line" | ||
15 | android:footerDividersEnabled="false" | ||
16 | android:headerDividersEnabled="false"/> | ||
17 | |||
18 | </android.support.v4.widget.SwipeRefreshLayout> | ||