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) {
|
||||
var launchIntent: Intent? = null
|
||||
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) {
|
||||
Log.e(TAG, "App cannot be open", e)
|
||||
}
|
||||
|
||||
@@ -138,11 +138,11 @@ class TextFieldView @JvmOverloads constructor(context: Context,
|
||||
when {
|
||||
labelView.text.contains(APPLICATION_ID_FIELD_NAME) -> {
|
||||
val packageName = valueView.text.toString()
|
||||
if (UriUtil.isExternalAppInstalled(context, packageName)) {
|
||||
// TODO #996 if (UriUtil.isExternalAppInstalled(context, packageName)) {
|
||||
valueView.customLink {
|
||||
UriUtil.openExternalApp(context, packageName)
|
||||
}
|
||||
}
|
||||
//}
|
||||
}
|
||||
else -> {
|
||||
LinkifyCompat.addLinks(valueView, Linkify.WEB_URLS or Linkify.EMAIL_ADDRESSES)
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
app:layout_constraintTop_toBottomOf="@+id/entry_field_label"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/entry_field_show"
|
||||
android:textIsSelectable="true"
|
||||
tools:text="value"
|
||||
style="@style/KeepassDXStyle.TextAppearance.TextEntryItem" />
|
||||
<androidx.appcompat.widget.AppCompatImageButton
|
||||
|
||||
Reference in New Issue
Block a user