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

Add pref toggle

This commit is contained in:
Allan Wang 2019-08-04 23:39:00 -07:00
parent 2eacc8cb77
commit 74e0519987
No known key found for this signature in database
GPG Key ID: C93E3F9C679D7A56
3 changed files with 6 additions and 2 deletions

View File

@ -113,6 +113,7 @@ import kotlinx.android.synthetic.main.view_main_viewpager.*
import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import org.koin.android.ext.android.inject import org.koin.android.ext.android.inject
import kotlin.math.abs
/** /**
* Created by Allan Wang on 20/12/17. * Created by Allan Wang on 20/12/17.
@ -206,7 +207,7 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract,
fab.hide() fab.hide()
appBar.addOnOffsetChangedListener(AppBarLayout.OnOffsetChangedListener { appBarLayout, verticalOffset -> appBar.addOnOffsetChangedListener(AppBarLayout.OnOffsetChangedListener { appBarLayout, verticalOffset ->
if (!hasFab) return@OnOffsetChangedListener if (!hasFab) return@OnOffsetChangedListener
val percent = Math.abs(verticalOffset.toFloat() / appBarLayout.totalScrollRange) val percent = abs(verticalOffset.toFloat() / appBarLayout.totalScrollRange)
val shouldShow = percent < 0.2 val shouldShow = percent < 0.2
if (this.shouldShow != shouldShow) { if (this.shouldShow != shouldShow) {
this.shouldShow = shouldShow this.shouldShow = shouldShow

View File

@ -23,6 +23,7 @@ import com.pitchedapps.frost.contracts.MainFabContract
import com.pitchedapps.frost.facebook.FbItem import com.pitchedapps.frost.facebook.FbItem
import com.pitchedapps.frost.injectors.JsActions import com.pitchedapps.frost.injectors.JsActions
import com.pitchedapps.frost.utils.L import com.pitchedapps.frost.utils.L
import com.pitchedapps.frost.utils.Prefs
import com.pitchedapps.frost.views.FrostWebView import com.pitchedapps.frost.views.FrostWebView
import com.pitchedapps.frost.web.FrostWebViewClient import com.pitchedapps.frost.web.FrostWebViewClient
import com.pitchedapps.frost.web.FrostWebViewClientMenu import com.pitchedapps.frost.web.FrostWebViewClientMenu
@ -51,7 +52,7 @@ class WebFragment : BaseFragment() {
L.e { "Webview not found in fragment $baseEnum" } L.e { "Webview not found in fragment $baseEnum" }
return super.updateFab(contract) return super.updateFab(contract)
} }
if (baseEnum.isFeed) { if (baseEnum.isFeed && Prefs.showCreateFab) {
contract.showFab(GoogleMaterial.Icon.gmd_edit) { contract.showFab(GoogleMaterial.Icon.gmd_edit) {
JsActions.CREATE_POST.inject(web) JsActions.CREATE_POST.inject(web)
} }

View File

@ -189,6 +189,8 @@ object Prefs : KPref() {
var autoRefreshFeed: Boolean by kpref("auto_refresh_feed", false) var autoRefreshFeed: Boolean by kpref("auto_refresh_feed", false)
var showCreateFab: Boolean by kpref("show_create_fab", true)
inline val mainActivityLayout: MainActivityLayout inline val mainActivityLayout: MainActivityLayout
get() = MainActivityLayout(mainActivityLayoutType) get() = MainActivityLayout(mainActivityLayoutType)