mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-19 09:25:34 +00:00
For #21906 ⁃ Remove old copy form inactive tabs section
(cherry picked from commit 25c784b684
)
This commit is contained in:
parent
a5fa918e1f
commit
85914a4232
@ -5,7 +5,6 @@
|
||||
package org.mozilla.fenix.tabstray.browser
|
||||
|
||||
import android.view.View
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.core.view.updatePadding
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import mozilla.components.browser.toolbar.MAX_URI_LENGTH
|
||||
@ -19,10 +18,6 @@ import org.mozilla.fenix.ext.loadIntoView
|
||||
import org.mozilla.fenix.ext.toShortUrl
|
||||
import org.mozilla.fenix.home.sessioncontrol.viewholders.topsites.dpToPx
|
||||
import org.mozilla.fenix.tabstray.TabsTrayInteractor
|
||||
import org.mozilla.fenix.tabstray.browser.AutoCloseInterval.Manual
|
||||
import org.mozilla.fenix.tabstray.browser.AutoCloseInterval.OneDay
|
||||
import org.mozilla.fenix.tabstray.browser.AutoCloseInterval.OneMonth
|
||||
import org.mozilla.fenix.tabstray.browser.AutoCloseInterval.OneWeek
|
||||
|
||||
sealed class InactiveTabViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||
|
||||
@ -113,27 +108,8 @@ sealed class InactiveTabViewHolder(itemView: View) : RecyclerView.ViewHolder(ite
|
||||
|
||||
class FooterHolder(itemView: View) : InactiveTabViewHolder(itemView) {
|
||||
|
||||
val binding = InactiveFooterItemBinding.bind(itemView)
|
||||
|
||||
fun bind(interval: AutoCloseInterval) {
|
||||
val context = itemView.context
|
||||
val stringRes = when (interval) {
|
||||
Manual, OneDay -> {
|
||||
binding.inactiveDescription.visibility = View.GONE
|
||||
binding.topDivider.visibility = View.GONE
|
||||
null
|
||||
}
|
||||
OneWeek -> {
|
||||
context.getString(interval.description)
|
||||
}
|
||||
OneMonth -> {
|
||||
context.getString(interval.description)
|
||||
}
|
||||
}
|
||||
if (stringRes != null) {
|
||||
binding.inactiveDescription.text =
|
||||
context.getString(R.string.inactive_tabs_description, stringRes)
|
||||
}
|
||||
init {
|
||||
InactiveFooterItemBinding.bind(itemView)
|
||||
}
|
||||
|
||||
companion object {
|
||||
@ -141,10 +117,3 @@ sealed class InactiveTabViewHolder(itemView: View) : RecyclerView.ViewHolder(ite
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum class AutoCloseInterval(@StringRes val description: Int) {
|
||||
Manual(0),
|
||||
OneDay(0),
|
||||
OneWeek(R.string.inactive_tabs_7_days),
|
||||
OneMonth(R.string.inactive_tabs_30_days)
|
||||
}
|
||||
|
@ -18,7 +18,6 @@ import org.mozilla.fenix.tabstray.TabsTrayInteractor
|
||||
import org.mozilla.fenix.tabstray.browser.InactiveTabViewHolder.FooterHolder
|
||||
import org.mozilla.fenix.tabstray.browser.InactiveTabViewHolder.HeaderHolder
|
||||
import org.mozilla.fenix.tabstray.browser.InactiveTabViewHolder.TabViewHolder
|
||||
import org.mozilla.fenix.tabstray.ext.autoCloseInterval
|
||||
import mozilla.components.support.base.observer.Observable as ComponentObservable
|
||||
|
||||
/**
|
||||
@ -67,11 +66,8 @@ class InactiveTabsAdapter(
|
||||
val item = getItem(position) as Item.Tab
|
||||
holder.bind(item.tab)
|
||||
}
|
||||
is FooterHolder -> {
|
||||
val item = getItem(position) as Item.Footer
|
||||
holder.bind(item.interval)
|
||||
}
|
||||
is HeaderHolder -> {
|
||||
|
||||
is HeaderHolder, is FooterHolder -> {
|
||||
// do nothing.
|
||||
}
|
||||
}
|
||||
@ -99,7 +95,7 @@ class InactiveTabsAdapter(
|
||||
}
|
||||
|
||||
val items = tabs.list.map { Item.Tab(it) }
|
||||
val footer = Item.Footer(context.autoCloseInterval)
|
||||
val footer = Item.Footer
|
||||
|
||||
submitList(listOf(Item.Header) + items + listOf(footer))
|
||||
}
|
||||
@ -140,6 +136,6 @@ class InactiveTabsAdapter(
|
||||
* A footer for the inactive tab section. This may be seen only
|
||||
* when at least one inactive tab is present.
|
||||
*/
|
||||
data class Footer(val interval: AutoCloseInterval) : Item()
|
||||
object Footer : Item()
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ package org.mozilla.fenix.tabstray.ext
|
||||
|
||||
import android.content.Context
|
||||
import org.mozilla.fenix.ext.components
|
||||
import org.mozilla.fenix.tabstray.browser.AutoCloseInterval
|
||||
|
||||
const val MIN_COLUMN_WIDTH_DP = 180
|
||||
|
||||
@ -32,16 +31,3 @@ internal val Context.defaultBrowserLayoutColumns: Int
|
||||
1
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the appropriate [AutoCloseInterval] based on user preferences.
|
||||
*/
|
||||
internal val Context.autoCloseInterval: AutoCloseInterval
|
||||
get() = with(components.settings) {
|
||||
when {
|
||||
closeTabsAfterOneDay -> AutoCloseInterval.OneDay
|
||||
closeTabsAfterOneWeek -> AutoCloseInterval.OneWeek
|
||||
closeTabsAfterOneMonth -> AutoCloseInterval.OneMonth
|
||||
else -> AutoCloseInterval.Manual
|
||||
}
|
||||
}
|
||||
|
@ -15,37 +15,11 @@
|
||||
android:paddingEnd="1dp"
|
||||
android:paddingBottom="1dp">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/rounded_bottom_corners"
|
||||
android:paddingBottom="8dp">
|
||||
|
||||
<View
|
||||
android:id="@+id/top_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?neutralFaded"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/inactive_description"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:textColor="?secondaryText"
|
||||
android:textSize="12sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/top_divider"
|
||||
tools:text="@string/inactive_tabs_description" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</FrameLayout>
|
@ -1928,11 +1928,11 @@
|
||||
<!-- Content description for closing all inactive tabs -->
|
||||
<string name="inactive_tabs_delete_all">Close all inactive tabs</string>
|
||||
<!-- A description below the section of "inactive" tabs to notify the user when those tabs will be closed, if appropriate. See strings inactive_tabs_30_days and inactive_tabs_7_days for placeholders options. -->
|
||||
<string name="inactive_tabs_description">Tabs are available here for %s. After that time, tabs will be automatically closed.</string>
|
||||
<string name="inactive_tabs_description" moz:removedIn="95" tools:ignore="UnusedResources">Tabs are available here for %s. After that time, tabs will be automatically closed.</string>
|
||||
<!-- The amount of time until a tab in the "inactive" section of the tabs tray will be closed. See string inactive_tabs_description as well -->
|
||||
<string name="inactive_tabs_30_days">30 days</string>
|
||||
<string name="inactive_tabs_30_days" moz:removedIn="95" tools:ignore="UnusedResources">30 days</string>
|
||||
<!-- The amount of time until a tab in the "inactive" section of the tabs tray will be closed. See string inactive_tabs_description as well -->
|
||||
<string name="inactive_tabs_7_days">1 week</string>
|
||||
<string name="inactive_tabs_7_days" moz:removedIn="95" tools:ignore="UnusedResources">1 week</string>
|
||||
|
||||
<!-- Inactive tabs auto-close message in the tabs tray -->
|
||||
<!-- The header text of the auto-close message when the user is asked if they want to turn on the auto-closing of inactive tabs. -->
|
||||
|
Loading…
Reference in New Issue
Block a user