WebActivity: gracefully handle unsupported link types.

pull/96/head
Tom Hacohen 5 years ago
parent 461c870638
commit 16efe446c0

@ -2,6 +2,7 @@ package com.etesync.syncadapter.ui
import android.annotation.SuppressLint
import android.annotation.TargetApi
import android.content.ActivityNotFoundException
import android.content.Context
import android.content.Intent
import android.net.Uri
@ -11,6 +12,7 @@ import android.view.KeyEvent
import android.view.View
import android.webkit.*
import android.widget.ProgressBar
import android.widget.Toast
import androidx.appcompat.app.ActionBar
import com.etesync.syncadapter.Constants
import com.etesync.syncadapter.R
@ -127,7 +129,11 @@ class WebViewActivity : BaseActivity() {
return true
}
} 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
}
}
@ -163,7 +169,11 @@ class WebViewActivity : BaseActivity() {
intent.putExtra(WebViewActivity.KEY_URL, uri)
context.startActivity(intent)
} 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()
}
}
}

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

Loading…
Cancel
Save