Commit Graph

217 Commits

Author SHA1 Message Date
mcarare
92fe0c0234 [components] For https://github.com/mozilla-mobile/android-components/issues/12724: Upgrade compose to 1.2.1 version.
Split versioning of compose compiler.
Enable Xjvm-default to allow inheriting from interfaces with '@JvmDefault' members
like RememberObserver.
2022-09-08 08:22:09 +00:00
Jonathan Almeida
7bb88450b5 [components] Close https://github.com/mozilla-mobile/android-components/issues/12267: Add support for Save to PDF in GeckoEngineSession
Adds support for Save to PDF from the GeckoSession by plugging the
API into `onExternalResponse` to provide the same flow as a typical
file download experience would be.

Co-authored-by: Olivia Hall <ohall@mozilla.com>
2022-08-15 14:29:34 +00:00
mcarare
30e5a6f476 [components] For https://github.com/mozilla-mobile/android-components/issues/12402: Run Robolectric with SDK 32. 2022-06-29 16:31:33 +00:00
mcarare
2a1c468edc [components] For https://github.com/mozilla-mobile/android-components/issues/12376: Run Robolectric with SDK 31.
Current Robolectric version does not support SDK 32.
2022-06-28 13:42:14 +00:00
Alexandru2909
9096d03439 [components] For https://github.com/mozilla-mobile/android-components/issues/12217 - Add support for onPromptUpdate
- Handle ChoicePrompt updates
2022-06-02 15:01:29 +00:00
Arturo Mejia
b6b2484fcd [components] Closes https://github.com/mozilla-mobile/android-components/issues/12190: Create a middleware that allows to change tabs priority. 2022-05-26 13:38:30 +00:00
Roger Yang
09dd0c3e07 [components] Issue https://github.com/mozilla-mobile/android-components/issues/12149: Add support for application search engine type 2022-05-16 19:02:13 +00:00
Mugurell
d78b06b6bf [components] For https://github.com/mozilla-mobile/android-components/pull/11175 - Migrate runBlocking and runBlockingTest to runTest in unit tests
Used `runTestOnMain` where `MainCoroutineRule` was used or needed to be used,
`runTest` elsewhere.

Extra effort for removing all `runBlocking` occurrences in unit tests.
`kotlinx.coroutines.test.runTest` is a test specific API that seems like a more
appropriate way for running tests in a coroutine than the general
`kotlinx.coroutines.runBlocking` api.
2022-05-10 13:45:03 +00:00
Mugurell
2963708053 [components] For https://github.com/mozilla-mobile/android-components/issues/11755 - Replace TestCoroutineDispatcher with UnconfinedTestDispatcher
- Refactor out all usages of TestCoroutineDispatcher and TestCoroutineScope
- Refactor MainCoroutineRule to now use UnconfinedTestDispatcher by default.
This dispatcher will eagerly enter all launch or async blocks being more suited
to our codebase.
2022-05-10 13:45:03 +00:00
mcarare
2275e49731 [components] For https://github.com/mozilla-mobile/android-components/issues/9684: Run tests on sdk 30. 2022-04-28 08:33:29 +00:00
Mugurell
f91cb8abe1 [components] For https://github.com/mozilla-mobile/android-components/issues/11753 - Update compose to 1.1.1 and Kotlin to 1.6.10
This also required updating room to >= 2.4.0.
This new version adds a deprecation of the `MigrationTestHelper` api used in
`LoginExceptionStorageTest` that is to be later fixed in https://github.com/mozilla-mobile/android-components/issues/11765.

`activity_compose` was also update to the latest stable version to ensure a
better match with the latest stable version for compose.

Used 1.6.10 for Kotlin although 1.6.20 is available to prevent any issues with
Compose 1.1.1 reported as an error at compile time:
"e: This version (1.1.1) of the Compose Compiler requires Kotlin version 1.6.10
but you appear to be using Kotlin version 1.6.20 which is not known to be
compatible.  Please fix your configuration (or
`suppressKotlinVersionCompatibilityCheck` but don't say I didn't warn you!)."
2022-04-18 17:28:25 +00:00
Mugurell
f04e8b683c [components] Revert "For https://github.com/mozilla-mobile/android-components/issues/11753 - Update compose to 1.1.0 and Kotlin to 1.6.10"
This reverts commit 3feac3db3901ef73efcd0e14c04b47cbdab2e7ff.
2022-02-28 22:27:21 +00:00
Mugurell
97b77729c7 [components] For https://github.com/mozilla-mobile/android-components/issues/11753 - Update compose to 1.1.0 and Kotlin to 1.6.10
This also required updating room to >= 2.4.0.
This new version adds a deprecation of the `MigrationTestHelper` api used in
`LoginExceptionStorageTest` that is to be later fixed in https://github.com/mozilla-mobile/android-components/issues/11765.

activity_compose was also update to the latest stable version to ensure a
better match with the latest stable version for compose.
2022-02-24 10:12:43 +00:00
Grigory Kruglov
03794ddc5b [components] Avoid eagerly rehydrating EngineSessionState for recently closed tabs
This change splits out tab-specific data from RecoverableTab data class
into a separate TabState (so, it doesn't have the EngineSessionState).

Then, once we have the simplified TabState, everything that touches RecentlyClosedTabs
is converted to use that instead of its more expensive sibling.

This way we avoid having to eagerly process EngineSessionState simply to populate BrowserState.closedTabs.
This saves us from having to hit disk (where the EngineSessionState is persisted) on initializing BrowserState (so, startup in most cases).
It also saves us from having to parse/rehydrate that persisted state.

At the point we actually need the EngineSessionState for a tab we'd like to restore, we can read/process it.
2022-02-14 14:54:00 -08:00
Roger Yang
5fd04be267 [components] No issue: Add TabPartition tests 2022-01-19 23:43:56 +00:00
Roger Yang
5ebbe97126 [components] Close https://github.com/mozilla-mobile/android-components/issues/11383: Ensure each tab group does not have duplicate tab IDs 2022-01-12 23:18:58 +00:00
Roger Yang
fdd23e4a5f [components] Close https://github.com/mozilla-mobile/android-components/issues/11383: Add tabstray support for search term tab grouping logic with middleware 2022-01-12 15:27:26 +00:00
Jonathan Almeida
2916c0a537 [components] Close https://github.com/mozilla-mobile/android-components/issues/11444: Add optional user interaction param to goBack/goForward 2021-12-31 02:47:38 +00:00
Sebastian Kaspari
e2a4af5cf6 [components] Issue https://github.com/mozilla-mobile/android-components/issues/11300: EngineMiddleware: Add option for disabling TrimMemoryMiddleware 2021-11-23 18:43:44 +00:00
Christian Sadilek
e2b56538db [components] Closes https://github.com/mozilla-mobile/android-components/issues/11208: Add tab partitions and groups to BrowserState 2021-11-22 21:49:21 +00:00
Christian Sadilek
57173a94e0 [components] Closes https://github.com/mozilla-mobile/android-components/issues/11241: TabSessionState.lastAccess not updated when application resumes 2021-11-09 13:57:57 -05:00
Gabriel Luong
7fe5c17265 [components] Issue https://github.com/mozilla-mobile/android-components/issues/11155 - Integrate onPreviewImage API from GeckoView 2021-10-25 20:46:09 +00:00
Sebastian Kaspari
90ec41fc3a [components] Update Kotlin and Jetpack Compose versions. 2021-10-25 10:58:07 +00:00
Grisha Kruglov
b356d9275a [components] Add DisbandSearchGroupAction to allow removing search groups from tab state 2021-10-13 10:13:39 -07:00
Christian Sadilek
743fcdaa5c [components] Issue https://github.com/mozilla-mobile/android-components/issues/11066: Make optimized load url case observable in middlewares 2021-10-13 15:42:38 +00:00
codrut.topliceanu
ef9c198245 [components] For https://github.com/mozilla-mobile/android-components/issues/10867 - Dismisses user prompt when GV calls onPromptDismiss 2021-10-06 14:47:52 +00:00
ssk97
6e1133eacf [components] Support Moving/Reordering Tabs (https://github.com/mozilla-mobile/android-components/pull/10936)
* Add MoveTabsAction and tests for it

* Add MoveTabsUseCase and a test

* Add getFilter to TabsFeature

* ktlint/detekt formating pass

* Changelog entry

* Fix cut off comment

* Remove action reference comment

* Remove unneeded setting of selectedTabId in copy

* Replace filter getter with just making the variable public
It's simpler and I can't see why it shouldn't be modifiable.

* API change from position+filter to target+placeAfter.
Also added a "tab not found" check.

* Add another test, clean up changelog

* Animate moving tabs via movement rather than add+delete.

* Put Private modifier back, improve documentation.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-09-22 15:16:29 +00:00
Roger Yang
f92d25401a [components] Close https://github.com/mozilla-mobile/android-components/issues/10984: Persist search term in content state 2021-09-15 15:56:34 +00:00
Sebastian Kaspari
0a59c1785a [components] RemoveAllPrivateTabsAction: Clear selectedTabId if no new selection is available. 2021-09-06 12:49:36 +00:00
Noah Bond
6d21d293b6 [components] Undo tab position fix - fix for https://github.com/mozilla-mobile/fenix/issues/18210 (https://github.com/mozilla-mobile/android-components/pull/10777)
* Refactored the tab restoration flow to support restoring tabs at their original index.

* Lint check fixes

* Refactored the index class variable name and made it non-null

* Refactored RestoreAction to take an ENUM for a restoration location.

* Cleaned up tests and lint errors

* Fixed broken test after restore tab refactor

* Refactored the location of RestoreLocation and revised instances of "removalIndex"

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-08-31 19:06:48 +00:00
Noah Bond
ae756f53a9 [components] For https://github.com/mozilla-mobile/android-components/issues/10560: Fixed bug causing external links to open tabs irrespective of the session's private status (https://github.com/mozilla-mobile/android-components/pull/10857)
* For https://github.com/mozilla-mobile/android-components/issues/10560: Fixed bug causing external links to open tabs irrespective of the session's private status

* Updated findTabByUrl function names and comments for better clarity

* Fixed import detekt issue

* Refactored selectors test for better clarity

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-08-31 18:53:52 +00:00
Mugurell
e277dd03f0 [components] For https://github.com/mozilla-mobile/android-components/issues/10803 - Force expanding the toolbar if requested by GeckoView 2021-08-16 07:46:15 +00:00
Jonathan Almeida
e7d3f34077 [components] Close https://github.com/mozilla-mobile/android-components/issues/10769: Add DebugAction.UpdateCreatedAtAction with reducer
We wanted to introduce this action for testing purposes in client apps
that want to "turn back time" for a certain tab.

The difficulty is in ensuring clients do not misuse these actions, and
we thought of a few strategies:

- Option 1: Make a separate grouping called `DebugAction` and document
that these are special actions.

- Option 2: Using a middleware, we only allow changes to the store
depending on some dynmamic logic in the client app. This is a bit
complicated and requries the user to restart the app to add this
special middleware.

- Option 3: Add an annotation that requires the client to opt into using
the action.

In this patch, I decided to go with a combination of options 1 and 3
which gave us the right about of warning and flexibility.

With option 2, we were still required to add new actions to the store
and the middleware would not have prevented misuse in those cases.
2021-08-12 03:56:04 +00:00
Grisha Kruglov
47a5196e6a [components] Make sure to preserve private state when recreating a RecoverableTab
regression from https://github.com/mozilla-mobile/android-components/pull/10711/files
2021-08-05 15:53:27 -07:00
Grisha Kruglov
2cb270feed [components] Introduced 'restored' content state for tracking tab restoration 2021-08-05 11:47:54 -07:00
Grisha Kruglov
14a116801f [components] Support for tracking external sources
Mainly, does two things:
- refactors SessionState.Source into a richer form (splitting sources
  into Internal and External, where External ones track information
  about originating package)
- adds persistence of External sources into tab session state; we don't
  want to persist Internal sources as that was explicitly removed before
  for causing various issues (e.g. UI behaving incorrectly after
  restoring tabs with various internal sources set)
2021-08-05 11:47:54 -07:00
codrut.topliceanu
3bd5ddb4a0 [components] For https://github.com/mozilla-mobile/android-components/issues/10603 - Adds createdAt to TabSessionState 2021-08-02 10:07:38 +00:00
Sebastian Kaspari
ce323400dd [components] Run ktlintFormat to fix new ktlint errors. 2021-07-28 12:03:23 +00:00
Arturo Mejia
e4d539f111 [components] Closes https://github.com/mozilla-mobile/android-components/issues/10448 show toolbar permissions indicator when permissions change from their default. 2021-07-27 17:25:23 +00:00
Mugurell
d67a681ba6 [components] For https://github.com/mozilla-mobile/android-components/issues/10632 - Add a new mediaSessionActive property to LastMediaAccessState
This new property helps with separating the current responsibilities of
lastMediaAccess such that after this:
- lastMediaAccess is only updated when media starts playing allowing clients to
order media tabs and find the first / last tab with in progress media.
- lastHadMediaSessionActive indicates whether a MediaSession should be active
for this tab and serves as a backup for lastMediaUrl for the situations where a
website might allow media to continue playing even when the users accesses
another page (with another URL) in that same HTML document.
2021-07-21 19:10:46 +00:00
Mugurell
58cf65e681 [components] For https://github.com/mozilla-mobile/android-components/issues/10632 - Persist and restore tab LastMediaAccessState 2021-07-21 19:10:46 +00:00
Mugurell
097eeb01e2 [components] For https://github.com/mozilla-mobile/android-components/issues/10632 - Try to update mediaState only for TabSessionState
Renamed "BrowserState.updateTabState" to a more appropriate
"BrowserState.updateTabOrCustomTabState" signaling that it can be used to
update any tab or custom tab.

Created two new "BrowserState.updateTabState" and
"BrowserState.updateCustomTabState" extension methods to allow updating the
state of either tabs or custom tabs depending on the properties needing update.

By this we are forcing the clients to choose what type of SessionState they
want updated and in so limiting the situations in which the old API would try
to update any SessionState and could throw a ClassCastException if in the
"update" lambda parameter callers would try to update a property not existing
in one SessionState implementation but available in other.
2021-07-21 19:10:46 +00:00
Mugurell
0c7b4d7866 [components] For https://github.com/mozilla-mobile/android-components/issues/10632 - Migrate TabSessionState's lastMediaAccess to LastMediaAccessState
LastMediaAccessState contains both
- lastMediaAccess - timestamp for the last time media started playing
(which is reset to 0 when GV deactivates the MediaSession)
- lastMediaUrl - tab url when media started playing

By combining this two properties we'll know that a tab has in progress media
even when:
- the user navigates to another page in the same document
but media continues to play, MediaSession exists, lastMediaAccess is not reset,
- media starts playing in another tab
but the previous media tab has the same url as lastMediaUrl.

After media starting to play in a tab only if
- user navigated to another website and
- MediaSession is deactivated (happens when navigating to another website or
when media starts playing in another tab)
will we consider that this tab doesn't anymore have in progress media.
2021-07-21 19:10:46 +00:00
Sebastian Kaspari
f14b267388 [components] Issue https://github.com/mozilla-mobile/android-components/issues/10335: Update dependencies to support Jetpack Compose and add first prototype components.
* Issue https://github.com/mozilla-mobile/android-components/issues/10335: Upgrade to Gradle 7.
* Update Android Gradle Plugin to 7.0.0 Beta 2.
* Issue https://github.com/mozilla-mobile/android-components/issues/10335: Generate BuildConfig with VERSION_CODE and VERSION_NAME fields in library modules (for Glean).
* Issue https://github.com/mozilla-mobile/android-components/issues/10335: Add first component using Jetpack Compose: compose-browser-toolbar.
* Issue https://github.com/mozilla-mobile/android-components/issues/10335: Introduce Jetpack Compose bindings for lib-state.
* Issue https://github.com/mozilla-mobile/android-components/issues/10335: Upstream Jetpack Compose toolbar prototype from Reference Browser.
* Issue https://github.com/mozilla-mobile/android-components/issues/10335: Add TargetTab helper for observing specific tabs.
* Issue https://github.com/mozilla-mobile/android-components/issues/10335: Add compose-engine component for adding Jetpack Compose bindings to a concept-engine implementation.
* Issue https://github.com/mozilla-mobile/android-components/issues/10335: Add new sample app (samples-compose-browser) for prototyping browser UI using Jetpack Compose.
* Issue https://github.com/mozilla-mobile/android-components/issues/10335: Update to Beta 3 of the Android Gradle plugin.
* Issue https://github.com/mozilla-mobile/android-components/issues/10335: Allow usage of http when substituting maven repositories in CI.
* Issue https://github.com/mozilla-mobile/android-components/issues/10335: Rename TabTarget helper to just Target.
* Issue https://github.com/mozilla-mobile/android-components/issues/10335: Make BrowserToolbar follow target tab too.
* Add awesomebar prototype using Jetpack Compose.
* Update to Gradle 7.0.2.
2021-07-20 16:22:26 +00:00
codrut.topliceanu
1e510d2772 [components] For https://github.com/mozilla-mobile/android-components/issues/10624 - Adds recoverable param to RemoveAllTabsAction
...to be used by UndoMiddleware.kt to prevent closed tabs from being recoverable
2021-07-19 14:49:23 +00:00
Mugurell
4e14471fa6 [components] For https://github.com/mozilla-mobile/android-components/issues/10470 - Persist and restore lastMediaAccess of TabSessionState 2021-07-08 17:08:25 +00:00
Mugurell
11b0ca6e98 [components] For https://github.com/mozilla-mobile/android-components/issues/10470 - Add a new lastMediaAccess property for TabSessionState
This new property will be a timestamp of the last time media started playing in
the current page or be 0 if media hadn't started playing or another page loaded
in this tab so media was stopped.

To observe the media changes and update this property LastMediaAccessMiddleware
will have to be set on BrowserStore.
2021-07-08 17:08:25 +00:00
Grisha Kruglov
ccb0a5014b [components] Extension functions for converting URLs to search terms 2021-06-17 19:36:48 +00:00
Christian Sadilek
ad14e1fdd2 [components] Add findNormalTab and selectedNormalTab extensions 2021-06-16 14:14:46 +00:00
mcarare
636adaf2a9 [components] For https://github.com/mozilla-mobile/android-components/issues/10404: Remove deprecated kotlin-android-extensions plugin
(cherry picked from commit d99621583ceb11e7d91ebe284e40aec145793e48)
2021-06-15 08:32:26 +00:00