Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b4745d76b8 | ||
|
|
9b821dd7cb | ||
|
|
213902c854 | ||
|
|
2054922586 | ||
|
|
a17b7355f5 | ||
|
|
066a1e1f3a | ||
|
|
b10cbfbd63 |
17
.idea/deploymentTargetDropDown.xml
generated
17
.idea/deploymentTargetDropDown.xml
generated
@@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="deploymentTargetDropDown">
|
||||
<runningDeviceTargetSelectedWithDropDown>
|
||||
<Target>
|
||||
<type value="RUNNING_DEVICE_TARGET" />
|
||||
<deviceKey>
|
||||
<Key>
|
||||
<type value="VIRTUAL_DEVICE_PATH" />
|
||||
<value value="$USER_HOME$/.android/avd/Pixel_2_API_30.avd" />
|
||||
</Key>
|
||||
</deviceKey>
|
||||
</Target>
|
||||
</runningDeviceTargetSelectedWithDropDown>
|
||||
<timeTargetWasSelectedWithDropDown value="2022-01-01T07:38:11.679673Z" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -2,7 +2,7 @@
|
||||
*Pupil, Hitomi.la viewer for Android*
|
||||
|
||||

|
||||
[](https://github.com/tom5079/Pupil/releases/download/5.1.30/Pupil-v5.1.30.apk)
|
||||
[](https://github.com/tom5079/Pupil/releases/download/5.1.36/Pupil-v5.1.36.apk)
|
||||
[](https://discord.gg/Stj4b5v)
|
||||
|
||||
# Features
|
||||
|
||||
@@ -38,7 +38,7 @@ android {
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 30
|
||||
versionCode 69
|
||||
versionName "5.1.30"
|
||||
versionName "5.1.32"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
vectorDrawables.useSupportLibrary = true
|
||||
}
|
||||
@@ -126,7 +126,6 @@ dependencies {
|
||||
implementation "ru.noties.markwon:core:3.1.0"
|
||||
|
||||
implementation "org.jsoup:jsoup:1.14.3"
|
||||
implementation "com.github.seven332:quickjs-android:0.1.0"
|
||||
|
||||
implementation "com.google.guava:guava:31.0.1-android"
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
"type": "SINGLE",
|
||||
"filters": [],
|
||||
"versionCode": 69,
|
||||
"versionName": "5.1.30",
|
||||
"versionName": "5.1.32",
|
||||
"outputFile": "app-release.apk"
|
||||
}
|
||||
]
|
||||
|
||||
@@ -20,8 +20,14 @@
|
||||
|
||||
package xyz.quaver.pupil
|
||||
|
||||
import android.util.Log
|
||||
import android.webkit.WebView
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import kotlinx.coroutines.MainScope
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
@@ -37,5 +43,17 @@ class ExampleInstrumentedTest {
|
||||
fun useAppContext() {
|
||||
// Context of the app under test.
|
||||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
|
||||
runBlocking {
|
||||
MainScope().launch {
|
||||
val webView = WebView(appContext).apply {
|
||||
settings.javaScriptEnabled = true
|
||||
}
|
||||
webView.evaluateJavascript("3") {
|
||||
Log.d("PUPILD", it)
|
||||
}
|
||||
Log.d("PUPILD", "SYNC?")
|
||||
}.join()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package xyz.quaver.pupil
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Application
|
||||
import android.app.Notification
|
||||
import android.app.NotificationChannel
|
||||
@@ -26,6 +27,7 @@ import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.webkit.WebView
|
||||
import androidx.appcompat.app.AppCompatDelegate
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.preference.PreferenceManager
|
||||
@@ -69,9 +71,26 @@ val client: OkHttpClient
|
||||
clientHolder = it
|
||||
}
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
lateinit var webView: WebView
|
||||
|
||||
class Pupil : Application() {
|
||||
|
||||
companion object {
|
||||
lateinit var instance: Pupil
|
||||
private set
|
||||
}
|
||||
|
||||
@SuppressLint("SetJavaScriptEnabled")
|
||||
override fun onCreate() {
|
||||
instance = this
|
||||
|
||||
webView = WebView(this).apply {
|
||||
settings.javaScriptEnabled = true
|
||||
|
||||
loadData("""<script src="https://ltn.hitomi.la/gg.js"></script>""", "text/html", null)
|
||||
}
|
||||
|
||||
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true)
|
||||
|
||||
preferences = PreferenceManager.getDefaultSharedPreferences(this)
|
||||
|
||||
@@ -16,15 +16,15 @@
|
||||
|
||||
package xyz.quaver.pupil.hitomi
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.util.Log
|
||||
import com.hippo.quickjs.android.QuickJS
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.sync.Mutex
|
||||
import kotlinx.coroutines.sync.withLock
|
||||
import android.webkit.WebView
|
||||
import android.webkit.WebViewClient
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.serialization.decodeFromString
|
||||
import xyz.quaver.json
|
||||
import xyz.quaver.pupil.Pupil
|
||||
import xyz.quaver.pupil.webView
|
||||
import xyz.quaver.readText
|
||||
import java.net.URL
|
||||
import java.nio.charset.Charset
|
||||
@@ -44,6 +44,7 @@ const val galleryblockextension = ".html"
|
||||
const val galleryblockdir = "galleryblock"
|
||||
const val nozomiextension = ".nozomi"
|
||||
|
||||
@SuppressLint("SetJavaScriptEnabled")
|
||||
interface gg {
|
||||
fun m(g: Int): Int
|
||||
val b: String
|
||||
@@ -55,33 +56,51 @@ interface gg {
|
||||
fun getInstance(): gg =
|
||||
instance ?: synchronized(this) {
|
||||
instance ?: object: gg {
|
||||
private val ggjs by lazy { URL("https://ltn.hitomi.la/gg.js").readText(Charset.defaultCharset()) }
|
||||
private val quickJS = QuickJS.Builder().build()
|
||||
override fun m(g: Int): Int {
|
||||
var result: Int? = null
|
||||
|
||||
override fun m(g: Int): Int =
|
||||
quickJS.createJSRuntime().use { runtime ->
|
||||
runtime.createJSContext().use { context ->
|
||||
context.evaluate(ggjs, "gg.js")
|
||||
context.evaluate("gg.m($g)", "gg.js", Int::class.java)
|
||||
MainScope().launch {
|
||||
while (webView.progress != 100) delay(100)
|
||||
webView.evaluateJavascript("gg.m($g)") {
|
||||
result = it.toInt()
|
||||
}
|
||||
}
|
||||
|
||||
while (result == null) Thread.sleep(100)
|
||||
|
||||
return result!!
|
||||
}
|
||||
|
||||
override val b: String
|
||||
get() =
|
||||
quickJS.createJSRuntime().use { runtime ->
|
||||
runtime.createJSContext().use { context ->
|
||||
context.evaluate(ggjs, "gg.js")
|
||||
context.evaluate("gg.b", "gg.js", String::class.java)
|
||||
get() {
|
||||
var result: String? = null
|
||||
|
||||
MainScope().launch {
|
||||
while (webView.progress != 100) delay(100)
|
||||
webView.evaluateJavascript("gg.b") {
|
||||
result = it.replace("\"", "")
|
||||
}
|
||||
}
|
||||
|
||||
override fun s(h: String): String =
|
||||
quickJS.createJSRuntime().use { runtime ->
|
||||
runtime.createJSContext().use { context ->
|
||||
context.evaluate(ggjs, "gg.js")
|
||||
context.evaluate("gg.s('$h')", "gg.js", String::class.java)
|
||||
while (result == null) Thread.sleep(100)
|
||||
|
||||
return result!!
|
||||
}
|
||||
|
||||
override fun s(h: String): String {
|
||||
var result: String? = null
|
||||
|
||||
MainScope().launch {
|
||||
while (webView.progress != 100) delay(100)
|
||||
webView.evaluateJavascript("gg.s('$h')") {
|
||||
result = it.replace("\"", "")
|
||||
}
|
||||
}
|
||||
|
||||
while (result == null) Thread.sleep(100)
|
||||
|
||||
return result!!
|
||||
}
|
||||
}.also { instance = it }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user