From 2afb85489e30ce9823234715c32db80cd722677d Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Tue, 6 Aug 2019 21:48:07 -0700 Subject: Disable more components if web only --- .../com/pitchedapps/frost/activities/BaseMainActivity.kt | 11 +++++------ .../kotlin/com/pitchedapps/frost/fragments/FragmentBase.kt | 2 +- .../com/pitchedapps/frost/services/FrostRequestService.kt | 7 ++++++- .../com/pitchedapps/frost/services/NotificationService.kt | 4 ++++ 4 files changed, 16 insertions(+), 8 deletions(-) (limited to 'app/src/main/kotlin/com') 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 05321b69..292db7cc 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt @@ -635,12 +635,11 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract, override fun getPageTitle(position: Int): CharSequence = getString(pages[position].titleId) override fun getItemPosition(fragment: Any) = - if (fragment !is BaseFragment) - POSITION_UNCHANGED - else if (fragment is WebFragment || fragment.valid) - POSITION_UNCHANGED - else - POSITION_NONE + when { + fragment !is BaseFragment -> POSITION_UNCHANGED + fragment is WebFragment || fragment.valid -> POSITION_UNCHANGED + else -> POSITION_NONE + } } override val lowerVideoPadding: PointF diff --git a/app/src/main/kotlin/com/pitchedapps/frost/fragments/FragmentBase.kt b/app/src/main/kotlin/com/pitchedapps/frost/fragments/FragmentBase.kt index 55fbcd40..c580c9ed 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/fragments/FragmentBase.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/fragments/FragmentBase.kt @@ -67,7 +67,7 @@ abstract class BaseFragment : Fragment(), CoroutineScope, FragmentContract, Dyna data: FbItem, position: Int ): BaseFragment { - val fragment = if (!useFallback) base() else WebFragment() + val fragment = if (useFallback || Prefs.webOnly) WebFragment() else base() val d = if (data == FbItem.FEED) FeedSort(Prefs.feedSort).item else data fragment.withArguments( ARG_URL to d.url, diff --git a/app/src/main/kotlin/com/pitchedapps/frost/services/FrostRequestService.kt b/app/src/main/kotlin/com/pitchedapps/frost/services/FrostRequestService.kt index 0d707dae..fe59c421 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/services/FrostRequestService.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/services/FrostRequestService.kt @@ -31,6 +31,7 @@ import com.pitchedapps.frost.utils.EnumBundle import com.pitchedapps.frost.utils.EnumBundleCompanion import com.pitchedapps.frost.utils.EnumCompanion import com.pitchedapps.frost.utils.L +import com.pitchedapps.frost.utils.Prefs import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch @@ -162,13 +163,17 @@ class FrostRequestService : BaseJobService() { override fun onStartJob(params: JobParameters?): Boolean { super.onStartJob(params) + if (Prefs.webOnly) { + L.i { "Web only; skipping request service" } + return false + } val bundle = params?.extras if (bundle == null) { L.eThrow("Launched ${this::class.java.simpleName} without param data") return false } val cookie = bundle.getCookie() - if (cookie.isNullOrBlank()) { + if (cookie.isBlank()) { L.eThrow("Launched ${this::class.java.simpleName} without cookie") return false } 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 95726974..091fbb4b 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt @@ -72,6 +72,10 @@ class NotificationService : BaseJobService() { override fun onStartJob(params: JobParameters?): Boolean { super.onStartJob(params) L.i { "Fetching notifications" } + if (Prefs.webOnly) { + L.i { "Web only mode; skipping notification service" } + return false + } launch { try { sendNotifications(params) -- cgit v1.2.3