pref: 优化官方客户端是否安装的判断方式
This commit is contained in:
parent
20496e5ae2
commit
beac03a322
|
|
@ -33,6 +33,14 @@
|
||||||
android:resizeable="true"
|
android:resizeable="true"
|
||||||
android:smallScreens="true" />
|
android:smallScreens="true" />
|
||||||
|
|
||||||
|
<queries>
|
||||||
|
<intent>
|
||||||
|
<data
|
||||||
|
android:host="unidispatch"
|
||||||
|
android:scheme="com.baidu.tieba" />
|
||||||
|
</intent>
|
||||||
|
</queries>
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:name=".BaseApplication"
|
android:name=".BaseApplication"
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import android.animation.AnimatorListenerAdapter
|
||||||
import android.content.ActivityNotFoundException
|
import android.content.ActivityNotFoundException
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.content.pm.PackageManager
|
||||||
import android.content.res.ColorStateList
|
import android.content.res.ColorStateList
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
|
|
@ -438,22 +439,25 @@ class ForumActivity : BaseActivity(), View.OnClickListener, OnRefreshedListener,
|
||||||
launchPost()
|
launchPost()
|
||||||
}
|
}
|
||||||
setPositiveButton(R.string.button_official_client_post) { _, _ ->
|
setPositiveButton(R.string.button_official_client_post) { _, _ ->
|
||||||
try {
|
val intent =
|
||||||
if (isOfficialClientInstalled()) {
|
Intent(Intent.ACTION_VIEW).setData(
|
||||||
startActivity(
|
Uri.parse(
|
||||||
Intent(Intent.ACTION_VIEW).setData(
|
"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"
|
||||||
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 {
|
} else {
|
||||||
toastShort(R.string.toast_official_client_not_install)
|
toastShort(R.string.toast_official_client_not_install)
|
||||||
}
|
}
|
||||||
} catch (e: ActivityNotFoundException) {
|
} catch (e: ActivityNotFoundException) {
|
||||||
toastShort(R.string.toast_official_client_not_install)
|
toastShort(R.string.toast_official_client_not_install)
|
||||||
}
|
}
|
||||||
finish()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import android.annotation.SuppressLint
|
||||||
import android.content.ActivityNotFoundException
|
import android.content.ActivityNotFoundException
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.Intent.ACTION_VIEW
|
import android.content.Intent.ACTION_VIEW
|
||||||
|
import android.content.pm.PackageManager
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
|
@ -132,9 +133,13 @@ class ReplyActivity : BaseActivity(), View.OnClickListener,
|
||||||
}
|
}
|
||||||
setNeutralButton(R.string.btn_continue_reply, null)
|
setNeutralButton(R.string.btn_continue_reply, null)
|
||||||
setPositiveButton(R.string.button_official_client_reply) { _, _ ->
|
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 {
|
try {
|
||||||
if (isOfficialClientInstalled()) {
|
if (resolveInfos.isNotEmpty()) {
|
||||||
startActivity(Intent(ACTION_VIEW).setData(getDispatchUri()))
|
startActivity(intent)
|
||||||
} else {
|
} else {
|
||||||
toastShort(R.string.toast_official_client_not_install)
|
toastShort(R.string.toast_official_client_not_install)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue