#4596 migrate collections (#5911)
* For #4596: move code from CollectionCreationComponent to CollectionCreationStore
Other than adding comments, no changes were made. The code will be updated in a following commit. This is in order to make the commit diff more readable.
* For 4596: update CollectionCreateStore to libstate
* For 4596: copied CollectionCreationUIView into CollectionCreationView
Otherwise, no code was changed. The next commit will update this code. This is in order to make the commit diff more readable.
* For 4596: update CollectionCreationView to LibState
Note that the minimal changes possible to enable migration were made. Refactoring will happen in a later commit.
* For 4596: updated CollectionCreationTabListAdapter to work with the new View
* For 4596: updated SaveCollectionListAdapter to work with the new View
* For 4596: implemented CollectionCreationController
For now, it has an identical interface to the interactor. In a later commit several of its responsibilities will be moved around, some to the interactor and some to the reducer
* For 4596: copied over previous reducer code
No other changes were made. The code will be updated in the following commit. This is done to make changes more readable for the reviewer
* For 4596: update reducer code param names
Otherwise, no changes at this time
* For 4596: add arguments to CreateCollectionFragment in nav_graph
These will be used to replace the current CreateCollectionViewModel, which shares data between fragments in a way that doesn't fit within our architecture.
* For 4596: pass arguments to collection via transaction instead of VM
The VM will be removed in a later commit
* For 4596: update BrowserToolbarController to share state to collection via its Direction
* For 4596: removed CreateCollectionViewModel
* For 4596: test tab retrieval in CreateCollectionFragment
* For 4596: fix crashing CreateCollectionFragmentTest
* For 4596: removed classes create collection classes used by old architecture
* For 4596: collection interactor rename + kdoc
* For 4596: moved collection interactor interface
* For 4596: renamed CreateCollectionFragment
All related classes followed the pattern of CollectionCreationX
* For 4596: kdoc CollectionCreationController
There's no effective difference between these calls and their interactor equivalent, so I linked to them
* For 4596: fix bug that caused rename to not work
* For 4596: removed unused collection actions
These were unused before the LibState refactor
* For 4596: kdoc StepChanged
* For 4596: removed todos about moving logic to the reducer
saveTabsToCollection: this could be moved, but that would involve creating a new action. SaveCollectionStep should probably be refactored out, so adding this layer of indirection seemed counterproductive
handleBackPress: needs to be able to call dismiss(). The reducer doesn't (and shouldn't) be able to do that, so this needs to live here
stepBack: called by handleBackPress. See above
* For 4596: wrote tests for CollectionCreationController#stepback
* For 4596: fixed tests broken by changes to collections
* For 4596: small readability refactor for CollectionController#stepBack
No change to functionality (see tests)
* For 4596: broke apart CollectionView#update
There's probably a lot more that could be done here, but smaller changes were made to reduce scope
* For 4596: remove unnecessary todos
It looks like we don't follow the suggested pattern in this project
* For 4596: test CollectionCreationController#normalSessionSize
* For 4596: updated naming in CollectionCreationController per review
5 years ago
|
|
|
/* 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/. */
|
|
|
|
|
|
|
|
package org.mozilla.fenix.collections
|
|
|
|
|
|
|
|
import android.os.Handler
|
|
|
|
import android.text.InputFilter
|
|
|
|
import android.view.KeyEvent
|
|
|
|
import android.view.LayoutInflater
|
|
|
|
import android.view.View
|
|
|
|
import android.view.ViewGroup
|
|
|
|
import android.view.inputmethod.EditorInfo
|
|
|
|
import androidx.appcompat.content.res.AppCompatResources
|
#4596 migrate collections (#5911)
* For #4596: move code from CollectionCreationComponent to CollectionCreationStore
Other than adding comments, no changes were made. The code will be updated in a following commit. This is in order to make the commit diff more readable.
* For 4596: update CollectionCreateStore to libstate
* For 4596: copied CollectionCreationUIView into CollectionCreationView
Otherwise, no code was changed. The next commit will update this code. This is in order to make the commit diff more readable.
* For 4596: update CollectionCreationView to LibState
Note that the minimal changes possible to enable migration were made. Refactoring will happen in a later commit.
* For 4596: updated CollectionCreationTabListAdapter to work with the new View
* For 4596: updated SaveCollectionListAdapter to work with the new View
* For 4596: implemented CollectionCreationController
For now, it has an identical interface to the interactor. In a later commit several of its responsibilities will be moved around, some to the interactor and some to the reducer
* For 4596: copied over previous reducer code
No other changes were made. The code will be updated in the following commit. This is done to make changes more readable for the reviewer
* For 4596: update reducer code param names
Otherwise, no changes at this time
* For 4596: add arguments to CreateCollectionFragment in nav_graph
These will be used to replace the current CreateCollectionViewModel, which shares data between fragments in a way that doesn't fit within our architecture.
* For 4596: pass arguments to collection via transaction instead of VM
The VM will be removed in a later commit
* For 4596: update BrowserToolbarController to share state to collection via its Direction
* For 4596: removed CreateCollectionViewModel
* For 4596: test tab retrieval in CreateCollectionFragment
* For 4596: fix crashing CreateCollectionFragmentTest
* For 4596: removed classes create collection classes used by old architecture
* For 4596: collection interactor rename + kdoc
* For 4596: moved collection interactor interface
* For 4596: renamed CreateCollectionFragment
All related classes followed the pattern of CollectionCreationX
* For 4596: kdoc CollectionCreationController
There's no effective difference between these calls and their interactor equivalent, so I linked to them
* For 4596: fix bug that caused rename to not work
* For 4596: removed unused collection actions
These were unused before the LibState refactor
* For 4596: kdoc StepChanged
* For 4596: removed todos about moving logic to the reducer
saveTabsToCollection: this could be moved, but that would involve creating a new action. SaveCollectionStep should probably be refactored out, so adding this layer of indirection seemed counterproductive
handleBackPress: needs to be able to call dismiss(). The reducer doesn't (and shouldn't) be able to do that, so this needs to live here
stepBack: called by handleBackPress. See above
* For 4596: wrote tests for CollectionCreationController#stepback
* For 4596: fixed tests broken by changes to collections
* For 4596: small readability refactor for CollectionController#stepBack
No change to functionality (see tests)
* For 4596: broke apart CollectionView#update
There's probably a lot more that could be done here, but smaller changes were made to reduce scope
* For 4596: remove unnecessary todos
It looks like we don't follow the suggested pattern in this project
* For 4596: test CollectionCreationController#normalSessionSize
* For 4596: updated naming in CollectionCreationController per review
5 years ago
|
|
|
import androidx.constraintlayout.widget.ConstraintSet
|
|
|
|
import androidx.core.content.ContextCompat
|
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager
|
|
|
|
import androidx.recyclerview.widget.RecyclerView
|
|
|
|
import androidx.transition.AutoTransition
|
|
|
|
import androidx.transition.Transition
|
|
|
|
import androidx.transition.TransitionManager
|
|
|
|
import kotlinx.android.extensions.LayoutContainer
|
|
|
|
import kotlinx.android.synthetic.main.component_collection_creation.back_button
|
|
|
|
import kotlinx.android.synthetic.main.component_collection_creation.collection_constraint_layout
|
|
|
|
import kotlinx.android.synthetic.main.component_collection_creation.name_collection_edittext
|
|
|
|
import kotlinx.android.synthetic.main.component_collection_creation.save_button
|
|
|
|
import kotlinx.android.synthetic.main.component_collection_creation.select_all_button
|
|
|
|
import kotlinx.android.synthetic.main.component_collection_creation.view.bottom_bar_icon_button
|
|
|
|
import kotlinx.android.synthetic.main.component_collection_creation.view.bottom_bar_text
|
|
|
|
import kotlinx.android.synthetic.main.component_collection_creation.view.bottom_button_bar_layout
|
|
|
|
import kotlinx.android.synthetic.main.component_collection_creation.view.collection_constraint_layout
|
|
|
|
import kotlinx.android.synthetic.main.component_collection_creation.view.collections_list
|
|
|
|
import kotlinx.android.synthetic.main.component_collection_creation.view.name_collection_edittext
|
|
|
|
import kotlinx.android.synthetic.main.component_collection_creation.view.select_all_button
|
|
|
|
import kotlinx.android.synthetic.main.component_collection_creation.view.tab_list
|
|
|
|
import mozilla.components.browser.state.state.MediaState
|
|
|
|
import mozilla.components.feature.tab.collections.TabCollection
|
#4596 migrate collections (#5911)
* For #4596: move code from CollectionCreationComponent to CollectionCreationStore
Other than adding comments, no changes were made. The code will be updated in a following commit. This is in order to make the commit diff more readable.
* For 4596: update CollectionCreateStore to libstate
* For 4596: copied CollectionCreationUIView into CollectionCreationView
Otherwise, no code was changed. The next commit will update this code. This is in order to make the commit diff more readable.
* For 4596: update CollectionCreationView to LibState
Note that the minimal changes possible to enable migration were made. Refactoring will happen in a later commit.
* For 4596: updated CollectionCreationTabListAdapter to work with the new View
* For 4596: updated SaveCollectionListAdapter to work with the new View
* For 4596: implemented CollectionCreationController
For now, it has an identical interface to the interactor. In a later commit several of its responsibilities will be moved around, some to the interactor and some to the reducer
* For 4596: copied over previous reducer code
No other changes were made. The code will be updated in the following commit. This is done to make changes more readable for the reviewer
* For 4596: update reducer code param names
Otherwise, no changes at this time
* For 4596: add arguments to CreateCollectionFragment in nav_graph
These will be used to replace the current CreateCollectionViewModel, which shares data between fragments in a way that doesn't fit within our architecture.
* For 4596: pass arguments to collection via transaction instead of VM
The VM will be removed in a later commit
* For 4596: update BrowserToolbarController to share state to collection via its Direction
* For 4596: removed CreateCollectionViewModel
* For 4596: test tab retrieval in CreateCollectionFragment
* For 4596: fix crashing CreateCollectionFragmentTest
* For 4596: removed classes create collection classes used by old architecture
* For 4596: collection interactor rename + kdoc
* For 4596: moved collection interactor interface
* For 4596: renamed CreateCollectionFragment
All related classes followed the pattern of CollectionCreationX
* For 4596: kdoc CollectionCreationController
There's no effective difference between these calls and their interactor equivalent, so I linked to them
* For 4596: fix bug that caused rename to not work
* For 4596: removed unused collection actions
These were unused before the LibState refactor
* For 4596: kdoc StepChanged
* For 4596: removed todos about moving logic to the reducer
saveTabsToCollection: this could be moved, but that would involve creating a new action. SaveCollectionStep should probably be refactored out, so adding this layer of indirection seemed counterproductive
handleBackPress: needs to be able to call dismiss(). The reducer doesn't (and shouldn't) be able to do that, so this needs to live here
stepBack: called by handleBackPress. See above
* For 4596: wrote tests for CollectionCreationController#stepback
* For 4596: fixed tests broken by changes to collections
* For 4596: small readability refactor for CollectionController#stepBack
No change to functionality (see tests)
* For 4596: broke apart CollectionView#update
There's probably a lot more that could be done here, but smaller changes were made to reduce scope
* For 4596: remove unnecessary todos
It looks like we don't follow the suggested pattern in this project
* For 4596: test CollectionCreationController#normalSessionSize
* For 4596: updated naming in CollectionCreationController per review
5 years ago
|
|
|
import mozilla.components.support.ktx.android.view.hideKeyboard
|
|
|
|
import mozilla.components.support.ktx.android.view.showKeyboard
|
|
|
|
import org.mozilla.fenix.R
|
|
|
|
import org.mozilla.fenix.components.metrics.Event
|
|
|
|
import org.mozilla.fenix.ext.components
|
|
|
|
import org.mozilla.fenix.ext.toShortUrl
|
|
|
|
import org.mozilla.fenix.home.Tab
|
#4596 migrate collections (#5911)
* For #4596: move code from CollectionCreationComponent to CollectionCreationStore
Other than adding comments, no changes were made. The code will be updated in a following commit. This is in order to make the commit diff more readable.
* For 4596: update CollectionCreateStore to libstate
* For 4596: copied CollectionCreationUIView into CollectionCreationView
Otherwise, no code was changed. The next commit will update this code. This is in order to make the commit diff more readable.
* For 4596: update CollectionCreationView to LibState
Note that the minimal changes possible to enable migration were made. Refactoring will happen in a later commit.
* For 4596: updated CollectionCreationTabListAdapter to work with the new View
* For 4596: updated SaveCollectionListAdapter to work with the new View
* For 4596: implemented CollectionCreationController
For now, it has an identical interface to the interactor. In a later commit several of its responsibilities will be moved around, some to the interactor and some to the reducer
* For 4596: copied over previous reducer code
No other changes were made. The code will be updated in the following commit. This is done to make changes more readable for the reviewer
* For 4596: update reducer code param names
Otherwise, no changes at this time
* For 4596: add arguments to CreateCollectionFragment in nav_graph
These will be used to replace the current CreateCollectionViewModel, which shares data between fragments in a way that doesn't fit within our architecture.
* For 4596: pass arguments to collection via transaction instead of VM
The VM will be removed in a later commit
* For 4596: update BrowserToolbarController to share state to collection via its Direction
* For 4596: removed CreateCollectionViewModel
* For 4596: test tab retrieval in CreateCollectionFragment
* For 4596: fix crashing CreateCollectionFragmentTest
* For 4596: removed classes create collection classes used by old architecture
* For 4596: collection interactor rename + kdoc
* For 4596: moved collection interactor interface
* For 4596: renamed CreateCollectionFragment
All related classes followed the pattern of CollectionCreationX
* For 4596: kdoc CollectionCreationController
There's no effective difference between these calls and their interactor equivalent, so I linked to them
* For 4596: fix bug that caused rename to not work
* For 4596: removed unused collection actions
These were unused before the LibState refactor
* For 4596: kdoc StepChanged
* For 4596: removed todos about moving logic to the reducer
saveTabsToCollection: this could be moved, but that would involve creating a new action. SaveCollectionStep should probably be refactored out, so adding this layer of indirection seemed counterproductive
handleBackPress: needs to be able to call dismiss(). The reducer doesn't (and shouldn't) be able to do that, so this needs to live here
stepBack: called by handleBackPress. See above
* For 4596: wrote tests for CollectionCreationController#stepback
* For 4596: fixed tests broken by changes to collections
* For 4596: small readability refactor for CollectionController#stepBack
No change to functionality (see tests)
* For 4596: broke apart CollectionView#update
There's probably a lot more that could be done here, but smaller changes were made to reduce scope
* For 4596: remove unnecessary todos
It looks like we don't follow the suggested pattern in this project
* For 4596: test CollectionCreationController#normalSessionSize
* For 4596: updated naming in CollectionCreationController per review
5 years ago
|
|
|
|
|
|
|
@SuppressWarnings("LargeClass")
|
|
|
|
class CollectionCreationView(
|
|
|
|
override val containerView: ViewGroup,
|
|
|
|
private val interactor: CollectionCreationInteractor
|
|
|
|
) : LayoutContainer {
|
|
|
|
val view: View = LayoutInflater.from(containerView.context)
|
|
|
|
.inflate(R.layout.component_collection_creation, containerView, true)
|
|
|
|
|
|
|
|
private val collectionCreationTabListAdapter = CollectionCreationTabListAdapter(interactor)
|
|
|
|
private val collectionSaveListAdapter = SaveCollectionListAdapter(interactor)
|
|
|
|
private val selectTabsConstraints = ConstraintSet()
|
|
|
|
private val selectCollectionConstraints = ConstraintSet()
|
|
|
|
private val nameCollectionConstraints = ConstraintSet()
|
|
|
|
private val transition = AutoTransition()
|
|
|
|
|
|
|
|
private var selectedCollection: TabCollection? = null
|
|
|
|
private var selectedTabs: Set<Tab> = setOf()
|
|
|
|
var step: SaveCollectionStep = SaveCollectionStep.SelectTabs
|
|
|
|
private set
|
|
|
|
|
|
|
|
init {
|
|
|
|
transition.duration = TRANSITION_DURATION
|
|
|
|
transition.excludeTarget(back_button, true)
|
#4596 migrate collections (#5911)
* For #4596: move code from CollectionCreationComponent to CollectionCreationStore
Other than adding comments, no changes were made. The code will be updated in a following commit. This is in order to make the commit diff more readable.
* For 4596: update CollectionCreateStore to libstate
* For 4596: copied CollectionCreationUIView into CollectionCreationView
Otherwise, no code was changed. The next commit will update this code. This is in order to make the commit diff more readable.
* For 4596: update CollectionCreationView to LibState
Note that the minimal changes possible to enable migration were made. Refactoring will happen in a later commit.
* For 4596: updated CollectionCreationTabListAdapter to work with the new View
* For 4596: updated SaveCollectionListAdapter to work with the new View
* For 4596: implemented CollectionCreationController
For now, it has an identical interface to the interactor. In a later commit several of its responsibilities will be moved around, some to the interactor and some to the reducer
* For 4596: copied over previous reducer code
No other changes were made. The code will be updated in the following commit. This is done to make changes more readable for the reviewer
* For 4596: update reducer code param names
Otherwise, no changes at this time
* For 4596: add arguments to CreateCollectionFragment in nav_graph
These will be used to replace the current CreateCollectionViewModel, which shares data between fragments in a way that doesn't fit within our architecture.
* For 4596: pass arguments to collection via transaction instead of VM
The VM will be removed in a later commit
* For 4596: update BrowserToolbarController to share state to collection via its Direction
* For 4596: removed CreateCollectionViewModel
* For 4596: test tab retrieval in CreateCollectionFragment
* For 4596: fix crashing CreateCollectionFragmentTest
* For 4596: removed classes create collection classes used by old architecture
* For 4596: collection interactor rename + kdoc
* For 4596: moved collection interactor interface
* For 4596: renamed CreateCollectionFragment
All related classes followed the pattern of CollectionCreationX
* For 4596: kdoc CollectionCreationController
There's no effective difference between these calls and their interactor equivalent, so I linked to them
* For 4596: fix bug that caused rename to not work
* For 4596: removed unused collection actions
These were unused before the LibState refactor
* For 4596: kdoc StepChanged
* For 4596: removed todos about moving logic to the reducer
saveTabsToCollection: this could be moved, but that would involve creating a new action. SaveCollectionStep should probably be refactored out, so adding this layer of indirection seemed counterproductive
handleBackPress: needs to be able to call dismiss(). The reducer doesn't (and shouldn't) be able to do that, so this needs to live here
stepBack: called by handleBackPress. See above
* For 4596: wrote tests for CollectionCreationController#stepback
* For 4596: fixed tests broken by changes to collections
* For 4596: small readability refactor for CollectionController#stepBack
No change to functionality (see tests)
* For 4596: broke apart CollectionView#update
There's probably a lot more that could be done here, but smaller changes were made to reduce scope
* For 4596: remove unnecessary todos
It looks like we don't follow the suggested pattern in this project
* For 4596: test CollectionCreationController#normalSessionSize
* For 4596: updated naming in CollectionCreationController per review
5 years ago
|
|
|
|
|
|
|
view.name_collection_edittext.filters += InputFilter.LengthFilter(COLLECTION_NAME_MAX_LENGTH)
|
|
|
|
view.name_collection_edittext.setOnEditorActionListener { view, actionId, _ ->
|
|
|
|
val text = view.text.toString()
|
|
|
|
if (actionId == EditorInfo.IME_ACTION_DONE && text.isNotBlank()) {
|
|
|
|
when (step) {
|
|
|
|
SaveCollectionStep.NameCollection ->
|
|
|
|
interactor.onNewCollectionNameSaved(selectedTabs.toList(), text)
|
|
|
|
SaveCollectionStep.RenameCollection ->
|
|
|
|
selectedCollection?.let { interactor.onCollectionRenamed(it, text) }
|
|
|
|
else -> { /* noop */ }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
false
|
|
|
|
}
|
|
|
|
|
|
|
|
view.tab_list.run {
|
|
|
|
adapter = collectionCreationTabListAdapter
|
|
|
|
itemAnimator = null
|
|
|
|
layoutManager = LinearLayoutManager(containerView.context, RecyclerView.VERTICAL, true)
|
|
|
|
}
|
|
|
|
|
|
|
|
view.collections_list.run {
|
|
|
|
adapter = collectionSaveListAdapter
|
|
|
|
layoutManager = LinearLayoutManager(containerView.context, RecyclerView.VERTICAL, true)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fun update(state: CollectionCreationState) {
|
|
|
|
|
|
|
|
cacheState(state)
|
|
|
|
|
|
|
|
when (step) {
|
|
|
|
SaveCollectionStep.SelectTabs -> updateForSelectTabs(state)
|
|
|
|
SaveCollectionStep.SelectCollection -> updateForSelectCollection()
|
|
|
|
SaveCollectionStep.NameCollection -> updateForNameCollection(state)
|
|
|
|
SaveCollectionStep.RenameCollection -> updateForRenameCollection(state)
|
|
|
|
}
|
|
|
|
|
|
|
|
collectionSaveListAdapter.updateData(state.tabCollections, state.selectedTabs)
|
|
|
|
}
|
|
|
|
|
|
|
|
private fun cacheState(state: CollectionCreationState) {
|
|
|
|
step = state.saveCollectionStep
|
|
|
|
selectedTabs = state.selectedTabs
|
|
|
|
selectedCollection = state.selectedTabCollection
|
|
|
|
}
|
|
|
|
|
|
|
|
@SuppressWarnings("ComplexMethod")
|
|
|
|
private fun updateForSelectTabs(state: CollectionCreationState) {
|
|
|
|
view.context.components.analytics.metrics.track(Event.CollectionTabSelectOpened)
|
|
|
|
|
|
|
|
view.tab_list.isClickable = true
|
|
|
|
|
|
|
|
back_button.setOnClickListener {
|
|
|
|
interactor.onBackPressed(SaveCollectionStep.SelectTabs)
|
|
|
|
}
|
|
|
|
val allSelected = state.selectedTabs.size == state.tabs.size
|
|
|
|
select_all_button.text =
|
|
|
|
if (allSelected) view.context.getString(R.string.create_collection_deselect_all)
|
|
|
|
else view.context.getString(R.string.create_collection_select_all)
|
|
|
|
|
|
|
|
view.select_all_button.setOnClickListener {
|
|
|
|
if (allSelected) interactor.deselectAllTapped()
|
|
|
|
else interactor.selectAllTapped()
|
|
|
|
}
|
|
|
|
|
|
|
|
view.bottom_button_bar_layout.setOnClickListener(null)
|
|
|
|
view.bottom_button_bar_layout.isClickable = false
|
|
|
|
|
|
|
|
val drawable = AppCompatResources.getDrawable(view.context, R.drawable.ic_close)
|
#4596 migrate collections (#5911)
* For #4596: move code from CollectionCreationComponent to CollectionCreationStore
Other than adding comments, no changes were made. The code will be updated in a following commit. This is in order to make the commit diff more readable.
* For 4596: update CollectionCreateStore to libstate
* For 4596: copied CollectionCreationUIView into CollectionCreationView
Otherwise, no code was changed. The next commit will update this code. This is in order to make the commit diff more readable.
* For 4596: update CollectionCreationView to LibState
Note that the minimal changes possible to enable migration were made. Refactoring will happen in a later commit.
* For 4596: updated CollectionCreationTabListAdapter to work with the new View
* For 4596: updated SaveCollectionListAdapter to work with the new View
* For 4596: implemented CollectionCreationController
For now, it has an identical interface to the interactor. In a later commit several of its responsibilities will be moved around, some to the interactor and some to the reducer
* For 4596: copied over previous reducer code
No other changes were made. The code will be updated in the following commit. This is done to make changes more readable for the reviewer
* For 4596: update reducer code param names
Otherwise, no changes at this time
* For 4596: add arguments to CreateCollectionFragment in nav_graph
These will be used to replace the current CreateCollectionViewModel, which shares data between fragments in a way that doesn't fit within our architecture.
* For 4596: pass arguments to collection via transaction instead of VM
The VM will be removed in a later commit
* For 4596: update BrowserToolbarController to share state to collection via its Direction
* For 4596: removed CreateCollectionViewModel
* For 4596: test tab retrieval in CreateCollectionFragment
* For 4596: fix crashing CreateCollectionFragmentTest
* For 4596: removed classes create collection classes used by old architecture
* For 4596: collection interactor rename + kdoc
* For 4596: moved collection interactor interface
* For 4596: renamed CreateCollectionFragment
All related classes followed the pattern of CollectionCreationX
* For 4596: kdoc CollectionCreationController
There's no effective difference between these calls and their interactor equivalent, so I linked to them
* For 4596: fix bug that caused rename to not work
* For 4596: removed unused collection actions
These were unused before the LibState refactor
* For 4596: kdoc StepChanged
* For 4596: removed todos about moving logic to the reducer
saveTabsToCollection: this could be moved, but that would involve creating a new action. SaveCollectionStep should probably be refactored out, so adding this layer of indirection seemed counterproductive
handleBackPress: needs to be able to call dismiss(). The reducer doesn't (and shouldn't) be able to do that, so this needs to live here
stepBack: called by handleBackPress. See above
* For 4596: wrote tests for CollectionCreationController#stepback
* For 4596: fixed tests broken by changes to collections
* For 4596: small readability refactor for CollectionController#stepBack
No change to functionality (see tests)
* For 4596: broke apart CollectionView#update
There's probably a lot more that could be done here, but smaller changes were made to reduce scope
* For 4596: remove unnecessary todos
It looks like we don't follow the suggested pattern in this project
* For 4596: test CollectionCreationController#normalSessionSize
* For 4596: updated naming in CollectionCreationController per review
5 years ago
|
|
|
drawable?.setTint(ContextCompat.getColor(view.context, R.color.photonWhite))
|
|
|
|
view.bottom_bar_icon_button.setImageDrawable(drawable)
|
|
|
|
view.bottom_bar_icon_button.contentDescription =
|
|
|
|
view.context.getString(R.string.create_collection_close)
|
|
|
|
view.bottom_bar_icon_button.importantForAccessibility = View.IMPORTANT_FOR_ACCESSIBILITY_YES
|
|
|
|
view.bottom_bar_icon_button.setOnClickListener {
|
|
|
|
interactor.close()
|
|
|
|
}
|
|
|
|
selectTabsConstraints.clone(collection_constraint_layout)
|
|
|
|
selectTabsConstraints.applyTo(view.collection_constraint_layout)
|
#4596 migrate collections (#5911)
* For #4596: move code from CollectionCreationComponent to CollectionCreationStore
Other than adding comments, no changes were made. The code will be updated in a following commit. This is in order to make the commit diff more readable.
* For 4596: update CollectionCreateStore to libstate
* For 4596: copied CollectionCreationUIView into CollectionCreationView
Otherwise, no code was changed. The next commit will update this code. This is in order to make the commit diff more readable.
* For 4596: update CollectionCreationView to LibState
Note that the minimal changes possible to enable migration were made. Refactoring will happen in a later commit.
* For 4596: updated CollectionCreationTabListAdapter to work with the new View
* For 4596: updated SaveCollectionListAdapter to work with the new View
* For 4596: implemented CollectionCreationController
For now, it has an identical interface to the interactor. In a later commit several of its responsibilities will be moved around, some to the interactor and some to the reducer
* For 4596: copied over previous reducer code
No other changes were made. The code will be updated in the following commit. This is done to make changes more readable for the reviewer
* For 4596: update reducer code param names
Otherwise, no changes at this time
* For 4596: add arguments to CreateCollectionFragment in nav_graph
These will be used to replace the current CreateCollectionViewModel, which shares data between fragments in a way that doesn't fit within our architecture.
* For 4596: pass arguments to collection via transaction instead of VM
The VM will be removed in a later commit
* For 4596: update BrowserToolbarController to share state to collection via its Direction
* For 4596: removed CreateCollectionViewModel
* For 4596: test tab retrieval in CreateCollectionFragment
* For 4596: fix crashing CreateCollectionFragmentTest
* For 4596: removed classes create collection classes used by old architecture
* For 4596: collection interactor rename + kdoc
* For 4596: moved collection interactor interface
* For 4596: renamed CreateCollectionFragment
All related classes followed the pattern of CollectionCreationX
* For 4596: kdoc CollectionCreationController
There's no effective difference between these calls and their interactor equivalent, so I linked to them
* For 4596: fix bug that caused rename to not work
* For 4596: removed unused collection actions
These were unused before the LibState refactor
* For 4596: kdoc StepChanged
* For 4596: removed todos about moving logic to the reducer
saveTabsToCollection: this could be moved, but that would involve creating a new action. SaveCollectionStep should probably be refactored out, so adding this layer of indirection seemed counterproductive
handleBackPress: needs to be able to call dismiss(). The reducer doesn't (and shouldn't) be able to do that, so this needs to live here
stepBack: called by handleBackPress. See above
* For 4596: wrote tests for CollectionCreationController#stepback
* For 4596: fixed tests broken by changes to collections
* For 4596: small readability refactor for CollectionController#stepBack
No change to functionality (see tests)
* For 4596: broke apart CollectionView#update
There's probably a lot more that could be done here, but smaller changes were made to reduce scope
* For 4596: remove unnecessary todos
It looks like we don't follow the suggested pattern in this project
* For 4596: test CollectionCreationController#normalSessionSize
* For 4596: updated naming in CollectionCreationController per review
5 years ago
|
|
|
|
|
|
|
collectionCreationTabListAdapter.updateData(state.tabs, state.selectedTabs)
|
|
|
|
|
|
|
|
back_button.text = view.context.getString(R.string.create_collection_select_tabs)
|
|
|
|
|
|
|
|
val selectTabsText = if (state.selectedTabs.isEmpty()) {
|
|
|
|
view.context.getString(R.string.create_collection_save_to_collection_empty)
|
|
|
|
} else {
|
|
|
|
view.context.getString(
|
|
|
|
if (state.selectedTabs.size == 1)
|
|
|
|
R.string.create_collection_save_to_collection_tab_selected else
|
|
|
|
R.string.create_collection_save_to_collection_tabs_selected,
|
|
|
|
state.selectedTabs.size
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
view.bottom_bar_text.text = selectTabsText
|
|
|
|
|
|
|
|
save_button.setOnClickListener { _ ->
|
|
|
|
if (selectedCollection != null) {
|
|
|
|
interactor.selectCollection(
|
|
|
|
collection = selectedCollection!!,
|
|
|
|
tabs = state.selectedTabs.toList()
|
|
|
|
)
|
|
|
|
} else {
|
|
|
|
interactor.saveTabsToCollection(tabs = selectedTabs.toList())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
save_button.visibility = if (state.selectedTabs.isEmpty()) {
|
|
|
|
View.GONE
|
|
|
|
} else {
|
|
|
|
View.VISIBLE
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private fun updateForSelectCollection() {
|
|
|
|
view.tab_list.isClickable = false
|
|
|
|
|
|
|
|
save_button.visibility = View.GONE
|
|
|
|
|
|
|
|
view.bottom_bar_text.text =
|
|
|
|
view.context.getString(R.string.create_collection_add_new_collection)
|
|
|
|
|
|
|
|
val drawable = AppCompatResources.getDrawable(view.context, R.drawable.ic_new)
|
#4596 migrate collections (#5911)
* For #4596: move code from CollectionCreationComponent to CollectionCreationStore
Other than adding comments, no changes were made. The code will be updated in a following commit. This is in order to make the commit diff more readable.
* For 4596: update CollectionCreateStore to libstate
* For 4596: copied CollectionCreationUIView into CollectionCreationView
Otherwise, no code was changed. The next commit will update this code. This is in order to make the commit diff more readable.
* For 4596: update CollectionCreationView to LibState
Note that the minimal changes possible to enable migration were made. Refactoring will happen in a later commit.
* For 4596: updated CollectionCreationTabListAdapter to work with the new View
* For 4596: updated SaveCollectionListAdapter to work with the new View
* For 4596: implemented CollectionCreationController
For now, it has an identical interface to the interactor. In a later commit several of its responsibilities will be moved around, some to the interactor and some to the reducer
* For 4596: copied over previous reducer code
No other changes were made. The code will be updated in the following commit. This is done to make changes more readable for the reviewer
* For 4596: update reducer code param names
Otherwise, no changes at this time
* For 4596: add arguments to CreateCollectionFragment in nav_graph
These will be used to replace the current CreateCollectionViewModel, which shares data between fragments in a way that doesn't fit within our architecture.
* For 4596: pass arguments to collection via transaction instead of VM
The VM will be removed in a later commit
* For 4596: update BrowserToolbarController to share state to collection via its Direction
* For 4596: removed CreateCollectionViewModel
* For 4596: test tab retrieval in CreateCollectionFragment
* For 4596: fix crashing CreateCollectionFragmentTest
* For 4596: removed classes create collection classes used by old architecture
* For 4596: collection interactor rename + kdoc
* For 4596: moved collection interactor interface
* For 4596: renamed CreateCollectionFragment
All related classes followed the pattern of CollectionCreationX
* For 4596: kdoc CollectionCreationController
There's no effective difference between these calls and their interactor equivalent, so I linked to them
* For 4596: fix bug that caused rename to not work
* For 4596: removed unused collection actions
These were unused before the LibState refactor
* For 4596: kdoc StepChanged
* For 4596: removed todos about moving logic to the reducer
saveTabsToCollection: this could be moved, but that would involve creating a new action. SaveCollectionStep should probably be refactored out, so adding this layer of indirection seemed counterproductive
handleBackPress: needs to be able to call dismiss(). The reducer doesn't (and shouldn't) be able to do that, so this needs to live here
stepBack: called by handleBackPress. See above
* For 4596: wrote tests for CollectionCreationController#stepback
* For 4596: fixed tests broken by changes to collections
* For 4596: small readability refactor for CollectionController#stepBack
No change to functionality (see tests)
* For 4596: broke apart CollectionView#update
There's probably a lot more that could be done here, but smaller changes were made to reduce scope
* For 4596: remove unnecessary todos
It looks like we don't follow the suggested pattern in this project
* For 4596: test CollectionCreationController#normalSessionSize
* For 4596: updated naming in CollectionCreationController per review
5 years ago
|
|
|
drawable?.setTint(ContextCompat.getColor(view.context, R.color.photonWhite))
|
|
|
|
view.bottom_bar_icon_button.setImageDrawable(drawable)
|
|
|
|
view.bottom_bar_icon_button.contentDescription = null
|
|
|
|
view.bottom_bar_icon_button.importantForAccessibility = View.IMPORTANT_FOR_ACCESSIBILITY_NO
|
|
|
|
view.bottom_button_bar_layout.isClickable = true
|
|
|
|
view.bottom_button_bar_layout.setOnClickListener {
|
|
|
|
interactor.addNewCollection()
|
|
|
|
}
|
|
|
|
|
|
|
|
back_button.setOnClickListener {
|
|
|
|
interactor.onBackPressed(SaveCollectionStep.SelectCollection)
|
|
|
|
}
|
|
|
|
TransitionManager.beginDelayedTransition(
|
|
|
|
view.collection_constraint_layout,
|
|
|
|
transition
|
|
|
|
)
|
|
|
|
selectCollectionConstraints.clone(
|
|
|
|
view.context,
|
|
|
|
R.layout.component_collection_creation_select_collection
|
|
|
|
)
|
|
|
|
selectCollectionConstraints.applyTo(view.collection_constraint_layout)
|
#4596 migrate collections (#5911)
* For #4596: move code from CollectionCreationComponent to CollectionCreationStore
Other than adding comments, no changes were made. The code will be updated in a following commit. This is in order to make the commit diff more readable.
* For 4596: update CollectionCreateStore to libstate
* For 4596: copied CollectionCreationUIView into CollectionCreationView
Otherwise, no code was changed. The next commit will update this code. This is in order to make the commit diff more readable.
* For 4596: update CollectionCreationView to LibState
Note that the minimal changes possible to enable migration were made. Refactoring will happen in a later commit.
* For 4596: updated CollectionCreationTabListAdapter to work with the new View
* For 4596: updated SaveCollectionListAdapter to work with the new View
* For 4596: implemented CollectionCreationController
For now, it has an identical interface to the interactor. In a later commit several of its responsibilities will be moved around, some to the interactor and some to the reducer
* For 4596: copied over previous reducer code
No other changes were made. The code will be updated in the following commit. This is done to make changes more readable for the reviewer
* For 4596: update reducer code param names
Otherwise, no changes at this time
* For 4596: add arguments to CreateCollectionFragment in nav_graph
These will be used to replace the current CreateCollectionViewModel, which shares data between fragments in a way that doesn't fit within our architecture.
* For 4596: pass arguments to collection via transaction instead of VM
The VM will be removed in a later commit
* For 4596: update BrowserToolbarController to share state to collection via its Direction
* For 4596: removed CreateCollectionViewModel
* For 4596: test tab retrieval in CreateCollectionFragment
* For 4596: fix crashing CreateCollectionFragmentTest
* For 4596: removed classes create collection classes used by old architecture
* For 4596: collection interactor rename + kdoc
* For 4596: moved collection interactor interface
* For 4596: renamed CreateCollectionFragment
All related classes followed the pattern of CollectionCreationX
* For 4596: kdoc CollectionCreationController
There's no effective difference between these calls and their interactor equivalent, so I linked to them
* For 4596: fix bug that caused rename to not work
* For 4596: removed unused collection actions
These were unused before the LibState refactor
* For 4596: kdoc StepChanged
* For 4596: removed todos about moving logic to the reducer
saveTabsToCollection: this could be moved, but that would involve creating a new action. SaveCollectionStep should probably be refactored out, so adding this layer of indirection seemed counterproductive
handleBackPress: needs to be able to call dismiss(). The reducer doesn't (and shouldn't) be able to do that, so this needs to live here
stepBack: called by handleBackPress. See above
* For 4596: wrote tests for CollectionCreationController#stepback
* For 4596: fixed tests broken by changes to collections
* For 4596: small readability refactor for CollectionController#stepBack
No change to functionality (see tests)
* For 4596: broke apart CollectionView#update
There's probably a lot more that could be done here, but smaller changes were made to reduce scope
* For 4596: remove unnecessary todos
It looks like we don't follow the suggested pattern in this project
* For 4596: test CollectionCreationController#normalSessionSize
* For 4596: updated naming in CollectionCreationController per review
5 years ago
|
|
|
back_button.text =
|
|
|
|
view.context.getString(R.string.create_collection_select_collection)
|
|
|
|
}
|
|
|
|
|
|
|
|
private fun updateForNameCollection(state: CollectionCreationState) {
|
|
|
|
view.tab_list.isClickable = false
|
|
|
|
|
|
|
|
collectionCreationTabListAdapter.updateData(state.selectedTabs.toList(), state.selectedTabs, true)
|
|
|
|
back_button.setOnClickListener {
|
|
|
|
name_collection_edittext.hideKeyboard()
|
|
|
|
val handler = Handler()
|
|
|
|
handler.postDelayed({
|
|
|
|
interactor.onBackPressed(SaveCollectionStep.NameCollection)
|
|
|
|
}, TRANSITION_DURATION)
|
|
|
|
}
|
|
|
|
|
|
|
|
view.name_collection_edittext.showKeyboard()
|
|
|
|
nameCollectionConstraints.clone(
|
|
|
|
view.context,
|
|
|
|
R.layout.component_collection_creation_name_collection
|
|
|
|
)
|
|
|
|
nameCollectionConstraints.applyTo(view.collection_constraint_layout)
|
#4596 migrate collections (#5911)
* For #4596: move code from CollectionCreationComponent to CollectionCreationStore
Other than adding comments, no changes were made. The code will be updated in a following commit. This is in order to make the commit diff more readable.
* For 4596: update CollectionCreateStore to libstate
* For 4596: copied CollectionCreationUIView into CollectionCreationView
Otherwise, no code was changed. The next commit will update this code. This is in order to make the commit diff more readable.
* For 4596: update CollectionCreationView to LibState
Note that the minimal changes possible to enable migration were made. Refactoring will happen in a later commit.
* For 4596: updated CollectionCreationTabListAdapter to work with the new View
* For 4596: updated SaveCollectionListAdapter to work with the new View
* For 4596: implemented CollectionCreationController
For now, it has an identical interface to the interactor. In a later commit several of its responsibilities will be moved around, some to the interactor and some to the reducer
* For 4596: copied over previous reducer code
No other changes were made. The code will be updated in the following commit. This is done to make changes more readable for the reviewer
* For 4596: update reducer code param names
Otherwise, no changes at this time
* For 4596: add arguments to CreateCollectionFragment in nav_graph
These will be used to replace the current CreateCollectionViewModel, which shares data between fragments in a way that doesn't fit within our architecture.
* For 4596: pass arguments to collection via transaction instead of VM
The VM will be removed in a later commit
* For 4596: update BrowserToolbarController to share state to collection via its Direction
* For 4596: removed CreateCollectionViewModel
* For 4596: test tab retrieval in CreateCollectionFragment
* For 4596: fix crashing CreateCollectionFragmentTest
* For 4596: removed classes create collection classes used by old architecture
* For 4596: collection interactor rename + kdoc
* For 4596: moved collection interactor interface
* For 4596: renamed CreateCollectionFragment
All related classes followed the pattern of CollectionCreationX
* For 4596: kdoc CollectionCreationController
There's no effective difference between these calls and their interactor equivalent, so I linked to them
* For 4596: fix bug that caused rename to not work
* For 4596: removed unused collection actions
These were unused before the LibState refactor
* For 4596: kdoc StepChanged
* For 4596: removed todos about moving logic to the reducer
saveTabsToCollection: this could be moved, but that would involve creating a new action. SaveCollectionStep should probably be refactored out, so adding this layer of indirection seemed counterproductive
handleBackPress: needs to be able to call dismiss(). The reducer doesn't (and shouldn't) be able to do that, so this needs to live here
stepBack: called by handleBackPress. See above
* For 4596: wrote tests for CollectionCreationController#stepback
* For 4596: fixed tests broken by changes to collections
* For 4596: small readability refactor for CollectionController#stepBack
No change to functionality (see tests)
* For 4596: broke apart CollectionView#update
There's probably a lot more that could be done here, but smaller changes were made to reduce scope
* For 4596: remove unnecessary todos
It looks like we don't follow the suggested pattern in this project
* For 4596: test CollectionCreationController#normalSessionSize
* For 4596: updated naming in CollectionCreationController per review
5 years ago
|
|
|
name_collection_edittext.setText(
|
|
|
|
view.context.getString(
|
|
|
|
R.string.create_collection_default_name,
|
|
|
|
state.defaultCollectionNumber
|
#4596 migrate collections (#5911)
* For #4596: move code from CollectionCreationComponent to CollectionCreationStore
Other than adding comments, no changes were made. The code will be updated in a following commit. This is in order to make the commit diff more readable.
* For 4596: update CollectionCreateStore to libstate
* For 4596: copied CollectionCreationUIView into CollectionCreationView
Otherwise, no code was changed. The next commit will update this code. This is in order to make the commit diff more readable.
* For 4596: update CollectionCreationView to LibState
Note that the minimal changes possible to enable migration were made. Refactoring will happen in a later commit.
* For 4596: updated CollectionCreationTabListAdapter to work with the new View
* For 4596: updated SaveCollectionListAdapter to work with the new View
* For 4596: implemented CollectionCreationController
For now, it has an identical interface to the interactor. In a later commit several of its responsibilities will be moved around, some to the interactor and some to the reducer
* For 4596: copied over previous reducer code
No other changes were made. The code will be updated in the following commit. This is done to make changes more readable for the reviewer
* For 4596: update reducer code param names
Otherwise, no changes at this time
* For 4596: add arguments to CreateCollectionFragment in nav_graph
These will be used to replace the current CreateCollectionViewModel, which shares data between fragments in a way that doesn't fit within our architecture.
* For 4596: pass arguments to collection via transaction instead of VM
The VM will be removed in a later commit
* For 4596: update BrowserToolbarController to share state to collection via its Direction
* For 4596: removed CreateCollectionViewModel
* For 4596: test tab retrieval in CreateCollectionFragment
* For 4596: fix crashing CreateCollectionFragmentTest
* For 4596: removed classes create collection classes used by old architecture
* For 4596: collection interactor rename + kdoc
* For 4596: moved collection interactor interface
* For 4596: renamed CreateCollectionFragment
All related classes followed the pattern of CollectionCreationX
* For 4596: kdoc CollectionCreationController
There's no effective difference between these calls and their interactor equivalent, so I linked to them
* For 4596: fix bug that caused rename to not work
* For 4596: removed unused collection actions
These were unused before the LibState refactor
* For 4596: kdoc StepChanged
* For 4596: removed todos about moving logic to the reducer
saveTabsToCollection: this could be moved, but that would involve creating a new action. SaveCollectionStep should probably be refactored out, so adding this layer of indirection seemed counterproductive
handleBackPress: needs to be able to call dismiss(). The reducer doesn't (and shouldn't) be able to do that, so this needs to live here
stepBack: called by handleBackPress. See above
* For 4596: wrote tests for CollectionCreationController#stepback
* For 4596: fixed tests broken by changes to collections
* For 4596: small readability refactor for CollectionController#stepBack
No change to functionality (see tests)
* For 4596: broke apart CollectionView#update
There's probably a lot more that could be done here, but smaller changes were made to reduce scope
* For 4596: remove unnecessary todos
It looks like we don't follow the suggested pattern in this project
* For 4596: test CollectionCreationController#normalSessionSize
* For 4596: updated naming in CollectionCreationController per review
5 years ago
|
|
|
)
|
|
|
|
)
|
|
|
|
name_collection_edittext.setSelection(0, name_collection_edittext.text.length)
|
|
|
|
back_button.text =
|
|
|
|
view.context.getString(R.string.create_collection_name_collection)
|
|
|
|
}
|
|
|
|
|
|
|
|
private fun updateForRenameCollection(state: CollectionCreationState) {
|
|
|
|
view.tab_list.isClickable = false
|
|
|
|
|
|
|
|
state.selectedTabCollection?.let { tabCollection ->
|
|
|
|
tabCollection.tabs.map { tab ->
|
|
|
|
Tab(
|
|
|
|
tab.id.toString(),
|
|
|
|
tab.url,
|
|
|
|
tab.url.toShortUrl(view.context.components.publicSuffixList),
|
|
|
|
tab.title,
|
|
|
|
mediaState = MediaState.State.NONE
|
#4596 migrate collections (#5911)
* For #4596: move code from CollectionCreationComponent to CollectionCreationStore
Other than adding comments, no changes were made. The code will be updated in a following commit. This is in order to make the commit diff more readable.
* For 4596: update CollectionCreateStore to libstate
* For 4596: copied CollectionCreationUIView into CollectionCreationView
Otherwise, no code was changed. The next commit will update this code. This is in order to make the commit diff more readable.
* For 4596: update CollectionCreationView to LibState
Note that the minimal changes possible to enable migration were made. Refactoring will happen in a later commit.
* For 4596: updated CollectionCreationTabListAdapter to work with the new View
* For 4596: updated SaveCollectionListAdapter to work with the new View
* For 4596: implemented CollectionCreationController
For now, it has an identical interface to the interactor. In a later commit several of its responsibilities will be moved around, some to the interactor and some to the reducer
* For 4596: copied over previous reducer code
No other changes were made. The code will be updated in the following commit. This is done to make changes more readable for the reviewer
* For 4596: update reducer code param names
Otherwise, no changes at this time
* For 4596: add arguments to CreateCollectionFragment in nav_graph
These will be used to replace the current CreateCollectionViewModel, which shares data between fragments in a way that doesn't fit within our architecture.
* For 4596: pass arguments to collection via transaction instead of VM
The VM will be removed in a later commit
* For 4596: update BrowserToolbarController to share state to collection via its Direction
* For 4596: removed CreateCollectionViewModel
* For 4596: test tab retrieval in CreateCollectionFragment
* For 4596: fix crashing CreateCollectionFragmentTest
* For 4596: removed classes create collection classes used by old architecture
* For 4596: collection interactor rename + kdoc
* For 4596: moved collection interactor interface
* For 4596: renamed CreateCollectionFragment
All related classes followed the pattern of CollectionCreationX
* For 4596: kdoc CollectionCreationController
There's no effective difference between these calls and their interactor equivalent, so I linked to them
* For 4596: fix bug that caused rename to not work
* For 4596: removed unused collection actions
These were unused before the LibState refactor
* For 4596: kdoc StepChanged
* For 4596: removed todos about moving logic to the reducer
saveTabsToCollection: this could be moved, but that would involve creating a new action. SaveCollectionStep should probably be refactored out, so adding this layer of indirection seemed counterproductive
handleBackPress: needs to be able to call dismiss(). The reducer doesn't (and shouldn't) be able to do that, so this needs to live here
stepBack: called by handleBackPress. See above
* For 4596: wrote tests for CollectionCreationController#stepback
* For 4596: fixed tests broken by changes to collections
* For 4596: small readability refactor for CollectionController#stepBack
No change to functionality (see tests)
* For 4596: broke apart CollectionView#update
There's probably a lot more that could be done here, but smaller changes were made to reduce scope
* For 4596: remove unnecessary todos
It looks like we don't follow the suggested pattern in this project
* For 4596: test CollectionCreationController#normalSessionSize
* For 4596: updated naming in CollectionCreationController per review
5 years ago
|
|
|
)
|
|
|
|
}.let { tabs ->
|
|
|
|
collectionCreationTabListAdapter.updateData(tabs, tabs.toSet(), true)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
nameCollectionConstraints.clone(
|
|
|
|
view.context,
|
|
|
|
R.layout.component_collection_creation_name_collection
|
|
|
|
)
|
|
|
|
nameCollectionConstraints.applyTo(view.collection_constraint_layout)
|
#4596 migrate collections (#5911)
* For #4596: move code from CollectionCreationComponent to CollectionCreationStore
Other than adding comments, no changes were made. The code will be updated in a following commit. This is in order to make the commit diff more readable.
* For 4596: update CollectionCreateStore to libstate
* For 4596: copied CollectionCreationUIView into CollectionCreationView
Otherwise, no code was changed. The next commit will update this code. This is in order to make the commit diff more readable.
* For 4596: update CollectionCreationView to LibState
Note that the minimal changes possible to enable migration were made. Refactoring will happen in a later commit.
* For 4596: updated CollectionCreationTabListAdapter to work with the new View
* For 4596: updated SaveCollectionListAdapter to work with the new View
* For 4596: implemented CollectionCreationController
For now, it has an identical interface to the interactor. In a later commit several of its responsibilities will be moved around, some to the interactor and some to the reducer
* For 4596: copied over previous reducer code
No other changes were made. The code will be updated in the following commit. This is done to make changes more readable for the reviewer
* For 4596: update reducer code param names
Otherwise, no changes at this time
* For 4596: add arguments to CreateCollectionFragment in nav_graph
These will be used to replace the current CreateCollectionViewModel, which shares data between fragments in a way that doesn't fit within our architecture.
* For 4596: pass arguments to collection via transaction instead of VM
The VM will be removed in a later commit
* For 4596: update BrowserToolbarController to share state to collection via its Direction
* For 4596: removed CreateCollectionViewModel
* For 4596: test tab retrieval in CreateCollectionFragment
* For 4596: fix crashing CreateCollectionFragmentTest
* For 4596: removed classes create collection classes used by old architecture
* For 4596: collection interactor rename + kdoc
* For 4596: moved collection interactor interface
* For 4596: renamed CreateCollectionFragment
All related classes followed the pattern of CollectionCreationX
* For 4596: kdoc CollectionCreationController
There's no effective difference between these calls and their interactor equivalent, so I linked to them
* For 4596: fix bug that caused rename to not work
* For 4596: removed unused collection actions
These were unused before the LibState refactor
* For 4596: kdoc StepChanged
* For 4596: removed todos about moving logic to the reducer
saveTabsToCollection: this could be moved, but that would involve creating a new action. SaveCollectionStep should probably be refactored out, so adding this layer of indirection seemed counterproductive
handleBackPress: needs to be able to call dismiss(). The reducer doesn't (and shouldn't) be able to do that, so this needs to live here
stepBack: called by handleBackPress. See above
* For 4596: wrote tests for CollectionCreationController#stepback
* For 4596: fixed tests broken by changes to collections
* For 4596: small readability refactor for CollectionController#stepBack
No change to functionality (see tests)
* For 4596: broke apart CollectionView#update
There's probably a lot more that could be done here, but smaller changes were made to reduce scope
* For 4596: remove unnecessary todos
It looks like we don't follow the suggested pattern in this project
* For 4596: test CollectionCreationController#normalSessionSize
* For 4596: updated naming in CollectionCreationController per review
5 years ago
|
|
|
name_collection_edittext.setText(state.selectedTabCollection?.title)
|
|
|
|
name_collection_edittext.setSelection(0, name_collection_edittext.text.length)
|
|
|
|
|
|
|
|
back_button.text =
|
|
|
|
view.context.getString(R.string.collection_rename)
|
|
|
|
back_button.setOnClickListener {
|
|
|
|
name_collection_edittext.hideKeyboard()
|
|
|
|
val handler = Handler()
|
|
|
|
handler.postDelayed({
|
|
|
|
interactor.onBackPressed(SaveCollectionStep.RenameCollection)
|
|
|
|
}, TRANSITION_DURATION)
|
|
|
|
}
|
|
|
|
transition.addListener(object : Transition.TransitionListener {
|
|
|
|
override fun onTransitionStart(transition: Transition) { /* noop */ }
|
|
|
|
|
|
|
|
override fun onTransitionEnd(transition: Transition) {
|
|
|
|
view.name_collection_edittext.showKeyboard()
|
|
|
|
transition.removeListener(this)
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun onTransitionCancel(transition: Transition) { /* noop */ }
|
|
|
|
override fun onTransitionPause(transition: Transition) { /* noop */ }
|
|
|
|
override fun onTransitionResume(transition: Transition) { /* noop */ }
|
|
|
|
})
|
|
|
|
TransitionManager.beginDelayedTransition(
|
|
|
|
view.collection_constraint_layout,
|
|
|
|
transition
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
fun onResumed() {
|
|
|
|
if (step == SaveCollectionStep.NameCollection || step == SaveCollectionStep.RenameCollection) {
|
|
|
|
view.name_collection_edittext.showKeyboard()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fun onKey(keyCode: Int, event: KeyEvent): Boolean {
|
|
|
|
return if (event.action == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) {
|
#4596 migrate collections (#5911)
* For #4596: move code from CollectionCreationComponent to CollectionCreationStore
Other than adding comments, no changes were made. The code will be updated in a following commit. This is in order to make the commit diff more readable.
* For 4596: update CollectionCreateStore to libstate
* For 4596: copied CollectionCreationUIView into CollectionCreationView
Otherwise, no code was changed. The next commit will update this code. This is in order to make the commit diff more readable.
* For 4596: update CollectionCreationView to LibState
Note that the minimal changes possible to enable migration were made. Refactoring will happen in a later commit.
* For 4596: updated CollectionCreationTabListAdapter to work with the new View
* For 4596: updated SaveCollectionListAdapter to work with the new View
* For 4596: implemented CollectionCreationController
For now, it has an identical interface to the interactor. In a later commit several of its responsibilities will be moved around, some to the interactor and some to the reducer
* For 4596: copied over previous reducer code
No other changes were made. The code will be updated in the following commit. This is done to make changes more readable for the reviewer
* For 4596: update reducer code param names
Otherwise, no changes at this time
* For 4596: add arguments to CreateCollectionFragment in nav_graph
These will be used to replace the current CreateCollectionViewModel, which shares data between fragments in a way that doesn't fit within our architecture.
* For 4596: pass arguments to collection via transaction instead of VM
The VM will be removed in a later commit
* For 4596: update BrowserToolbarController to share state to collection via its Direction
* For 4596: removed CreateCollectionViewModel
* For 4596: test tab retrieval in CreateCollectionFragment
* For 4596: fix crashing CreateCollectionFragmentTest
* For 4596: removed classes create collection classes used by old architecture
* For 4596: collection interactor rename + kdoc
* For 4596: moved collection interactor interface
* For 4596: renamed CreateCollectionFragment
All related classes followed the pattern of CollectionCreationX
* For 4596: kdoc CollectionCreationController
There's no effective difference between these calls and their interactor equivalent, so I linked to them
* For 4596: fix bug that caused rename to not work
* For 4596: removed unused collection actions
These were unused before the LibState refactor
* For 4596: kdoc StepChanged
* For 4596: removed todos about moving logic to the reducer
saveTabsToCollection: this could be moved, but that would involve creating a new action. SaveCollectionStep should probably be refactored out, so adding this layer of indirection seemed counterproductive
handleBackPress: needs to be able to call dismiss(). The reducer doesn't (and shouldn't) be able to do that, so this needs to live here
stepBack: called by handleBackPress. See above
* For 4596: wrote tests for CollectionCreationController#stepback
* For 4596: fixed tests broken by changes to collections
* For 4596: small readability refactor for CollectionController#stepBack
No change to functionality (see tests)
* For 4596: broke apart CollectionView#update
There's probably a lot more that could be done here, but smaller changes were made to reduce scope
* For 4596: remove unnecessary todos
It looks like we don't follow the suggested pattern in this project
* For 4596: test CollectionCreationController#normalSessionSize
* For 4596: updated naming in CollectionCreationController per review
5 years ago
|
|
|
interactor.onBackPressed(step)
|
|
|
|
true
|
|
|
|
} else {
|
|
|
|
false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
companion object {
|
|
|
|
private const val TRANSITION_DURATION = 200L
|
|
|
|
private const val COLLECTION_NAME_MAX_LENGTH = 128
|
|
|
|
}
|
|
|
|
}
|