From 85914a4232ae02d2b5fcc303b52b9fee79377fdd Mon Sep 17 00:00:00 2001 From: Arturo Mejia Date: Thu, 14 Oct 2021 10:25:47 -0400 Subject: [PATCH] =?UTF-8?q?For=20#21906=20=E2=81=83=20Remove=20old=20copy?= =?UTF-8?q?=20form=20inactive=20tabs=20section?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit 25c784b684efaa46cdb16652b1a2bd8a777aed46) --- .../tabstray/browser/InactiveTabViewHolder.kt | 35 ++----------------- .../tabstray/browser/InactiveTabsAdapter.kt | 12 +++---- .../org/mozilla/fenix/tabstray/ext/Context.kt | 14 -------- .../main/res/layout/inactive_footer_item.xml | 28 +-------------- app/src/main/res/values/strings.xml | 6 ++-- 5 files changed, 10 insertions(+), 85 deletions(-) diff --git a/app/src/main/java/org/mozilla/fenix/tabstray/browser/InactiveTabViewHolder.kt b/app/src/main/java/org/mozilla/fenix/tabstray/browser/InactiveTabViewHolder.kt index b7677b8867..d2d8671d58 100644 --- a/app/src/main/java/org/mozilla/fenix/tabstray/browser/InactiveTabViewHolder.kt +++ b/app/src/main/java/org/mozilla/fenix/tabstray/browser/InactiveTabViewHolder.kt @@ -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) -} diff --git a/app/src/main/java/org/mozilla/fenix/tabstray/browser/InactiveTabsAdapter.kt b/app/src/main/java/org/mozilla/fenix/tabstray/browser/InactiveTabsAdapter.kt index 473950a7ec..11e94a3bb4 100644 --- a/app/src/main/java/org/mozilla/fenix/tabstray/browser/InactiveTabsAdapter.kt +++ b/app/src/main/java/org/mozilla/fenix/tabstray/browser/InactiveTabsAdapter.kt @@ -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() } } diff --git a/app/src/main/java/org/mozilla/fenix/tabstray/ext/Context.kt b/app/src/main/java/org/mozilla/fenix/tabstray/ext/Context.kt index 92ad59cbfb..e8082ac6e7 100644 --- a/app/src/main/java/org/mozilla/fenix/tabstray/ext/Context.kt +++ b/app/src/main/java/org/mozilla/fenix/tabstray/ext/Context.kt @@ -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 - } - } diff --git a/app/src/main/res/layout/inactive_footer_item.xml b/app/src/main/res/layout/inactive_footer_item.xml index 955ff5b42a..ae13e8b318 100644 --- a/app/src/main/res/layout/inactive_footer_item.xml +++ b/app/src/main/res/layout/inactive_footer_item.xml @@ -15,37 +15,11 @@ android:paddingEnd="1dp" android:paddingBottom="1dp"> - - - - - \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6039ed8ca6..e45f7462b5 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1928,11 +1928,11 @@ Close all inactive tabs - Tabs are available here for %s. After that time, tabs will be automatically closed. + Tabs are available here for %s. After that time, tabs will be automatically closed. - 30 days + 30 days - 1 week + 1 week