diff options
author | pacien | 2018-08-05 21:04:19 +0200 |
---|---|---|
committer | pacien | 2018-08-05 21:04:19 +0200 |
commit | 0961e674fd7738d7a7ff6d76179677bc3779d535 (patch) | |
tree | 0e1ea7d674626a99466296c9cd92a5c11780c3b0 /app/src/main | |
parent | 464adf4257097bac9975485969d19162ee25a33e (diff) | |
download | tincapp-0961e674fd7738d7a7ff6d76179677bc3779d535.tar.gz |
Replace deprecated progress dialog
Diffstat (limited to 'app/src/main')
5 files changed, 91 insertions, 6 deletions
diff --git a/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt b/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt index 7b9c202..fde99d0 100644 --- a/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt +++ b/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt | |||
@@ -18,7 +18,6 @@ | |||
18 | 18 | ||
19 | package org.pacien.tincapp.activities | 19 | package org.pacien.tincapp.activities |
20 | 20 | ||
21 | import android.app.ProgressDialog | ||
22 | import android.os.Bundle | 21 | import android.os.Bundle |
23 | import android.support.annotation.StringRes | 22 | import android.support.annotation.StringRes |
24 | import android.support.design.widget.Snackbar | 23 | import android.support.design.widget.Snackbar |
@@ -33,6 +32,7 @@ import org.pacien.tincapp.context.App | |||
33 | import org.pacien.tincapp.context.AppInfo | 32 | import org.pacien.tincapp.context.AppInfo |
34 | import org.pacien.tincapp.context.AppPaths | 33 | import org.pacien.tincapp.context.AppPaths |
35 | import org.pacien.tincapp.context.CrashRecorder | 34 | import org.pacien.tincapp.context.CrashRecorder |
35 | import org.pacien.tincapp.utils.ProgressModal | ||
36 | 36 | ||
37 | /** | 37 | /** |
38 | * @author pacien | 38 | * @author pacien |
@@ -109,7 +109,7 @@ abstract class BaseActivity : AppCompatActivity() { | |||
109 | 109 | ||
110 | protected fun notify(@StringRes msg: Int) = Snackbar.make(activity_base, msg, Snackbar.LENGTH_LONG).show() | 110 | protected fun notify(@StringRes msg: Int) = Snackbar.make(activity_base, msg, Snackbar.LENGTH_LONG).show() |
111 | protected fun notify(msg: String) = Snackbar.make(activity_base, msg, Snackbar.LENGTH_LONG).show() | 111 | protected fun notify(msg: String) = Snackbar.make(activity_base, msg, Snackbar.LENGTH_LONG).show() |
112 | protected fun showProgressDialog(@StringRes msg: Int): ProgressDialog = ProgressDialog.show(this, null, getString(msg), true, false) | 112 | protected fun showProgressDialog(@StringRes msg: Int): AlertDialog = ProgressModal.show(this, getString(msg)) |
113 | protected fun showErrorDialog(msg: String): AlertDialog = AlertDialog.Builder(this) | 113 | protected fun showErrorDialog(msg: String): AlertDialog = AlertDialog.Builder(this) |
114 | .setTitle(R.string.title_error).setMessage(msg) | 114 | .setTitle(R.string.title_error).setMessage(msg) |
115 | .setPositiveButton(R.string.action_close, { _, _ -> Unit }).show() | 115 | .setPositiveButton(R.string.action_close, { _, _ -> Unit }).show() |
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 c775618..fbcde81 100644 --- a/app/src/main/java/org/pacien/tincapp/activities/StartActivity.kt +++ b/app/src/main/java/org/pacien/tincapp/activities/StartActivity.kt | |||
@@ -19,7 +19,6 @@ | |||
19 | package org.pacien.tincapp.activities | 19 | package org.pacien.tincapp.activities |
20 | 20 | ||
21 | import android.app.Activity | 21 | import android.app.Activity |
22 | import android.app.ProgressDialog | ||
23 | import android.content.Intent | 22 | import android.content.Intent |
24 | import android.net.VpnService | 23 | import android.net.VpnService |
25 | import android.os.Bundle | 24 | import android.os.Bundle |
@@ -137,7 +136,7 @@ class StartActivity : BaseActivity() { | |||
137 | Actions.EVENT_CONNECTED to this::onVpnStart, | 136 | Actions.EVENT_CONNECTED to this::onVpnStart, |
138 | Actions.EVENT_ABORTED to this::onVpnStartError)) | 137 | Actions.EVENT_ABORTED to this::onVpnStartError)) |
139 | 138 | ||
140 | private var connectDialog: ProgressDialog? = null | 139 | private var connectDialog: AlertDialog? = null |
141 | 140 | ||
142 | override fun onCreate(savedInstanceState: Bundle?) { | 141 | override fun onCreate(savedInstanceState: Bundle?) { |
143 | super.onCreate(savedInstanceState) | 142 | super.onCreate(savedInstanceState) |
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 a7a1853..cd64355 100644 --- a/app/src/main/java/org/pacien/tincapp/activities/StatusActivity.kt +++ b/app/src/main/java/org/pacien/tincapp/activities/StatusActivity.kt | |||
@@ -18,7 +18,6 @@ | |||
18 | 18 | ||
19 | package org.pacien.tincapp.activities | 19 | package org.pacien.tincapp.activities |
20 | 20 | ||
21 | import android.app.ProgressDialog | ||
22 | import android.content.Intent | 21 | import android.content.Intent |
23 | import android.os.Bundle | 22 | import android.os.Bundle |
24 | import android.support.v4.widget.SwipeRefreshLayout | 23 | import android.support.v4.widget.SwipeRefreshLayout |
@@ -51,7 +50,7 @@ import kotlin.concurrent.timerTask | |||
51 | */ | 50 | */ |
52 | class StatusActivity : BaseActivity(), AdapterView.OnItemClickListener, SwipeRefreshLayout.OnRefreshListener { | 51 | class StatusActivity : BaseActivity(), AdapterView.OnItemClickListener, SwipeRefreshLayout.OnRefreshListener { |
53 | private val broadcastMapper = BroadcastMapper(mapOf(Actions.EVENT_DISCONNECTED to this::onVpnShutdown)) | 52 | private val broadcastMapper = BroadcastMapper(mapOf(Actions.EVENT_DISCONNECTED to this::onVpnShutdown)) |
54 | private var shutdownDialog: ProgressDialog? = null | 53 | private var shutdownDialog: AlertDialog? = null |
55 | private var nodeListAdapter: ArrayAdapter<String>? = null | 54 | private var nodeListAdapter: ArrayAdapter<String>? = null |
56 | private var refreshTimer: Timer? = null | 55 | private var refreshTimer: Timer? = null |
57 | private var listNetworksAfterExit = true | 56 | private var listNetworksAfterExit = true |
diff --git a/app/src/main/java/org/pacien/tincapp/utils/ProgressModal.kt b/app/src/main/java/org/pacien/tincapp/utils/ProgressModal.kt new file mode 100644 index 0000000..379e3af --- /dev/null +++ b/app/src/main/java/org/pacien/tincapp/utils/ProgressModal.kt | |||
@@ -0,0 +1,47 @@ | |||
1 | /* | ||
2 | * tinc app, an Android binding and user interface for the tinc mesh VPN daemon | ||
3 | * Copyright (C) 2017-2018 Pacien TRAN-GIRARD | ||
4 | * | ||
5 | * This program is free software: you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation, either version 3 of the License, or | ||
8 | * (at your option) any later version. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
17 | */ | ||
18 | |||
19 | package org.pacien.tincapp.utils | ||
20 | |||
21 | import android.annotation.SuppressLint | ||
22 | import android.app.Activity | ||
23 | import android.support.v7.app.AlertDialog | ||
24 | import android.view.LayoutInflater | ||
25 | import android.view.View | ||
26 | import android.widget.TextView | ||
27 | import org.pacien.tincapp.R | ||
28 | |||
29 | /** | ||
30 | * @author pacien | ||
31 | */ | ||
32 | object ProgressModal { | ||
33 | fun show(context: Activity, text: String): AlertDialog { | ||
34 | return AlertDialog.Builder(context) | ||
35 | .setView(newDialogView(context.layoutInflater, text)) | ||
36 | .setCancelable(false) | ||
37 | .show() | ||
38 | } | ||
39 | |||
40 | @SuppressLint("InflateParams") | ||
41 | private fun newDialogView(inflater: LayoutInflater, text: String): View { | ||
42 | val view = inflater.inflate(R.layout.common_progress_dialog, null) | ||
43 | val textView: TextView = view.findViewById(R.id.common_progress_dialog_text) | ||
44 | textView.text = text | ||
45 | return view | ||
46 | } | ||
47 | } | ||
diff --git a/app/src/main/res/layout/common_progress_dialog.xml b/app/src/main/res/layout/common_progress_dialog.xml new file mode 100644 index 0000000..a55834d --- /dev/null +++ b/app/src/main/res/layout/common_progress_dialog.xml | |||
@@ -0,0 +1,40 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | ||
2 | |||
3 | <!-- | ||
4 | * tinc app, an Android binding and user interface for the tinc mesh VPN daemon | ||
5 | * Copyright (C) 2017-2018 Pacien TRAN-GIRARD | ||
6 | * | ||
7 | * This program is free software: you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation, either version 3 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
19 | --> | ||
20 | |||
21 | <LinearLayout | ||
22 | xmlns:android="http://schemas.android.com/apk/res/android" | ||
23 | android:layout_width="match_parent" | ||
24 | android:layout_height="match_parent" | ||
25 | android:gravity="center_vertical" | ||
26 | android:orientation="horizontal" | ||
27 | android:padding="20dp"> | ||
28 | |||
29 | <ProgressBar | ||
30 | style="?android:attr/progressBarStyle" | ||
31 | android:layout_width="wrap_content" | ||
32 | android:layout_height="wrap_content"/> | ||
33 | |||
34 | <TextView | ||
35 | android:id="@+id/common_progress_dialog_text" | ||
36 | android:layout_width="wrap_content" | ||
37 | android:layout_height="wrap_content" | ||
38 | android:layout_marginStart="20dp"/> | ||
39 | |||
40 | </LinearLayout> | ||