This repository has been archived by the owner on Feb 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into issue-19956
- Loading branch information
Showing
15 changed files
with
244 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
app/src/main/java/org/mozilla/fenix/tabstray/browser/InactiveTabsController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* 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.tabstray.browser | ||
|
||
import mozilla.components.browser.state.state.TabSessionState | ||
import mozilla.components.browser.state.store.BrowserStore | ||
import mozilla.components.concept.tabstray.TabsTray | ||
import mozilla.components.feature.tabs.ext.toTabs | ||
|
||
class InactiveTabsController( | ||
private val browserStore: BrowserStore, | ||
private val tabFilter: (TabSessionState) -> Boolean, | ||
private val tray: TabsTray | ||
) { | ||
/** | ||
* Updates the inactive card to be expanded to display all the tabs, or collapsed with only | ||
* the title showing. | ||
*/ | ||
fun updateCardExpansion(isExpanded: Boolean) { | ||
InactiveTabsState.isExpanded = isExpanded | ||
|
||
val tabs = browserStore.state.toTabs { tabFilter.invoke(it) } | ||
|
||
tray.updateTabs(tabs) | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
app/src/main/java/org/mozilla/fenix/tabstray/browser/InactiveTabsInteractor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* 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.tabstray.browser | ||
|
||
interface InactiveTabsInteractor { | ||
fun onHeaderClicked(activated: Boolean) | ||
} | ||
|
||
class DefaultInactiveTabsInteractor( | ||
private val controller: InactiveTabsController | ||
) : InactiveTabsInteractor { | ||
override fun onHeaderClicked(activated: Boolean) { | ||
controller.updateCardExpansion(activated) | ||
} | ||
} | ||
|
||
/** | ||
* An experimental state holder for [InactiveTabsAdapter] that lives at the application lifetime. | ||
* | ||
* TODO This should be replaced with the AppStore. | ||
*/ | ||
object InactiveTabsState { | ||
var isExpanded = true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
app/src/test/java/org/mozilla/fenix/tabstray/browser/DefaultInactiveTabsInteractorTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* 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.tabstray.browser | ||
|
||
import io.mockk.mockk | ||
import io.mockk.verify | ||
import org.junit.Test | ||
|
||
class DefaultInactiveTabsInteractorTest { | ||
|
||
@Test | ||
fun `WHEN onHeaderClicked THEN updateCardExpansion`() { | ||
val controller: InactiveTabsController = mockk(relaxed = true) | ||
val interactor = DefaultInactiveTabsInteractor(controller) | ||
|
||
interactor.onHeaderClicked(true) | ||
|
||
verify { controller.updateCardExpansion(true) } | ||
} | ||
} |
Oops, something went wrong.