From a93cdf52cc3b7eff1e2d4cf436b8f8dbc3cf14a2 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sat, 29 Feb 2020 18:37:09 -0800 Subject: Update versions --- .idea/jarRepositories.xml | 30 ++++++++++++++++++++++++++++++ app/build.gradle | 14 +++++++------- build.gradle | 4 ---- buildSrc/src/main/kotlin/Versions.kt | 6 +++--- gradle.properties | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- 6 files changed, 42 insertions(+), 16 deletions(-) create mode 100644 .idea/jarRepositories.xml diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 00000000..eb2873e7 --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 63ada71b..ca23c928 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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") } diff --git a/build.gradle b/build.gradle index cc64b047..2faeee34 100644 --- a/build.gradle +++ b/build.gradle @@ -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 diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt index 75544cfb..dedca472 100644 --- a/buildSrc/src/main/kotlin/Versions.kt +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -14,7 +14,7 @@ object Versions { const val mockk = "1.9.3" // https://github.com/jhy/jsoup/releases - const val jsoup = "1.12.1" + const val jsoup = "1.13.1" // https://square.github.io/leakcanary/changelog/ const val leakCanary = "2.2" // https://square.github.io/okhttp/changelog/ @@ -25,6 +25,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" } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 1fe7b114..3060a721 100644 --- a/gradle.properties +++ b/gradle.properties @@ -16,7 +16,7 @@ org.gradle.daemon = true APP_ID=Frost APP_GROUP=com.pitchedapps -KAU=5038b93 +KAU=eb4c4ae android.useAndroidX=true android.enableJetifier=true diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index d31f47c5..beef26ac 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -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 -- cgit v1.2.3 From c5d38e5122bcb452b1e61ea6526434cf62e9da8c Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sat, 29 Feb 2020 19:29:09 -0800 Subject: Update koin usage --- .../pitchedapps/frost/activities/BaseActivity.kt | 2 +- .../frost/activities/BaseMainActivity.kt | 12 ++++++------ .../pitchedapps/frost/activities/IntroActivity.kt | 2 +- .../frost/activities/SettingsActivity.kt | 6 ++++-- .../kotlin/com/pitchedapps/frost/db/CookiesDb.kt | 2 +- .../kotlin/com/pitchedapps/frost/db/Database.kt | 7 +------ .../kotlin/com/pitchedapps/frost/enums/Support.kt | 1 + .../frost/fragments/RecyclerFragments.kt | 2 +- .../com/pitchedapps/frost/iitems/GenericIItems.kt | 11 ++++++----- .../pitchedapps/frost/iitems/NotificationIItem.kt | 4 ++-- .../frost/services/FrostNotifications.kt | 10 +++++----- .../frost/services/NotificationService.kt | 7 ++++--- .../frost/services/NotificationUtils.kt | 5 ++--- .../com/pitchedapps/frost/settings/Appearance.kt | 8 ++++---- .../kotlin/com/pitchedapps/frost/settings/Debug.kt | 3 ++- .../pitchedapps/frost/settings/Notifications.kt | 2 +- .../kotlin/com/pitchedapps/frost/utils/Prefs.kt | 3 ++- .../kotlin/com/pitchedapps/frost/utils/Utils.kt | 22 ++++++++++------------ .../com/pitchedapps/frost/utils/WebContextMenu.kt | 2 +- .../pitchedapps/frost/views/FrostVideoViewer.kt | 6 +++--- .../com/pitchedapps/frost/views/FrostWebView.kt | 5 +++-- .../frost/web/FrostUrlOverlayValidator.kt | 6 +++--- 22 files changed, 64 insertions(+), 64 deletions(-) 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 af49cb33..f41f19e5 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseActivity.kt @@ -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() { 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 8d580ebd..bfb87a2f 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt @@ -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) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/IntroActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/IntroActivity.kt index d594963e..232fc56d 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/IntroActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/IntroActivity.kt @@ -114,7 +114,7 @@ class IntroActivity : KauBaseActivity(), ViewPager.PageTransformer, indicator.invalidate() } fragments.forEach { it.themeFragment() } - setFrostTheme(true) + setFrostTheme(prefs, true) } /** 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 55ff3fba..67f605be 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/SettingsActivity.kt @@ -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() { diff --git a/app/src/main/kotlin/com/pitchedapps/frost/db/CookiesDb.kt b/app/src/main/kotlin/com/pitchedapps/frost/db/CookiesDb.kt index 1b90b1e3..68e7e3de 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/db/CookiesDb.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/db/CookiesDb.kt @@ -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) = 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) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/db/Database.kt b/app/src/main/kotlin/com/pitchedapps/frost/db/Database.kt index e54daa69..9ceb05aa 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/db/Database.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/db/Database.kt @@ -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().notifDao() } single { get().genericDao() } } - - /** - * Get from koin - * For the most part, you can retrieve directly from other koin components - */ - fun get(): FrostDatabase = GlobalContext.get().koin.get() } } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/enums/Support.kt b/app/src/main/kotlin/com/pitchedapps/frost/enums/Support.kt index 23ea5a8f..1fa56f7e 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/enums/Support.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/enums/Support.kt @@ -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 /** diff --git a/app/src/main/kotlin/com/pitchedapps/frost/fragments/RecyclerFragments.kt b/app/src/main/kotlin/com/pitchedapps/frost/fragments/RecyclerFragments.kt index 35b390c4..b282b36c 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/fragments/RecyclerFragments.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/fragments/RecyclerFragments.kt @@ -40,6 +40,6 @@ class NotificationFragment : FrostParserFragment response.data.notifs.map { NotificationIItem(it, response.cookie) } override fun bindImpl(recyclerView: FrostRecyclerView) { - NotificationIItem.bindEvents(adapter, fbCookie) + NotificationIItem.bindEvents(adapter, fbCookie, prefs) } } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/iitems/GenericIItems.kt b/app/src/main/kotlin/com/pitchedapps/frost/iitems/GenericIItems.kt index 1262c078..5257be5e 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/iitems/GenericIItems.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/iitems/GenericIItems.kt @@ -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, fbCookie: FbCookie) { + fun bindEvents(adapter: IAdapter, 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(R.layout.iitem_header, ::ViewHolder, itemId) { - class ViewHolder(itemView: View) : FastAdapter.ViewHolder(itemView), KoinComponent { + class ViewHolder(itemView: View) : FastAdapter.ViewHolder(itemView), + KoinComponent { private val prefs: Prefs by inject() 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 8624fff0..9d3b59eb 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/iitems/NotificationIItem.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/iitems/NotificationIItem.kt @@ -51,7 +51,7 @@ class NotificationIItem(val notification: FrostNotif, val cookie: String) : ) { companion object { - fun bindEvents(adapter: ItemAdapter, fbCookie: FbCookie) { + fun bindEvents(adapter: ItemAdapter, 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 } } 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 7b20e07c..5b62a4ed 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt @@ -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 } 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 73c97b5e..4c80f63d 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt @@ -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()) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationUtils.kt b/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationUtils.kt index 5f01dfd2..60cf874f 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationUtils.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationUtils.kt @@ -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 diff --git a/app/src/main/kotlin/com/pitchedapps/frost/settings/Appearance.kt b/app/src/main/kotlin/com/pitchedapps/frost/settings/Appearance.kt index 8c83850b..65e24ab8 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Appearance.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Appearance.kt @@ -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 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 9a4751b8..834a78fd 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Debug.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Debug.kt @@ -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. diff --git a/app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt b/app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt index 06159ba5..2aaea4b0 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt @@ -185,7 +185,7 @@ fun SettingsActivity.getNotificationPrefs(): KPrefAdapterBuilder.() -> Unit = { plainText(R.string.reset_notif_epoch) { onClick = { launch { - FrostDatabase.get().notifDao().deleteAll() + notifDao.deleteAll() } } } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt index 8052533b..36e3971a 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt @@ -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()) } 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 1f266eb9..6db7179d 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt @@ -125,9 +125,9 @@ fun Activity.cookies(): ArrayList { */ private inline fun 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 Context.launchWebOverlay } } -fun Context.launchWebOverlay(url: String, fbCookie: FbCookie) = - launchWebOverlayImpl(url, fbCookie) +fun Context.launchWebOverlay(url: String, fbCookie: FbCookie, prefs: Prefs) = + launchWebOverlayImpl(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(url, fbCookie) +fun Context.launchWebOverlayMobile(url: String, fbCookie: FbCookie, prefs: Prefs) = + launchWebOverlayImpl(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 } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/WebContextMenu.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/WebContextMenu.kt index d6e8f9e9..2e5d2fce 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/WebContextMenu.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/WebContextMenu.kt @@ -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) }), 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 16df7f8e..ec822bfa 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoViewer.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoViewer.kt @@ -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) } } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostWebView.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostWebView.kt index dd31d303..9ca622a3 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostWebView.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostWebView.kt @@ -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, 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 b4dd93da..d08f80a6 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt @@ -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 } -- cgit v1.2.3 From 551dbbcf1a56c33c378d6edfc3a3615311867001 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sat, 29 Feb 2020 22:26:01 -0800 Subject: Update travis and kau --- .travis.yml | 2 +- app/build.gradle | 2 +- buildSrc/src/main/kotlin/Versions.kt | 2 -- gradle.properties | 2 +- 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 49c54d02..52bd3470 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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: diff --git a/app/build.gradle b/app/build.gradle index ca23c928..ac93a214 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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 diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt index dedca472..3e33e6f1 100644 --- a/buildSrc/src/main/kotlin/Versions.kt +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -15,8 +15,6 @@ object Versions { // https://github.com/jhy/jsoup/releases const val jsoup = "1.13.1" - // https://square.github.io/leakcanary/changelog/ - const val leakCanary = "2.2" // https://square.github.io/okhttp/changelog/ const val okhttp = "4.3.1" // https://developer.android.com/jetpack/androidx/releases/room diff --git a/gradle.properties b/gradle.properties index 3060a721..bec7b586 100644 --- a/gradle.properties +++ b/gradle.properties @@ -16,7 +16,7 @@ org.gradle.daemon = true APP_ID=Frost APP_GROUP=com.pitchedapps -KAU=eb4c4ae +KAU=33e117a android.useAndroidX=true android.enableJetifier=true -- cgit v1.2.3