Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Commit

Permalink
feat(speedtest/web): Update speedtest activity code java to kotlin
Browse files Browse the repository at this point in the history
  • Loading branch information
AnGgIt86 committed Oct 4, 2024
1 parent 91ab458 commit af79e89
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 63 deletions.
63 changes: 0 additions & 63 deletions app/src/main/java/com/neko/tools/SpeedTestActivity.java

This file was deleted.

68 changes: 68 additions & 0 deletions app/src/main/java/com/neko/tools/SpeedTestActivity.kt
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)
}
}

0 comments on commit af79e89

Please sign in to comment.