mirror of
https://github.com/AllanWang/Frost-for-Facebook.git
synced 2024-11-10 04:52:38 +01:00
Port rest of cookie items
This commit is contained in:
parent
65bb9233b2
commit
9a1d9719ad
@ -17,6 +17,7 @@
|
||||
<application
|
||||
android:name=".FrostApp"
|
||||
android:allowBackup="true"
|
||||
android:fullBackupContent="@xml/frost_backup_rules"
|
||||
android:icon="@mipmap/ic_launcher_round"
|
||||
android:label="@string/frost_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
|
@ -35,13 +35,15 @@ import com.pitchedapps.frost.activities.SelectorActivity
|
||||
import com.pitchedapps.frost.db.CookieDao
|
||||
import com.pitchedapps.frost.db.CookieEntity
|
||||
import com.pitchedapps.frost.db.CookieModel
|
||||
import com.pitchedapps.frost.db.loadFbCookiesSync
|
||||
import com.pitchedapps.frost.db.FbTabModel
|
||||
import com.pitchedapps.frost.facebook.FbCookie
|
||||
import com.pitchedapps.frost.utils.EXTRA_COOKIES
|
||||
import com.pitchedapps.frost.utils.L
|
||||
import com.pitchedapps.frost.utils.Prefs
|
||||
import com.pitchedapps.frost.utils.launchNewTask
|
||||
import com.pitchedapps.frost.utils.loadAssets
|
||||
import com.raizlabs.android.dbflow.kotlinextensions.from
|
||||
import com.raizlabs.android.dbflow.kotlinextensions.select
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
@ -97,8 +99,12 @@ class StartActivity : KauBaseActivity() {
|
||||
/**
|
||||
* Migrate from dbflow to room
|
||||
*/
|
||||
private suspend fun migrate() {
|
||||
|
||||
private suspend fun migrate() = withContext(Dispatchers.IO) {
|
||||
if (cookieDao.selectAll().isNotEmpty()) return@withContext
|
||||
val cookies = (select from CookieModel::class).queryList()
|
||||
cookieDao.insertCookies(cookies.map { CookieEntity(it.id, it.name, it.cookie) })
|
||||
// TODO
|
||||
val tabs = (select from FbTabModel::class).queryList()
|
||||
}
|
||||
|
||||
private fun showInvalidWebView() =
|
||||
|
@ -22,23 +22,13 @@ import androidx.room.Entity
|
||||
import androidx.room.Insert
|
||||
import androidx.room.OnConflictStrategy
|
||||
import androidx.room.Query
|
||||
import com.pitchedapps.frost.utils.L
|
||||
import com.pitchedapps.frost.utils.Prefs
|
||||
import com.raizlabs.android.dbflow.annotation.ConflictAction
|
||||
import com.raizlabs.android.dbflow.annotation.Database
|
||||
import com.raizlabs.android.dbflow.annotation.PrimaryKey
|
||||
import com.raizlabs.android.dbflow.annotation.Table
|
||||
import com.raizlabs.android.dbflow.kotlinextensions.async
|
||||
import com.raizlabs.android.dbflow.kotlinextensions.delete
|
||||
import com.raizlabs.android.dbflow.kotlinextensions.eq
|
||||
import com.raizlabs.android.dbflow.kotlinextensions.from
|
||||
import com.raizlabs.android.dbflow.kotlinextensions.save
|
||||
import com.raizlabs.android.dbflow.kotlinextensions.select
|
||||
import com.raizlabs.android.dbflow.kotlinextensions.where
|
||||
import com.raizlabs.android.dbflow.structure.BaseModel
|
||||
import kotlinx.android.parcel.Parcelize
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
/**
|
||||
* Created by Allan Wang on 2017-05-30.
|
||||
@ -69,6 +59,9 @@ interface CookieDao {
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
suspend fun insertCookie(cookie: CookieEntity)
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
suspend fun insertCookies(cookies: List<CookieEntity>)
|
||||
|
||||
@Query("DELETE FROM cookies WHERE id = :id")
|
||||
suspend fun deleteById(id: Long)
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ import android.webkit.CookieManager
|
||||
import com.pitchedapps.frost.db.CookieDao
|
||||
import com.pitchedapps.frost.db.CookieEntity
|
||||
import com.pitchedapps.frost.db.FrostDatabase
|
||||
import com.pitchedapps.frost.db.removeCookie
|
||||
import com.pitchedapps.frost.utils.L
|
||||
import com.pitchedapps.frost.utils.Prefs
|
||||
import com.pitchedapps.frost.utils.cookies
|
||||
|
@ -24,15 +24,19 @@ import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import ca.allanwang.kau.utils.AnimHolder
|
||||
import ca.allanwang.kau.utils.launchMain
|
||||
import com.pitchedapps.frost.contracts.FrostContentContainer
|
||||
import com.pitchedapps.frost.contracts.FrostContentCore
|
||||
import com.pitchedapps.frost.contracts.FrostContentParent
|
||||
import com.pitchedapps.frost.db.FrostDatabase
|
||||
import com.pitchedapps.frost.db.currentCookie
|
||||
import com.pitchedapps.frost.facebook.FB_HOME_URL
|
||||
import com.pitchedapps.frost.facebook.FbItem
|
||||
import com.pitchedapps.frost.facebook.USER_AGENT_BASIC
|
||||
import com.pitchedapps.frost.facebook.USER_AGENT_FULL
|
||||
import com.pitchedapps.frost.fragments.WebFragment
|
||||
import com.pitchedapps.frost.utils.Prefs
|
||||
import com.pitchedapps.frost.utils.ctxCoroutine
|
||||
import com.pitchedapps.frost.utils.frostDownload
|
||||
import com.pitchedapps.frost.web.FrostChromeClient
|
||||
import com.pitchedapps.frost.web.FrostJSI
|
||||
@ -80,7 +84,13 @@ class FrostWebView @JvmOverloads constructor(
|
||||
webChromeClient = FrostChromeClient(this)
|
||||
addJavascriptInterface(FrostJSI(this), "Frost")
|
||||
setBackgroundColor(Color.TRANSPARENT)
|
||||
setDownloadListener(context::frostDownload)
|
||||
val db = FrostDatabase.get()
|
||||
setDownloadListener { url, userAgent, contentDisposition, mimetype, contentLength ->
|
||||
context.ctxCoroutine.launchMain {
|
||||
val cookie = db.cookieDao().currentCookie() ?: return@launchMain
|
||||
context.frostDownload(cookie, url, userAgent, contentDisposition, mimetype, contentLength)
|
||||
}
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
|
@ -2,11 +2,11 @@
|
||||
"formatVersion": 1,
|
||||
"database": {
|
||||
"version": 1,
|
||||
"identityHash": "6af67964d00193c6a3aa2a20200ea0ea",
|
||||
"identityHash": "ba6f1d7e47823dac6ed1622fec043d5d",
|
||||
"entities": [
|
||||
{
|
||||
"tableName": "cookies",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER NOT NULL, `name` TEXT NOT NULL, `cookie` TEXT NOT NULL, PRIMARY KEY(`id`))",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER NOT NULL, `name` TEXT, `cookie` TEXT, PRIMARY KEY(`id`))",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "id",
|
||||
@ -18,13 +18,13 @@
|
||||
"fieldPath": "name",
|
||||
"columnName": "name",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
"notNull": false
|
||||
},
|
||||
{
|
||||
"fieldPath": "cookie",
|
||||
"columnName": "cookie",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
"notNull": false
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
@ -37,9 +37,10 @@
|
||||
"foreignKeys": []
|
||||
}
|
||||
],
|
||||
"views": [],
|
||||
"setupQueries": [
|
||||
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
|
||||
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, \"6af67964d00193c6a3aa2a20200ea0ea\")"
|
||||
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, \"ba6f1d7e47823dac6ed1622fec043d5d\")"
|
||||
]
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user