summaryrefslogtreecommitdiffstats
path: root/mobile/android/android-components/components/concept/tabstray
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:34:42 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:34:42 +0000
commitda4c7e7ed675c3bf405668739c3012d140856109 (patch)
treecdd868dba063fecba609a1d819de271f0d51b23e /mobile/android/android-components/components/concept/tabstray
parentAdding upstream version 125.0.3. (diff)
downloadfirefox-da4c7e7ed675c3bf405668739c3012d140856109.tar.xz
firefox-da4c7e7ed675c3bf405668739c3012d140856109.zip
Adding upstream version 126.0.upstream/126.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'mobile/android/android-components/components/concept/tabstray')
-rw-r--r--mobile/android/android-components/components/concept/tabstray/README.md19
-rw-r--r--mobile/android/android-components/components/concept/tabstray/build.gradle33
-rw-r--r--mobile/android/android-components/components/concept/tabstray/proguard-rules.pro21
-rw-r--r--mobile/android/android-components/components/concept/tabstray/src/main/AndroidManifest.xml4
-rw-r--r--mobile/android/android-components/components/concept/tabstray/src/main/java/mozilla/components/concept/tabstray/Tab.kt42
-rw-r--r--mobile/android/android-components/components/concept/tabstray/src/main/java/mozilla/components/concept/tabstray/Tabs.kt21
-rw-r--r--mobile/android/android-components/components/concept/tabstray/src/main/java/mozilla/components/concept/tabstray/TabsTray.kt44
7 files changed, 184 insertions, 0 deletions
diff --git a/mobile/android/android-components/components/concept/tabstray/README.md b/mobile/android/android-components/components/concept/tabstray/README.md
new file mode 100644
index 0000000000..56b5838a55
--- /dev/null
+++ b/mobile/android/android-components/components/concept/tabstray/README.md
@@ -0,0 +1,19 @@
+# [Android Components](../../../README.md) > Concept > Tabstray
+
+Abstract definition of a tabs tray component.
+
+## Usage
+
+### Setting up the dependency
+
+Use Gradle to download the library from [maven.mozilla.org](https://maven.mozilla.org/) ([Setup repository](../../../README.md#maven-repository)):
+
+```Groovy
+implementation "org.mozilla.components:concept-tabstray:{latest-version}"
+```
+
+## License
+
+ 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/
diff --git a/mobile/android/android-components/components/concept/tabstray/build.gradle b/mobile/android/android-components/components/concept/tabstray/build.gradle
new file mode 100644
index 0000000000..67d5ae9d25
--- /dev/null
+++ b/mobile/android/android-components/components/concept/tabstray/build.gradle
@@ -0,0 +1,33 @@
+/* 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/. */
+
+apply plugin: 'com.android.library'
+apply plugin: 'kotlin-android'
+
+android {
+ defaultConfig {
+ minSdkVersion config.minSdkVersion
+ compileSdk config.compileSdkVersion
+ targetSdkVersion config.targetSdkVersion
+ }
+
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ }
+ }
+
+ namespace 'mozilla.components.concept.tabstray'
+}
+
+dependencies {
+ api project(':concept-engine')
+
+ implementation project(':support-base')
+}
+
+apply from: '../../../android-lint.gradle'
+apply from: '../../../publish.gradle'
+ext.configurePublish(config.componentsGroupId, archivesBaseName, project.ext.description)
diff --git a/mobile/android/android-components/components/concept/tabstray/proguard-rules.pro b/mobile/android/android-components/components/concept/tabstray/proguard-rules.pro
new file mode 100644
index 0000000000..f1b424510d
--- /dev/null
+++ b/mobile/android/android-components/components/concept/tabstray/proguard-rules.pro
@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
diff --git a/mobile/android/android-components/components/concept/tabstray/src/main/AndroidManifest.xml b/mobile/android/android-components/components/concept/tabstray/src/main/AndroidManifest.xml
new file mode 100644
index 0000000000..e16cda1d34
--- /dev/null
+++ b/mobile/android/android-components/components/concept/tabstray/src/main/AndroidManifest.xml
@@ -0,0 +1,4 @@
+<!-- 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/. -->
+<manifest />
diff --git a/mobile/android/android-components/components/concept/tabstray/src/main/java/mozilla/components/concept/tabstray/Tab.kt b/mobile/android/android-components/components/concept/tabstray/src/main/java/mozilla/components/concept/tabstray/Tab.kt
new file mode 100644
index 0000000000..4de7bc7fe6
--- /dev/null
+++ b/mobile/android/android-components/components/concept/tabstray/src/main/java/mozilla/components/concept/tabstray/Tab.kt
@@ -0,0 +1,42 @@
+/* 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 mozilla.components.concept.tabstray
+
+import android.graphics.Bitmap
+import mozilla.components.concept.engine.mediasession.MediaSession
+
+/**
+ * Data class representing a tab to be displayed in a [TabsTray].
+ *
+ * @property id Unique ID of the tab.
+ * @property url Current URL of the tab.
+ * @property title Current title of the tab (or an empty [String]]).
+ * @property private whether or not the session is private.
+ * @property icon Current icon of the tab (or null)
+ * @property thumbnail Current thumbnail of the tab (or null)
+ * @property playbackState Current media session playback state for the tab (or null)
+ * @property controller Current media session controller for the tab (or null)
+ * @property lastAccess The last time this tab was selected.
+ * @property createdAt When the tab was first created.
+ * @property searchTerm the last used search term for this tab or from the originating tab, or an
+ * empty string if no search was executed.
+ */
+@Deprecated(
+ "This will be removed in a future release",
+ ReplaceWith("TabSessionState", "mozilla.components.browser.state.state"),
+)
+data class Tab(
+ val id: String,
+ val url: String,
+ val title: String = "",
+ val private: Boolean = false,
+ val icon: Bitmap? = null,
+ val thumbnail: Bitmap? = null,
+ val playbackState: MediaSession.PlaybackState? = null,
+ val controller: MediaSession.Controller? = null,
+ val lastAccess: Long = 0L,
+ val createdAt: Long = 0L,
+ val searchTerm: String = "",
+)
diff --git a/mobile/android/android-components/components/concept/tabstray/src/main/java/mozilla/components/concept/tabstray/Tabs.kt b/mobile/android/android-components/components/concept/tabstray/src/main/java/mozilla/components/concept/tabstray/Tabs.kt
new file mode 100644
index 0000000000..a6d83d4297
--- /dev/null
+++ b/mobile/android/android-components/components/concept/tabstray/src/main/java/mozilla/components/concept/tabstray/Tabs.kt
@@ -0,0 +1,21 @@
+/* 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 mozilla.components.concept.tabstray
+
+/**
+ * Aggregate data type keeping a reference to the list of tabs and the index of the selected tab.
+ *
+ * @property list The list of tabs.
+ * @property selectedTabId Id of the selected tab in the list of tabs (or null).
+ */
+@Deprecated(
+ "This will be removed in future versions",
+ ReplaceWith("TabList", "mozilla.components.feature.tabs.tabstray"),
+)
+@Suppress("Deprecation")
+data class Tabs(
+ val list: List<Tab>,
+ val selectedTabId: String?,
+)
diff --git a/mobile/android/android-components/components/concept/tabstray/src/main/java/mozilla/components/concept/tabstray/TabsTray.kt b/mobile/android/android-components/components/concept/tabstray/src/main/java/mozilla/components/concept/tabstray/TabsTray.kt
new file mode 100644
index 0000000000..0b85de4f74
--- /dev/null
+++ b/mobile/android/android-components/components/concept/tabstray/src/main/java/mozilla/components/concept/tabstray/TabsTray.kt
@@ -0,0 +1,44 @@
+/* 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 mozilla.components.concept.tabstray
+
+import mozilla.components.support.base.observer.Observable
+
+/**
+ * Generic interface for components that provide "tabs tray" functionality.
+ */
+@Deprecated("This will be removed in a future release", ReplaceWith("TabsTray", "mozilla.components.browser.tabstray"))
+@Suppress("Deprecation")
+interface TabsTray : Observable<TabsTray.Observer> {
+ /**
+ * Interface to be implemented by classes that want to observe a tabs tray.
+ */
+ interface Observer {
+ /**
+ * One or many tabs have been added or removed.
+ */
+ fun onTabsUpdated() = Unit
+
+ /**
+ * A new tab has been selected.
+ */
+ fun onTabSelected(tab: Tab)
+
+ /**
+ * A tab has been closed.
+ */
+ fun onTabClosed(tab: Tab)
+ }
+
+ /**
+ * Updates the list of tabs.
+ */
+ fun updateTabs(tabs: Tabs)
+
+ /**
+ * Called when binding a new item to get if it should be shown as selected or not.
+ */
+ fun isTabSelected(tabs: Tabs, position: Int): Boolean
+}