Created
September 10, 2020 09:40
-
-
Save luca020400/3c58028a8b019b5a659423e40413196c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/app/src/main/java/org/lineageos/jelly/MainActivity.kt b/app/src/main/java/org/lineageos/jelly/MainActivity.kt | |
index 9c6dcab..cbe382b 100644 | |
--- a/app/src/main/java/org/lineageos/jelly/MainActivity.kt | |
+++ b/app/src/main/java/org/lineageos/jelly/MainActivity.kt | |
@@ -361,7 +361,10 @@ class MainActivity : WebViewExtActivity(), SearchBarController.OnCancelListener, | |
mSearchActive = false | |
} | |
- private fun shareUrl(url: String) { | |
+ private fun shareUrl(url: String?) { | |
+ if (url == null) { | |
+ return | |
+ } | |
val intent = Intent(Intent.ACTION_SEND) | |
intent.putExtra(Intent.EXTRA_TEXT, url) | |
if (PrefsUtils.getAdvancedShare(this) && url == mWebView.url) { | |
@@ -386,7 +389,10 @@ class MainActivity : WebViewExtActivity(), SearchBarController.OnCancelListener, | |
startActivity(Intent.createChooser(intent, getString(R.string.share_title))) | |
} | |
- private fun setAsFavorite(title: String, url: String) { | |
+ private fun setAsFavorite(title: String?, url: String?) { | |
+ if (title == null || url == null) { | |
+ return | |
+ } | |
val hasValidIcon = mUrlIcon != null && !mUrlIcon!!.isRecycled | |
var color = if (hasValidIcon) UiUtils.getColor(mUrlIcon, false) else Color.TRANSPARENT | |
if (color == Color.TRANSPARENT) { | |
@@ -604,7 +610,7 @@ class MainActivity : WebViewExtActivity(), SearchBarController.OnCancelListener, | |
} else { | |
Icon.createWithResource(this, R.mipmap.ic_launcher) | |
} | |
- val title = mWebView.title | |
+ val title = mWebView.title.toString() | |
val shortcutInfo = ShortcutInfo.Builder(this, title) | |
.setShortLabel(title) | |
.setIcon(launcherIcon) | |
diff --git a/app/src/main/java/org/lineageos/jelly/ui/AutoCompleteTextViewExt.kt b/app/src/main/java/org/lineageos/jelly/ui/AutoCompleteTextViewExt.kt | |
index ed18954..a39f576 100644 | |
--- a/app/src/main/java/org/lineageos/jelly/ui/AutoCompleteTextViewExt.kt | |
+++ b/app/src/main/java/org/lineageos/jelly/ui/AutoCompleteTextViewExt.kt | |
@@ -24,9 +24,9 @@ class AutoCompleteTextViewExt : AppCompatAutoCompleteTextView { | |
private var mFocusChangeListener: OnFocusChangeListener? = null | |
private var mPositionX = 0 | |
- constructor(context: Context?) : super(context) | |
- constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs) | |
- constructor(context: Context?, attrs: AttributeSet?, defStyle: Int) : | |
+ constructor(context: Context) : super(context) | |
+ constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) | |
+ constructor(context: Context, attrs: AttributeSet?, defStyle: Int) : | |
super(context, attrs, defStyle) | |
override fun getOnFocusChangeListener(): OnFocusChangeListener { | |
diff --git a/app/src/main/java/org/lineageos/jelly/ui/SearchBarController.kt b/app/src/main/java/org/lineageos/jelly/ui/SearchBarController.kt | |
index 0f3b31b..a92d7b1 100644 | |
--- a/app/src/main/java/org/lineageos/jelly/ui/SearchBarController.kt | |
+++ b/app/src/main/java/org/lineageos/jelly/ui/SearchBarController.kt | |
@@ -97,12 +97,14 @@ class SearchBarController( | |
} | |
private fun startSearch() { | |
- if (query.isNullOrEmpty()) { | |
- clearSearchResults() | |
- mStatus.text = null | |
- } else { | |
- mWebView.findAllAsync(query) | |
- mHasStartedSearch = true | |
+ query.let { | |
+ if (it.isNullOrEmpty()) { | |
+ clearSearchResults() | |
+ mStatus.text = null | |
+ } else { | |
+ mWebView.findAllAsync(it) | |
+ mHasStartedSearch = true | |
+ } | |
} | |
updateStatusText() | |
} | |
diff --git a/app/src/main/java/org/lineageos/jelly/webview/ChromeClient.kt b/app/src/main/java/org/lineageos/jelly/webview/ChromeClient.kt | |
index e8b9564..f5f7d84 100644 | |
--- a/app/src/main/java/org/lineageos/jelly/webview/ChromeClient.kt | |
+++ b/app/src/main/java/org/lineageos/jelly/webview/ChromeClient.kt | |
@@ -44,8 +44,10 @@ internal class ChromeClient( | |
override fun onReceivedTitle(view: WebView, title: String) { | |
mUrlBarController.onTitleReceived(title) | |
- if (!mIncognito) { | |
- HistoryProvider.addOrUpdateItem(mActivity.contentResolver, title, view.url) | |
+ view.url?.let { | |
+ if (!mIncognito) { | |
+ HistoryProvider.addOrUpdateItem(mActivity.contentResolver, title, it) | |
+ } | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment