diff options
author | Allan Wang <me@allanwang.ca> | 2017-07-13 15:08:06 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-13 15:08:06 -0700 |
commit | 1d364a1f5a8322ce8fbe200fcc9f5a41f91b41e8 (patch) | |
tree | efef20bdba32bcd0fbbdd303dfd01018b4871e01 /app/src | |
parent | 91119de328bf5f4e8c945f8fb470453319b9f0ed (diff) | |
download | frost-1d364a1f5a8322ce8fbe200fcc9f5a41f91b41e8.tar.gz frost-1d364a1f5a8322ce8fbe200fcc9f5a41f91b41e8.tar.bz2 frost-1d364a1f5a8322ce8fbe200fcc9f5a41f91b41e8.zip |
Only use basic user agent when necessary (#59)
* Log more iab and web chrome
* Only add basic user string for messages
* Clean up logging
Diffstat (limited to 'app/src')
7 files changed, 51 insertions, 35 deletions
diff --git a/app/src/main/assets/css/core/main.compact.css b/app/src/main/assets/css/core/main.compact.css index 6bd571bb..65fd3b84 100644 --- a/app/src/main/assets/css/core/main.compact.css +++ b/app/src/main/assets/css/core/main.compact.css @@ -1,12 +1,12 @@ #viewport { background: #451515 !important; } -body, #root, #header, [style*="background-color"], ._55wo, ._1upc, input, ._2f9r, ._59e9, ._5pz4, ._5lp4, ._5lp5, .container, .subpage, ._5n_f, #static_templates, .tlBody, #timelineBody, .timelineX, .timeline, .feed, .tlPrelude, .tlFeedPlaceholder, ._4_d0, .al, ._1gkq, ._5c5b, ._1qxg, ._5luf, ._2new, ._cld, ._11ub, ._5p7j, ._55wm, ._5rgs, ._5xuj, ._1sv1, ._45fu, ._18qg, ._1_ac, ._5w3g, ._3e18, ._10c_, ._2jl2, ._5q_r, ._5yt8, ._idb, ._2ip_, ._f6s, ._2l5v, ._d4i, ._577z, ._2u4w, ._3u9p, ._3u9t, ._2v9s, ._cw4, ._5_y-, ._5_y_, ._5_z3, ._cwy, ._5_z0, ._5_z1, ._5_z2, ._2mtc, ._206a, ._1_-1, ._1ybg, .appCenterCategorySelectorButton, ._5c9u, div._5y57::before, ._59f6._55so::before, .structuredPublisher, ._94v, ._vqv, ._5lp5, ._55wm, ._2om3, ._2ol-, ._1f9d, ._vee, ._31a-, ._3r8b, ._3r9d, .acw, ._4_xl, ._1p70, ._1p70, ._1ih_, ._51v6, ._u2c, ._484w, ._3ils, ._rm7, ._32qk, ._d01, ._2y60, ._5fu3, ._2foa, ._2y5_, ._38o9, ._1kb, .mAppCenterFatLabel, ._3f50, .mentions-placeholder, .mentions, .mentions-shadow, .mentions-measurer, .acg, ._59tu, ._52z5, ._4l9b, ._4gj3, .groupChromeView, ._uww, textarea, ._15n_, ._skt, ._5f28, ._14_j, ._3bg5, ._53_-, ._52x1 { background: rgba(255, 0, 255, 0.02) !important; } +body, #root, #header, [style*="background-color"], ._55wo, ._1upc, input, ._2f9r, ._59e9, ._5pz4, ._5lp4, ._5lp5, .container, .subpage, ._5n_f, #static_templates, .tlBody, #timelineBody, .timelineX, .timeline, .feed, .tlPrelude, .tlFeedPlaceholder, ._4_d0, .al, ._1gkq, ._5c5b, ._1qxg, ._5luf, ._2new, ._cld, ._3zvb, ._11ub, ._5p7j, ._55wm, ._5rgs, ._5xuj, ._1sv1, ._45fu, ._18qg, ._1_ac, ._5w3g, ._3e18, ._10c_, ._2jl2, ._5q_r, ._5yt8, ._idb, ._2ip_, ._f6s, ._2l5v, ._d4i, ._577z, ._2u4w, ._3u9p, ._3u9t, ._2v9s, ._cw4, ._5_y-, ._5_y_, ._5_z3, ._cwy, ._5_z0, ._5_z1, ._5_z2, ._2mtc, ._206a, ._1_-1, ._1ybg, .appCenterCategorySelectorButton, ._5c9u, div._5y57::before, ._59f6._55so::before, .structuredPublisher, ._94v, ._vqv, ._5lp5, ._55wm, ._2om3, ._2ol-, ._1f9d, ._vee, ._31a-, ._3r8b, ._3r9d, .acw, ._4_xl, ._1p70, ._1p70, ._1ih_, ._51v6, ._u2c, ._484w, ._3ils, ._rm7, ._32qk, ._d01, ._2y60, ._5fu3, ._2foa, ._2y5_, ._38o9, ._1kb, .mAppCenterFatLabel, ._3f50, .mentions-placeholder, .mentions, .mentions-shadow, .mentions-measurer, .acg, ._59tu, ._52z5, ._4l9b, ._4gj3, .groupChromeView, ._uww, textarea, ._15n_, ._skt, ._5f28, ._14_j, ._3bg5, ._53_-, ._52x1 { background: rgba(255, 0, 255, 0.02) !important; } ._cv_, ._2sq8 { background-color: rgba(255, 0, 255, 0.02) !important; } #page { background: transparent !important; } -.jewel, .flyout, ._13e_, ._5-lw, ._5c0e, .jx-result, ._336p { background: #451515 !important; } +.jewel, .flyout, ._13e_, ._5-lw, ._5c0e, .jx-result, ._336p, .mentions-suggest-item, .mentions-suggest { background: #451515 !important; } button:not([style*=image]), button::before, .touch ._56bt, ._56be::before, .btnS, .touch::before, ._590n, ._4g8h, ._5xo2, ._5u5a::before, ._4u3j, ._15ks, ._5hua, ._59tt, ._41ft, .jx-tokenizer, ._55fj, .excessItem, ._4e8n, ._5pxa._3uj9, ._5n_5, ._u2d, ._56bu::before, ._5h8f, ._d00, ._2066, ._2k51, ._4qax, .aclb, ._4756, ._w34, ._56bv::before, ._5769, ._34iv, ._z-w, .acbk { background: rgba(199, 70, 70, 0.2) !important; } @@ -20,7 +20,7 @@ button:not([style*=image]), button::before, .touch ._56bt, ._56be::before, .btnS ._15ny::after, ._z-w, ._2u4w, ._577z:not(:last-child) ._ygd, ._3u9u, ._3mgz, ._52x6, ._2066, ._5luf, .mAppCenterFatLabel, .appCenterCategorySelectorButton, ._1q6v, ._5q_r, ._5yt8, ._ap1, ._52x1, ._59tu, ._usq, ._13e_, ._59f6._55so::before, ._4gj3, .jx-result, ._2om3, ._2ol-, ._1f9d, ._vef, ._55x2 > *, .al, ._44qk, ._1gkq, ._5rgs, ._5xuj, ._1sv1, ._idb, ._5lp5, ._3-2-, ._3to6, ._ir5, ._4nw6, ._4nwh, ._27ve, div._51v6::before, ._3c9h::before, ._2s20, ._gui, ._5jku, ._2foa, ._2y60, ._5fu3, ._4en9, ._1kb:not(:last-child) ._1kc, ._5pz4, ._5lp4, ._5lp5, ._3on6, ._5h6z, ._5h6x, ._2om4, ._5fjw > div, ._5fjv > :first-child, ._5fjw > :first-child, ._5fjv, ._5fjw, ._4z83 { border-bottom: 1px solid rgba(215, 176, 215, 0.3) !important; } -._d4i, ._f6s, ._1_y5, ._lr0, ._5hgt, ._4e8n, ._uww, .mentions-placeholder, .mentions-shadow, .mentions-measurer, ._5whq, ._59tt, ._41ft::after, .jx-tokenizer, ._3uqf, ._4756, ._1rrd, ._5n_f { border: 1px solid rgba(215, 176, 215, 0.3) !important; } +._d4i, ._f6s, .mentions-suggest-item, .mentions-suggest, ._1_y5, ._lr0, ._5hgt, ._4e8n, ._uww, .mentions-placeholder, .mentions-shadow, .mentions-measurer, ._5whq, ._59tt, ._41ft::after, .jx-tokenizer, ._3uqf, ._4756, ._1rrd, ._5n_f { border: 1px solid rgba(215, 176, 215, 0.3) !important; } ._4o58::after, .acw, .aclb, ._4qax, ._5h8f { border-color: rgba(215, 176, 215, 0.3) !important; } diff --git a/app/src/main/assets/css/core/main.scss b/app/src/main/assets/css/core/main.scss index 87cc65bf..5fb582e1 100644 --- a/app/src/main/assets/css/core/main.scss +++ b/app/src/main/assets/css/core/main.scss @@ -6,7 +6,7 @@ } body, #root, #header, [style*="background-color"], ._55wo, ._1upc, input, ._2f9r, ._59e9, ._5pz4, ._5lp4, ._5lp5, .container, .subpage, ._5n_f, #static_templates, -.tlBody, #timelineBody, .timelineX, .timeline, .feed, .tlPrelude, .tlFeedPlaceholder, ._4_d0, .al, ._1gkq, ._5c5b, ._1qxg, ._5luf, ._2new, ._cld, +.tlBody, #timelineBody, .timelineX, .timeline, .feed, .tlPrelude, .tlFeedPlaceholder, ._4_d0, .al, ._1gkq, ._5c5b, ._1qxg, ._5luf, ._2new, ._cld, ._3zvb, ._11ub, ._5p7j, ._55wm, ._5rgs, ._5xuj, ._1sv1, ._45fu, ._18qg, ._1_ac, ._5w3g, ._3e18, ._10c_, ._2jl2, ._5q_r, ._5yt8, ._idb, ._2ip_, ._f6s, ._2l5v, ._d4i, ._577z, ._2u4w, ._3u9p, ._3u9t, ._2v9s, ._cw4, ._5_y-, ._5_y_, ._5_z3, ._cwy, ._5_z0, ._5_z1, ._5_z2, ._2mtc, ._206a, ._1_-1, ._1ybg, .appCenterCategorySelectorButton, ._5c9u, div._5y57::before, ._59f6._55so::before, .structuredPublisher, ._94v, ._vqv, ._5lp5, ._55wm, ._2om3, ._2ol-, ._1f9d, ._vee, ._31a-, ._3r8b, ._3r9d, @@ -25,7 +25,7 @@ body, #root, #header, [style*="background-color"], ._55wo, ._1upc, input, ._2f9r background: transparent !important; } -.jewel, .flyout, ._13e_, ._5-lw, ._5c0e, .jx-result, ._336p { +.jewel, .flyout, ._13e_, ._5-lw, ._5c0e, .jx-result, ._336p, .mentions-suggest-item, .mentions-suggest { background: $bg_opaque !important; } @@ -73,7 +73,7 @@ h1, h2, h3, h4, h5, h6 { } //friend card border -._d4i, ._f6s, +._d4i, ._f6s, .mentions-suggest-item, .mentions-suggest, ._1_y5, ._lr0, ._5hgt, ._4e8n, ._uww, .mentions-placeholder, .mentions-shadow, .mentions-measurer, ._5whq, ._59tt, ._41ft::after, .jx-tokenizer, ._3uqf, ._4756, ._1rrd, ._5n_f { border: 1px solid $divider !important; diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbConst.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbConst.kt index 5c8b0a1a..e5216881 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbConst.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbConst.kt @@ -8,5 +8,6 @@ const val FACEBOOK_COM = "facebook.com" const val FB_URL_BASE = "https://m.facebook.com/" fun PROFILE_PICTURE_URL(id: Long) = "https://graph.facebook.com/$id/picture?type=large" +const val USER_AGENT_BASIC_FULL = "Mozilla/5.0 (Linux; Android 4.4.2; en-us; SAMSUNG SM-G900T Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Version/1.6 Chrome/28.0.1500.94 Mobile Safari/537.36" const val USER_AGENT_BASIC = "Mozilla/5.0 (Linux; U; Android 2.3.3; en-gb; Nexus S Build/GRI20) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1" const val USER_AGENT_MESSENGER = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36"
\ No newline at end of file diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IAB.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IAB.kt index 21326efa..58c748c2 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IAB.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IAB.kt @@ -40,10 +40,12 @@ object IAB { onFailed: () -> Unit = {}, onStart: (helper: IabHelper) -> Unit) { with(activity) { - if (isInProgress) if (userRequest) snackbar(R.string.iab_still_in_progress, Snackbar.LENGTH_LONG) - else if (helper?.disposed ?: true) { + if (isInProgress) { + if (userRequest) snackbar(R.string.iab_still_in_progress, Snackbar.LENGTH_LONG) + L.d("Play Store IAB in progress") + } else if (helper?.disposed ?: true) { helper = null - L.d("IAB setup async") + L.d("Play Store IAB setup async") if (!isFrostPlay) { if (mustHavePlayStore) playStoreNotFound() onFailed() @@ -54,12 +56,12 @@ object IAB { helper!!.enableDebugLogging(BuildConfig.DEBUG || Prefs.verboseLogging, "Frost:") helper!!.startSetup { result -> - L.d("IAB setup finished; ${result.isSuccess}") + L.d("Play Store IAB setup finished; ${result.isSuccess}") if (result.isSuccess) { - L.d("IAB setup success") + L.d("Play Store IAB setup success") onStart(helper!!) } else { - L.d("IAB setup fail") + L.d("Play Store IAB setup fail") if (mustHavePlayStore) activity.playStoreGenericError("Setup error: ${result.response} ${result.message}") onFailed() @@ -67,7 +69,7 @@ object IAB { } } } catch (e: Exception) { - L.e(e, "IAB error") + L.e(e, "Play Store IAB error") if (mustHavePlayStore) playStoreGenericError(null) onFailed() @@ -84,17 +86,23 @@ object IAB { * Call this after any execution to dispose the helper */ fun dispose() { - helper?.disposeWhenFinished() - helper = null + synchronized(this) { + L.d("Play Store IAB dispose") + helper?.disposeWhenFinished() + helper = null + } } /** * Dispose given helper and check if it matches with our own helper */ fun dispose(helper: IabHelper) { - helper.disposeWhenFinished() - if (IAB.helper?.disposed ?: true) - this.helper = null + synchronized(this) { + L.d("Play Store IAB helper dispose") + helper.disposeWhenFinished() + if (IAB.helper?.disposed ?: true) + this.helper = null + } } val isInProgress: Boolean @@ -118,7 +126,7 @@ fun SettingsActivity.restorePurchases() { restore.setAction(R.string.kau_close) { restore.dismiss() } //called if inventory is not properly retrieved val reset = { - L.d("Restore reset") + L.d("Play Store Restore reset") if (Prefs.pro) { Prefs.pro = false Prefs.theme = Theme.DEFAULT.ordinal @@ -129,7 +137,7 @@ fun SettingsActivity.restorePurchases() { inv, helper -> val proSku = inv.hasPurchase(FROST_PRO) Prefs.pro = proSku - L.d("Restore found: ${Prefs.pro}") + L.d("Play Store Restore found: ${Prefs.pro}") finishRestore(restore, Prefs.pro) } } @@ -149,11 +157,11 @@ private fun SettingsActivity.finishRestore(snackbar: Snackbar, hasPro: Boolean) * If cache matches result, it finishes silently */ fun Activity.validatePro() { - L.d("Validate pro") + L.d("Play Store Validate pro") getInventory(Prefs.pro, false, { if (Prefs.pro) playStoreNoLongerPro() }) { inv, helper -> val proSku = inv.hasPurchase(FROST_PRO) - L.d("Validation finished: ${Prefs.pro} should be $proSku") + L.d("Play Store Validation finished: ${Prefs.pro} should be $proSku") if (!proSku && Prefs.pro) playStoreNoLongerPro() else if (proSku && !Prefs.pro) playStoreFoundPro() helper.disposeWhenFinished() @@ -169,12 +177,11 @@ fun Activity.getInventory( helper -> helper.queryInventoryAsync { res, inv -> - L.d("Inventory query finished") + L.d("Play Store Inventory query finished") if (res.isFailure || inv == null) { - L.e("Res error ${res.message}") + L.e("Play Store Res error ${res.message}") onFailed() - } - else onSuccess(inv, helper) + } else onSuccess(inv, helper) } } } @@ -188,7 +195,7 @@ fun Activity.openPlayProPurchase(code: Int) { } fun Activity.openPlayPurchase(key: String, code: Int, onSuccess: (key: String) -> Unit) { - L.d("Open play purchase $key $code") + L.d("Play Store open purchase $key $code") getInventory(true, true, { playStoreGenericError("Query res error") }) { inv, helper -> if (inv.hasPurchase(key)) { diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClient.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClient.kt index 363bf795..aab3a165 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClient.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClient.kt @@ -1,6 +1,8 @@ package com.pitchedapps.frost.web import android.net.Uri +import android.os.Message +import android.view.View import android.webkit.* import ca.allanwang.kau.utils.snackbar import com.pitchedapps.frost.contracts.ActivityWebContract @@ -39,10 +41,4 @@ class FrostChromeClient(webCore: FrostWebViewCore) : WebChromeClient() { return activityContract != null } - override fun onGeolocationPermissionsShowPrompt(origin: String, callback: GeolocationPermissions.Callback) { - super.onGeolocationPermissionsShowPrompt(origin, callback) - L.d("Geo prompt") - } - - }
\ No newline at end of file diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebView.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebView.kt index 5583c63d..7c0a6597 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebView.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebView.kt @@ -15,6 +15,7 @@ import ca.allanwang.kau.utils.visible import ca.allanwang.kau.utils.withAlpha import com.pitchedapps.frost.R import com.pitchedapps.frost.facebook.FbTab +import com.pitchedapps.frost.facebook.USER_AGENT_BASIC import com.pitchedapps.frost.utils.Prefs import io.reactivex.android.schedulers.AndroidSchedulers @@ -59,9 +60,9 @@ class FrostWebView @JvmOverloads constructor( baseEnum = enum with(settings) { javaScriptEnabled = true - userAgentString = com.pitchedapps.frost.facebook.USER_AGENT_BASIC + if (url.contains("com/message")) + userAgentString = USER_AGENT_BASIC allowFileAccess = true - defaultFontSize textZoom = Prefs.webTextScaling } setLayerType(View.LAYER_TYPE_HARDWARE, null) 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 0a254c50..ce2daa07 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClient.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClient.kt @@ -97,4 +97,15 @@ open class FrostWebViewClient(val webCore: FrostWebViewCore) : WebViewClient() { return super.shouldOverrideUrlLoading(view, request) } + override fun onPageCommitVisible(view: WebView?, url: String?) { + L.d("ASDF PCV") + super.onPageCommitVisible(view, url) + } + +// override fun onLoadResource(view: WebView, url: String) { +// L.v("Load resource $url") +// super.onLoadResource(view, url) +// } + + }
\ No newline at end of file |