This repository has been archived by the owner on Nov 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(speedtest/web): Update speedtest activity code java to kotlin
- Loading branch information
Showing
2 changed files
with
68 additions
and
63 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package com.neko.tools | ||
|
||
import android.graphics.Bitmap | ||
import android.os.Bundle | ||
import android.view.KeyEvent | ||
import android.view.View | ||
import android.webkit.WebSettings | ||
import android.webkit.WebView | ||
import android.webkit.WebViewClient | ||
import android.widget.ProgressBar | ||
import android.widget.TextView | ||
|
||
import com.neko.v2ray.ui.BaseActivity | ||
import com.neko.v2ray.R | ||
|
||
class SpeedTestActivity : BaseActivity() { | ||
private lateinit var progressBar: ProgressBar | ||
private lateinit var txtwait: TextView | ||
private lateinit var web: WebView | ||
|
||
private inner class MyWebClient : WebViewClient() { | ||
override fun onPageFinished(webView: WebView, url: String) { | ||
super.onPageFinished(webView, url) | ||
txtwait.visibility = View.GONE | ||
progressBar.visibility = View.GONE | ||
} | ||
|
||
override fun onPageStarted(webView: WebView, url: String, favicon: Bitmap?) { | ||
super.onPageStarted(webView, url, favicon) | ||
} | ||
|
||
override fun shouldOverrideUrlLoading(webView: WebView, url: String): Boolean { | ||
webView.loadUrl(url) | ||
return true | ||
} | ||
} | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.uwu_speedtest) | ||
|
||
web = findViewById(R.id.uwu_WebView) | ||
progressBar = findViewById(R.id.uwu_ProgressBar) | ||
txtwait = findViewById(R.id.uwu_TextView) | ||
|
||
web.webViewClient = MyWebClient() | ||
web.settings.apply { | ||
javaScriptEnabled = true | ||
domStorageEnabled = true | ||
loadsImagesAutomatically = true | ||
mixedContentMode = WebSettings.MIXED_CONTENT_ALWAYS_ALLOW | ||
loadWithOverviewMode = true | ||
useWideViewPort = true | ||
} | ||
web.setInitialScale(1) | ||
web.clearCache(true) | ||
web.clearHistory() | ||
web.loadUrl("https://fusiontempest.speedtestcustom.com") | ||
} | ||
|
||
override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { | ||
if (keyCode == KeyEvent.KEYCODE_BACK && web.canGoBack()) { | ||
web.goBack() | ||
return true | ||
} | ||
return super.onKeyDown(keyCode, event) | ||
} | ||
} |