diff options
Diffstat (limited to 'app/src/main/java/org/pacien/tincapp/context/App.kt')
-rw-r--r-- | app/src/main/java/org/pacien/tincapp/context/App.kt | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/app/src/main/java/org/pacien/tincapp/context/App.kt b/app/src/main/java/org/pacien/tincapp/context/App.kt index 2d9151e..88308ba 100644 --- a/app/src/main/java/org/pacien/tincapp/context/App.kt +++ b/app/src/main/java/org/pacien/tincapp/context/App.kt | |||
@@ -25,8 +25,6 @@ import android.net.Uri | |||
25 | import android.os.Build | 25 | import android.os.Build |
26 | import android.os.Handler | 26 | import android.os.Handler |
27 | import android.support.annotation.StringRes | 27 | import android.support.annotation.StringRes |
28 | import android.support.v7.app.AlertDialog | ||
29 | import android.view.WindowManager | ||
30 | import org.pacien.tincapp.BuildConfig | 28 | import org.pacien.tincapp.BuildConfig |
31 | import org.pacien.tincapp.R | 29 | import org.pacien.tincapp.R |
32 | import org.slf4j.LoggerFactory | 30 | import org.slf4j.LoggerFactory |
@@ -59,16 +57,13 @@ class App : Application() { | |||
59 | private var appContext: Context? = null | 57 | private var appContext: Context? = null |
60 | private var handler: Handler? = null | 58 | private var handler: Handler? = null |
61 | 59 | ||
60 | val notificationManager: AppNotificationManager by lazy { AppNotificationManager(appContext!!) } | ||
61 | |||
62 | fun getContext() = appContext!! | 62 | fun getContext() = appContext!! |
63 | fun getResources() = getContext().resources!! | 63 | fun getResources() = getContext().resources!! |
64 | 64 | ||
65 | fun alert(@StringRes title: Int, msg: String, manualLink: String? = null) = handler!!.post { | 65 | fun alert(@StringRes title: Int, msg: String, manualLink: String? = null) = |
66 | AlertDialog.Builder(getContext(), R.style.Theme_AppCompat_Dialog) | 66 | notificationManager.notifyError(appContext!!.getString(title), msg, manualLink) |
67 | .setTitle(title).setMessage(msg) | ||
68 | .apply { if (manualLink != null) setNeutralButton(R.string.action_open_manual) { _, _ -> openURL(manualLink) } } | ||
69 | .setPositiveButton(R.string.action_close) { _, _ -> Unit } | ||
70 | .create().apply { window.setType(WindowManager.LayoutParams.TYPE_SYSTEM_ERROR) }.show() | ||
71 | } | ||
72 | 67 | ||
73 | fun openURL(url: String) { | 68 | fun openURL(url: String) { |
74 | val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url)) | 69 | val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url)) |