mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Fix launch application #996
This commit is contained in:
@@ -239,8 +239,23 @@ object UriUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun openExternalApp(context: Context, packageName: String) {
|
fun openExternalApp(context: Context, packageName: String) {
|
||||||
|
var launchIntent: Intent? = null
|
||||||
try {
|
try {
|
||||||
context.startActivity(context.applicationContext.packageManager.getLaunchIntentForPackage(packageName))
|
launchIntent = context.packageManager.getLaunchIntentForPackage(packageName)?.apply {
|
||||||
|
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||||
|
}
|
||||||
|
} catch (ignored: Exception) {
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if (launchIntent == null) {
|
||||||
|
context.startActivity(
|
||||||
|
Intent(Intent.ACTION_VIEW)
|
||||||
|
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||||
|
.setData(Uri.parse("https://play.google.com/store/apps/details?id=$packageName"))
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
context.startActivity(launchIntent)
|
||||||
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.e(TAG, "App cannot be open", e)
|
Log.e(TAG, "App cannot be open", e)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -138,11 +138,11 @@ class TextFieldView @JvmOverloads constructor(context: Context,
|
|||||||
when {
|
when {
|
||||||
labelView.text.contains(APPLICATION_ID_FIELD_NAME) -> {
|
labelView.text.contains(APPLICATION_ID_FIELD_NAME) -> {
|
||||||
val packageName = valueView.text.toString()
|
val packageName = valueView.text.toString()
|
||||||
if (UriUtil.isExternalAppInstalled(context, packageName)) {
|
// TODO #996 if (UriUtil.isExternalAppInstalled(context, packageName)) {
|
||||||
valueView.customLink {
|
valueView.customLink {
|
||||||
UriUtil.openExternalApp(context, packageName)
|
UriUtil.openExternalApp(context, packageName)
|
||||||
}
|
}
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
LinkifyCompat.addLinks(valueView, Linkify.WEB_URLS or Linkify.EMAIL_ADDRESSES)
|
LinkifyCompat.addLinks(valueView, Linkify.WEB_URLS or Linkify.EMAIL_ADDRESSES)
|
||||||
|
|||||||
@@ -41,6 +41,7 @@
|
|||||||
app:layout_constraintTop_toBottomOf="@+id/entry_field_label"
|
app:layout_constraintTop_toBottomOf="@+id/entry_field_label"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintEnd_toStartOf="@+id/entry_field_show"
|
app:layout_constraintEnd_toStartOf="@+id/entry_field_show"
|
||||||
|
android:textIsSelectable="true"
|
||||||
tools:text="value"
|
tools:text="value"
|
||||||
style="@style/KeepassDXStyle.TextAppearance.TextEntryItem" />
|
style="@style/KeepassDXStyle.TextAppearance.TextEntryItem" />
|
||||||
<androidx.appcompat.widget.AppCompatImageButton
|
<androidx.appcompat.widget.AppCompatImageButton
|
||||||
|
|||||||
Reference in New Issue
Block a user