1
0
mirror of https://github.com/etesync/android synced 2024-11-25 17:38:13 +00:00

WebActivity: gracefully handle unsupported link types.

This commit is contained in:
Tom Hacohen 2019-06-13 10:10:23 +01:00
parent 461c870638
commit 16efe446c0
2 changed files with 13 additions and 2 deletions

View File

@ -2,6 +2,7 @@ package com.etesync.syncadapter.ui
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.annotation.TargetApi import android.annotation.TargetApi
import android.content.ActivityNotFoundException
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.net.Uri import android.net.Uri
@ -11,6 +12,7 @@ import android.view.KeyEvent
import android.view.View import android.view.View
import android.webkit.* import android.webkit.*
import android.widget.ProgressBar import android.widget.ProgressBar
import android.widget.Toast
import androidx.appcompat.app.ActionBar import androidx.appcompat.app.ActionBar
import com.etesync.syncadapter.Constants import com.etesync.syncadapter.Constants
import com.etesync.syncadapter.R import com.etesync.syncadapter.R
@ -127,7 +129,11 @@ class WebViewActivity : BaseActivity() {
return true return true
} }
} else { } else {
startActivity(Intent(Intent.ACTION_VIEW, uri)) try {
startActivity(Intent(Intent.ACTION_VIEW, uri))
} catch (e: ActivityNotFoundException) {
Toast.makeText(this, getString(R.string.open_url_no_activity), Toast.LENGTH_LONG).show()
}
return true return true
} }
} }
@ -163,7 +169,11 @@ class WebViewActivity : BaseActivity() {
intent.putExtra(WebViewActivity.KEY_URL, uri) intent.putExtra(WebViewActivity.KEY_URL, uri)
context.startActivity(intent) context.startActivity(intent)
} else { } else {
context.startActivity(Intent(Intent.ACTION_VIEW, uri)) try {
context.startActivity(Intent(Intent.ACTION_VIEW, uri))
} catch (e: ActivityNotFoundException) {
Toast.makeText(context, context.getString(R.string.open_url_no_activity), Toast.LENGTH_LONG).show()
}
} }
} }

View File

@ -374,6 +374,7 @@
<string name="loading">Loading...</string> <string name="loading">Loading...</string>
<string name="loading_error_title">Loading Error</string> <string name="loading_error_title">Loading Error</string>
<string name="loading_error_content">Refresh</string> <string name="loading_error_content">Refresh</string>
<string name="open_url_no_activity">Failed opening link: link is not supported!</string>
<!-- Import Activity --> <!-- Import Activity -->
<string name="import_button_file">From File</string> <string name="import_button_file">From File</string>