Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codestyle cleanup #22

Merged
merged 3 commits into from
Apr 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,45 +1,49 @@
package to.dev.dev_android.view.main.view

import android.content.Context
import android.net.Uri
import androidx.browser.customtabs.CustomTabsIntent
import android.webkit.WebView
import android.webkit.WebViewClient
import androidx.core.content.ContextCompat.startActivity
import android.content.Intent
import android.graphics.Bitmap
import android.net.Uri
import android.os.Build
import android.view.View
import android.webkit.CookieManager
import android.webkit.CookieSyncManager
import android.webkit.WebView
import android.webkit.WebViewClient
import androidx.browser.customtabs.CustomTabsIntent
import to.dev.dev_android.databinding.ActivityMainBinding

class CustomWebViewClient(val context: Context, val binding: ActivityMainBinding) : WebViewClient() {
class CustomWebViewClient(private val context: Context, private val binding: ActivityMainBinding) : WebViewClient() {

private val overrideUrlList = listOf(
"api.twitter.com/oauth",
"api.twitter.com/account/login_verification",
"github.com/login",
"github.com/sessions/"
)
override fun onPageFinished(view: WebView, url: String?) {
binding.splash.visibility = View.GONE
view.visibility = View.VISIBLE
super.onPageFinished(view, url)
}

override fun shouldOverrideUrlLoading(view: WebView, url: String): Boolean {
if(view.originalUrl == "https://dev.to/signout_confirm" && url == "https://dev.to/") {
if (view.originalUrl == "https://dev.to/signout_confirm" && url == "https://dev.to/") {
view.clearCache(true)
view.clearFormData()
view.clearHistory()
when (Build.VERSION.SDK_INT) {
in Int.MIN_VALUE..20 -> CookieManager.getInstance().removeAllCookie()
else -> CookieManager.getInstance().removeAllCookies(null)
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP) {
CookieManager.getInstance().removeAllCookie()
} else {
CookieManager.getInstance().removeAllCookies(null)
}
}

if (url.contains("://dev.to")) {
return false
} else {
if(url.contains("api.twitter.com/oauth") ||
url.contains("api.twitter.com/account/login_verification") ||
url.contains("github.com/login") ||
url.contains("github.com/sessions/")) {
return false
for (i in 0 until overrideUrlList.size) {
if (url.contains(overrideUrlList[i])) {
return false
}
}
val builder = CustomTabsIntent.Builder()
builder.setToolbarColor(-0x1000000)
Expand Down