Bug 7189 - Provide page title in website information dialog (#7255)
* Bug 7189 - Provide page title in website information dialog * Update QSFS test * Fix Tiger's nitsmaster
parent
db34700e3a
commit
f728cdaf05
|
@ -155,6 +155,7 @@ class BrowserFragment : BaseBrowserFragment(), UserInteractionHandler {
|
|||
BrowserFragmentDirections.actionBrowserFragmentToQuickSettingsSheetDialogFragment(
|
||||
sessionId = session.id,
|
||||
url = session.url,
|
||||
title = session.title,
|
||||
isSecured = session.securityInfo.secure,
|
||||
sitePermissions = sitePermissions,
|
||||
gravity = getAppropriateLayoutGravity()
|
||||
|
|
|
@ -161,6 +161,7 @@ class ExternalAppBrowserFragment : BaseBrowserFragment(), UserInteractionHandler
|
|||
.actionExternalAppBrowserFragmentToQuickSettingsSheetDialogFragment(
|
||||
sessionId = session.id,
|
||||
url = session.url,
|
||||
title = session.title,
|
||||
isSecured = session.securityInfo.secure,
|
||||
sitePermissions = sitePermissions,
|
||||
gravity = getAppropriateLayoutGravity()
|
||||
|
|
|
@ -67,6 +67,7 @@ class QuickSettingsFragmentStore(
|
|||
*
|
||||
* @param context [Context] used for access to various Android resources.
|
||||
* @param websiteUrl [String] the URL of the current web page.
|
||||
* @param websiteTitle [String] the title of the current web page.
|
||||
* @param isSecured [Boolean] whether the connection is secured (TLS) or not.
|
||||
* @param permissions [SitePermissions]? list of website permissions and their status.
|
||||
* @param settings [Settings] application settings.
|
||||
|
@ -75,12 +76,13 @@ class QuickSettingsFragmentStore(
|
|||
fun createStore(
|
||||
context: Context,
|
||||
websiteUrl: String,
|
||||
websiteTitle: String,
|
||||
isSecured: Boolean,
|
||||
permissions: SitePermissions?,
|
||||
settings: Settings
|
||||
) = QuickSettingsFragmentStore(
|
||||
QuickSettingsFragmentState(
|
||||
webInfoState = createWebsiteInfoState(websiteUrl, isSecured),
|
||||
webInfoState = createWebsiteInfoState(websiteUrl, websiteTitle, isSecured),
|
||||
websitePermissionsState = createWebsitePermissionState(
|
||||
context,
|
||||
permissions,
|
||||
|
@ -101,13 +103,14 @@ class QuickSettingsFragmentStore(
|
|||
@VisibleForTesting
|
||||
fun createWebsiteInfoState(
|
||||
websiteUrl: String,
|
||||
websiteTitle: String,
|
||||
isSecured: Boolean
|
||||
): WebsiteInfoState {
|
||||
val (stringRes, iconRes, colorRes) = when (isSecured) {
|
||||
true -> getSecuredWebsiteUiValues
|
||||
false -> getInsecureWebsiteUiValues
|
||||
}
|
||||
return WebsiteInfoState(websiteUrl, stringRes, iconRes, colorRes)
|
||||
return WebsiteInfoState(websiteUrl, websiteTitle, stringRes, iconRes, colorRes)
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -217,12 +220,14 @@ data class QuickSettingsFragmentState(
|
|||
* [State] to be rendered by [WebsiteInfoView] indicating whether the connection is secure or not.
|
||||
*
|
||||
* @param websiteUrl [String] the URL of the current web page.
|
||||
* @param websiteTitle [String] the title of the current web page.
|
||||
* @param securityInfoRes [StringRes] for the connection description.
|
||||
* @param iconRes [DrawableRes] image indicating the connection status.
|
||||
* @param iconTintRes [ColorRes] icon color.
|
||||
*/
|
||||
data class WebsiteInfoState(
|
||||
val websiteUrl: String,
|
||||
val websiteTitle: String,
|
||||
@StringRes val securityInfoRes: Int,
|
||||
@DrawableRes val iconRes: Int,
|
||||
@ColorRes val iconTintRes: Int
|
||||
|
|
|
@ -67,6 +67,7 @@ class QuickSettingsSheetDialogFragment : AppCompatDialogFragment() {
|
|||
quickSettingsStore = QuickSettingsFragmentStore.createStore(
|
||||
context = context,
|
||||
websiteUrl = args.url,
|
||||
websiteTitle = args.title,
|
||||
isSecured = args.isSecured,
|
||||
permissions = args.sitePermissions,
|
||||
settings = Settings.getInstance(context)
|
||||
|
|
|
@ -37,6 +37,7 @@ class WebsiteInfoView(
|
|||
*/
|
||||
fun update(state: WebsiteInfoState) {
|
||||
bindUrl(state.websiteUrl)
|
||||
bindTitle(state.websiteTitle)
|
||||
bindSecurityInfo(state.securityInfoRes, state.iconRes, state.iconTintRes)
|
||||
}
|
||||
|
||||
|
@ -44,6 +45,10 @@ class WebsiteInfoView(
|
|||
view.url.text = url
|
||||
}
|
||||
|
||||
private fun bindTitle(title: String) {
|
||||
view.title.text = title
|
||||
}
|
||||
|
||||
private fun bindSecurityInfo(
|
||||
@StringRes securityInfoRes: Int,
|
||||
@DrawableRes iconRes: Int,
|
||||
|
|
|
@ -12,15 +12,21 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
style="@style/QuickSettingsText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="8dp"
|
||||
android:textStyle="bold"
|
||||
tools:text="Wikipedia" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/url"
|
||||
style="@style/QuickSettingsText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="8dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="https://wikipedia.org" />
|
||||
|
||||
<TextView
|
||||
|
@ -28,9 +34,6 @@
|
|||
style="@style/QuickSettingsText.Icon"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/quicksettings_item_height"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/url"
|
||||
tools:drawableStart="@drawable/mozac_ic_lock"
|
||||
tools:drawableTint="@color/photonGreen50"
|
||||
tools:text="Secure connection" />
|
||||
|
|
|
@ -582,6 +582,9 @@
|
|||
<argument
|
||||
android:name="sessionId"
|
||||
app:argType="string" />
|
||||
<argument
|
||||
android:name="title"
|
||||
app:argType="string" />
|
||||
<argument
|
||||
android:name="url"
|
||||
app:argType="string" />
|
||||
|
|
|
@ -57,7 +57,7 @@ class QuickSettingsFragmentStoreTest {
|
|||
val permissions = mockk<SitePermissions>(relaxed = true)
|
||||
|
||||
val store = QuickSettingsFragmentStore.createStore(
|
||||
context, "url", true, permissions, settings
|
||||
context, "url", "Hello", true, permissions, settings
|
||||
)
|
||||
|
||||
assertAll {
|
||||
|
@ -71,13 +71,15 @@ class QuickSettingsFragmentStoreTest {
|
|||
@Test
|
||||
fun `createWebsiteInfoState constructs a WebsiteInfoState with the right values for a secure connection`() {
|
||||
val websiteUrl = "https://host.com/page1"
|
||||
val websiteTitle = "Hello"
|
||||
val securedStatus = true
|
||||
|
||||
val state = QuickSettingsFragmentStore.createWebsiteInfoState(websiteUrl, securedStatus)
|
||||
val state = QuickSettingsFragmentStore.createWebsiteInfoState(websiteUrl, websiteTitle, securedStatus)
|
||||
|
||||
assertAll {
|
||||
assertThat(state).isNotNull()
|
||||
assertThat(state.websiteUrl).isSameAs(websiteUrl)
|
||||
assertThat(state.websiteTitle).isSameAs(websiteTitle)
|
||||
assertThat(state.securityInfoRes).isEqualTo(secureStringRes)
|
||||
assertThat(state.iconRes).isEqualTo(secureDrawableRes)
|
||||
assertThat(state.iconTintRes).isEqualTo(secureColorRes)
|
||||
|
@ -87,13 +89,15 @@ class QuickSettingsFragmentStoreTest {
|
|||
@Test
|
||||
fun `createWebsiteInfoState constructs a WebsiteInfoState with the right values for an insecure connection`() {
|
||||
val websiteUrl = "https://host.com/page1"
|
||||
val websiteTitle = "Hello"
|
||||
val securedStatus = false
|
||||
|
||||
val state = QuickSettingsFragmentStore.createWebsiteInfoState(websiteUrl, securedStatus)
|
||||
val state = QuickSettingsFragmentStore.createWebsiteInfoState(websiteUrl, websiteTitle, securedStatus)
|
||||
|
||||
assertAll {
|
||||
assertThat(state).isNotNull()
|
||||
assertThat(state.websiteUrl).isSameAs(websiteUrl)
|
||||
assertThat(state.websiteTitle).isSameAs(websiteTitle)
|
||||
assertThat(state.securityInfoRes).isEqualTo(insecureStringRes)
|
||||
assertThat(state.iconRes).isEqualTo(insecureDrawableRes)
|
||||
assertThat(state.iconTintRes).isEqualTo(insecureColorRes)
|
||||
|
|
Loading…
Reference in New Issue