1
0
mirror of https://github.com/AllanWang/Frost-for-Facebook.git synced 2024-11-08 12:02:33 +01:00

Cleanup and docs

This commit is contained in:
Allan Wang 2017-07-01 12:14:29 -07:00
parent d24ee84000
commit 0018677886
8 changed files with 17 additions and 9 deletions

View File

@ -24,11 +24,6 @@ object FbTabsDb {
@Table(database = FbTabsDb::class, allFields = true)
data class FbTabModel(@PrimaryKey var position: Int = -1, var tab: FbTab = FbTab.FEED) : BaseModel()
//const val FB_URL_BASE = "https://touch.facebook.com/"
//BOOKMARKS("https://touch.facebook.com/bookmarks"),
//SEARCH("https://touch.facebook.com/search"),
fun loadFbTabs(): List<FbTab> {
val tabs: List<FbTabModel>? = SQLite.select().from(FbTabModel::class).orderBy(FbTabModel_Table.position, true).queryList()
if (tabs?.isNotEmpty() ?: false) return tabs!!.map { it.tab }

View File

@ -5,6 +5,8 @@ import com.pitchedapps.frost.utils.L
/**
* Created by Allan Wang on 2017-05-31.
*
* List of elements to hide
*/
enum class CssHider(vararg val items: String) : InjectorContract {
CORE("[data-sigil=m_login_upsell]"),

View File

@ -5,6 +5,8 @@ import com.pitchedapps.frost.facebook.FB_URL_BASE
/**
* Created by Allan Wang on 2017-05-31.
*
* Collection of short js functions that are embedded directly
*/
enum class JsActions(body: String) : InjectorContract {
/**

View File

@ -7,7 +7,6 @@ import com.pitchedapps.frost.utils.L
* Created by Allan Wang on 2017-05-31.
* Mapping of the available assets
* The enum name must match the css file name
* //TODO add folder mapping using Prefs
*/
enum class JsAssets : InjectorContract {
MENU, CLICK_A, CLICK_INTERCEPTOR, HEADER_BADGES, SEARCH

View File

@ -34,6 +34,9 @@ class JsBuilder {
}
}
/**
* Contract for all injectors to allow it to interact properly with a webview
*/
interface InjectorContract {
fun inject(webView: WebView) = inject(webView, null)
fun inject(webView: WebView, callback: ((String) -> Unit)?)
@ -58,6 +61,9 @@ fun WebView.jsInject(vararg injectors: InjectorContract, callback: ((Array<Strin
fun FrostWebViewClient.jsInject(vararg injectors: InjectorContract, callback: ((Array<String>) -> Unit) = {}) = webCore.jsInject(*injectors, callback = callback)
/**
* Wrapper class to convert a function into an injector
*/
class JsInjector(val function: String) : InjectorContract {
override fun inject(webView: WebView, callback: ((String) -> Unit)?) {
webView.evaluateJavascript(function, { value -> callback?.invoke(value) })

View File

@ -28,6 +28,9 @@ import java.util.concurrent.Future
/**
* Created by Allan Wang on 2017-06-14.
*
* Service to manage notifications
* Will periodically check through all accounts in the db and send notifications when appropriate
*/
class NotificationService : JobService() {
@ -41,7 +44,6 @@ class NotificationService : JobService() {
override fun onStartJob(params: JobParameters?): Boolean {
future = doAsync {
// debugNotification("Load notifs")
loadFbCookiesSync().forEach {
data ->
L.i("Handle notifications for $data")

View File

@ -9,6 +9,8 @@ import com.pitchedapps.frost.utils.scheduleNotifications
/**
* Created by Allan Wang on 2017-05-31.
*
* Receiver that is triggered whenever the app updates so it can bind the notifications again
*/
class UpdateReceiver : BroadcastReceiver() {

View File

@ -16,8 +16,8 @@ APP_GROUP=com.pitchedapps
MIN_SDK=21
TARGET_SDK=26
BUILD_TOOLS=26.0.0
VERSION_CODE=10
VERSION_NAME=1.0
VERSION_CODE=11
VERSION_NAME=1.1
KAU=e1e3b37000
KOTLIN=1.1.3