Truncate urls to prevent slowing down of UI
This commit is contained in:
parent
adfed996a2
commit
8ac2dc317b
|
@ -11,9 +11,9 @@ import android.util.Patterns
|
|||
import android.webkit.URLUtil
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.core.net.toUri
|
||||
import mozilla.components.browser.toolbar.MAX_URI_LENGTH
|
||||
import mozilla.components.lib.publicsuffixlist.PublicSuffixList
|
||||
import mozilla.components.support.ktx.android.net.hostWithoutCommonPrefixes
|
||||
import mozilla.components.support.ktx.kotlin.MAX_URI_LENGTH
|
||||
import org.mozilla.fenix.components.components
|
||||
import org.mozilla.fenix.compose.inComposePreview
|
||||
import java.net.IDN
|
||||
|
|
|
@ -43,6 +43,7 @@ import androidx.compose.ui.tooling.preview.Preview
|
|||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import mozilla.components.concept.sync.DeviceType
|
||||
import mozilla.components.support.ktx.kotlin.trimmed
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.compose.Image
|
||||
import org.mozilla.fenix.compose.ThumbnailCard
|
||||
|
@ -127,7 +128,7 @@ fun RecentSyncedTab(
|
|||
RecentTabTitlePlaceholder()
|
||||
} else {
|
||||
Text(
|
||||
text = tab.title,
|
||||
text = tab.title.trimmed(),
|
||||
color = FirefoxTheme.colors.textPrimary,
|
||||
fontSize = 14.sp,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
|
|
|
@ -52,6 +52,7 @@ import mozilla.components.browser.icons.compose.Placeholder
|
|||
import mozilla.components.browser.icons.compose.WithIcon
|
||||
import mozilla.components.browser.state.state.ContentState
|
||||
import mozilla.components.browser.state.state.TabSessionState
|
||||
import mozilla.components.support.ktx.kotlin.trimmed
|
||||
import mozilla.components.ui.colors.PhotonColors
|
||||
import org.mozilla.fenix.components.components
|
||||
import org.mozilla.fenix.compose.Image
|
||||
|
@ -143,7 +144,7 @@ private fun RecentTabItem(
|
|||
verticalArrangement = Arrangement.SpaceBetween,
|
||||
) {
|
||||
Text(
|
||||
text = tab.state.content.title.ifEmpty { tab.state.content.url },
|
||||
text = tab.state.content.title.ifEmpty { tab.state.content.url.trimmed() },
|
||||
color = FirefoxTheme.colors.textPrimary,
|
||||
fontSize = 14.sp,
|
||||
maxLines = 2,
|
||||
|
@ -163,7 +164,7 @@ private fun RecentTabItem(
|
|||
Spacer(modifier = Modifier.width(8.dp))
|
||||
|
||||
Text(
|
||||
text = tab.state.content.url,
|
||||
text = tab.state.content.url.trimmed(),
|
||||
color = FirefoxTheme.colors.textSecondary,
|
||||
fontSize = 12.sp,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
|
|
|
@ -46,6 +46,7 @@ import androidx.compose.ui.text.style.TextOverflow
|
|||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import mozilla.components.support.ktx.kotlin.trimmed
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.compose.EagerFlingBehavior
|
||||
import org.mozilla.fenix.compose.Favicon
|
||||
|
@ -239,7 +240,7 @@ private fun RecentlyVisitedHistoryHighlight(
|
|||
|
||||
Box(modifier = Modifier.fillMaxSize()) {
|
||||
RecentlyVisitedTitle(
|
||||
text = recentVisit.title,
|
||||
text = recentVisit.title.trimmed(),
|
||||
modifier = Modifier.align(Alignment.CenterStart),
|
||||
)
|
||||
|
||||
|
|
|
@ -25,10 +25,10 @@ import mozilla.components.browser.tabstray.SelectableTabViewHolder
|
|||
import mozilla.components.browser.tabstray.TabsTray
|
||||
import mozilla.components.browser.tabstray.TabsTrayStyling
|
||||
import mozilla.components.browser.tabstray.thumbnail.TabThumbnailView
|
||||
import mozilla.components.browser.toolbar.MAX_URI_LENGTH
|
||||
import mozilla.components.concept.base.images.ImageLoadRequest
|
||||
import mozilla.components.concept.base.images.ImageLoader
|
||||
import mozilla.components.concept.engine.mediasession.MediaSession
|
||||
import mozilla.components.support.ktx.kotlin.MAX_URI_LENGTH
|
||||
import mozilla.telemetry.glean.private.NoExtras
|
||||
import org.mozilla.fenix.FeatureFlags
|
||||
import org.mozilla.fenix.GleanMetrics.Tab
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
package org.mozilla.fenix.tabstray.ext
|
||||
|
||||
import mozilla.components.browser.storage.sync.SyncedDeviceTabs
|
||||
import mozilla.components.browser.toolbar.MAX_URI_LENGTH
|
||||
import mozilla.components.support.ktx.kotlin.trimmed
|
||||
import org.mozilla.fenix.tabstray.syncedtabs.SyncedTabsListItem
|
||||
|
||||
/**
|
||||
|
@ -20,7 +20,7 @@ fun List<SyncedDeviceTabs>.toComposeList(
|
|||
} else {
|
||||
tabs.map {
|
||||
val url = it.active().url
|
||||
val titleText = it.active().title.ifEmpty { url.take(MAX_URI_LENGTH) }
|
||||
val titleText = it.active().title.ifEmpty { url.trimmed() }
|
||||
SyncedTabsListItem.Tab(titleText, url, it)
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ fun List<SyncedDeviceTabs>.toComposeList(
|
|||
} else {
|
||||
tabs.asSequence().map {
|
||||
val url = it.active().url
|
||||
val titleText = it.active().title.ifEmpty { url.take(MAX_URI_LENGTH) }
|
||||
val titleText = it.active().title.ifEmpty { url.trimmed() }
|
||||
SyncedTabsListItem.Tab(titleText, url, it)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
package org.mozilla.fenix.tabstray.ext
|
||||
|
||||
import mozilla.components.browser.state.state.TabSessionState
|
||||
import mozilla.components.browser.toolbar.MAX_URI_LENGTH
|
||||
import mozilla.components.support.ktx.kotlin.trimmed
|
||||
|
||||
fun TabSessionState.isActive(maxActiveTime: Long): Boolean {
|
||||
val lastActiveTime = maxOf(lastAccess, createdAt)
|
||||
|
@ -58,4 +58,4 @@ internal fun TabSessionState.isNormalTab(): Boolean {
|
|||
/**
|
||||
* Returns a [String] for displaying a [TabSessionState]'s title or its url when a title is not available.
|
||||
*/
|
||||
fun TabSessionState.toDisplayTitle(): String = content.title.ifEmpty { content.url.take(MAX_URI_LENGTH) }
|
||||
fun TabSessionState.toDisplayTitle(): String = content.title.ifEmpty { content.url.trimmed() }
|
||||
|
|
|
@ -3,5 +3,5 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
object AndroidComponents {
|
||||
const val VERSION = "108.0.20221019143129"
|
||||
const val VERSION = "108.0.20221019190112"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue