Closes #908, Closes #910, Closes #911, Closes #912 Co-authored-by: Jonathan Almeida <jalmeida@mozilla.com>master
parent
49ac75c8b2
commit
9b0422b062
|
@ -287,6 +287,7 @@ dependencies {
|
||||||
implementation Deps.mozilla_feature_findinpage
|
implementation Deps.mozilla_feature_findinpage
|
||||||
implementation Deps.mozilla_feature_session_bundling
|
implementation Deps.mozilla_feature_session_bundling
|
||||||
implementation Deps.mozilla_feature_site_permissions
|
implementation Deps.mozilla_feature_site_permissions
|
||||||
|
implementation Deps.mozilla_feature_readerview
|
||||||
|
|
||||||
implementation Deps.mozilla_service_firefox_accounts
|
implementation Deps.mozilla_service_firefox_accounts
|
||||||
implementation Deps.mozilla_service_fretboard
|
implementation Deps.mozilla_service_fretboard
|
||||||
|
|
|
@ -39,6 +39,7 @@ import mozilla.components.feature.contextmenu.ContextMenuFeature
|
||||||
import mozilla.components.feature.downloads.DownloadsFeature
|
import mozilla.components.feature.downloads.DownloadsFeature
|
||||||
import mozilla.components.feature.intent.IntentProcessor
|
import mozilla.components.feature.intent.IntentProcessor
|
||||||
import mozilla.components.feature.prompts.PromptFeature
|
import mozilla.components.feature.prompts.PromptFeature
|
||||||
|
import mozilla.components.feature.readerview.ReaderViewFeature
|
||||||
import mozilla.components.feature.session.FullScreenFeature
|
import mozilla.components.feature.session.FullScreenFeature
|
||||||
import mozilla.components.feature.session.SessionFeature
|
import mozilla.components.feature.session.SessionFeature
|
||||||
import mozilla.components.feature.session.SessionUseCases
|
import mozilla.components.feature.session.SessionUseCases
|
||||||
|
@ -101,6 +102,7 @@ class BrowserFragment : Fragment(), BackHandler, CoroutineScope,
|
||||||
private val promptsFeature = ViewBoundFeatureWrapper<PromptFeature>()
|
private val promptsFeature = ViewBoundFeatureWrapper<PromptFeature>()
|
||||||
private val findInPageIntegration = ViewBoundFeatureWrapper<FindInPageIntegration>()
|
private val findInPageIntegration = ViewBoundFeatureWrapper<FindInPageIntegration>()
|
||||||
private val toolbarIntegration = ViewBoundFeatureWrapper<ToolbarIntegration>()
|
private val toolbarIntegration = ViewBoundFeatureWrapper<ToolbarIntegration>()
|
||||||
|
private val readerViewFeature = ViewBoundFeatureWrapper<ReaderViewFeature>()
|
||||||
private val sitePermissionsFeature = ViewBoundFeatureWrapper<SitePermissionsFeature>()
|
private val sitePermissionsFeature = ViewBoundFeatureWrapper<SitePermissionsFeature>()
|
||||||
private val fullScreenFeature = ViewBoundFeatureWrapper<FullScreenFeature>()
|
private val fullScreenFeature = ViewBoundFeatureWrapper<FullScreenFeature>()
|
||||||
private val thumbnailsFeature = ViewBoundFeatureWrapper<ThumbnailsFeature>()
|
private val thumbnailsFeature = ViewBoundFeatureWrapper<ThumbnailsFeature>()
|
||||||
|
@ -286,6 +288,24 @@ class BrowserFragment : Fragment(), BackHandler, CoroutineScope,
|
||||||
view = view
|
view = view
|
||||||
)
|
)
|
||||||
|
|
||||||
|
readerViewFeature.set(
|
||||||
|
feature = ReaderViewFeature(
|
||||||
|
requireContext(),
|
||||||
|
requireComponents.core.engine,
|
||||||
|
requireComponents.core.sessionManager,
|
||||||
|
view.readerViewControlsBar
|
||||||
|
) {
|
||||||
|
getManagedEmitter<QuickActionChange>().apply {
|
||||||
|
onNext(QuickActionChange.ReadableStateChange(it))
|
||||||
|
onNext(QuickActionChange.ReaderActiveStateChange(
|
||||||
|
sessionManager.selectedSession?.readerMode ?: false)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
owner = this,
|
||||||
|
view = view
|
||||||
|
)
|
||||||
|
|
||||||
val actionEmitter = ActionBusFactory.get(this).getManagedEmitter(SearchAction::class.java)
|
val actionEmitter = ActionBusFactory.get(this).getManagedEmitter(SearchAction::class.java)
|
||||||
|
|
||||||
customTabSessionId?.let {
|
customTabSessionId?.let {
|
||||||
|
@ -380,8 +400,24 @@ class BrowserFragment : Fragment(), BackHandler, CoroutineScope,
|
||||||
bookmarkTapped()
|
bookmarkTapped()
|
||||||
}
|
}
|
||||||
is QuickActionAction.ReadPressed -> {
|
is QuickActionAction.ReadPressed -> {
|
||||||
requireComponents.analytics.metrics.track(Event.QuickActionSheetReadTapped)
|
readerViewFeature.withFeature { feature ->
|
||||||
ItsNotBrokenSnack(context!!).showSnackbar(issueNumber = "908")
|
requireComponents.analytics.metrics.track(Event.QuickActionSheetReadTapped)
|
||||||
|
val actionEmitter = getManagedEmitter<QuickActionChange>()
|
||||||
|
val enabled = requireComponents.core.sessionManager.selectedSession?.readerMode ?: false
|
||||||
|
if (enabled) {
|
||||||
|
feature.hideReaderView()
|
||||||
|
actionEmitter.onNext(QuickActionChange.ReaderActiveStateChange(false))
|
||||||
|
} else {
|
||||||
|
feature.showReaderView()
|
||||||
|
actionEmitter.onNext(QuickActionChange.ReaderActiveStateChange(true))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
is QuickActionAction.ReadAppearancePressed -> {
|
||||||
|
// TODO telemetry: https://github.com/mozilla-mobile/fenix/issues/2267
|
||||||
|
readerViewFeature.withFeature { feature ->
|
||||||
|
feature.showControls()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -454,6 +490,7 @@ class BrowserFragment : Fragment(), BackHandler, CoroutineScope,
|
||||||
return when {
|
return when {
|
||||||
findInPageIntegration.onBackPressed() -> true
|
findInPageIntegration.onBackPressed() -> true
|
||||||
fullScreenFeature.onBackPressed() -> true
|
fullScreenFeature.onBackPressed() -> true
|
||||||
|
readerViewFeature.onBackPressed() -> true
|
||||||
sessionFeature.onBackPressed() -> true
|
sessionFeature.onBackPressed() -> true
|
||||||
else -> false
|
else -> false
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,8 @@ class QuickActionComponent(
|
||||||
bus: ActionBusFactory,
|
bus: ActionBusFactory,
|
||||||
override var initialState: QuickActionState = QuickActionState(
|
override var initialState: QuickActionState = QuickActionState(
|
||||||
readable = false,
|
readable = false,
|
||||||
bookmarked = false
|
bookmarked = false,
|
||||||
|
readerActive = false
|
||||||
)
|
)
|
||||||
) : UIComponent<QuickActionState, QuickActionAction, QuickActionChange>(
|
) : UIComponent<QuickActionState, QuickActionAction, QuickActionChange>(
|
||||||
bus.getManagedEmitter(QuickActionAction::class.java),
|
bus.getManagedEmitter(QuickActionAction::class.java),
|
||||||
|
@ -33,6 +34,9 @@ class QuickActionComponent(
|
||||||
is QuickActionChange.ReadableStateChange -> {
|
is QuickActionChange.ReadableStateChange -> {
|
||||||
state.copy(readable = change.readable)
|
state.copy(readable = change.readable)
|
||||||
}
|
}
|
||||||
|
is QuickActionChange.ReaderActiveStateChange -> {
|
||||||
|
state.copy(readerActive = change.active)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +48,7 @@ class QuickActionComponent(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
data class QuickActionState(val readable: Boolean, val bookmarked: Boolean) : ViewState
|
data class QuickActionState(val readable: Boolean, val bookmarked: Boolean, val readerActive: Boolean) : ViewState
|
||||||
|
|
||||||
sealed class QuickActionAction : Action {
|
sealed class QuickActionAction : Action {
|
||||||
object Opened : QuickActionAction()
|
object Opened : QuickActionAction()
|
||||||
|
@ -53,9 +57,11 @@ sealed class QuickActionAction : Action {
|
||||||
object DownloadsPressed : QuickActionAction()
|
object DownloadsPressed : QuickActionAction()
|
||||||
object BookmarkPressed : QuickActionAction()
|
object BookmarkPressed : QuickActionAction()
|
||||||
object ReadPressed : QuickActionAction()
|
object ReadPressed : QuickActionAction()
|
||||||
|
object ReadAppearancePressed : QuickActionAction()
|
||||||
}
|
}
|
||||||
|
|
||||||
sealed class QuickActionChange : Change {
|
sealed class QuickActionChange : Change {
|
||||||
data class BookmarkedStateChange(val bookmarked: Boolean) : QuickActionChange()
|
data class BookmarkedStateChange(val bookmarked: Boolean) : QuickActionChange()
|
||||||
data class ReadableStateChange(val readable: Boolean) : QuickActionChange()
|
data class ReadableStateChange(val readable: Boolean) : QuickActionChange()
|
||||||
|
data class ReaderActiveStateChange(val active: Boolean) : QuickActionChange()
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,6 +78,10 @@ class QuickActionUIView(
|
||||||
actionEmitter.onNext(QuickActionAction.ReadPressed)
|
actionEmitter.onNext(QuickActionAction.ReadPressed)
|
||||||
quickActionSheetBehavior.state = BottomSheetBehavior.STATE_COLLAPSED
|
quickActionSheetBehavior.state = BottomSheetBehavior.STATE_COLLAPSED
|
||||||
}
|
}
|
||||||
|
view.quick_action_read_appearance.setOnClickListener {
|
||||||
|
actionEmitter.onNext(QuickActionAction.ReadAppearancePressed)
|
||||||
|
quickActionSheetBehavior.state = BottomSheetBehavior.STATE_COLLAPSED
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -105,7 +109,16 @@ class QuickActionUIView(
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun updateView() = Consumer<QuickActionState> {
|
override fun updateView() = Consumer<QuickActionState> {
|
||||||
view.quick_action_read.visibility = if (it.readable) View.VISIBLE else View.GONE
|
view.quick_action_read.apply {
|
||||||
|
visibility = if (it.readable) View.VISIBLE else View.GONE
|
||||||
|
isSelected = it.readerActive
|
||||||
|
text = if (it.readerActive) {
|
||||||
|
context.getString(R.string.quick_action_read_close)
|
||||||
|
} else {
|
||||||
|
context.getString(R.string.quick_action_read)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
view.quick_action_read_appearance.visibility = if (it.readerActive) View.VISIBLE else View.GONE
|
||||||
view.quick_action_bookmark.isSelected = it.bookmarked
|
view.quick_action_bookmark.isSelected = it.bookmarked
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,10 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:state_selected="false"
|
||||||
|
android:drawable="@drawable/quick_action_icon_read" />
|
||||||
|
<item android:state_selected="true"
|
||||||
|
android:drawable="@drawable/quick_action_icon_close" />
|
||||||
|
</selector>
|
|
@ -38,4 +38,13 @@
|
||||||
mozac:findInPageButtonsTint="?primaryText"
|
mozac:findInPageButtonsTint="?primaryText"
|
||||||
mozac:findInPageResultCountTextColor="?primaryText" />
|
mozac:findInPageResultCountTextColor="?primaryText" />
|
||||||
|
|
||||||
|
<mozilla.components.feature.readerview.view.ReaderViewControlsBar
|
||||||
|
android:id="@+id/readerViewControlsBar"
|
||||||
|
android:background="?foundation"
|
||||||
|
android:elevation="24dp"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:layout_gravity="bottom"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
|
@ -77,13 +77,27 @@
|
||||||
android:textColor="?primaryText"
|
android:textColor="?primaryText"
|
||||||
android:textSize="12sp" />
|
android:textSize="12sp" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/quick_action_read_appearance"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:background="?selectableItemBackgroundBorderless"
|
||||||
|
android:drawableTop="@drawable/quick_action_icon_appearance"
|
||||||
|
android:drawablePadding="5dp"
|
||||||
|
android:text="@string/quick_action_read_appearance"
|
||||||
|
android:textAllCaps="false"
|
||||||
|
android:textColor="?primaryText"
|
||||||
|
android:textSize="12sp"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/quick_action_read"
|
android:id="@+id/quick_action_read"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:background="?selectableItemBackgroundBorderless"
|
android:background="?selectableItemBackgroundBorderless"
|
||||||
android:drawableTop="@drawable/quick_action_icon_read"
|
android:drawableTop="@drawable/reader_two_state"
|
||||||
android:drawablePadding="5dp"
|
android:drawablePadding="5dp"
|
||||||
android:text="@string/quick_action_read"
|
android:text="@string/quick_action_read"
|
||||||
android:textAllCaps="false"
|
android:textAllCaps="false"
|
||||||
|
|
|
@ -21,4 +21,7 @@
|
||||||
<color name="scrimEnd_normal_theme">@color/scrimStart_dark_theme</color>
|
<color name="scrimEnd_normal_theme">@color/scrimStart_dark_theme</color>
|
||||||
<color name="toggle_off_knob_normal_theme">@color/toggle_off_knob_dark_theme</color>
|
<color name="toggle_off_knob_normal_theme">@color/toggle_off_knob_dark_theme</color>
|
||||||
<color name="toggle_off_track_normal_theme">@color/toggle_off_track_dark_theme</color>
|
<color name="toggle_off_track_normal_theme">@color/toggle_off_track_dark_theme</color>
|
||||||
|
|
||||||
|
<!-- Reader View colors -->
|
||||||
|
<color name="mozac_feature_readerview_text_color">@color/primary_text_dark_theme</color>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -109,6 +109,12 @@
|
||||||
<color name="quick_action_read_icon">#8a201f</color>
|
<color name="quick_action_read_icon">#8a201f</color>
|
||||||
<color name="quick_action_read_icon_background">#fce98f</color>
|
<color name="quick_action_read_icon_background">#fce98f</color>
|
||||||
|
|
||||||
|
<color name="quick_action_reader_close_icon">#f9f9fb</color>
|
||||||
|
<color name="quick_action_reader_close_icon_background">#582bcb</color>
|
||||||
|
|
||||||
|
<color name="quick_action_reader_appearance_icon">#482166</color>
|
||||||
|
<color name="quick_action_reader_appearance_icon_background">#ecbcfb</color>
|
||||||
|
|
||||||
<!-- Toggle Colors -->
|
<!-- Toggle Colors -->
|
||||||
<color name="toggle_off_knob_light_theme">@color/photonGrey10</color>
|
<color name="toggle_off_knob_light_theme">@color/photonGrey10</color>
|
||||||
<color name="toggle_off_track_light_theme">@color/dark_grey_90</color>
|
<color name="toggle_off_track_light_theme">@color/dark_grey_90</color>
|
||||||
|
@ -124,4 +130,7 @@
|
||||||
<color name="light_grey_05">#FBFBFE</color>
|
<color name="light_grey_05">#FBFBFE</color>
|
||||||
<color name="dark_grey_90">#15141A</color>
|
<color name="dark_grey_90">#15141A</color>
|
||||||
<color name="neutral_text">@color/white_color</color>
|
<color name="neutral_text">@color/white_color</color>
|
||||||
|
|
||||||
|
<!-- Reader View colors -->
|
||||||
|
<color name="mozac_feature_readerview_text_color">@color/primary_text_light_theme</color>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -206,6 +206,10 @@
|
||||||
<string name="quick_action_bookmark">Bookmark</string>
|
<string name="quick_action_bookmark">Bookmark</string>
|
||||||
<!-- Button in the browser chrome in the browser to put the the current page in reader mode -->
|
<!-- Button in the browser chrome in the browser to put the the current page in reader mode -->
|
||||||
<string name="quick_action_read">Read</string>
|
<string name="quick_action_read">Read</string>
|
||||||
|
<!-- Button in the browser chrome to exit reader mode -->
|
||||||
|
<string name="quick_action_read_close">Close</string>
|
||||||
|
<!-- Button in the browser chrome to configure reader mode appearance e.g. the used font type and size -->
|
||||||
|
<string name="quick_action_read_appearance">Appearance</string>
|
||||||
<!-- Content description (not visible, for screen readers etc.): Quick action sheet handle to provide users
|
<!-- Content description (not visible, for screen readers etc.): Quick action sheet handle to provide users
|
||||||
with shortcuts to commonly used actions such as Share, Bookmark etc.. -->
|
with shortcuts to commonly used actions such as Share, Bookmark etc.. -->
|
||||||
<string name="quick_action_sheet_handle">Quick actions</string>
|
<string name="quick_action_sheet_handle">Quick actions</string>
|
||||||
|
@ -475,4 +479,5 @@
|
||||||
<!-- QR code scanner prompt which appears after scanning a code, but before navigating to it
|
<!-- QR code scanner prompt which appears after scanning a code, but before navigating to it
|
||||||
First parameter is the name of the app, second parameter is the URL or text scanned-->
|
First parameter is the name of the app, second parameter is the URL or text scanned-->
|
||||||
<string name="qr_scanner_confirmation_dialog_message">Allow %1$s to open %2$s</string>
|
<string name="qr_scanner_confirmation_dialog_message">Allow %1$s to open %2$s</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -103,6 +103,7 @@ object Deps {
|
||||||
const val mozilla_feature_findinpage = "org.mozilla.components:feature-findinpage:${Versions.mozilla_android_components}"
|
const val mozilla_feature_findinpage = "org.mozilla.components:feature-findinpage:${Versions.mozilla_android_components}"
|
||||||
const val mozilla_feature_session_bundling = "org.mozilla.components:feature-session-bundling:${Versions.mozilla_android_components}"
|
const val mozilla_feature_session_bundling = "org.mozilla.components:feature-session-bundling:${Versions.mozilla_android_components}"
|
||||||
const val mozilla_feature_site_permissions = "org.mozilla.components:feature-sitepermissions:${Versions.mozilla_android_components}"
|
const val mozilla_feature_site_permissions = "org.mozilla.components:feature-sitepermissions:${Versions.mozilla_android_components}"
|
||||||
|
const val mozilla_feature_readerview = "org.mozilla.components:feature-readerview:${Versions.mozilla_android_components}"
|
||||||
|
|
||||||
const val mozilla_service_firefox_accounts = "org.mozilla.components:service-firefox-accounts:${Versions.mozilla_android_components}"
|
const val mozilla_service_firefox_accounts = "org.mozilla.components:service-firefox-accounts:${Versions.mozilla_android_components}"
|
||||||
const val mozilla_service_fretboard = "org.mozilla.components:service-fretboard:${Versions.mozilla_android_components}"
|
const val mozilla_service_fretboard = "org.mozilla.components:service-fretboard:${Versions.mozilla_android_components}"
|
||||||
|
|
Loading…
Reference in New Issue