Compare commits

..

8 Commits

Author SHA1 Message Date
tom5079
9b821dd7cb Update README.md 2022-01-02 23:49:58 +09:00
tom5079
213902c854 Update README.md 2022-01-02 16:46:54 +09:00
tom5079
2054922586 Update README.md 2022-01-02 16:46:43 +09:00
tom5079
a17b7355f5 Merge remote-tracking branch 'origin/master' 2022-01-02 15:30:20 +09:00
tom5079
066a1e1f3a use WebView(!) as a js engine 2022-01-02 15:30:03 +09:00
tom5079
b10cbfbd63 Update README.md 2022-01-02 15:18:11 +09:00
tom5079
fcd72bb8bd Revert back to quickjs-android (quickjs stackoverflows) 2022-01-02 09:16:28 +09:00
tom5079
37cd99731c Fixed images not loading 2022-01-02 09:08:53 +09:00
8 changed files with 88 additions and 52 deletions

View File

@@ -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>

View File

@@ -81,5 +81,10 @@
<option name="name" value="MavenLocal" /> <option name="name" value="MavenLocal" />
<option name="url" value="file:$USER_HOME$/.m2/repository/" /> <option name="url" value="file:$USER_HOME$/.m2/repository/" />
</remote-repository> </remote-repository>
<remote-repository>
<option name="id" value="maven2" />
<option name="name" value="maven2" />
<option name="url" value="https://oss.sonatype.org/content/repositories/snapshots" />
</remote-repository>
</component> </component>
</project> </project>

View File

@@ -2,7 +2,7 @@
*Pupil, Hitomi.la viewer for Android* *Pupil, Hitomi.la viewer for Android*
![](https://img.shields.io/github/downloads/tom5079/Pupil/total) ![](https://img.shields.io/github/downloads/tom5079/Pupil/total)
[![](https://img.shields.io/github/downloads/tom5079/Pupil/5.1.29/Pupil-v5.1.29.apk?color=%234fc3f7&label=DOWNLOAD%20APP&style=for-the-badge)](https://github.com/tom5079/Pupil/releases/download/5.1.29/Pupil-v5.1.29.apk) [![](https://img.shields.io/github/downloads/tom5079/Pupil/5.1.34/Pupil-v5.1.34.apk?color=%234fc3f7&label=DOWNLOAD%20APP&style=for-the-badge)](https://github.com/tom5079/Pupil/releases/download/5.1.34/Pupil-v5.1.34.apk)
[![](https://discordapp.com/api/guilds/610452916612104194/embed.png?style=banner2)](https://discord.gg/Stj4b5v) [![](https://discordapp.com/api/guilds/610452916612104194/embed.png?style=banner2)](https://discord.gg/Stj4b5v)
# Features # Features

View File

@@ -38,7 +38,7 @@ android {
minSdkVersion 16 minSdkVersion 16
targetSdkVersion 30 targetSdkVersion 30
versionCode 69 versionCode 69
versionName "5.1.29" versionName "5.1.32"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true vectorDrawables.useSupportLibrary = true
} }
@@ -126,7 +126,6 @@ dependencies {
implementation "ru.noties.markwon:core:3.1.0" implementation "ru.noties.markwon:core:3.1.0"
implementation "org.jsoup:jsoup:1.14.3" 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" implementation "com.google.guava:guava:31.0.1-android"

View File

@@ -11,7 +11,7 @@
"type": "SINGLE", "type": "SINGLE",
"filters": [], "filters": [],
"versionCode": 69, "versionCode": 69,
"versionName": "5.1.29", "versionName": "5.1.32",
"outputFile": "app-release.apk" "outputFile": "app-release.apk"
} }
] ]

View File

@@ -20,8 +20,14 @@
package xyz.quaver.pupil package xyz.quaver.pupil
import android.util.Log
import android.webkit.WebView
import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry 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.Test
import org.junit.runner.RunWith import org.junit.runner.RunWith
@@ -37,5 +43,17 @@ class ExampleInstrumentedTest {
fun useAppContext() { fun useAppContext() {
// Context of the app under test. // Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext 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()
}
} }
} }

View File

@@ -18,6 +18,7 @@
package xyz.quaver.pupil package xyz.quaver.pupil
import android.annotation.SuppressLint
import android.app.Application import android.app.Application
import android.app.Notification import android.app.Notification
import android.app.NotificationChannel import android.app.NotificationChannel
@@ -26,7 +27,7 @@ import android.content.Context
import android.content.Intent import android.content.Intent
import android.net.Uri import android.net.Uri
import android.os.Build import android.os.Build
import android.util.Log import android.webkit.WebView
import androidx.appcompat.app.AppCompatDelegate import androidx.appcompat.app.AppCompatDelegate
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.preference.PreferenceManager import androidx.preference.PreferenceManager
@@ -36,11 +37,6 @@ import com.google.android.gms.common.GooglePlayServicesNotAvailableException
import com.google.android.gms.common.GooglePlayServicesRepairableException import com.google.android.gms.common.GooglePlayServicesRepairableException
import com.google.android.gms.security.ProviderInstaller import com.google.android.gms.security.ProviderInstaller
import com.google.firebase.crashlytics.FirebaseCrashlytics import com.google.firebase.crashlytics.FirebaseCrashlytics
import com.hippo.quickjs.android.QuickJS
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.MainScope
import kotlinx.coroutines.launch
import okhttp3.Dispatcher import okhttp3.Dispatcher
import okhttp3.Interceptor import okhttp3.Interceptor
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
@@ -48,9 +44,7 @@ import okhttp3.Response
import xyz.quaver.io.FileX import xyz.quaver.io.FileX
import xyz.quaver.pupil.types.Tag import xyz.quaver.pupil.types.Tag
import xyz.quaver.pupil.util.* import xyz.quaver.pupil.util.*
import xyz.quaver.readText
import java.io.File import java.io.File
import java.net.URL
import java.util.* import java.util.*
import java.util.concurrent.Executors import java.util.concurrent.Executors
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
@@ -77,9 +71,26 @@ val client: OkHttpClient
clientHolder = it clientHolder = it
} }
@SuppressLint("StaticFieldLeak")
lateinit var webView: WebView
class Pupil : Application() { class Pupil : Application() {
companion object {
lateinit var instance: Pupil
private set
}
@SuppressLint("SetJavaScriptEnabled")
override fun onCreate() { 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) AppCompatDelegate.setCompatVectorFromResourcesEnabled(true)
preferences = PreferenceManager.getDefaultSharedPreferences(this) preferences = PreferenceManager.getDefaultSharedPreferences(this)

View File

@@ -16,17 +16,18 @@
package xyz.quaver.pupil.hitomi package xyz.quaver.pupil.hitomi
import android.annotation.SuppressLint
import android.util.Log import android.util.Log
import com.hippo.quickjs.android.QuickJS import android.webkit.WebView
import kotlinx.coroutines.CoroutineScope import android.webkit.WebViewClient
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.*
import kotlinx.coroutines.launch
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
import kotlinx.serialization.decodeFromString import kotlinx.serialization.decodeFromString
import xyz.quaver.json import xyz.quaver.json
import xyz.quaver.pupil.Pupil
import xyz.quaver.pupil.webView
import xyz.quaver.readText import xyz.quaver.readText
import java.net.URL import java.net.URL
import java.nio.charset.Charset
const val protocol = "https:" const val protocol = "https:"
@@ -43,6 +44,7 @@ const val galleryblockextension = ".html"
const val galleryblockdir = "galleryblock" const val galleryblockdir = "galleryblock"
const val nozomiextension = ".nozomi" const val nozomiextension = ".nozomi"
@SuppressLint("SetJavaScriptEnabled")
interface gg { interface gg {
fun m(g: Int): Int fun m(g: Int): Int
val b: String val b: String
@@ -54,33 +56,51 @@ interface gg {
fun getInstance(): gg = fun getInstance(): gg =
instance ?: synchronized(this) { instance ?: synchronized(this) {
instance ?: object: gg { instance ?: object: gg {
private val ggjs by lazy { URL("https://ltn.hitomi.la/gg.js").readText() } override fun m(g: Int): Int {
private val quickJS = QuickJS.Builder().build() var result: Int? = null
override fun m(g: Int): Int = MainScope().launch {
quickJS.createJSRuntime().use { runtime -> while (webView.progress != 100) delay(100)
runtime.createJSContext().use { context -> webView.evaluateJavascript("gg.m($g)") {
context.evaluate(ggjs, "gg.js") result = it.toInt()
context.evaluate("gg.m($g)", "gg.js", Int::class.java)
} }
} }
while (result == null) Thread.sleep(100)
return result!!
}
override val b: String override val b: String
get() = get() {
quickJS.createJSRuntime().use { runtime -> var result: String? = null
runtime.createJSContext().use { context ->
context.evaluate(ggjs, "gg.js") MainScope().launch {
context.evaluate("gg.b", "gg.js", String::class.java) while (webView.progress != 100) delay(100)
webView.evaluateJavascript("gg.b") {
result = it.replace("\"", "")
} }
} }
override fun s(h: String): String = while (result == null) Thread.sleep(100)
quickJS.createJSRuntime().use { runtime ->
runtime.createJSContext().use { context -> return result!!
context.evaluate(ggjs, "gg.js") }
context.evaluate("gg.s('$h')", "gg.js", String::class.java)
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 } }.also { instance = it }
} }
} }