1
0
mirror of https://github.com/AllanWang/Frost-for-Facebook.git synced 2024-09-19 23:21:34 +02:00

Merge pull request #1657 from AllanWang/versions

Update versions
This commit is contained in:
Allan Wang 2020-02-29 23:34:58 -08:00 committed by GitHub
commit e732e30d97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 108 additions and 84 deletions

30
.idea/jarRepositories.xml Normal file
View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
<remote-repository>
<option name="id" value="BintrayJCenter" />
<option name="name" value="BintrayJCenter" />
<option name="url" value="https://jcenter.bintray.com/" />
</remote-repository>
<remote-repository>
<option name="id" value="maven" />
<option name="name" value="maven" />
<option name="url" value="https://jitpack.io" />
</remote-repository>
<remote-repository>
<option name="id" value="Google" />
<option name="name" value="Google" />
<option name="url" value="https://dl.google.com/dl/android/maven2/" />
</remote-repository>
</component>
</project>

View File

@ -4,7 +4,7 @@ jdk:
env:
global:
- ANDROID_API=29
- ANDROID_BUILD_TOOLS=29.0.0
- ANDROID_BUILD_TOOLS=29.0.2
- secure: X3J97ccW+8K0bXPXhX608vPx7Pr/G4ju7quxydqMaYGgClHxoL/WpXOBAyyllde5P28PY4kioaqcI21BEhnAw0QUbmnzVLA1Qd5VS7aMPHpEnInKuOxGZ2d570OZd1f+ozFVt05vzG0VBJlBAkVhz2GWNxQdmIV1sO28MH526JMuYaEREuuywVSZmAeY7AAbW9MeCC2wvHvNmhk2nk6NLRQcsrDHcBsimy9fnnQ9lT/QsvToi1ZJd/MN7YkGDUULR+YmaotBzG546UJ1EiZQX91bFEJfP0oL43Pk7t5snzmHnKjLOr8Mt5QsIUXaiy/uzhUVmuDh1i0GEpZmhqM7nz/T6P7ogaLbbyJeauNmf15nu+e3hSvNiTzKyIwfSSflv8Do3g8/Eo3dKfIi3I8/OKF/uZ76kywh2LRqtZAqxRDiAMDZVwsRgD4aztoWm5AWa3tSoGy1J7i1eoqX6bNqokRbjgheTqcjN13kCdSZi3pZX7UBYm2Vumhn4izhTume19Rh9SqTmRgQ8jM7ynxHh7vVsJPPJG0HbQ623xz+d9mtXGy1fAb0dcUJMXdOhFN3m6AnKuHiF7cmsqje7Euk/TOZyqZmu0xEhTkugMbNKwGrklJiwRr3IoLtPdhLE38u3/auloUqBQ4K/iA9ZdhAreTSHEaI9d3J4N6kqCj3U30=
android:
components:

View File

@ -10,20 +10,20 @@ apply plugin: 'com.gladed.androidgitversion'
buildscript {
repositories {
jcenter()
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath "com.moowork.gradle:gradle-node-plugin:${Versions.nodeGradle}"
classpath "com.github.node-gradle:gradle-node-plugin:${Versions.nodeGradle}"
}
}
apply plugin: com.moowork.gradle.node.NodePlugin
apply plugin: 'com.github.node-gradle.node'
apply from: '../spotless.gradle'
group = APP_GROUP
android {
compileSdkVersion Versions.targetSdk
buildToolsVersion kau.Versions.buildTools
androidGitVersion {
codeFormat = 'MMNNPPXX'
@ -75,8 +75,8 @@ android {
textOutput 'stdout'
}
viewBinding {
enabled = true
buildFeatures {
viewBinding = true
}
def testKeystoreFile = file('../files/test.keystore')
@ -199,8 +199,8 @@ android {
}
node {
version = '12.4.0'
npmVersion = '6.9.0'
version = '13.8.0'
npmVersion = '6.13.7'
download = true
nodeModulesDir = file("${project.projectDir}/src/web")
}
@ -283,7 +283,7 @@ dependencies {
//noinspection GradleDependency
kapt kau.Dependencies.glideKapt
debugImplementation "com.squareup.leakcanary:leakcanary-android:${Versions.leakCanary}"
debugImplementation kau.Dependencies.leakCanary
//Icons
implementation kau.Dependencies.iconicsMaterial

View File

@ -48,7 +48,7 @@ abstract class BaseActivity : KauBaseActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
if (this !is WebOverlayActivityBase) setFrostTheme()
if (this !is WebOverlayActivityBase) setFrostTheme(prefs)
}
override fun onStop() {

View File

@ -313,7 +313,7 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract,
val item = FbItem.values[it.itemId]
frostEvent("Drawer Tab", "name" to item.name)
drawer.closeDrawer(navigation)
launchWebOverlay(item.url, fbCookie)
launchWebOverlay(item.url, fbCookie, prefs)
false
}
val navBg = prefs.bgColor.withMinAlpha(200)
@ -464,7 +464,7 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract,
setOptionsIcon(GoogleMaterial.Icon.gmd_exit_to_app)
setOnClickListener {
launch {
val currentCookie = cookieDao.currentCookie()
val currentCookie = cookieDao.currentCookie(prefs)
if (currentCookie == null) {
toast(R.string.account_not_found)
fbCookie.reset()
@ -596,7 +596,7 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract,
.into(this)
setOnClickListener {
if (primary) {
launchWebOverlay(FbItem.PROFILE.url, fbCookie)
launchWebOverlay(FbItem.PROFILE.url, fbCookie, prefs)
} else {
switchAccount(cookie.id)
}
@ -661,11 +661,11 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract,
}
textDebounceInterval = 300
searchCallback =
{ query, _ -> launchWebOverlay("${FbItem._SEARCH.url}/?q=$query", fbCookie); true }
{ query, _ -> launchWebOverlay("${FbItem._SEARCH.url}/?q=$query", fbCookie, prefs); true }
closeListener = { _ -> searchViewCache.clear() }
foregroundColor = prefs.textColor
backgroundColor = prefs.bgColor.withMinAlpha(200)
onItemClick = { _, key, _, _ -> launchWebOverlay(key, fbCookie) }
onItemClick = { _, key, _, _ -> launchWebOverlay(key, fbCookie, prefs) }
}
}
}
@ -723,7 +723,7 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract,
fragmentChannel.offer(REQUEST_REFRESH)
}
if (hasRequest(REQUEST_NAV)) {
frostNavigationBar()
frostNavigationBar(prefs)
}
if (hasRequest(REQUEST_TEXT_ZOOM)) {
fragmentChannel.offer(REQUEST_TEXT_ZOOM)

View File

@ -114,7 +114,7 @@ class IntroActivity : KauBaseActivity(), ViewPager.PageTransformer,
indicator.invalidate()
}
fragments.forEach { it.themeFragment() }
setFrostTheme(true)
setFrostTheme(prefs, true)
}
/**

View File

@ -40,6 +40,7 @@ import com.afollestad.materialdialogs.list.listItems
import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial
import com.mikepenz.iconics.typeface.library.googlematerial.GoogleMaterial
import com.pitchedapps.frost.R
import com.pitchedapps.frost.db.NotificationDao
import com.pitchedapps.frost.enums.Support
import com.pitchedapps.frost.facebook.FbCookie
import com.pitchedapps.frost.settings.getAppearancePrefs
@ -70,6 +71,7 @@ import org.koin.android.ext.android.inject
class SettingsActivity : KPrefActivity() {
val fbCookie: FbCookie by inject()
val notifDao: NotificationDao by inject()
val prefs: Prefs by inject()
private var resultFlag = Activity.RESULT_CANCELED
@ -218,7 +220,7 @@ class SettingsActivity : KPrefActivity() {
@SuppressLint("MissingSuperCall")
override fun onCreate(savedInstanceState: Bundle?) {
setFrostTheme(true)
setFrostTheme(prefs, true)
super.onCreate(savedInstanceState)
animate = prefs.animate
themeExterior(false)
@ -229,7 +231,7 @@ class SettingsActivity : KPrefActivity() {
else bgCanvas.set(prefs.bgColor)
if (animate) toolbarCanvas.ripple(prefs.headerColor, RippleCanvas.MIDDLE, RippleCanvas.END)
else toolbarCanvas.set(prefs.headerColor)
frostNavigationBar()
frostNavigationBar(prefs)
}
override fun onBackPressed() {

View File

@ -68,4 +68,4 @@ suspend fun CookieDao.selectById(id: Long) = dao { _selectById(id) }
suspend fun CookieDao.save(cookie: CookieEntity) = dao { _save(cookie) }
suspend fun CookieDao.save(cookies: List<CookieEntity>) = dao { _save(cookies) }
suspend fun CookieDao.deleteById(id: Long) = dao { _deleteById(id) }
suspend fun CookieDao.currentCookie() = selectById(Prefs.get().userId)
suspend fun CookieDao.currentCookie(prefs: Prefs) = selectById(prefs.userId)

View File

@ -22,6 +22,7 @@ import androidx.room.Room
import androidx.room.RoomDatabase
import com.pitchedapps.frost.BuildConfig
import org.koin.core.context.GlobalContext
import org.koin.core.context.KoinContextHandler
import org.koin.dsl.module
interface FrostPrivateDao {
@ -100,11 +101,5 @@ class FrostDatabase(
single { get<FrostDatabase>().notifDao() }
single { get<FrostDatabase>().genericDao() }
}
/**
* Get from koin
* For the most part, you can retrieve directly from other koin components
*/
fun get(): FrostDatabase = GlobalContext.get().koin.get()
}
}

View File

@ -20,6 +20,7 @@ import android.content.Context
import androidx.annotation.StringRes
import ca.allanwang.kau.utils.string
import com.pitchedapps.frost.R
import com.pitchedapps.frost.utils.Prefs
import com.pitchedapps.frost.utils.sendFrostEmail
/**

View File

@ -40,6 +40,6 @@ class NotificationFragment : FrostParserFragment<FrostNotifs, NotificationIItem>
response.data.notifs.map { NotificationIItem(it, response.cookie) }
override fun bindImpl(recyclerView: FrostRecyclerView) {
NotificationIItem.bindEvents(adapter, fbCookie)
NotificationIItem.bindEvents(adapter, fbCookie, prefs)
}
}

View File

@ -44,20 +44,20 @@ interface ClickableIItemContract {
val url: String?
fun click(context: Context, fbCookie: FbCookie) {
fun click(context: Context, fbCookie: FbCookie, prefs: Prefs) {
val url = url ?: return
context.launchWebOverlay(url, fbCookie)
context.launchWebOverlay(url, fbCookie, prefs)
}
companion object {
fun bindEvents(adapter: IAdapter<GenericItem>, fbCookie: FbCookie) {
fun bindEvents(adapter: IAdapter<GenericItem>, fbCookie: FbCookie, prefs: Prefs) {
adapter.fastAdapter?.apply {
selectExtension {
isSelectable = false
}
onClickListener = { v, _, item, _ ->
if (item is ClickableIItemContract) {
item.click(v!!.context, fbCookie)
item.click(v!!.context, fbCookie, prefs)
true
} else
false
@ -76,7 +76,8 @@ open class HeaderIItem(
itemId: Int = R.layout.iitem_header
) : KauIItem<HeaderIItem.ViewHolder>(R.layout.iitem_header, ::ViewHolder, itemId) {
class ViewHolder(itemView: View) : FastAdapter.ViewHolder<HeaderIItem>(itemView), KoinComponent {
class ViewHolder(itemView: View) : FastAdapter.ViewHolder<HeaderIItem>(itemView),
KoinComponent {
private val prefs: Prefs by inject()

View File

@ -51,7 +51,7 @@ class NotificationIItem(val notification: FrostNotif, val cookie: String) :
) {
companion object {
fun bindEvents(adapter: ItemAdapter<NotificationIItem>, fbCookie: FbCookie) {
fun bindEvents(adapter: ItemAdapter<NotificationIItem>, fbCookie: FbCookie, prefs: Prefs) {
adapter.fastAdapter?.apply {
selectExtension {
isSelectable = false
@ -65,7 +65,7 @@ class NotificationIItem(val notification: FrostNotif, val cookie: String) :
)
}
// TODO temp fix. If url is dependent, we cannot load it directly
v!!.context.launchWebOverlay(if (notif.url.isIndependent) notif.url else FbItem.NOTIFICATIONS.url, fbCookie)
v!!.context.launchWebOverlay(if (notif.url.isIndependent) notif.url else FbItem.NOTIFICATIONS.url, fbCookie, prefs)
true
}
}

View File

@ -33,6 +33,7 @@ import com.pitchedapps.frost.R
import com.pitchedapps.frost.activities.FrostWebActivity
import com.pitchedapps.frost.db.CookieEntity
import com.pitchedapps.frost.db.FrostDatabase
import com.pitchedapps.frost.db.NotificationDao
import com.pitchedapps.frost.db.latestEpoch
import com.pitchedapps.frost.db.saveNotifications
import com.pitchedapps.frost.enums.OverlayContext
@ -112,8 +113,7 @@ enum class NotificationType(
* Returns the number of notifications generated,
* or -1 if an error occurred
*/
suspend fun fetch(context: Context, data: CookieEntity, prefs: Prefs): Int {
val notifDao = FrostDatabase.get().notifDao()
suspend fun fetch(context: Context, data: CookieEntity, prefs: Prefs, notifDao: NotificationDao): Int {
val response = try {
parser.parse(data.cookie)
} catch (ignored: Exception) {
@ -170,7 +170,7 @@ enum class NotificationType(
val ringtone = ringtoneProvider(prefs)
notifs.forEachIndexed { i, notif ->
// Ring at most twice
notif.withAlert(context, i < 2, ringtone).notify(context)
notif.withAlert(context, i < 2, ringtone, prefs).notify(context)
}
return notifs.size
}
@ -307,8 +307,8 @@ data class FrostNotification(
val notif: NotificationCompat.Builder
) {
fun withAlert(context: Context, enable: Boolean, ringtone: String): FrostNotification {
notif.setFrostAlert(context, enable, ringtone)
fun withAlert(context: Context, enable: Boolean, ringtone: String, prefs: Prefs): FrostNotification {
notif.setFrostAlert(context, enable, ringtone, prefs)
return this
}

View File

@ -23,6 +23,7 @@ import com.pitchedapps.frost.BuildConfig
import com.pitchedapps.frost.R
import com.pitchedapps.frost.db.CookieDao
import com.pitchedapps.frost.db.CookieEntity
import com.pitchedapps.frost.db.NotificationDao
import com.pitchedapps.frost.db.selectAll
import com.pitchedapps.frost.utils.L
import com.pitchedapps.frost.utils.Prefs
@ -34,7 +35,6 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import kotlinx.coroutines.yield
import org.koin.android.ext.android.inject
import org.koin.core.inject
/**
* Created by Allan Wang on 2017-06-14.
@ -47,6 +47,7 @@ import org.koin.core.inject
class NotificationService : BaseJobService() {
private val prefs: Prefs by inject()
private val notifDao: NotificationDao by inject()
private val cookieDao: CookieDao by inject()
override fun onStopJob(params: JobParameters?): Boolean {
@ -119,7 +120,7 @@ class NotificationService : BaseJobService() {
* Also normalized the output to return the number of notifications received
*/
private suspend fun fetch(jobId: Int, type: NotificationType, cookie: CookieEntity): Int {
val count = type.fetch(this, cookie, prefs)
val count = type.fetch(this, cookie, prefs, notifDao)
if (count < 0) {
if (jobId == NOTIFICATION_JOB_NOW)
generalNotification(666, R.string.error_notification, BuildConfig.DEBUG)
@ -135,7 +136,7 @@ class NotificationService : BaseJobService() {
private fun generalNotification(id: Int, textRes: Int, withDefaults: Boolean) {
val notifBuilder = frostNotification(NOTIF_CHANNEL_GENERAL)
.setFrostAlert(this, withDefaults, prefs.notificationRingtone)
.setFrostAlert(this, withDefaults, prefs.notificationRingtone, prefs)
.setContentTitle(string(R.string.frost_name))
.setContentText(string(textRes))
NotificationManagerCompat.from(this).notify(id, notifBuilder.build())

View File

@ -92,10 +92,9 @@ fun Context.frostNotification(id: String) =
fun NotificationCompat.Builder.setFrostAlert(
context: Context,
enable: Boolean,
ringtone: String
ringtone: String,
prefs: Prefs
): NotificationCompat.Builder {
val prefs = Prefs.get()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
setGroupAlertBehavior(
if (enable) NotificationCompat.GROUP_ALERT_CHILDREN

View File

@ -56,7 +56,7 @@ fun SettingsActivity.getAppearancePrefs(): KPrefAdapterBuilder.() -> Unit = {
item.pref = index
shouldRestartMain()
reload()
setFrostTheme(true)
setFrostTheme(prefs, true)
themeExterior()
invalidateOptionsMenu()
frostEvent("Theme", "Count" to Theme(index).name)
@ -103,7 +103,7 @@ fun SettingsActivity.getAppearancePrefs(): KPrefAdapterBuilder.() -> Unit = {
prefs.customBackgroundColor = it
bgCanvas.ripple(it, duration = 500L)
invalidateCustomTheme()
setFrostTheme(true)
setFrostTheme(prefs, true)
shouldRestartMain()
}) {
dependsOnCustom()
@ -112,7 +112,7 @@ fun SettingsActivity.getAppearancePrefs(): KPrefAdapterBuilder.() -> Unit = {
colorPicker(R.string.header_color, prefs::customHeaderColor, {
prefs.customHeaderColor = it
frostNavigationBar()
frostNavigationBar(prefs)
toolbarCanvas.ripple(it, RippleCanvas.MIDDLE, RippleCanvas.END, duration = 500L)
reload()
shouldRestartMain()
@ -161,7 +161,7 @@ fun SettingsActivity.getAppearancePrefs(): KPrefAdapterBuilder.() -> Unit = {
checkbox(R.string.tint_nav, prefs::tintNavBar, {
prefs.tintNavBar = it
frostNavigationBar()
frostNavigationBar(prefs)
setFrostResult(REQUEST_NAV)
}) {
descRes = R.string.tint_nav_desc

View File

@ -37,13 +37,14 @@ import com.pitchedapps.frost.facebook.parsers.MessageParser
import com.pitchedapps.frost.facebook.parsers.NotifParser
import com.pitchedapps.frost.facebook.parsers.SearchParser
import com.pitchedapps.frost.utils.L
import com.pitchedapps.frost.utils.Prefs
import com.pitchedapps.frost.utils.frostUriFromFile
import com.pitchedapps.frost.utils.sendFrostEmail
import java.io.File
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.launch
import java.io.File
/**
* Created by Allan Wang on 2017-06-30.

View File

@ -185,7 +185,7 @@ fun SettingsActivity.getNotificationPrefs(): KPrefAdapterBuilder.() -> Unit = {
plainText(R.string.reset_notif_epoch) {
onClick = {
launch {
FrostDatabase.get().notifDao().deleteAll()
notifDao.deleteAll()
}
}
}

View File

@ -31,6 +31,7 @@ import com.pitchedapps.frost.enums.MainActivityLayout
import com.pitchedapps.frost.enums.Theme
import com.pitchedapps.frost.injectors.InjectorContract
import org.koin.core.context.GlobalContext
import org.koin.core.context.KoinContextHandler
import org.koin.dsl.module
/**
@ -202,7 +203,7 @@ class Prefs(factory: KPrefFactory) : KPref("${BuildConfig.APPLICATION_ID}.prefs"
get() = MainActivityLayout(mainActivityLayoutType)
companion object {
fun get(): Prefs = GlobalContext.get().koin.get()
fun get(): Prefs = KoinContextHandler.get().get()
fun module() = module {
single { Prefs(get()) }

View File

@ -125,9 +125,9 @@ fun Activity.cookies(): ArrayList<CookieEntity> {
*/
private inline fun <reified T : WebOverlayActivityBase> Context.launchWebOverlayImpl(
url: String,
fbCookie: FbCookie
fbCookie: FbCookie,
prefs: Prefs
) {
val prefs = Prefs.get()
val argUrl = url.formattedFbUrl
L.v { "Launch received: $url\nLaunch web overlay: $argUrl" }
if (argUrl.isFacebookUrl && argUrl.contains("/logout.php")) {
@ -142,15 +142,15 @@ private inline fun <reified T : WebOverlayActivityBase> Context.launchWebOverlay
}
}
fun Context.launchWebOverlay(url: String, fbCookie: FbCookie) =
launchWebOverlayImpl<WebOverlayActivity>(url, fbCookie)
fun Context.launchWebOverlay(url: String, fbCookie: FbCookie, prefs: Prefs) =
launchWebOverlayImpl<WebOverlayActivity>(url, fbCookie, prefs)
// TODO Currently, default is overlay. Switch this if default changes
fun Context.launchWebOverlayDesktop(url: String, fbCookie: FbCookie) =
launchWebOverlay(url, fbCookie)
fun Context.launchWebOverlayDesktop(url: String, fbCookie: FbCookie, prefs: Prefs) =
launchWebOverlay(url, fbCookie, prefs)
fun Context.launchWebOverlayMobile(url: String, fbCookie: FbCookie) =
launchWebOverlayImpl<WebOverlayMobileActivity>(url, fbCookie)
fun Context.launchWebOverlayMobile(url: String, fbCookie: FbCookie, prefs: Prefs) =
launchWebOverlayImpl<WebOverlayMobileActivity>(url, fbCookie, prefs)
private fun Context.fadeBundle() = ActivityOptions.makeCustomAnimation(
this,
@ -178,8 +178,7 @@ fun WebOverlayActivity.url(): String {
return intent.getStringExtra(ARG_URL) ?: FbItem.FEED.url
}
fun Activity.setFrostTheme(forceTransparent: Boolean = false) {
val prefs = Prefs.get()
fun Activity.setFrostTheme(prefs: Prefs, forceTransparent: Boolean = false) {
val isTransparent =
forceTransparent || (Color.alpha(prefs.bgColor) != 255) || (Color.alpha(prefs.headerColor) != 255)
if (prefs.bgColor.isColorDark) {
@ -267,8 +266,7 @@ private inline fun frostSnackbar(crossinline builder: Snackbar.() -> Unit): Snac
}
}
fun Activity.frostNavigationBar() {
val prefs = Prefs.get()
fun Activity.frostNavigationBar(prefs: Prefs) {
navigationBarColor = if (prefs.tintNavBar) prefs.headerColor else Color.BLACK
}

View File

@ -71,7 +71,7 @@ enum class WebContextType(
OPEN_LINK(
R.string.open_link,
{ it.hasUrl },
{ c, wc, fc -> c.launchWebOverlay(wc.url!!, fc) }),
{ c, wc, fc -> c.launchWebOverlay(wc.url!!, fc, Prefs.get()) }),
COPY_LINK(R.string.copy_link, { it.hasUrl }, { c, wc, _ -> c.copyToClipboard(wc.url) }),
COPY_TEXT(R.string.copy_text, { it.hasText }, { c, wc, _ -> c.copyToClipboard(wc.text) }),
SHARE_LINK(R.string.share_link, { it.hasUrl }, { c, wc, _ -> c.shareText(wc.url) }),

View File

@ -41,7 +41,7 @@ import com.devbrackets.android.exomedia.listener.VideoControlsVisibilityListener
import com.mikepenz.iconics.typeface.library.googlematerial.GoogleMaterial
import com.pitchedapps.frost.R
import com.pitchedapps.frost.databinding.ViewVideoBinding
import com.pitchedapps.frost.db.FrostDatabase
import com.pitchedapps.frost.db.CookieDao
import com.pitchedapps.frost.db.currentCookie
import com.pitchedapps.frost.utils.L
import com.pitchedapps.frost.utils.Prefs
@ -88,6 +88,7 @@ class FrostVideoViewer @JvmOverloads constructor(
}
private val prefs: Prefs by inject()
private val cookieDao: CookieDao by inject()
private val binding: ViewVideoBinding =
ViewVideoBinding.inflate(LayoutInflater.from(context), this, true)
@ -116,8 +117,7 @@ class FrostVideoViewer @JvmOverloads constructor(
when (it.itemId) {
R.id.action_pip -> video.isExpanded = false
R.id.action_download -> context.ctxCoroutine.launchMain {
val cookie =
FrostDatabase.get().cookieDao().currentCookie() ?: return@launchMain
val cookie = cookieDao.currentCookie(prefs) ?: return@launchMain
context.frostDownload(cookie, video.videoUri)
}
}

View File

@ -28,6 +28,7 @@ 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.CookieDao
import com.pitchedapps.frost.db.FrostDatabase
import com.pitchedapps.frost.db.currentCookie
import com.pitchedapps.frost.facebook.FB_HOME_URL
@ -62,6 +63,7 @@ class FrostWebView @JvmOverloads constructor(
val fbCookie: FbCookie by inject()
val prefs: Prefs by inject()
val cookieDao: CookieDao by inject()
override fun reload(animate: Boolean) {
if (parent.registerTransition(false, animate))
@ -92,10 +94,9 @@ class FrostWebView @JvmOverloads constructor(
webChromeClient = FrostChromeClient(this)
addJavascriptInterface(FrostJSI(this), "Frost")
setBackgroundColor(Color.TRANSPARENT)
val db = FrostDatabase.get()
setDownloadListener { url, userAgent, contentDisposition, mimetype, contentLength ->
context.ctxCoroutine.launchMain {
val cookie = db.cookieDao().currentCookie() ?: return@launchMain
val cookie = cookieDao.currentCookie(prefs) ?: return@launchMain
context.frostDownload(
cookie,
url,

View File

@ -80,19 +80,19 @@ fun FrostWebView.requestWebOverlay(url: String): Boolean {
// already overlay; manage user agent
if (userAgentString != USER_AGENT_DESKTOP_CONST && shouldUseDesktop) {
L._i { "Switch to desktop agent overlay" }
context.launchWebOverlayDesktop(url, fbCookie)
context.launchWebOverlayDesktop(url, fbCookie, prefs)
return true
}
if (userAgentString == USER_AGENT_DESKTOP_CONST && !shouldUseDesktop) {
L._i { "Switch from desktop agent" }
context.launchWebOverlayMobile(url, fbCookie)
context.launchWebOverlayMobile(url, fbCookie, prefs)
return true
}
L._i { "return false switch" }
return false
}
L.v { "Request web overlay passed" }
context.launchWebOverlay(url, fbCookie)
context.launchWebOverlay(url, fbCookie, prefs)
return true
}

View File

@ -18,10 +18,6 @@ buildscript {
wrapper.setDistributionType(Wrapper.DistributionType.ALL)
}
task clean(type: Delete) {
delete rootProject.buildDir
}
task generateChangelogMd() {
def changelog = kau.ChangelogGenerator.generate("${project.rootDir}/app/src/main/res/xml/frost_changelog.xml", "${project.rootDir}/docs/Changelog.md")
// If we have no changelog, something is wrong

View File

@ -14,9 +14,7 @@ object Versions {
const val mockk = "1.9.3"
// https://github.com/jhy/jsoup/releases
const val jsoup = "1.12.1"
// https://square.github.io/leakcanary/changelog/
const val leakCanary = "2.2"
const val jsoup = "1.13.1"
// https://square.github.io/okhttp/changelog/
const val okhttp = "4.3.1"
// https://developer.android.com/jetpack/androidx/releases/room
@ -25,6 +23,6 @@ object Versions {
const val roboelectric = "4.3"
// https://github.com/davemorrissey/subsampling-scale-image-view#quick-start
const val scaleImageView = "3.10.0"
// https://github.com/srs/gradle-node-plugin/releases
const val nodeGradle = "1.3.1"
// https://github.com/node-gradle/gradle-node-plugin/releases
const val nodeGradle = "2.2.3"
}

View File

@ -16,7 +16,7 @@ org.gradle.daemon = true
APP_ID=Frost
APP_GROUP=com.pitchedapps
KAU=5038b93
KAU=33e117a
android.useAndroidX=true
android.enableJetifier=true

View File

@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.1-all.zip