|
@@ -1,11 +1,8 @@
|
|
|
package org.sirekanyan.outline.ext
|
|
package org.sirekanyan.outline.ext
|
|
|
|
|
|
|
|
import android.content.Context
|
|
import android.content.Context
|
|
|
-import android.content.Intent
|
|
|
|
|
-import android.content.Intent.ACTION_VIEW
|
|
|
|
|
import android.content.pm.PackageManager.GET_ACTIVITIES
|
|
import android.content.pm.PackageManager.GET_ACTIVITIES
|
|
|
import android.content.pm.PackageManager.NameNotFoundException
|
|
import android.content.pm.PackageManager.NameNotFoundException
|
|
|
-import android.net.Uri
|
|
|
|
|
|
|
|
|
|
private const val OUTLINE_PACKAGE = "org.outline.android.client"
|
|
private const val OUTLINE_PACKAGE = "org.outline.android.client"
|
|
|
private const val OUTLINE_PLAY_LINK = "https://play.google.com/store/apps/details?id=$OUTLINE_PACKAGE"
|
|
private const val OUTLINE_PLAY_LINK = "https://play.google.com/store/apps/details?id=$OUTLINE_PACKAGE"
|
|
@@ -22,21 +19,16 @@ fun openOutline(context: Context) {
|
|
|
try {
|
|
try {
|
|
|
val intent = context.packageManager.getLaunchIntentForPackage(OUTLINE_PACKAGE)
|
|
val intent = context.packageManager.getLaunchIntentForPackage(OUTLINE_PACKAGE)
|
|
|
if (intent == null) {
|
|
if (intent == null) {
|
|
|
- openGooglePlay(context)
|
|
|
|
|
|
|
+ installOutline(context)
|
|
|
} else {
|
|
} else {
|
|
|
context.startActivity(intent)
|
|
context.startActivity(intent)
|
|
|
}
|
|
}
|
|
|
} catch (exception: Exception) {
|
|
} catch (exception: Exception) {
|
|
|
logDebug("Cannot open Outline", exception)
|
|
logDebug("Cannot open Outline", exception)
|
|
|
- openGooglePlay(context)
|
|
|
|
|
|
|
+ installOutline(context)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-fun openGooglePlay(context: Context) {
|
|
|
|
|
- try {
|
|
|
|
|
- context.startActivity(Intent(ACTION_VIEW, Uri.parse(OUTLINE_PLAY_LINK)))
|
|
|
|
|
- } catch (exception: Exception) {
|
|
|
|
|
- logDebug("Cannot open Google Play", exception)
|
|
|
|
|
- context.showToast("Cannot open Google Play")
|
|
|
|
|
- }
|
|
|
|
|
|
|
+fun installOutline(context: Context) {
|
|
|
|
|
+ context.openGooglePlay(OUTLINE_PLAY_LINK)
|
|
|
}
|
|
}
|