aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/facebook
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-12-31 02:44:46 -0500
committerGitHub <noreply@github.com>2017-12-31 02:44:46 -0500
commit725d6a99a07f91f940a07e6b49dd6224a6aa32d1 (patch)
tree4e0b1b3b9ffe9b5aef3c8d0f154ea9ab1058fd5e /app/src/main/kotlin/com/pitchedapps/frost/facebook
parent3076d9a97c203497aec1415d8ac6037d10eebb46 (diff)
downloadfrost-725d6a99a07f91f940a07e6b49dd6224a6aa32d1.tar.gz
frost-725d6a99a07f91f940a07e6b49dd6224a6aa32d1.tar.bz2
frost-725d6a99a07f91f940a07e6b49dd6224a6aa32d1.zip
Enhancement/proguard (#589)
* Add error log * Rewrite logger
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/facebook')
-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
5 files changed, 23 insertions, 18 deletions
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)