Compare commits
3 Commits
5.2.7
...
5.2.8-BETA
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dfb60461e4 | ||
|
|
bd6bc418e6 | ||
|
|
a284143ce1 |
4
.idea/deploymentTargetDropDown.xml
generated
4
.idea/deploymentTargetDropDown.xml
generated
@@ -7,11 +7,11 @@
|
|||||||
<deviceKey>
|
<deviceKey>
|
||||||
<Key>
|
<Key>
|
||||||
<type value="VIRTUAL_DEVICE_PATH" />
|
<type value="VIRTUAL_DEVICE_PATH" />
|
||||||
<value value="$USER_HOME$/.android/avd/Pixel_2_API_31.avd" />
|
<value value="$USER_HOME$/.android/avd/Pixel_2_API_30.avd" />
|
||||||
</Key>
|
</Key>
|
||||||
</deviceKey>
|
</deviceKey>
|
||||||
</Target>
|
</Target>
|
||||||
</targetSelectedWithDropDown>
|
</targetSelectedWithDropDown>
|
||||||
<timeTargetWasSelectedWithDropDown value="2022-01-04T14:06:06.261345Z" />
|
<timeTargetWasSelectedWithDropDown value="2022-01-04T14:31:24.587053Z" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
*Pupil, Hitomi.la viewer for Android*
|
*Pupil, Hitomi.la viewer for Android*
|
||||||
|
|
||||||

|

|
||||||
[](https://github.com/tom5079/Pupil/releases/download/5.2.6/Pupil-v5.2.6.apk)
|
[](https://github.com/tom5079/Pupil/releases/download/5.2.7/Pupil-v5.2.7.apk)
|
||||||
[](https://discord.gg/Stj4b5v)
|
[](https://discord.gg/Stj4b5v)
|
||||||
|
|
||||||
# Features
|
# Features
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ android {
|
|||||||
minSdkVersion 16
|
minSdkVersion 16
|
||||||
targetSdkVersion 31
|
targetSdkVersion 31
|
||||||
versionCode 69
|
versionCode 69
|
||||||
versionName "5.2.6"
|
versionName "5.2.8-BETA01"
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
vectorDrawables.useSupportLibrary = true
|
vectorDrawables.useSupportLibrary = true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
"filters": [],
|
"filters": [],
|
||||||
"attributes": [],
|
"attributes": [],
|
||||||
"versionCode": 69,
|
"versionCode": 69,
|
||||||
"versionName": "5.2.6",
|
"versionName": "5.2.8-BETA01",
|
||||||
"outputFile": "app-release.apk"
|
"outputFile": "app-release.apk"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ class Pupil : Application() {
|
|||||||
instance = this
|
instance = this
|
||||||
isDebugBuild = applicationInfo.flags and ApplicationInfo.FLAG_DEBUGGABLE != 0
|
isDebugBuild = applicationInfo.flags and ApplicationInfo.FLAG_DEBUGGABLE != 0
|
||||||
|
|
||||||
WebView.setWebContentsDebuggingEnabled(true)
|
if (isDebugBuild) WebView.setWebContentsDebuggingEnabled(true)
|
||||||
|
|
||||||
webView = WebView(this).apply {
|
webView = WebView(this).apply {
|
||||||
with (settings) {
|
with (settings) {
|
||||||
@@ -257,11 +257,10 @@ class Pupil : Application() {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
Preferences.get<String>("download_folder").also {
|
Preferences.get<String>("download_folder").also {
|
||||||
if (it.startsWith("content") && Build.VERSION.SDK_INT > 19)
|
contentResolver.takePersistableUriPermission(
|
||||||
contentResolver.takePersistableUriPermission(
|
Uri.parse(it),
|
||||||
Uri.parse(it),
|
Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION
|
||||||
Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION
|
)
|
||||||
)
|
|
||||||
|
|
||||||
if (!FileX(this, it).canWrite())
|
if (!FileX(this, it).canWrite())
|
||||||
throw Exception()
|
throw Exception()
|
||||||
|
|||||||
@@ -20,13 +20,10 @@ import android.webkit.WebView
|
|||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import com.google.common.collect.ConcurrentHashMultiset
|
import com.google.common.collect.ConcurrentHashMultiset
|
||||||
import com.google.firebase.crashlytics.FirebaseCrashlytics
|
import com.google.firebase.crashlytics.FirebaseCrashlytics
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.*
|
||||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.flow.first
|
import kotlinx.coroutines.flow.first
|
||||||
import kotlinx.coroutines.flow.transformWhile
|
import kotlinx.coroutines.flow.transformWhile
|
||||||
import kotlinx.coroutines.withContext
|
|
||||||
import kotlinx.coroutines.yield
|
|
||||||
import kotlinx.serialization.ExperimentalSerializationApi
|
import kotlinx.serialization.ExperimentalSerializationApi
|
||||||
import kotlinx.serialization.decodeFromString
|
import kotlinx.serialization.decodeFromString
|
||||||
import kotlinx.serialization.encodeToString
|
import kotlinx.serialization.encodeToString
|
||||||
@@ -43,16 +40,18 @@ const val protocol = "https:"
|
|||||||
val evaluations = Collections.newSetFromMap<String>(ConcurrentHashMap())
|
val evaluations = Collections.newSetFromMap<String>(ConcurrentHashMap())
|
||||||
|
|
||||||
suspend fun WebView.evaluate(script: String): String = withContext(Dispatchers.Main) {
|
suspend fun WebView.evaluate(script: String): String = withContext(Dispatchers.Main) {
|
||||||
while (webViewFailed || !webViewReady) yield()
|
val result: String = withTimeout(10000) {
|
||||||
|
while (webViewFailed || !webViewReady) yield()
|
||||||
|
|
||||||
val uid = UUID.randomUUID().toString()
|
val uid = UUID.randomUUID().toString()
|
||||||
|
|
||||||
evaluations.add(uid)
|
evaluations.add(uid)
|
||||||
|
|
||||||
val result: String = suspendCoroutine { continuation ->
|
suspendCoroutine { continuation ->
|
||||||
evaluateJavascript(script) {
|
evaluateJavascript(script) {
|
||||||
evaluations.remove(uid)
|
evaluations.remove(uid)
|
||||||
continuation.resume(it)
|
continuation.resume(it)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,20 +60,22 @@ suspend fun WebView.evaluate(script: String): String = withContext(Dispatchers.M
|
|||||||
|
|
||||||
@OptIn(ExperimentalCoroutinesApi::class)
|
@OptIn(ExperimentalCoroutinesApi::class)
|
||||||
suspend fun WebView.evaluatePromise(script: String, then: String = ".then(result => Callback.onResult(%uid, JSON.stringify(result))).catch(err => Callback.onError(%uid, JSON.stringify(error)))"): String? = withContext(Dispatchers.Main) {
|
suspend fun WebView.evaluatePromise(script: String, then: String = ".then(result => Callback.onResult(%uid, JSON.stringify(result))).catch(err => Callback.onError(%uid, JSON.stringify(error)))"): String? = withContext(Dispatchers.Main) {
|
||||||
while (webViewFailed || !webViewReady) yield()
|
val flow: Flow<Pair<String, String?>> = withTimeout(10000) {
|
||||||
|
while (webViewFailed || !webViewReady) yield()
|
||||||
|
|
||||||
val uid = UUID.randomUUID().toString()
|
val uid = UUID.randomUUID().toString()
|
||||||
|
|
||||||
evaluations.add(uid)
|
evaluations.add(uid)
|
||||||
|
|
||||||
evaluateJavascript((script+then).replace("%uid", "'$uid'"), null)
|
evaluateJavascript((script+then).replace("%uid", "'$uid'"), null)
|
||||||
|
|
||||||
val flow: Flow<Pair<String, String?>> = webViewFlow.transformWhile { (currentUid, result) ->
|
webViewFlow.transformWhile { (currentUid, result) ->
|
||||||
if (currentUid == uid) {
|
if (currentUid == uid) {
|
||||||
evaluations.remove(uid)
|
evaluations.remove(uid)
|
||||||
emit(currentUid to result)
|
emit(currentUid to result)
|
||||||
|
}
|
||||||
|
currentUid != uid
|
||||||
}
|
}
|
||||||
currentUid != uid
|
|
||||||
}
|
}
|
||||||
|
|
||||||
flow.first().second
|
flow.first().second
|
||||||
|
|||||||
Reference in New Issue
Block a user