mirror of
https://github.com/tateisu/SubwayTooter
synced 2025-01-29 18:19:22 +01:00
(マストドン2.4.2以降)http,https以外のスキーマのリンクに対応した
This commit is contained in:
parent
5fb7f1f0e6
commit
1a2a1b35ac
@ -12,8 +12,8 @@ android {
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 27
|
||||
|
||||
versionCode 257
|
||||
versionName "2.5.7"
|
||||
versionCode 258
|
||||
versionName "2.5.8"
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
|
||||
// https://stackoverflow.com/questions/47791227/java-lang-illegalstateexception-dex-archives-setting-dex-extension-only-for
|
||||
|
@ -508,7 +508,7 @@ class App1 : Application() {
|
||||
// Chrome Custom Tab を開く
|
||||
fun openCustomTab(activity : Activity, url : String) {
|
||||
try {
|
||||
if(Pref.bpPriorChrome(pref)) {
|
||||
if(url.startsWith("http") && Pref.bpPriorChrome(pref)) {
|
||||
try {
|
||||
// 初回はChrome指定で試す
|
||||
val builder = CustomTabsIntent.Builder()
|
||||
@ -539,7 +539,17 @@ class App1 : Application() {
|
||||
customTabsIntent.launchUrl(activity, Uri.parse(url))
|
||||
} catch(ex : Throwable) {
|
||||
log.trace(ex)
|
||||
showToast(activity, false, "can't open browser app")
|
||||
val scheme = try{
|
||||
Uri.parse(url).scheme
|
||||
}catch(_:Throwable){
|
||||
url
|
||||
}
|
||||
showToast(
|
||||
activity,
|
||||
true,
|
||||
"can't open browser app for %s",scheme
|
||||
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -387,6 +387,8 @@ object HTMLDecoder {
|
||||
}
|
||||
}
|
||||
|
||||
private val reNormalLink = Pattern.compile("\\A\\w+://")
|
||||
|
||||
private fun encodeUrl(
|
||||
options : DecodeOptions,
|
||||
display_url : String,
|
||||
@ -398,7 +400,10 @@ object HTMLDecoder {
|
||||
return display_url
|
||||
}
|
||||
|
||||
if(! display_url.startsWith("http")) {
|
||||
// 通常リンクはhttp,httpsだけでなく幾つかのスキーマ名が含まれる
|
||||
// スキーマ名の直後には必ず :// が出現する
|
||||
// https://github.com/tootsuite/mastodon/pull/7810
|
||||
if(! reNormalLink.matcher(display_url).find() ) {
|
||||
if(display_url.startsWith("@") && href != null && Pref.bpMentionFullAcct(App1.pref)) {
|
||||
// メンションをfull acct にする
|
||||
val m = TootAccount.reAccountUrl.matcher(href)
|
||||
@ -410,8 +415,6 @@ object HTMLDecoder {
|
||||
return display_url
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(options.isMediaAttachment(href)) {
|
||||
val sb = SpannableStringBuilder()
|
||||
sb.append(href)
|
||||
@ -429,6 +432,10 @@ object HTMLDecoder {
|
||||
try {
|
||||
val uri = Uri.parse(display_url)
|
||||
val sb = StringBuilder()
|
||||
if(! display_url.startsWith("http")){
|
||||
sb.append(uri.scheme)
|
||||
sb.append("://")
|
||||
}
|
||||
sb.append(uri.authority)
|
||||
val a = uri.encodedPath
|
||||
val q = uri.encodedQuery
|
||||
|
Loading…
x
Reference in New Issue
Block a user