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