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 | 8 |
1 files changed, 1 insertions, 7 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 0a365d0..9fb910b 100644 --- a/app/src/main/java/org/pacien/tincapp/context/App.kt +++ b/app/src/main/java/org/pacien/tincapp/context/App.kt | |||
@@ -13,14 +13,12 @@ import org.pacien.tincapp.R | |||
13 | * @author pacien | 13 | * @author pacien |
14 | */ | 14 | */ |
15 | class App : Application() { | 15 | class App : Application() { |
16 | |||
17 | override fun onCreate() { | 16 | override fun onCreate() { |
18 | super.onCreate() | 17 | super.onCreate() |
19 | appContext = applicationContext | 18 | appContext = applicationContext |
20 | } | 19 | } |
21 | 20 | ||
22 | companion object { | 21 | companion object { |
23 | |||
24 | private var appContext: Context? = null | 22 | private var appContext: Context? = null |
25 | 23 | ||
26 | fun getContext() = appContext!! | 24 | fun getContext() = appContext!! |
@@ -30,14 +28,10 @@ class App : Application() { | |||
30 | AlertDialog.Builder(getContext(), R.style.Theme_AppCompat_Dialog) | 28 | AlertDialog.Builder(getContext(), R.style.Theme_AppCompat_Dialog) |
31 | .setTitle(title).setMessage(msg) | 29 | .setTitle(title).setMessage(msg) |
32 | .apply { if (manualLink != null) setNeutralButton(R.string.action_open_manual) { _, _ -> openURL(manualLink) } } | 30 | .apply { if (manualLink != null) setNeutralButton(R.string.action_open_manual) { _, _ -> openURL(manualLink) } } |
33 | .setPositiveButton(R.string.action_close, dismissAction) | 31 | .setPositiveButton(R.string.action_close, { _, _ -> Unit }) |
34 | .create().apply { window.setType(WindowManager.LayoutParams.TYPE_SYSTEM_ERROR) }.show() | 32 | .create().apply { window.setType(WindowManager.LayoutParams.TYPE_SYSTEM_ERROR) }.show() |
35 | 33 | ||
36 | fun openURL(url: String) = | 34 | fun openURL(url: String) = |
37 | appContext?.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(url)).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)) | 35 | appContext?.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(url)).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)) |
38 | |||
39 | val dismissAction = { _: Any, _: Any -> /* nop */ } | ||
40 | |||
41 | } | 36 | } |
42 | |||
43 | } | 37 | } |