2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-02 03:40:16 +00:00

Merge pull request #1842 from boek/i1840-collections_featureflag

For #1840 - Adds a save tab group button and puts it behind a feature  flag
This commit is contained in:
Jeff Boek 2019-04-20 14:15:18 -07:00 committed by GitHub
parent 7c00c2983b
commit f19a773ab9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 23 additions and 18 deletions

View File

@ -149,6 +149,8 @@ android.applicationVariants.all { variant ->
def buildType = variant.buildType.name
buildConfigField 'Boolean', 'COLLECTIONS_ENABLED', (buildType != "release").toString()
if (buildType == "release") {
def versionCode = generatedVersionCode
@ -358,7 +360,7 @@ dependencies {
}
androidTestImplementation Deps.espresso_idling_resources
androidTestImplementation Deps.tools_test_runner
androidTestImplementation Deps.tools_test_rules
androidTestUtil Deps.orchestrator

View File

@ -176,7 +176,7 @@ class HomeFragment : Fragment(), CoroutineScope {
@SuppressWarnings("ComplexMethod")
private fun handleTabAction(action: TabAction) {
Do exhaustive when (action) {
is TabAction.Archive -> {}
is TabAction.SaveTabGroup -> {}
is TabAction.MenuTapped -> {
val isPrivate = (activity as HomeActivity).browsingModeManager.isPrivate
val titles = requireComponents.core.sessionManager.sessions

View File

@ -9,7 +9,7 @@ import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import io.reactivex.Observer
import kotlinx.coroutines.Job
import org.mozilla.fenix.home.sessioncontrol.viewholders.ArchiveTabsViewHolder
import org.mozilla.fenix.home.sessioncontrol.viewholders.SaveTabGroupViewHolder
import org.mozilla.fenix.home.sessioncontrol.viewholders.DeleteTabsViewHolder
import org.mozilla.fenix.home.sessioncontrol.viewholders.NoTabMessageViewHolder
import org.mozilla.fenix.home.sessioncontrol.viewholders.PrivateBrowsingDescriptionViewHolder
@ -22,7 +22,7 @@ sealed class AdapterItem {
object NoTabMessage : AdapterItem()
data class TabItem(val tab: Tab) : AdapterItem()
object PrivateBrowsingDescription : AdapterItem()
object ArchiveTabs : AdapterItem()
object SaveTabGroup : AdapterItem()
object DeleteTabs : AdapterItem()
val viewType: Int
@ -30,7 +30,7 @@ sealed class AdapterItem {
TabHeader -> TabHeaderViewHolder.LAYOUT_ID
NoTabMessage -> NoTabMessageViewHolder.LAYOUT_ID
is TabItem -> TabViewHolder.LAYOUT_ID
ArchiveTabs -> ArchiveTabsViewHolder.LAYOUT_ID
SaveTabGroup -> SaveTabGroupViewHolder.LAYOUT_ID
PrivateBrowsingDescription -> PrivateBrowsingDescriptionViewHolder.LAYOUT_ID
DeleteTabs -> DeleteTabsViewHolder.LAYOUT_ID
}
@ -56,7 +56,7 @@ class SessionControlAdapter(
TabHeaderViewHolder.LAYOUT_ID -> TabHeaderViewHolder(view, actionEmitter)
NoTabMessageViewHolder.LAYOUT_ID -> NoTabMessageViewHolder(view)
TabViewHolder.LAYOUT_ID -> TabViewHolder(view, actionEmitter, job)
ArchiveTabsViewHolder.LAYOUT_ID -> ArchiveTabsViewHolder(view, actionEmitter)
SaveTabGroupViewHolder.LAYOUT_ID -> SaveTabGroupViewHolder(view, actionEmitter)
PrivateBrowsingDescriptionViewHolder.LAYOUT_ID -> PrivateBrowsingDescriptionViewHolder(
view,
actionEmitter

View File

@ -60,7 +60,7 @@ data class SessionControlState(
) : ViewState
sealed class TabAction : Action {
object Archive : TabAction()
object SaveTabGroup : TabAction()
object MenuTapped : TabAction()
object Add : TabAction()
data class CloseAll(val private: Boolean) : TabAction()

View File

@ -14,6 +14,7 @@ import io.reactivex.functions.Consumer
import org.mozilla.fenix.R
import org.mozilla.fenix.mvi.UIView
import androidx.recyclerview.widget.ItemTouchHelper
import org.mozilla.fenix.BuildConfig
// Convert HomeState into a data structure HomeAdapter understands
@SuppressWarnings("ComplexMethod")
@ -25,6 +26,8 @@ private fun SessionControlState.toAdapterList(): List<AdapterItem> {
tabs.reversed().map(AdapterItem::TabItem).forEach { items.add(it) }
if (mode == Mode.Private) {
items.add(AdapterItem.DeleteTabs)
} else if (BuildConfig.COLLECTIONS_ENABLED) {
items.add(AdapterItem.SaveTabGroup)
}
} else {
val item = if (mode == Mode.Private) AdapterItem.PrivateBrowsingDescription

View File

@ -7,24 +7,24 @@ package org.mozilla.fenix.home.sessioncontrol.viewholders
import android.view.View
import androidx.recyclerview.widget.RecyclerView
import io.reactivex.Observer
import kotlinx.android.synthetic.main.archive_tabs_button.view.*
import kotlinx.android.synthetic.main.save_tab_group_button.view.*
import org.mozilla.fenix.R
import org.mozilla.fenix.home.sessioncontrol.SessionControlAction
import org.mozilla.fenix.home.sessioncontrol.TabAction
import org.mozilla.fenix.home.sessioncontrol.onNext
class ArchiveTabsViewHolder(
class SaveTabGroupViewHolder(
view: View,
private val actionEmitter: Observer<SessionControlAction>
) : RecyclerView.ViewHolder(view) {
init {
view.save_session_button.setOnClickListener {
actionEmitter.onNext(TabAction.Archive)
view.save_tab_group_button.setOnClickListener {
actionEmitter.onNext(TabAction.SaveTabGroup)
}
}
companion object {
const val LAYOUT_ID = R.layout.archive_tabs_button
const val LAYOUT_ID = R.layout.save_tab_group_button
}
}

View File

@ -4,7 +4,7 @@
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/save_session_button"
android:id="@+id/save_tab_group_button"
android:layout_width="match_parent"
android:layout_height="36dp"
android:layout_marginTop="16dp"
@ -17,7 +17,7 @@
android:padding="6dp">
<TextView
android:id="@+id/save_session_button_text"
android:id="@+id/save_tab_group_button_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
@ -28,6 +28,6 @@
android:focusable="false"
android:gravity="center"
android:textStyle="bold"
android:text="@string/session_save"
android:text="@string/save_tab_group"
android:textColor="@color/foundation_light_theme"/>
</FrameLayout>

View File

@ -242,8 +242,8 @@
<string name="current_session_share">Share</string>
<!-- Content description (not visible, for screen readers etc.): Title icon for current session menu -->
<string name="current_session_image">Current session image</string>
<!-- Text for the button to save a session -->
<string name="session_save">Save session</string>
<!-- Button to save the current set of tabs into a group -->
<string name="save_tab_group">Save Tab Group</string>
<!-- Text for the button to delete a session -->
<string name="session_delete">Delete session</string>
<!-- Text for the button to delete a single session -->
@ -401,7 +401,7 @@
<!-- Summary of tracking protection preference if tracking protection is set to off -->
<string name="tracking_protection_off">Off</string>
<!-- DEPRECATED -->
<string name="tabs_header_title">DEPRECATED</string>
<string name="session_save">DEPRECATED</string>
</resources>