aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/BaseActivity.kt1
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/injectors/CssAssets.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/injectors/JsInjector.kt12
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClient.kt13
4 files changed, 10 insertions, 18 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/BaseActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/BaseActivity.kt
index 0e1caa9d..6212b2be 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/BaseActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/BaseActivity.kt
@@ -19,7 +19,6 @@ open class BaseActivity : AppCompatActivity() {
negativeText(android.R.string.no)
onPositive { _, _ -> super.onBackPressed() }
checkBoxPromptRes(R.string.do_not_show_again, false, { _, b -> Prefs.exitConfirmation = !b })
- show()
}
} else super.onBackPressed()
}
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssAssets.kt b/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssAssets.kt
index d207dddc..5cb9897e 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssAssets.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssAssets.kt
@@ -10,7 +10,7 @@ import com.pitchedapps.frost.utils.L
* //TODO add folder mapping using Prefs
*/
enum class CssAssets(val folder: String = "themes") : InjectorContract {
- MATERIAL_LIGHT, MATERIAL_DARK, MATERIAL_AMOLED, MATERIAL_GLASS, CUSTOM
+ MATERIAL_LIGHT, MATERIAL_DARK, MATERIAL_AMOLED, MATERIAL_GLASS, CUSTOM, ROUND_ICONS("components")
;
var file = "${name.toLowerCase()}.compact.css"
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/injectors/JsInjector.kt b/app/src/main/kotlin/com/pitchedapps/frost/injectors/JsInjector.kt
index 2d8d42e1..0a90c05f 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/injectors/JsInjector.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/injectors/JsInjector.kt
@@ -37,19 +37,25 @@ class JsBuilder {
interface InjectorContract {
fun inject(webView: WebView) = inject(webView, null)
fun inject(webView: WebView, callback: ((String) -> Unit)?)
+ /**
+ * Toggle the injector (usually through Prefs
+ * If false, will fallback to an empty action
+ */
+ fun maybe(enable: Boolean): InjectorContract = if (enable) this else JsActions.EMPTY
}
/**
* Helper method to inject multiple functions simultaneously with a single callback
*/
fun WebView.jsInject(vararg injectors: InjectorContract, callback: ((Array<String>) -> Unit) = {}) {
- val observables = Array(injectors.size, { SingleSubject.create<String>() })
+ val validInjectors = injectors.filter { it != JsActions.EMPTY }
+ val observables = Array(validInjectors.size, { SingleSubject.create<String>() })
Observable.zip<String, Array<String>>(observables.map { it.toObservable() }, { it.map { it.toString() }.toTypedArray() }).subscribeOn(AndroidSchedulers.mainThread()).subscribe({
callback.invoke(it)
})
- (0 until injectors.size).asSequence().forEach {
+ (0 until validInjectors.size).asSequence().forEach {
i ->
- injectors[i].inject(this, { observables[i].onSuccess(it) })
+ validInjectors[i].inject(this, { observables[i].onSuccess(it) })
}
}
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClient.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClient.kt
index ac2af3cb..0fe3304a 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClient.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClient.kt
@@ -64,7 +64,6 @@ open class FrostWebViewClient(val webCore: FrostWebViewCore) : WebViewClient() {
Prefs.themeInjector,
// JsAssets.CLICK_INTERCEPTOR,
callback = {
- L.d("Finished ${it.contentToString()}")
refreshObservable.onNext(false)
})
}
@@ -87,22 +86,10 @@ open class FrostWebViewClient(val webCore: FrostWebViewCore) : WebViewClient() {
return super.shouldOverrideUrlLoading(view, request)
}
-
-
override fun shouldInterceptRequest(view: WebView, request: WebResourceRequest?): WebResourceResponse? {
if (request == null || !(request.url.host?.contains(FACEBOOK_COM) ?: false)) return super.shouldInterceptRequest(view, request)
L.v("Url intercept ${request.url.path}")
return super.shouldInterceptRequest(view, request)
}
- override fun onLoadResource(view: WebView, url: String) {
- if (!url.contains(FACEBOOK_COM)) return super.onLoadResource(view, url)
- L.v("Resource $url")
-// FrostWebOverlay.values.forEach {
-// if (url.contains(it.match))
-// L.d("Resource Loaded $it")
-// }
- super.onLoadResource(view, url)
- }
-
} \ No newline at end of file