pref: 优化官方客户端是否安装的判断方式
This commit is contained in:
parent
20496e5ae2
commit
beac03a322
|
|
@ -33,6 +33,14 @@
|
|||
android:resizeable="true"
|
||||
android:smallScreens="true" />
|
||||
|
||||
<queries>
|
||||
<intent>
|
||||
<data
|
||||
android:host="unidispatch"
|
||||
android:scheme="com.baidu.tieba" />
|
||||
</intent>
|
||||
</queries>
|
||||
|
||||
<application
|
||||
android:name=".BaseApplication"
|
||||
android:allowBackup="true"
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import android.animation.AnimatorListenerAdapter
|
|||
import android.content.ActivityNotFoundException
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
import android.content.res.ColorStateList
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.Color
|
||||
|
|
@ -438,22 +439,25 @@ class ForumActivity : BaseActivity(), View.OnClickListener, OnRefreshedListener,
|
|||
launchPost()
|
||||
}
|
||||
setPositiveButton(R.string.button_official_client_post) { _, _ ->
|
||||
try {
|
||||
if (isOfficialClientInstalled()) {
|
||||
startActivity(
|
||||
val intent =
|
||||
Intent(Intent.ACTION_VIEW).setData(
|
||||
Uri.parse(
|
||||
"com.baidu.tieba://unidispatch/frs?obj_locate=frs_top_diverse&obj_source=wise&obj_name=index&obj_param2=chrome&has_token=0&qd=scheme&refer=tieba.baidu.com&wise_sample_id=3000232_2&fr=bpush&kw=$forumName"
|
||||
)
|
||||
)
|
||||
)
|
||||
val resolveInfos = packageManager.queryIntentActivities(
|
||||
intent,
|
||||
PackageManager.MATCH_DEFAULT_ONLY
|
||||
).filter { it.resolvePackageName != packageName }
|
||||
try {
|
||||
if (resolveInfos.isNotEmpty()) {
|
||||
startActivity(intent)
|
||||
} else {
|
||||
toastShort(R.string.toast_official_client_not_install)
|
||||
}
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
toastShort(R.string.toast_official_client_not_install)
|
||||
}
|
||||
finish()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import android.annotation.SuppressLint
|
|||
import android.content.ActivityNotFoundException
|
||||
import android.content.Intent
|
||||
import android.content.Intent.ACTION_VIEW
|
||||
import android.content.pm.PackageManager
|
||||
import android.graphics.Color
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
|
|
@ -132,9 +133,13 @@ class ReplyActivity : BaseActivity(), View.OnClickListener,
|
|||
}
|
||||
setNeutralButton(R.string.btn_continue_reply, null)
|
||||
setPositiveButton(R.string.button_official_client_reply) { _, _ ->
|
||||
val intent = Intent(ACTION_VIEW).setData(getDispatchUri())
|
||||
val resolveInfos =
|
||||
packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY)
|
||||
.filter { it.resolvePackageName != packageName }
|
||||
try {
|
||||
if (isOfficialClientInstalled()) {
|
||||
startActivity(Intent(ACTION_VIEW).setData(getDispatchUri()))
|
||||
if (resolveInfos.isNotEmpty()) {
|
||||
startActivity(intent)
|
||||
} else {
|
||||
toastShort(R.string.toast_official_client_not_install)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue