aboutsummaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt7
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/StartActivity.kt3
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/AboutActivity.kt4
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/BaseActivity.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt6
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt15
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/LoginActivity.kt6
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt7
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/SettingsActivity.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt14
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/contracts/FileChooser.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/contracts/VideoViewHolder.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/dbflow/CookiesDb.kt8
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/dbflow/DbUtils.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/dbflow/FbTabsDb.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/dbflow/NotificationDb.kt5
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt20
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/facebook/FbItem.kt5
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/facebook/FbUrlFormatter.kt4
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/facebook/requests/FbRequest.kt8
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/facebook/requests/Menu.kt4
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/fragments/FragmentBase.kt4
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/fragments/RecyclerFragmentBase.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/iitems/NotificationIItem.kt5
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/injectors/CssAssets.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/injectors/JsAssets.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/injectors/JsInjector.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/parsers/MessageParser.kt4
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/parsers/SearchParser.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/services/DownloadService.kt11
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt8
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/services/FrostRequestService.kt16
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt6
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/services/UpdateReceiver.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/settings/Debug.kt223
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/settings/Experimental.kt3
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/AdBlocker.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/AnimatedVectorDelegate.kt4
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/Downloader.kt6
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/L.kt54
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt5
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IABDialogs.kt12
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IabBinder.kt12
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoView.kt6
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoViewer.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClients.kt30
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt4
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/FrostRequestInterceptor.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt15
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt49
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/HeadlessHtmlExtractor.kt91
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt8
52 files changed, 305 insertions, 417 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt b/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt
index fa2bdf8a..8ba81414 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt
@@ -65,9 +65,8 @@ class FrostApp : Application() {
Crashlytics.setUserIdentifier(Prefs.frostId)
}
KL.debug(BuildConfig.DEBUG)
- L.debug(BuildConfig.DEBUG)
Prefs.verboseLogging = false
- L.i("Begin Frost for Facebook")
+ L.i { "Begin Frost for Facebook" }
FbCookie()
FrostPglAdBlock.init(this)
if (Prefs.installDate == -1L) Prefs.installDate = System.currentTimeMillis()
@@ -99,7 +98,7 @@ class FrostApp : Application() {
override fun onActivityStarted(activity: Activity) {}
override fun onActivityDestroyed(activity: Activity) {
- L.d("Activity ${activity.localClassName} destroyed")
+ L.d { "Activity ${activity.localClassName} destroyed" }
}
override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle?) {}
@@ -107,7 +106,7 @@ class FrostApp : Application() {
override fun onActivityStopped(activity: Activity) {}
override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {
- L.d("Activity ${activity.localClassName} created")
+ L.d { "Activity ${activity.localClassName} created" }
}
})
}
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/StartActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/StartActivity.kt
index 8c70f5f2..2107f31f 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/StartActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/StartActivity.kt
@@ -20,7 +20,8 @@ class StartActivity : KauBaseActivity() {
super.onCreate(savedInstanceState)
FbCookie.switchBackUser {
loadFbCookiesAsync { cookies ->
- L.d("Cookies loaded at time ${System.currentTimeMillis()}", cookies.toString())
+ L.i { "Cookies loaded at time ${System.currentTimeMillis()}" }
+ L._d { "Cookies: ${cookies.joinToString("\t")}" }
if (cookies.isNotEmpty())
launchNewTask(if (Prefs.userId != -1L) MainActivity::class.java else SelectorActivity::class.java, ArrayList(cookies))
else
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/AboutActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/AboutActivity.kt
index 94c43331..f0956ec7 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/AboutActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/AboutActivity.kt
@@ -60,7 +60,7 @@ class AboutActivity : AboutActivityBase(null, {
)
val l = libs.prepareLibraries(this, include, null, false, true)
-// l.forEach { KL.d("Lib ${it.definedName}") }
+// l.forEach { KL.d{"Lib ${it.definedName}"} }
return l
}
@@ -94,7 +94,7 @@ class AboutActivity : AboutActivityBase(null, {
lastClick = now
if (clickCount == 7 && !Prefs.debugSettings) {
Prefs.debugSettings = true
- L.d("Debugging section enabled")
+ L.d { "Debugging section enabled" }
toast(R.string.debug_toast_enabled)
}
}
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseActivity.kt
index a32ba10e..c5e1fbce 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseActivity.kt
@@ -44,7 +44,7 @@ abstract class BaseActivity : KauBaseActivity() {
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe { connectivity: Connectivity ->
// connectivity.apply {
-// L.d("Network connectivity changed: isAvailable: $isAvailable isRoaming: $isRoaming")
+// L.d{"Network connectivity changed: isAvailable: $isAvailable isRoaming: $isRoaming"}
// consumer(connectivity)
// }
// }
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt
index 64a3d14c..1e17f06a 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt
@@ -311,7 +311,7 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract,
super.onActivityResult(requestCode, resultCode, data)
if (requestCode == ACTIVITY_SETTINGS) {
if (resultCode and REQUEST_RESTART_APPLICATION > 0) { //completely restart application
- L.d("Restart Application Requested")
+ L.d { "Restart Application Requested" }
val intent = packageManager.getLaunchIntentForPackage(packageName)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK)
val pending = PendingIntent.getActivity(this, 666, intent, PendingIntent.FLAG_CANCEL_CURRENT)
@@ -356,7 +356,7 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract,
override fun onPause() {
controlWebview.pauseTimers()
- L.v("Pause main web timers")
+ L.v { "Pause main web timers" }
super.onPause()
}
@@ -407,7 +407,7 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract,
fun reloadFragment(fragment: BaseFragment) {
if (fragment is WebFragment) return
- L.d("Reload fragment ${fragment.position}: ${fragment.baseEnum.name}")
+ L.d { "Reload fragment ${fragment.position}: ${fragment.baseEnum.name}" }
forcedFallbacks.add(fragment.baseEnum.name)
supportFragmentManager.beginTransaction().remove(fragment).commitNowAllowingStateLoss()
notifyDataSetChanged()
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt
index cd01a718..d63fa25e 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt
@@ -54,7 +54,7 @@ class ImageActivity : KauBaseActivity() {
* Should be nonnull if the image is successfully loaded
* As this is temporary, the image is deleted upon exit
*/
- internal var tempFilePath: String? = null
+ private var tempFilePath: String? = null
/**
* Reference to path for downloaded image
* Nonnull once the image is downloaded by the user
@@ -77,7 +77,8 @@ class ImageActivity : KauBaseActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
intent?.extras ?: return finish()
- L.i("Displaying image", imageUrl)
+ L.i { "Displaying image" }
+ L._i { imageUrl }
val layout = if (!text.isNullOrBlank()) R.layout.activity_image else R.layout.activity_image_textless
setContentView(layout)
container.setBackgroundColor(Prefs.bgColor.withMinAlpha(222))
@@ -153,7 +154,7 @@ class ImageActivity : KauBaseActivity() {
callback(null)
} else {
tempFilePath = photoFile.absolutePath
- L.d("Temp image path $tempFilePath")
+ L.d { "Temp image path $tempFilePath" }
// File created; proceed with request
val photoURI = FileProvider.getUriForFile(this,
BuildConfig.APPLICATION_ID + ".provider",
@@ -166,7 +167,7 @@ class ImageActivity : KauBaseActivity() {
internal fun downloadImage() {
kauRequestPermissions(PERMISSION_WRITE_EXTERNAL_STORAGE) { granted, _ ->
- L.d("Download image callback granted: $granted")
+ L.d { "Download image callback granted: $granted" }
if (granted) {
doAsync {
val destination = createMediaFile(".png")
@@ -179,7 +180,7 @@ class ImageActivity : KauBaseActivity() {
errorRef = e
success = false
} finally {
- L.d("Download image async finished: $success")
+ L.d { "Download image async finished: $success" }
activityUiThreadWithContext {
val text = if (success) R.string.image_download_success else R.string.image_download_fail
frostSnackbar(text)
@@ -200,7 +201,7 @@ class ImageActivity : KauBaseActivity() {
override fun onDestroy() {
deleteTempFile()
- if (!BuildConfig.DEBUG) L.d("Closing $localClassName")
+ L.d { "Closing $localClassName" }
super.onDestroy()
}
}
@@ -214,7 +215,7 @@ internal enum class FabStates(val iicon: IIcon, val iconColor: Int = Prefs.iconC
positiveText(R.string.kau_yes)
onPositive { _, _ ->
if (activity.errorRef != null)
- L.e(activity.errorRef, "ImageActivity error report")
+ L.e(activity.errorRef) { "ImageActivity error report" }
activity.sendFrostEmail(R.string.debug_image_link_subject) {
addItem("Url", activity.imageUrl)
addItem("Message", activity.errorRef?.message ?: "Null")
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/LoginActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/LoginActivity.kt
index f98f9eaf..e9657934 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/LoginActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/LoginActivity.kt
@@ -64,7 +64,7 @@ class LoginActivity : BaseActivity() {
setTitle(R.string.kau_login)
setFrostColors(toolbar)
web.loadLogin({ refresh = it != 100 }) { cookie ->
- L.d("Login found")
+ L.d { "Login found" }
FbCookie.save(cookie.id)
web.fadeOut(onFinish = {
profile.fadeIn()
@@ -83,8 +83,8 @@ class LoginActivity : BaseActivity() {
.observeOn(AndroidSchedulers.mainThread()).subscribe { (foundImage, name) ->
refresh = false
if (!foundImage) {
- L.e("Could not get profile photo; Invalid userId?")
- L.i(null, cookie.toString())
+ L.e { "Could not get profile photo; Invalid userId?" }
+ L._i { cookie }
}
textview.text = String.format(getString(R.string.welcome), name)
textview.fadeIn()
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt
index 9b46a0a3..e672d7d8 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt
@@ -3,18 +3,11 @@ package com.pitchedapps.frost.activities
import android.os.Bundle
import android.support.design.widget.TabLayout
import android.support.v4.view.ViewPager
-import ca.allanwang.kau.utils.materialDialog
-import ca.allanwang.kau.utils.toast
-import com.pitchedapps.frost.facebook.FbCookie
import com.pitchedapps.frost.facebook.FbItem
-import com.pitchedapps.frost.facebook.requests.fbRequest
-import com.pitchedapps.frost.facebook.requests.getMenuData
import com.pitchedapps.frost.views.BadgedIcon
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import io.reactivex.subjects.PublishSubject
-import org.jetbrains.anko.doAsync
-import org.jetbrains.anko.uiThread
import org.jsoup.Jsoup
import java.util.concurrent.TimeUnit
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/SettingsActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/SettingsActivity.kt
index 19f5102a..58e73530 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/SettingsActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/SettingsActivity.kt
@@ -64,7 +64,7 @@ class SettingsActivity : KPrefActivity(), FrostBilling by IabSettings() {
try {
grantUriPermission("com.android.systemui", uri, Intent.FLAG_GRANT_READ_URI_PERMISSION)
} catch (e: Exception) {
- L.e(e, "grantUriPermission")
+ L.e(e) { "grantUriPermission" }
}
}
when (requestCode) {
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt
index c750c88b..853ade72 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt
@@ -76,12 +76,14 @@ class FrostWebActivity : WebOverlayActivityBase(false) {
val text = intent.getStringExtra(Intent.EXTRA_TEXT) ?: return true
val url = HttpUrl.parse(text)?.toString()
if (url == null) {
- L.i("Attempted to share a non-url", text)
+ L.i { "Attempted to share a non-url" }
+ L._i { "Shared text: $text" }
copyToClipboard(text, "Text to Share", showToast = false)
intent.putExtra(ARG_URL, FbItem.FEED.url)
return false
} else {
- L.i("Sharing url through overlay", url)
+ L.i { "Sharing url through overlay" }
+ L._i { "Url: $url" }
intent.putExtra(ARG_URL, "${FB_URL_BASE}/sharer/sharer.php?u=$url")
return true
}
@@ -132,7 +134,7 @@ open class WebOverlayActivityBase(private val forceBasicAgent: Boolean) : BaseAc
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
if (urlTest == null) {
- L.e("Empty link on web overlay")
+ L.e { "Empty link on web overlay" }
toast(R.string.null_url_overlay)
finish()
return
@@ -170,7 +172,7 @@ open class WebOverlayActivityBase(private val forceBasicAgent: Boolean) : BaseAc
}
FrostRunnable.propagate(this, intent)
- L.e("Done propagation")
+ L.e { "Done propagation" }
kauSwipeOnCreate {
if (!Prefs.overlayFullScreenSwipe) edgeSize = 20.dpToPx
@@ -186,7 +188,7 @@ open class WebOverlayActivityBase(private val forceBasicAgent: Boolean) : BaseAc
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
val newUrl = (intent.getStringExtra(ARG_URL) ?: intent.dataString ?: return).formattedFbUrl
- L.d("New intent")
+ L.d { "New intent" }
if (baseUrl != newUrl) {
this.intent = intent
content.baseUrl = newUrl
@@ -220,7 +222,7 @@ open class WebOverlayActivityBase(private val forceBasicAgent: Boolean) : BaseAc
override fun onPause() {
web.pauseTimers()
- L.v("Pause overlay web timers")
+ L.v { "Pause overlay web timers" }
super.onPause()
}
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/contracts/FileChooser.kt b/app/src/main/kotlin/com/pitchedapps/frost/contracts/FileChooser.kt
index 26b10532..15165456 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/contracts/FileChooser.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/contracts/FileChooser.kt
@@ -45,7 +45,7 @@ class FileChooserDelegate : FileChooserContract {
}
override fun Activity.onActivityResultWeb(requestCode: Int, resultCode: Int, intent: Intent?): Boolean {
- L.d("FileChooser On activity results web $requestCode")
+ L.d { "FileChooser On activity results web $requestCode" }
if (requestCode != MEDIA_CHOOSER_RESULT) return false
val data = intent?.data
filePathCallback?.onReceiveValue(if (data != null) arrayOf(data) else null)
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/contracts/VideoViewHolder.kt b/app/src/main/kotlin/com/pitchedapps/frost/contracts/VideoViewHolder.kt
index 6440cbb2..fc75ba14 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/contracts/VideoViewHolder.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/contracts/VideoViewHolder.kt
@@ -37,7 +37,7 @@ interface VideoViewHolder : FrameWrapper, FrostVideoContainerContract {
get() = frameWrapper
override fun onVideoFinished() {
- L.d("Video view released")
+ L.d { "Video view released" }
videoViewer = null
}
}
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/dbflow/CookiesDb.kt b/app/src/main/kotlin/com/pitchedapps/frost/dbflow/CookiesDb.kt
index 762dd4c1..e98020d4 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/dbflow/CookiesDb.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/dbflow/CookiesDb.kt
@@ -54,14 +54,16 @@ fun loadFbCookiesSync(): List<CookieModel> = (select from CookieModel::class).or
inline fun saveFbCookie(cookie: CookieModel, crossinline callback: (() -> Unit) = {}) {
cookie.async save {
- L.d("Fb cookie saved", cookie.toString())
+ L.d { "Fb cookie saved" }
+ L._d { cookie }
callback()
}
}
fun removeCookie(id: Long) {
loadFbCookie(id)?.async?.delete {
- L.d("Fb cookie deleted", id.toString())
+ L.d { "Fb cookie deleted" }
+ L._d { id }
}
}
@@ -71,7 +73,7 @@ inline fun CookieModel.fetchUsername(crossinline callback: (String) -> Unit) {
var result = ""
try {
result = frostJsoup(cookie, FbItem.PROFILE.url).title()
- L.d("Fetch username found", result)
+ L.d { "Fetch username found" }
} catch (e: Exception) {
if (e !is UnknownHostException)
e.logFrostAnswers("Fetch username failed")
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/dbflow/DbUtils.kt b/app/src/main/kotlin/com/pitchedapps/frost/dbflow/DbUtils.kt
index f5c962ed..e4aef2a9 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/dbflow/DbUtils.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/dbflow/DbUtils.kt
@@ -18,7 +18,7 @@ object DbUtils {
}
inline fun <reified T : Any> List<T>.replace(dbName: String) {
- L.d("Replacing $dbName.db")
+ L.d { "Replacing $dbName.db" }
DbUtils.db(dbName).reset()
FastStoreModelTransaction.saveBuilder(FlowManager.getModelAdapter(T::class.java)).addAll(this).build()
} \ No newline at end of file
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/dbflow/FbTabsDb.kt b/app/src/main/kotlin/com/pitchedapps/frost/dbflow/FbTabsDb.kt
index 18f0e2e8..827881e3 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/dbflow/FbTabsDb.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/dbflow/FbTabsDb.kt
@@ -33,7 +33,7 @@ data class FbTabModel(@PrimaryKey var position: Int = -1, var tab: FbItem = FbIt
fun loadFbTabs(): List<FbItem> {
val tabs: List<FbTabModel>? = (select from (FbTabModel::class)).orderBy(FbTabModel_Table.position, true).queryList()
if (tabs?.size == TAB_COUNT) return tabs.map(FbTabModel::tab)
- L.d("No tabs (${tabs?.size}); loading default")
+ L.d { "No tabs (${tabs?.size}); loading default" }
return defaultTabs()
}
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/dbflow/NotificationDb.kt b/app/src/main/kotlin/com/pitchedapps/frost/dbflow/NotificationDb.kt
index d3abb9a2..88a1383d 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/dbflow/NotificationDb.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/dbflow/NotificationDb.kt
@@ -22,7 +22,7 @@ class NotificationMigration2(modelClass: Class<NotificationModel>) : AlterTableM
override fun onPreMigrate() {
super.onPreMigrate()
addColumn(SQLiteType.INTEGER, "epochIm")
- L.d("Added column")
+ L.d { "Added column" }
}
}
@@ -33,7 +33,8 @@ fun lastNotificationTime(id: Long): NotificationModel = (select from Notificatio
fun saveNotificationTime(notificationModel: NotificationModel, callback: (() -> Unit)? = null) {
notificationModel.async save {
- L.d("Fb notification model saved", notificationModel.toString())
+ L.d { "Fb notification model saved" }
+ L._d { notificationModel }
callback?.invoke()
}
} \ No newline at end of file
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt
index 6f08981c..ccb23b93 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbCookie.kt
@@ -30,12 +30,13 @@ object FbCookie {
callback?.invoke()
return@removeAllCookies
}
- L.d("Setting cookie", cookie)
+ L.d { "Setting cookie" }
val cookies = cookie.split(";").map { Pair(it, SingleSubject.create<Boolean>()) }
cookies.forEach { (cookie, callback) -> setCookie(FB_URL_BASE, cookie, { callback.onSuccess(it) }) }
Observable.zip<Boolean, Unit>(cookies.map { (_, callback) -> callback.toObservable() }, {}).subscribeOn(AndroidSchedulers.mainThread()).subscribe {
callback?.invoke()
- L.d("Cookies set", webCookie)
+ L.d { "Cookies set" }
+ L._d { cookie }
flush()
}
}
@@ -43,19 +44,19 @@ object FbCookie {
}
operator fun invoke() {
- L.d("FbCookie Invoke User", Prefs.userId.toString())
+ L.d { "FbCookie Invoke User" }
with(CookieManager.getInstance()) {
setAcceptCookie(true)
}
val dbCookie = loadFbCookie(Prefs.userId)?.cookie
if (dbCookie != null && webCookie == null) {
- L.d("DbCookie found & WebCookie is null; setting webcookie")
+ L.d { "DbCookie found & WebCookie is null; setting webcookie" }
setWebCookie(dbCookie, null)
}
}
fun save(id: Long) {
- L.d("New cookie found", id.toString())
+ L.d { "New cookie found" }
Prefs.userId = id
CookieManager.getInstance().flush()
val cookie = CookieModel(Prefs.userId, "", webCookie)
@@ -78,11 +79,11 @@ object FbCookie {
fun switchUser(cookie: CookieModel?, callback: () -> Unit) {
if (cookie == null) {
- L.d("Switching User; null cookie")
+ L.d { "Switching User; null cookie" }
callback()
return
}
- L.d("Switching User", cookie.toString())
+ L.d { "Switching User" }
Prefs.userId = cookie.id
setWebCookie(cookie.cookie, callback)
}
@@ -104,7 +105,7 @@ object FbCookie {
* Clear the cookies of the given id
*/
fun logout(id: Long, callback: () -> Unit) {
- L.d("Logging out user $id")
+ L.d { "Logging out user" }
removeCookie(id)
reset(callback)
}
@@ -119,7 +120,8 @@ object FbCookie {
Prefs.prevId = -1L
if (prevId != Prefs.userId) {
switchUser(prevId) {
- L.d("Switch back user", "${Prefs.userId} to ${prevId}")
+ L.d { "Switch back user" }
+ L._d { "${Prefs.userId} to $prevId" }
callback()
}
} else callback()
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbItem.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbItem.kt
index 9220c0e0..462fae79 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbItem.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbItem.kt
@@ -6,7 +6,10 @@ import com.mikepenz.google_material_typeface_library.GoogleMaterial
import com.mikepenz.iconics.typeface.IIcon
import com.mikepenz.material_design_iconic_typeface_library.MaterialDesignIconic
import com.pitchedapps.frost.R
-import com.pitchedapps.frost.fragments.*
+import com.pitchedapps.frost.fragments.BaseFragment
+import com.pitchedapps.frost.fragments.MenuFragment
+import com.pitchedapps.frost.fragments.NotificationFragment
+import com.pitchedapps.frost.fragments.WebFragment
import com.pitchedapps.frost.utils.EnumBundle
import com.pitchedapps.frost.utils.EnumBundleCompanion
import com.pitchedapps.frost.utils.EnumCompanion
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbUrlFormatter.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbUrlFormatter.kt
index 22ca3138..76eb2c0c 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbUrlFormatter.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbUrlFormatter.kt
@@ -38,7 +38,7 @@ class FbUrlFormatter(url: String) {
try {
cleanedUrl = URLDecoder.decode(cleanedUrl, StandardCharsets.UTF_8.name())
} catch (e: Exception) {
- L.e(e, "Failed url formatting")
+ L.e(e) { "Failed url formatting" }
return url
}
if (changed && !cleanedUrl.contains("?")) //ensure we aren't missing '?'
@@ -57,7 +57,7 @@ class FbUrlFormatter(url: String) {
if (cleanedUrl.startsWith("#!")) cleanedUrl = cleanedUrl.substring(2)
if (cleanedUrl.startsWith("/")) cleanedUrl = FB_URL_BASE + cleanedUrl.substring(1)
cleanedUrl = cleanedUrl.replaceFirst(".facebook.com//", ".facebook.com/") //sometimes we are given a bad url
- L.v(null, "Formatted url from $url to $cleanedUrl")
+ L.v { "Formatted url from $url to $cleanedUrl" }
return cleanedUrl
}
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/requests/FbRequest.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/requests/FbRequest.kt
index cefece36..ca4aa4ac 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/requests/FbRequest.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/requests/FbRequest.kt
@@ -27,11 +27,11 @@ fun String?.fbRequest(fail: () -> Unit = {}, action: RequestAuth.() -> Unit) {
} else {
val auth = getAuth()
if (!auth.isValid) {
- L.e("Attempted fbrequest with invalid auth")
+ L.e { "Attempted fbrequest with invalid auth" }
return fail()
}
authMap.put(this, auth)
- L.i(null, "Found auth $auth")
+ L._i { "Found auth $auth" }
auth.action()
}
}
@@ -106,14 +106,14 @@ fun String.getAuth(): RequestAuth {
val text = StringEscapeUtils.unescapeEcmaScript(it)
val fb_dtsg = FB_DTSG_MATCHER.find(text)[1]
if (fb_dtsg != null) {
- L.d(null, "fb_dtsg for ${auth.userId}: $fb_dtsg")
+ L._d { "fb_dtsg for ${auth.userId}: $fb_dtsg" }
auth = auth.copy(fb_dtsg = fb_dtsg)
if (auth.isValid) return auth
}
val rev = FB_REV_MATCHER.find(text)[1]
if (rev != null) {
- L.d(null, "rev for ${auth.userId}: $rev")
+ L._d { "rev for ${auth.userId}: $rev" }
auth = auth.copy(rev = rev)
if (auth.isValid) return auth
}
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/requests/Menu.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/requests/Menu.kt
index 59f87fbd..72b6e0a4 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/requests/Menu.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/requests/Menu.kt
@@ -70,7 +70,7 @@ fun parseMenu(call: Call): MenuData? {
return data.copy(footer = MenuFooter(footerData, footerSmallData))
} catch (e: IOException) {
- L.e(e, "Menu parse fail")
+ L.e(e) { "Menu parse fail" }
null
}
}
@@ -83,7 +83,7 @@ data class MenuData(val data: List<MenuHeader> = emptyList(),
@JsonProperty("data") data: List<MenuHeader>?
) : this(data ?: emptyList(), MenuFooter())
- fun flatMapValid() : List<MenuItemData> {
+ fun flatMapValid(): List<MenuItemData> {
val items = mutableListOf<MenuItemData>()
data.forEach {
if (it.isValid) items.add(it)
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/fragments/FragmentBase.kt b/app/src/main/kotlin/com/pitchedapps/frost/fragments/FragmentBase.kt
index 8ab775e0..0aaeaa6d 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/fragments/FragmentBase.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/fragments/FragmentBase.kt
@@ -49,7 +49,7 @@ abstract class BaseFragment : Fragment(), FragmentContract, DynamicUiContract {
set(value) {
if (value || this is WebFragment) return
arguments!!.putBoolean(ARG_VALID, value)
- L.e("Invalidating position $position")
+ L.e { "Invalidating position $position" }
frostAnswersCustom("Native Fallback",
"Item" to baseEnum.name)
(context as MainActivityContract).reloadFragment(this)
@@ -146,7 +146,7 @@ abstract class BaseFragment : Fragment(), FragmentContract, DynamicUiContract {
}
override fun onDestroyView() {
- L.i("Fragment on destroy $position ${hashCode()}")
+ L.i { "Fragment on destroy $position ${hashCode()}" }
content?.destroy()
content = null
super.onDestroyView()
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/fragments/RecyclerFragmentBase.kt b/app/src/main/kotlin/com/pitchedapps/frost/fragments/RecyclerFragmentBase.kt
index c490de60..1a0c3b25 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/fragments/RecyclerFragmentBase.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/fragments/RecyclerFragmentBase.kt
@@ -11,11 +11,9 @@ import com.pitchedapps.frost.facebook.FbCookie
import com.pitchedapps.frost.parsers.FrostParser
import com.pitchedapps.frost.parsers.ParseResponse
import com.pitchedapps.frost.utils.L
-import com.pitchedapps.frost.utils.Prefs
import com.pitchedapps.frost.utils.frostJsoup
import com.pitchedapps.frost.views.FrostRecyclerView
import org.jetbrains.anko.doAsync
-import org.jetbrains.anko.toast
import org.jetbrains.anko.uiThread
/**
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/iitems/NotificationIItem.kt b/app/src/main/kotlin/com/pitchedapps/frost/iitems/NotificationIItem.kt
index a16b0224..2e16f386 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/iitems/NotificationIItem.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/iitems/NotificationIItem.kt
@@ -6,7 +6,10 @@ import android.widget.ImageView
import android.widget.TextView
import ca.allanwang.kau.iitems.KauIItem
import ca.allanwang.kau.ui.createSimpleRippleDrawable
-import ca.allanwang.kau.utils.*
+import ca.allanwang.kau.utils.bindView
+import ca.allanwang.kau.utils.gone
+import ca.allanwang.kau.utils.visible
+import ca.allanwang.kau.utils.withAlpha
import com.bumptech.glide.Glide
import com.mikepenz.fastadapter.FastAdapter
import com.mikepenz.fastadapter.adapters.ItemAdapter
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 cd13eede..015b5e2d 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssAssets.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssAssets.kt
@@ -46,7 +46,7 @@ enum class CssAssets(val folder: String = "themes") : InjectorContract {
}
JsBuilder().css(content).build()
} catch (e: FileNotFoundException) {
- L.e(e, "CssAssets file not found")
+ L.e(e) { "CssAssets file not found" }
JsInjector(JsActions.EMPTY.function)
}
}
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/injectors/JsAssets.kt b/app/src/main/kotlin/com/pitchedapps/frost/injectors/JsAssets.kt
index beb60293..74ab7d37 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/injectors/JsAssets.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/injectors/JsAssets.kt
@@ -21,7 +21,7 @@ enum class JsAssets : InjectorContract {
val content = it.assets.open("js/$file").bufferedReader().use { it.readText() }
JsBuilder().js(content).single(name).build()
} catch (e: FileNotFoundException) {
- L.e(e, "JsAssets file not found")
+ L.e(e) { "JsAssets file not found" }
JsInjector(JsActions.EMPTY.function)
}
}
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 4a5bff10..dd73209f 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/injectors/JsInjector.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/injectors/JsInjector.kt
@@ -75,7 +75,7 @@ fun WebView.jsInject(vararg injectors: InjectorContract, callback: ((Array<Strin
val validInjectors = injectors.filter { it != JsActions.EMPTY }
if (validInjectors.isEmpty()) return callback(emptyArray())
val observables = Array(validInjectors.size, { SingleSubject.create<String>() })
- L.d("Injecting ${observables.size} items")
+ L.d { "Injecting ${observables.size} items" }
Observable.zip<String, Array<String>>(observables.map(SingleSubject<String>::toObservable),
{ it.map(Any::toString).toTypedArray() })
.subscribeOn(AndroidSchedulers.mainThread()).subscribe({ callback(it) })
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/parsers/MessageParser.kt b/app/src/main/kotlin/com/pitchedapps/frost/parsers/MessageParser.kt
index 02c6f189..24ddd601 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/parsers/MessageParser.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/parsers/MessageParser.kt
@@ -75,13 +75,13 @@ private class MessageParserImpl : FrostParserBase<FrostMessages>(true) {
var content = StringEscapeUtils.unescapeEcmaScript(text)
val begin = content.indexOf("id=\"threadlist_rows\"")
if (begin <= 0) {
- L.d("Threadlist not found")
+ L.d { "Threadlist not found" }
return null
}
content = content.substring(begin)
val end = content.indexOf("</script>")
if (end <= 0) {
- L.d("Script tail not found")
+ L.d { "Script tail not found" }
return null
}
content = content.substring(0, end).substringBeforeLast("</div>")
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/parsers/SearchParser.kt b/app/src/main/kotlin/com/pitchedapps/frost/parsers/SearchParser.kt
index 557e80b8..7fbc0f08 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/parsers/SearchParser.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/parsers/SearchParser.kt
@@ -14,7 +14,7 @@ import org.jsoup.nodes.Element
object SearchParser : FrostParser<FrostSearches> by SearchParserImpl() {
fun query(cookie: String?, input: String): ParseResponse<FrostSearches>? {
val url = "${FbItem._SEARCH.url}?q=${if (input.isNotBlank()) input else "a"}"
- L.i(null, "Search Query $url")
+ L._i { "Search Query $url" }
return parseFromUrl(cookie, url)
}
}
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/services/DownloadService.kt b/app/src/main/kotlin/com/pitchedapps/frost/services/DownloadService.kt
index 520d750f..bf6e1329 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/services/DownloadService.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/services/DownloadService.kt
@@ -54,7 +54,7 @@ class DownloadService : IntentService("FrostVideoDownloader") {
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
if (intent != null && intent.flags == PendingIntent.FLAG_CANCEL_CURRENT) {
- L.i("Cancelling download service")
+ L.i { "Cancelling download service" }
cancelDownload()
return Service.START_NOT_STICKY
}
@@ -84,7 +84,7 @@ class DownloadService : IntentService("FrostVideoDownloader") {
client.newCall(request).execute().use { response ->
if (!response.isSuccessful) {
- L.e("Video download failed")
+ L.e { "Video download failed" }
toast("Video download failed")
return@use
}
@@ -107,7 +107,8 @@ class DownloadService : IntentService("FrostVideoDownloader") {
private fun getPendingIntent(context: Context, file: File): PendingIntent {
val uri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID + ".provider", file)
val type = context.contentResolver.getType(uri)
- L.i("DownloadType: retrieved pending intent - $uri $type")
+ L.i { "DownloadType: retrieved pending intent" }
+ L._i { "Contents: $uri $type" }
val intent = Intent(Intent.ACTION_VIEW, uri)
.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
.setDataAndType(uri, type)
@@ -119,7 +120,7 @@ class DownloadService : IntentService("FrostVideoDownloader") {
* Does not show the new notification
*/
private fun finishDownload(url: String) {
- L.i("Video download finished", url)
+ L.i { "Video download finished" }
downloaded.add(url)
notifBuilder.setContentTitle(string(R.string.downloaded_video))
.setProgress(0, 0, false).setOngoing(false).setAutoCancel(true)
@@ -132,7 +133,7 @@ class DownloadService : IntentService("FrostVideoDownloader") {
}
private fun onProgressUpdate(url: String, type: MediaType?, percentage: Float, done: Boolean) {
- L.v("Download request progress $percentage", url)
+ L.v { "Download request progress $percentage for $url" }
notifBuilder.setProgress(MAX_PROGRESS, (percentage * MAX_PROGRESS).toInt(), false)
if (done) finishDownload(url)
notifBuilder.show()
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt b/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt
index 2d9e0803..5e08b363 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt
@@ -152,10 +152,10 @@ enum class NotificationType(
val userId = data.id
val prevNotifTime = lastNotificationTime(userId)
val prevLatestEpoch = getTime(prevNotifTime)
- L.v("Notif $name prev epoch $prevLatestEpoch")
+ L.v { "Notif $name prev epoch $prevLatestEpoch" }
var newLatestEpoch = prevLatestEpoch
notifs.forEach { notif ->
- L.v("Notif timestamp ${notif.timestamp}")
+ L.v { "Notif timestamp ${notif.timestamp}" }
if (notif.timestamp <= prevLatestEpoch) return@forEach
createNotification(context, notif, notifCount == 0)
if (notif.timestamp > newLatestEpoch)
@@ -164,7 +164,7 @@ enum class NotificationType(
}
if (newLatestEpoch > prevLatestEpoch)
putTime(prevNotifTime, newLatestEpoch).save()
- L.d("Notif $name new epoch ${getTime(lastNotificationTime(userId))}")
+ L.d { "Notif $name new epoch ${getTime(lastNotificationTime(userId))}" }
summaryNotification(context, userId, notifCount)
}
@@ -195,7 +195,7 @@ enum class NotificationType(
notifBuilder.withDefaults(ringtone())
if (timestamp != -1L) notifBuilder.setWhen(timestamp * 1000)
- L.v("Notif load", context.toString())
+ L.v { "Notif load $content" }
NotificationManagerCompat.from(context).notify(group, notifId, notifBuilder.build())
if (profileUrl != null) {
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/services/FrostRequestService.kt b/app/src/main/kotlin/com/pitchedapps/frost/services/FrostRequestService.kt
index 2b407b7d..d5311fc0 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/services/FrostRequestService.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/services/FrostRequestService.kt
@@ -33,7 +33,7 @@ private enum class FrostRequestCommands : EnumBundle<FrostRequestCommands> {
override fun invoke(auth: RequestAuth, bundle: PersistableBundle) {
val id = bundle.getLong(ARG_0, -1L)
val success = auth.markNotificationRead(id).invoke()
- L.d("Marked notif $id as read: $success")
+ L.d { "Marked notif $id as read: $success" }
}
override fun propagate(bundle: BaseBundle) =
@@ -96,7 +96,7 @@ object FrostRunnable {
fun markNotificationRead(context: Context, id: Long, cookie: String): Boolean {
if (id <= 0) {
- L.d("Invalid notification id $id for marking as read")
+ L.d { "Invalid notification id $id for marking as read" }
return false
}
return schedule(context, FrostRequestCommands.NOTIF_READ,
@@ -107,7 +107,7 @@ object FrostRunnable {
intent?.extras ?: return
val command = FrostRequestCommands[intent] ?: return
intent.removeExtra(ARG_COMMAND) // reset
- L.d("Propagating command ${command.name}")
+ L.d { "Propagating command ${command.name}" }
val builder = command.propagate(intent.extras)
schedule(context, command, builder)
}
@@ -122,7 +122,7 @@ object FrostRunnable {
bundle.putString(ARG_COMMAND, command.name)
if (bundle.getCookie().isNullOrBlank()) {
- L.e("Scheduled frost request with empty cookie)")
+ L.e { "Scheduled frost request with empty cookie" }
return false
}
@@ -136,7 +136,7 @@ object FrostRunnable {
L.eThrow("FrostRequestService scheduler failed for ${command.name}")
return false
}
- L.d("Scheduled ${command.name}")
+ L.d { "Scheduled ${command.name}" }
return true
}
@@ -171,10 +171,12 @@ class FrostRequestService : JobService() {
val now = System.currentTimeMillis()
future = doAsync {
cookie.fbRequest {
- L.d("Requesting frost service for ${command.name}")
+ L.d { "Requesting frost service for ${command.name}" }
command.invoke(this, bundle)
}
- L.d("Finished frost service for ${command.name} in ${System.currentTimeMillis() - now} ms")
+ L.d {
+ "Finished frost service for ${command.name} in ${System.currentTimeMillis()} - now} ms"
+ }
jobFinished(params, false)
}
return true
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt b/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt
index c1a4ace1..3d19606b 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt
@@ -30,7 +30,7 @@ class NotificationService : JobService() {
override fun onStopJob(params: JobParameters?): Boolean {
val time = System.currentTimeMillis() - startTime
- L.d("Notification service has finished abruptly in $time ms")
+ L.d { "Notification service has finished abruptly in $time ms" }
frostAnswersCustom("NotificationTime",
"Type" to "Service force stop",
"IM Included" to Prefs.notificationsInstantMessages,
@@ -42,7 +42,7 @@ class NotificationService : JobService() {
fun finish(params: JobParameters?) {
val time = System.currentTimeMillis() - startTime
- L.i("Notification service has finished in $time ms")
+ L.i { "Notification service has finished in $time ms" }
frostAnswersCustom("NotificationTime",
"Type" to "Service",
"IM Included" to Prefs.notificationsInstantMessages,
@@ -53,7 +53,7 @@ class NotificationService : JobService() {
}
override fun onStartJob(params: JobParameters?): Boolean {
- L.i("Fetching notifications")
+ L.i { "Fetching notifications" }
future = doAsync {
val context = weakRef.get()
?: return@doAsync L.eThrow("NotificationService had null weakRef to self")
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/services/UpdateReceiver.kt b/app/src/main/kotlin/com/pitchedapps/frost/services/UpdateReceiver.kt
index 989ac127..59df9ed7 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/services/UpdateReceiver.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/services/UpdateReceiver.kt
@@ -15,7 +15,7 @@ class UpdateReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
if (intent.action != Intent.ACTION_MY_PACKAGE_REPLACED) return
- L.d("Frost has updated")
+ L.d { "Frost has updated" }
context.scheduleNotifications(Prefs.notificationFreq) //Update notifications
}
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/settings/Debug.kt b/app/src/main/kotlin/com/pitchedapps/frost/settings/Debug.kt
index 60512f17..269b5a95 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Debug.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Debug.kt
@@ -1,25 +1,8 @@
package com.pitchedapps.frost.settings
-import android.content.Context
-import android.support.annotation.UiThread
import ca.allanwang.kau.kpref.activity.KPrefAdapterBuilder
-import ca.allanwang.kau.utils.string
-import com.afollestad.materialdialogs.MaterialDialog
import com.pitchedapps.frost.R
import com.pitchedapps.frost.activities.SettingsActivity
-import com.pitchedapps.frost.facebook.FbItem
-import com.pitchedapps.frost.injectors.InjectorContract
-import com.pitchedapps.frost.injectors.JsAssets
-import com.pitchedapps.frost.utils.*
-import com.pitchedapps.frost.web.launchHeadlessHtmlExtractor
-import com.pitchedapps.frost.web.query
-import io.reactivex.disposables.Disposable
-import org.jetbrains.anko.AnkoAsyncContext
-import org.jetbrains.anko.doAsync
-import org.jetbrains.anko.runOnUiThread
-import org.jetbrains.anko.uiThread
-import org.jsoup.Jsoup
-import org.jsoup.nodes.Document
/**
* Created by Allan Wang on 2017-06-30.
@@ -33,108 +16,108 @@ fun SettingsActivity.getDebugPrefs(): KPrefAdapterBuilder.() -> Unit = {
descRes = R.string.debug_disclaimer_info
}
- Debugger.values().forEach {
- plainText(it.data.titleId) {
- iicon = it.data.icon
- onClick = { it.debug(itemView.context) }
- }
- }
+// Debugger.values().forEach {
+// plainText(it.data.titleId) {
+// iicon = it.data.icon
+// onClick = { it.debug(itemView.context) }
+// }
+// }
}
-
-private enum class Debugger(val data: FbItem, val injector: InjectorContract?, vararg query: String) {
- MENU(FbItem.MENU, JsAssets.MENU_DEBUG, "#viewport"), //todo modify menu js for debugging
- NOTIFICATIONS(FbItem.NOTIFICATIONS, null, "#notifications_list");
-// SEARCH(FbItem.SEARCH, JsActions.FETCH_BODY);
-
- val query = if (query.isNotEmpty()) arrayOf(*query, "#root", "main", "body") else emptyArray()
-
- fun debug(context: Context) {
- val dialog = context.materialDialogThemed {
- title("Debugging")
- progress(true, 0)
- canceledOnTouchOutside(false)
- positiveText(R.string.kau_cancel)
- onPositive { dialog, _ -> dialog.cancel() }
- }
- if (injector != null) dialog.extractHtml(injector)
- else dialog.debugAsync {
- loadJsoup()
- }
- }
-
- fun MaterialDialog.debugAsync(task: AnkoAsyncContext<MaterialDialog>.() -> Unit) {
- doAsync({ t: Throwable ->
- val msg = t.message
- L.e("Debugger failed: $msg")
- context.runOnUiThread {
- cancel()
- context.materialDialogThemed {
- title(R.string.debug_incomplete)
- if (msg != null) content(msg)
- }
- }
- }, task)
- }
-
- /**
- * Wait for html to be returned from headless webview
- *
- * from [debug] to [simplifyJsoup] if [query] is not empty, or [createReport] otherwise
- */
- @UiThread
- private fun MaterialDialog.extractHtml(injector: InjectorContract) {
- setContent("Fetching webpage")
- var disposable: Disposable? = null
- setOnCancelListener { disposable?.dispose() }
- context.launchHeadlessHtmlExtractor(data.url, injector) {
- disposable = it.subscribe { (html, errorRes) ->
- debugAsync {
- if (errorRes == -1) {
- L.i("Debug report successful", html)
- if (query.isNotEmpty()) simplifyJsoup(Jsoup.parseBodyFragment(html))
- else createReport(html)
- } else {
- throw Throwable(context.string(errorRes))
- }
- }
- }
- }
- }
-
- /**
- * Get data directly from the link and search for our queries, returning the outerHTML
- * of the first query found
- *
- * from [debug] to [simplifyJsoup]
- */
- private fun AnkoAsyncContext<MaterialDialog>.loadJsoup() {
- uiThread {
- it.setContent("Load Jsoup")
- it.setOnCancelListener(null)
- it.debugAsync { simplifyJsoup(frostJsoup(data.url)) }
- }
- }
-
- /**
- * Takes snippet of given document that matches the first query in the [query] items
- * before sending it to [createReport]
- */
- private fun AnkoAsyncContext<MaterialDialog>.simplifyJsoup(doc: Document) {
- weakRef.get() ?: return
- val q = query.first { doc.select(it).isNotEmpty() }
- createReport(doc.select(q).outerHtml())
- }
-
- private fun AnkoAsyncContext<MaterialDialog>.createReport(html: String) {
- val cleanHtml = html.cleanHtml()
- uiThread {
- val c = it.context
- it.dismiss()
- c.sendFrostEmail("${c.string(R.string.debug_report_email_title)} $name") {
- addItem("Query List", query.contentToString())
- footer = cleanHtml
- }
- }
- }
-} \ No newline at end of file
+//
+//private enum class Debugger(val data: FbItem, val injector: InjectorContract?, vararg query: String) {
+// MENU(FbItem.MENU, JsAssets.MENU_DEBUG, "#viewport"), //todo modify menu js for debugging
+// NOTIFICATIONS(FbItem.NOTIFICATIONS, null, "#notifications_list");
+//// SEARCH(FbItem.SEARCH, JsActions.FETCH_BODY);
+//
+// val query = if (query.isNotEmpty()) arrayOf(*query, "#root", "main", "body") else emptyArray()
+//
+// fun debug(context: Context) {
+// val dialog = context.materialDialogThemed {
+// title("Debugging")
+// progress(true, 0)
+// canceledOnTouchOutside(false)
+// positiveText(R.string.kau_cancel)
+// onPositive { dialog, _ -> dialog.cancel() }
+// }
+// if (injector != null) dialog.extractHtml(injector)
+// else dialog.debugAsync {
+// loadJsoup()
+// }
+// }
+//
+// fun MaterialDialog.debugAsync(task: AnkoAsyncContext<MaterialDialog>.() -> Unit) {
+// doAsync({ t: Throwable ->
+// val msg = t.message
+// L.e{"Debugger failed: $msg"}
+// context.runOnUiThread {
+// cancel()
+// context.materialDialogThemed {
+// title(R.string.debug_incomplete)
+// if (msg != null) content(msg)
+// }
+// }
+// }, task)
+// }
+//
+// /**
+// * Wait for html to be returned from headless webview
+// *
+// * from [debug] to [simplifyJsoup] if [query] is not empty, or [createReport] otherwise
+// */
+// @UiThread
+// private fun MaterialDialog.extractHtml(injector: InjectorContract) {
+// setContent("Fetching webpage")
+// var disposable: Disposable? = null
+// setOnCancelListener { disposable?.dispose() }
+// context.launchHeadlessHtmlExtractor(data.url, injector) {
+// disposable = it.subscribe { (html, errorRes) ->
+// debugAsync {
+// if (errorRes == -1) {
+// L.i("Debug report successful", html)
+// if (query.isNotEmpty()) simplifyJsoup(Jsoup.parseBodyFragment(html))
+// else createReport(html)
+// } else {
+// throw Throwable(context.string(errorRes))
+// }
+// }
+// }
+// }
+// }
+//
+// /**
+// * Get data directly from the link and search for our queries, returning the outerHTML
+// * of the first query found
+// *
+// * from [debug] to [simplifyJsoup]
+// */
+// private fun AnkoAsyncContext<MaterialDialog>.loadJsoup() {
+// uiThread {
+// it.setContent("Load Jsoup")
+// it.setOnCancelListener(null)
+// it.debugAsync { simplifyJsoup(frostJsoup(data.url)) }
+// }
+// }
+//
+// /**
+// * Takes snippet of given document that matches the first query in the [query] items
+// * before sending it to [createReport]
+// */
+// private fun AnkoAsyncContext<MaterialDialog>.simplifyJsoup(doc: Document) {
+// weakRef.get() ?: return
+// val q = query.first { doc.select(it).isNotEmpty() }
+// createReport(doc.select(q).outerHtml())
+// }
+//
+// private fun AnkoAsyncContext<MaterialDialog>.createReport(html: String) {
+// val cleanHtml = html.cleanHtml()
+// uiThread {
+// val c = it.context
+// it.dismiss()
+// c.sendFrostEmail("${c.string(R.string.debug_report_email_title)} $name") {
+// addItem("Query List", query.contentToString())
+// footer = cleanHtml
+// }
+// }
+// }
+//} \ No newline at end of file
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/settings/Experimental.kt b/app/src/main/kotlin/com/pitchedapps/frost/settings/Experimental.kt
index 06489033..87e479eb 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Experimental.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Experimental.kt
@@ -4,7 +4,6 @@ import ca.allanwang.kau.kpref.activity.KPrefAdapterBuilder
import ca.allanwang.kau.logging.KL
import com.pitchedapps.frost.R
import com.pitchedapps.frost.activities.SettingsActivity
-import com.pitchedapps.frost.utils.L
import com.pitchedapps.frost.utils.Prefs
import com.pitchedapps.frost.utils.REQUEST_RESTART_APPLICATION
import com.pitchedapps.frost.utils.Showcase
@@ -31,8 +30,6 @@ fun SettingsActivity.getExperimentalPrefs(): KPrefAdapterBuilder.() -> Unit = {
Prefs.verboseLogging = it
KL.debug(it)
KL.showPrivateText = false
- L.debug(it)
- KL.showPrivateText = false
}) {
descRes = R.string.verbose_logging_desc
}
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/AdBlocker.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/AdBlocker.kt
index be71a913..20041370 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/utils/AdBlocker.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/AdBlocker.kt
@@ -25,7 +25,7 @@ open class AdBlocker(val assetPath: String) {
doAsync {
val content = context.assets.open(assetPath).bufferedReader().use { it.readLines().filter { !it.startsWith("#") } }
data.addAll(content)
- L.i("Initialized adblock for $assetPath with ${data.size} hosts")
+ L.i { "Initialized adblock for $assetPath with ${data.size} hosts" }
}
}
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/AnimatedVectorDelegate.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/AnimatedVectorDelegate.kt
index a530df32..928f90d3 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/utils/AnimatedVectorDelegate.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/AnimatedVectorDelegate.kt
@@ -67,8 +67,8 @@ class AnimatedVectorDelegate(
override fun animateToggle() = animateImpl(!atStart)
private fun animateImpl(toStart: Boolean) {
- if ((atStart == toStart)) return L.d("AVD already at ${if (toStart) "start" else "end"}")
- if (avd == null) return L.d("AVD null resource")//no longer using animated vector; do not modify
+ if ((atStart == toStart)) return L.d { "AVD already at ${if (toStart) "start" else "end"}" }
+ if (avd == null) return L.d { "AVD null resource" }//no longer using animated vector; do not modify
avd?.stop()
view.setImageResource(if (toStart) avdEnd else avdStart)
animatedVectorListener?.invoke(avd!!, !toStart)
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/Downloader.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/Downloader.kt
index aab79e00..16b1d149 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Downloader.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Downloader.kt
@@ -37,10 +37,10 @@ fun Context.frostDownload(uri: Uri?,
mimeType: String? = null,
contentLength: Long = 0L) {
uri ?: return
- L.d("Received download request", "Download $uri")
+ L.d { "Received download request" }
if (uri.scheme != "http" && uri.scheme != "https") {
toast(R.string.error_invalid_download)
- return L.e(string(R.string.error_invalid_download), uri.toString())
+ return L.e { "Invalid download $uri" }
}
if (!isAppEnabled(DOWNLOAD_MANAGER_PACKAGE)) {
materialDialogThemed {
@@ -70,7 +70,7 @@ fun Context.frostDownload(uri: Uri?,
dm.enqueue(request)
} catch (e: Exception) {
toast(R.string.error_generic)
- L.e(e, "Download")
+ L.e(e) { "Download" }
}
}
}
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/L.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/L.kt
index d5c1a6fb..b4bed5e1 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/utils/L.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/L.kt
@@ -1,6 +1,6 @@
package com.pitchedapps.frost.utils
-import ca.allanwang.kau.logging.KauLogger
+import android.util.Log
import com.crashlytics.android.Crashlytics
import com.pitchedapps.frost.BuildConfig
@@ -15,15 +15,55 @@ import com.pitchedapps.frost.BuildConfig
* Debug and Error logs must not reveal person info
* Person info logs can be marked as info or verbose
*/
-object L : KauLogger("Frost") {
+object L {
- override fun logImpl(priority: Int, message: String?, privateMessage: String?, t: Throwable?) {
+ const val TAG = "Frost"
+
+ inline fun v(message: () -> Any?) {
+ if (BuildConfig.DEBUG)
+ logImpl(Log.VERBOSE, message)
+ }
+
+ inline fun i(message: () -> Any?) {
+ logImpl(Log.INFO, message)
+ }
+
+ inline fun _i(message: () -> Any?) {
+ if (BuildConfig.DEBUG)
+ logImpl(Log.INFO, message)
+ }
+
+ inline fun d(message: () -> Any?) {
+ if (BuildConfig.DEBUG || Prefs.verboseLogging)
+ logImpl(Log.DEBUG, message)
+ }
+
+ inline fun _d(message: () -> Any?) {
+ if (BuildConfig.DEBUG)
+ logImpl(Log.DEBUG, message)
+ }
+
+ inline fun e(t: Throwable? = null, message: () -> Any?) {
+ logImpl(Log.ERROR, message, t)
+ }
+
+ fun eThrow(message: Any) {
+ val msg = message.toString()
+ logImpl(Log.ERROR, { msg }, Throwable(msg))
+ }
+
+ inline fun logImpl(priority: Int, message: () -> Any?, t: Throwable? = null) {
+ val msg = message()?.toString()
if (BuildConfig.DEBUG) {
- super.logImpl(priority, message, privateMessage, t)
+ if (t != null)
+ Log.e(TAG, msg, t)
+ else
+ Log.println(priority, TAG, msg ?: "null")
} else {
- if (message != null)
- Crashlytics.log(priority, "Frost", message)
- if (t != null) Crashlytics.logException(t)
+ if (msg != null)
+ Crashlytics.log(priority, TAG, msg)
+ if (t != null)
+ Crashlytics.logException(t)
}
}
} \ No newline at end of file
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt
index 592dd4fc..72b2324a 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt
@@ -67,8 +67,7 @@ fun Activity.cookies(): ArrayList<CookieModel> {
*/
fun Context.launchWebOverlay(url: String, clazz: Class<out WebOverlayActivityBase> = WebOverlayActivity::class.java) {
val argUrl = url.formattedFbUrl
- L.v("Launch received", url)
- L.i("Launch web overlay", argUrl)
+ L.v { "Launch received: $url\nLaunch web overlay: $argUrl" }
if (argUrl.isFacebookUrl && argUrl.contains("/logout.php"))
FbCookie.logout(this)
else if (!(Prefs.linksInDefaultApp && resolveActivityForUri(Uri.parse(argUrl))))
@@ -162,7 +161,7 @@ fun frostAnswersCustom(name: String, vararg events: Pair<String, Any>) {
*/
fun Throwable?.logFrostAnswers(text: String) {
val msg = if (this == null) text else "$text: $message"
- L.e(msg)
+ L.e { msg }
frostAnswersCustom("Errors", "text" to text, "message" to (this?.message ?: "NA"))
}
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IABDialogs.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IABDialogs.kt
index 71c6df36..15d707a9 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IABDialogs.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IABDialogs.kt
@@ -15,7 +15,7 @@ import com.pitchedapps.frost.utils.*
*/
private fun playStoreLog(text: String) {
- L.e(Throwable(text), "IAB Play Store Exception")
+ L.e(Throwable(text)) { "IAB Play Store Exception" }
}
/**
@@ -30,7 +30,7 @@ private fun Activity.playRestart() {
fun Activity?.playStoreNoLongerPro() {
Prefs.pro = false
- L.d("IAB No longer pro")
+ L.d { "IAB No longer pro" }
frostAnswers {
logPurchase(PurchaseEvent()
.putCustomAttribute("result", "no longer pro")
@@ -49,7 +49,7 @@ fun Activity?.playStoreNoLongerPro() {
fun Activity?.playStoreFoundPro() {
Prefs.pro = true
- L.d("Found pro")
+ L.d { "Found pro" }
if (this == null) return
materialDialogThemed {
title(R.string.found_pro)
@@ -62,7 +62,7 @@ fun Activity?.playStoreFoundPro() {
}
fun Activity.playStorePurchaseUnsupported() {
- L.d("Play store not found")
+ L.d { "Play store not found" }
materialDialogThemed {
title(R.string.uh_oh)
content(R.string.play_store_unsupported)
@@ -75,7 +75,7 @@ fun Activity.playStorePurchaseUnsupported() {
}
fun Activity.playStorePurchasedSuccessfully(key: String) {
- L.d("Play store purchased $key successfully")
+ L.d { "Play store purchased $key successfully" }
materialDialogThemed {
title(R.string.play_thank_you)
content(R.string.play_purchased_pro)
@@ -86,7 +86,7 @@ fun Activity.playStorePurchasedSuccessfully(key: String) {
}
fun Activity.purchaseRestored() {
- L.d("Purchase restored")
+ L.d { "Purchase restored" }
materialDialogThemed {
title(R.string.play_thank_you)
content(R.string.purchases_restored_with_pro)
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IabBinder.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IabBinder.kt
index 64fc9cb8..00f99878 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IabBinder.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/iab/IabBinder.kt
@@ -58,13 +58,13 @@ abstract class IabBinder : FrostBilling {
bp = null
}
- override fun onBillingInitialized() = L.i("IAB initialized")
+ override fun onBillingInitialized() = L.i { "IAB initialized" }
- override fun onPurchaseHistoryRestored() = L.d("IAB restored")
+ override fun onPurchaseHistoryRestored() = L.d { "IAB restored" }
override fun onProductPurchased(productId: String, details: TransactionDetails?) {
bp.doAsync {
- L.i("IAB $productId purchased")
+ L.i { "IAB $productId purchased" }
val listing = weakRef.get()?.getPurchaseListingDetails(productId) ?: return@doAsync
val currency = try {
Currency.getInstance(listing.currency)
@@ -127,7 +127,7 @@ class IabSettings : IabBinder() {
override fun onBillingError(errorCode: Int, error: Throwable?) {
super.onBillingError(errorCode, error)
- L.e("Billing error $errorCode ${error?.message}")
+ L.e { "Billing error $errorCode ${error?.message}" }
}
/**
@@ -136,7 +136,7 @@ class IabSettings : IabBinder() {
override fun restorePurchases() {
bp.doAsync {
val load = weakRef.get()?.loadOwnedPurchasesFromGoogle() ?: return@doAsync
- L.d("IAB settings load from google $load")
+ L.d { "IAB settings load from google $load" }
uiThread {
if (!(weakRef.get()?.isPurchased(FROST_PRO) ?: return@uiThread)) {
if (Prefs.pro) activity.playStoreNoLongerPro()
@@ -174,7 +174,7 @@ class IabMain : IabBinder() {
restored = true
bp.doAsync {
val load = weakRef.get()?.loadOwnedPurchasesFromGoogle() ?: false
- L.d("IAB main load from google $load")
+ L.d { "IAB main load from google $load" }
onComplete {
if (!(weakRef.get()?.isPurchased(FROST_PRO) ?: false)) {
if (Prefs.pro) activity.playStoreNoLongerPro()
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoView.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoView.kt
index 4e3aa097..6f1c0fe4 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoView.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoView.kt
@@ -98,7 +98,7 @@ class FrostVideoView @JvmOverloads constructor(
*/
private fun mapBounds(): Triple<Float, Float, Float> {
if (videoDimensions.x <= 0f || videoDimensions.y <= 0f) {
- L.d("Attempted to toggle video expansion when points have not been finalized")
+ L.d { "Attempted to toggle video expansion when points have not been finalized" }
val dimen = Math.min(height, width).toFloat()
videoDimensions.set(dimen, dimen)
}
@@ -113,12 +113,12 @@ class FrostVideoView @JvmOverloads constructor(
val tY = offsetY / 2 - padding.y
videoBounds.set(offsetX, offsetY, width.toFloat(), height.toFloat())
videoBounds.offset(padding.x, padding.y)
- L.v("Video bounds: fullwidth $width, fullheight $height, scale $scale, tX $tX, tY $tY")
+ L.v { "Video bounds: fullwidth $width, fullheight $height, scale $scale, tX $tX, tY $tY" }
return Triple(scale, tX, tY)
}
fun updateLocation() {
- L.d("Update video location")
+ L.d { "Update video location" }
val (scale, tX, tY) = if (isExpanded) Triple(1f, 0f, 0f) else mapBounds()
scaleXY = scale
translationX = tX
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoViewer.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoViewer.kt
index 3a773288..2a7c519e 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoViewer.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoViewer.kt
@@ -84,7 +84,7 @@ class FrostVideoViewer @JvmOverloads constructor(
fun setVideo(url: String, repeat: Boolean = false) {
val formattedUrl = url.formattedFbUrl
- L.d("Load video view; repeat: $repeat", url)
+ L.d { "Load video view; repeat: $repeat" }
animate().alpha(1f).setDuration(FrostVideoView.ANIMATION_DURATION).start()
video.setVideoURI(Uri.parse(formattedUrl))
video.repeat = repeat
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClients.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClients.kt
index 960fe4c2..8c016e5c 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClients.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClients.kt
@@ -20,30 +20,6 @@ import io.reactivex.subjects.Subject
*/
/**
- * Fully quiet client that disables any prompts relating to the UI
- * (as nothing is attached)
- */
-class HeadlessChromeClient : WebChromeClient() {
-
- override fun onConsoleMessage(consoleMessage: ConsoleMessage) = true
-
- override fun onJsAlert(view: WebView, url: String?, message: String?, result: JsResult): Boolean {
- result.cancel()
- return true
- }
-
- override fun onJsConfirm(view: WebView, url: String?, message: String?, result: JsResult): Boolean {
- result.cancel()
- return true
- }
-
- override fun onJsPrompt(view: WebView, url: String?, message: String?, defaultValue: String?, result: JsPromptResult): Boolean {
- result.cancel()
- return true
- }
-}
-
-/**
* The default chrome client
*/
class FrostChromeClient(web: FrostWebView) : WebChromeClient() {
@@ -55,7 +31,7 @@ class FrostChromeClient(web: FrostWebView) : WebChromeClient() {
override fun onConsoleMessage(consoleMessage: ConsoleMessage): Boolean {
if (consoleBlacklist.any { consoleMessage.message().contains(it) }) return true
- L.v("Chrome Console ${consoleMessage.lineNumber()}: ${consoleMessage.message()}")
+ L.v { "Chrome Console ${consoleMessage.lineNumber()}: ${consoleMessage.message()}" }
return true
}
@@ -76,9 +52,9 @@ class FrostChromeClient(web: FrostWebView) : WebChromeClient() {
}
override fun onGeolocationPermissionsShowPrompt(origin: String, callback: GeolocationPermissions.Callback) {
- L.i("Requesting geolocation")
+ L.i { "Requesting geolocation" }
context.kauRequestPermissions(PERMISSION_ACCESS_FINE_LOCATION) { granted, _ ->
- L.i("Geolocation response received; ${if (granted) "granted" else "denied"}")
+ L.i { "Geolocation response received; ${if (granted) "granted" else "denied"}" }
callback(origin, granted, true)
}
}
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt
index b567801b..9264ea52 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt
@@ -33,13 +33,13 @@ class FrostJSI(val web: FrostWebView) {
if (url != null)
web.post {
(context as? VideoViewHolder)?.showVideo(url, isGif)
- ?: L.d("Could not load video; contract not implemented")
+ ?: L.d { "Could not load video; contract not implemented" }
}
}
@JavascriptInterface
fun reloadBaseUrl(animate: Boolean) {
- L.d("FrostJSI reload")
+ L.d { "FrostJSI reload" }
web.post {
web.stopLoading()
web.reloadBase(animate)
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostRequestInterceptor.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostRequestInterceptor.kt
index f7f5666d..454e2a4b 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostRequestInterceptor.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostRequestInterceptor.kt
@@ -47,7 +47,7 @@ fun WebView.shouldFrostInterceptRequest(request: WebResourceRequest): WebResourc
if (whitelistHost.contains(host)) return null
if (!adWhitelistHost.contains(host) && FrostPglAdBlock.isAdHost(host)) return blankResource
// if (!shouldLoadImages && !Prefs.loadMediaOnMeteredNetwork && request.isMedia) return blankResource
- L.v("Intercept Request", "$host $url")
+ L.v { "Intercept Request: $host $url" }
return null
}
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt
index 253d4801..8eec3402 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt
@@ -29,34 +29,35 @@ import org.jetbrains.anko.runOnUiThread
* as we have no need of sending a new intent to the same activity
*/
fun FrostWebView.requestWebOverlay(url: String): Boolean {
+ L.v { "Request web overlay: $url" }
val context = context // finalize reference
if (url.isVideoUrl && context is VideoViewHolder) {
- L.i("Found video", url)
+ L.d { "Found video" }
context.runOnUiThread { context.showVideo(url) }
return true
}
if (!url.isIndependent) {
- L.i("Forbid overlay switch", url)
+ L.d { "Forbid overlay switch" }
return false
}
if (!Prefs.overlayEnabled) return false
if (context is WebOverlayActivityBase) {
- L.v("Check web request from overlay", url)
+ L.v { "Check web request from overlay" }
//already overlay; manage user agent
if (userAgentString != USER_AGENT_BASIC && url.formattedFbUrl.shouldUseBasicAgent) {
- L.i("Switch to basic agent overlay")
+ L.i { "Switch to basic agent overlay" }
context.launchWebOverlay(url, WebOverlayBasicActivity::class.java)
return true
}
if (context is WebOverlayBasicActivity && !url.formattedFbUrl.shouldUseBasicAgent) {
- L.i("Switch from basic agent")
+ L.i { "Switch from basic agent" }
context.launchWebOverlay(url)
return true
}
- L.i("return false switch")
+ L.i { "return false switch" }
return false
}
- L.v("Request web overlay passed", url)
+ L.v { "Request web overlay passed" }
context.launchWebOverlay(url)
return true
}
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt
index 71c71b66..a826066d 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt
@@ -44,10 +44,12 @@ open class FrostWebViewClient(val web: FrostWebView) : BaseWebViewClient() {
private val refresh: Subject<Boolean> = web.parent.refreshObservable
private val isMain = web.parent.baseEnum != null
+ protected inline fun v(crossinline message: () -> Any?) = L.v { "web client: ${message()}" }
+
override fun onPageStarted(view: WebView, url: String?, favicon: Bitmap?) {
super.onPageStarted(view, url, favicon)
if (url == null) return
- L.d("FWV Loading", url)
+ v { "loading $url" }
refresh.onNext(true)
}
@@ -87,7 +89,7 @@ open class FrostWebViewClient(val web: FrostWebView) : BaseWebViewClient() {
override fun onPageFinished(view: WebView, url: String?) {
url ?: return
- L.d("Page finished", url)
+ v { "finished $url" }
if (!url.isFacebookUrl) {
refresh.onNext(false)
return
@@ -102,7 +104,7 @@ open class FrostWebViewClient(val web: FrostWebView) : BaseWebViewClient() {
}
internal fun injectAndFinish() {
- L.d("Page finished reveal")
+ v { "page finished reveal" }
refresh.onNext(false)
injectBackgroundColor()
web.jsInject(
@@ -117,11 +119,11 @@ open class FrostWebViewClient(val web: FrostWebView) : BaseWebViewClient() {
}
open fun handleHtml(html: String?) {
- L.d("Handle Html")
+ L.d { "Handle Html" }
}
open fun emit(flag: Int) {
- L.d("Emit $flag")
+ L.d { "Emit $flag" }
}
/**
@@ -130,21 +132,21 @@ open class FrostWebViewClient(val web: FrostWebView) : BaseWebViewClient() {
* returns false if we are already in an overlaying activity
*/
private fun launchRequest(request: WebResourceRequest): Boolean {
- L.d("Launching Url", request.url?.toString() ?: "null")
+ v { "Launching url: ${request.url}" }
return web.requestWebOverlay(request.url.toString())
}
private fun launchImage(url: String, text: String? = null): Boolean {
- L.d("Launching Image", url)
+ v { "Launching image: $url" }
web.context.launchImageActivity(url, text)
if (web.canGoBack()) web.goBack()
return true
}
override fun shouldOverrideUrlLoading(view: WebView, request: WebResourceRequest): Boolean {
- L.i("Url Loading", request.url?.toString())
+ v { "Url loading: ${request.url}" }
val path = request.url?.path ?: return super.shouldOverrideUrlLoading(view, request)
- L.v("Url Loading Path", path)
+ v { "Url path $path" }
val url = request.url.toString()
if (url.isExplicitIntent) {
view.context.resolveActivityForUri(request.url)
@@ -184,34 +186,7 @@ class FrostWebViewClientMenu(web: FrostWebView) : FrostWebViewClient(web) {
}
override fun onPageFinishedActions(url: String) {
- L.d("Should inject ${url.shouldInjectMenu}")
+ v { "Should inject ${url.shouldInjectMenu}" }
if (!url.shouldInjectMenu) injectAndFinish()
}
-}
-
-/**
- * Headless client that injects content after a page load
- * The JSI is meant to handle everything else
- */
-class HeadlessWebViewClient(val tag: String, val postInjection: InjectorContract) : BaseWebViewClient() {
-
- override fun onPageStarted(view: WebView, url: String?, favicon: Bitmap?) {
- super.onPageStarted(view, url, favicon)
- if (url == null) return
- L.d("Headless Page $tag Started", url)
- }
-
- override fun onPageFinished(view: WebView, url: String?) {
- super.onPageFinished(view, url)
- if (url == null) return
- L.d("Headless Page $tag Finished", url)
- postInjection.inject(view)
- }
-
- /**
- * In addition to general filtration, we will also strip away css and images
- */
- override fun shouldInterceptRequest(view: WebView, request: WebResourceRequest): WebResourceResponse?
- = super.shouldInterceptRequest(view, request).filterCss(request).filterImage(request)
-
} \ No newline at end of file
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/HeadlessHtmlExtractor.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/HeadlessHtmlExtractor.kt
deleted file mode 100644
index 2c7735a4..00000000
--- a/app/src/main/kotlin/com/pitchedapps/frost/web/HeadlessHtmlExtractor.kt
+++ /dev/null
@@ -1,91 +0,0 @@
-package com.pitchedapps.frost.web
-
-import android.annotation.SuppressLint
-import android.content.Context
-import android.webkit.JavascriptInterface
-import android.webkit.WebView
-import ca.allanwang.kau.utils.gone
-import com.pitchedapps.frost.R
-import com.pitchedapps.frost.facebook.USER_AGENT_BASIC
-import com.pitchedapps.frost.injectors.InjectorContract
-import com.pitchedapps.frost.utils.L
-import io.reactivex.Single
-import io.reactivex.SingleEmitter
-import io.reactivex.android.schedulers.AndroidSchedulers
-import io.reactivex.schedulers.Schedulers
-import org.jetbrains.anko.runOnUiThread
-import java.util.concurrent.TimeUnit
-
-/**
- * Created by Allan Wang on 2017-08-12.
- *
- * Launches a headless html request and returns a result pair
- * When successful, the pair will contain the html content and -1
- * When unsuccessful, the pair will contain an empty string and a StringRes for the given error
- *
- * All errors are rerouted to success calls, so no exceptions should occur.
- * The headless extractor will also destroy itself on cancellation or when the request is finished
- */
-fun Context.launchHeadlessHtmlExtractor(url: String, injector: InjectorContract, action: (Single<Pair<String, Int>>) -> Unit) {
- val single = Single.create<Pair<String, Int>> { e: SingleEmitter<Pair<String, Int>> ->
- val extractor = HeadlessHtmlExtractor(this, url, injector, e)
- extractor.resumeTimers()
- e.setCancellable {
- runOnUiThread {
- extractor.pauseTimers()
- extractor.destroy()
- }
- e.onSuccess("" to R.string.html_extraction_cancelled)
- }
- }.subscribeOn(AndroidSchedulers.mainThread())
- .timeout(20, TimeUnit.SECONDS, Schedulers.io(), { it.onSuccess("" to R.string.html_extraction_timeout) })
- .onErrorReturn { "" to R.string.html_extraction_error }
- action(single)
-}
-
-/**
- * Given a link and some javascript, will load the link and load the JS on completion
- * The JS is expected to call [HeadlessHtmlExtractor.HtmlJSI.handleHtml], which will be sent
- * to the [emitter]
- */
-@SuppressLint("ViewConstructor")
-private class HeadlessHtmlExtractor(
- context: Context, url: String, val injector: InjectorContract, val emitter: SingleEmitter<Pair<String, Int>>
-) : WebView(context) {
-
- val startTime = System.currentTimeMillis()
-
- init {
- L.v("Created HeadlessHtmlExtractor for $url")
- gone()
- setupWebview(url)
- }
-
- @SuppressLint("SetJavaScriptEnabled")
- private fun setupWebview(url: String) {
- settings.javaScriptEnabled = true
- settings.userAgentString = USER_AGENT_BASIC
- webViewClient = HeadlessWebViewClient(url, injector) // basic client that loads our JS once the page has loaded
- webChromeClient = HeadlessChromeClient()
- addJavascriptInterface(HtmlJSI(), "Frost")
- loadUrl(url)
- }
-
- inner class HtmlJSI {
- @JavascriptInterface
- fun handleHtml(html: String?) {
- val time = System.currentTimeMillis() - startTime
- emitter.onSuccess((html ?: "") to -1)
- post {
- L.d("HeadlessHtmlExtractor fetched $url in $time ms")
- destroy()
- }
- }
- }
-
- override fun destroy() {
- pauseTimers()
- super.destroy()
- L.d("HeadlessHtmlExtractor destroyed")
- }
-} \ No newline at end of file
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt
index 9855040d..a2f341ef 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt
@@ -46,7 +46,7 @@ class LoginWebView @JvmOverloads constructor(
fun loadLogin(progressCallback: (Int) -> Unit, loginCallback: (CookieModel) -> Unit) {
this.progressCallback = progressCallback
this.loginCallback = loginCallback
- L.d("Begin loading login")
+ L.d { "Begin loading login" }
loadUrl(FB_LOGIN_URL)
}
@@ -62,7 +62,7 @@ class LoginWebView @JvmOverloads constructor(
doAsync {
if (!url.isFacebookUrl) return@doAsync
val cookie = CookieManager.getInstance().getCookie(url) ?: return@doAsync
- L.d("Checking cookie for login", cookie)
+ L.d { "Checking cookie for login" }
val id = FB_USER_MATCHER.find(cookie)[1]?.toLong() ?: return@doAsync
uiThread { onFound(id, cookie) }
}
@@ -70,7 +70,7 @@ class LoginWebView @JvmOverloads constructor(
override fun onPageCommitVisible(view: WebView, url: String?) {
super.onPageCommitVisible(view, url)
- L.d("Login page commit visible")
+ L.d { "Login page commit visible" }
view.setBackgroundColor(Color.TRANSPARENT)
if (url.isFacebookUrl)
view.jsInject(CssHider.HEADER,
@@ -88,7 +88,7 @@ class LoginWebView @JvmOverloads constructor(
inner class LoginChromeClient : WebChromeClient() {
override fun onConsoleMessage(consoleMessage: ConsoleMessage): Boolean {
- L.d("Login Console ${consoleMessage.lineNumber()}: ${consoleMessage.message()}")
+ L.v { "Login Console ${consoleMessage.lineNumber()}: ${consoleMessage.message()}" }
return true
}