Add accessibility labels/hints. Fix tests. Show analytics prompt to everyone.

This commit is contained in:
Doug 2021-12-08 12:00:23 +00:00
parent a2aa01f06c
commit 59486c824a
6 changed files with 26 additions and 11 deletions

View file

@ -78,6 +78,7 @@
// Accessibility
"accessibility_checkbox_label" = "checkbox";
"accessibility_button_label" = "button";
// Authentication
"auth_login" = "Log in";

View file

@ -15,6 +15,10 @@ public class VectorL10n: NSObject {
public static var accept: String {
return VectorL10n.tr("Vector", "accept")
}
/// button
public static var accessibilityButtonLabel: String {
return VectorL10n.tr("Vector", "accessibility_button_label")
}
/// checkbox
public static var accessibilityCheckboxLabel: String {
return VectorL10n.tr("Vector", "accessibility_checkbox_label")

View file

@ -32,10 +32,10 @@ import AnalyticsEvents
/// Whether or not the object is enabled and sending events to the server.
var isRunning: Bool { client.isRunning }
/// Whether the user has yet to opt in or out of analytics collection.
/// Whether to show the user the analytics opt in prompt.
var shouldShowAnalyticsPrompt: Bool {
// Show an analytics prompt when the user hasn't seen the PostHog prompt before.
!RiotSettings.shared.hasSeenAnalyticsPrompt
// Only show the prompt once, and when analytics are configured in BuildSettings.
!RiotSettings.shared.hasSeenAnalyticsPrompt && PHGPostHogConfiguration.standard != nil
}
/// Indicates whether the user previously accepted Matomo analytics and should be shown the upgrade prompt.

View file

@ -14,7 +14,7 @@
// limitations under the License.
//
import Foundation
import UIKit
struct MockAnalyticsPromptStrings: AnalyticsPromptStringsProtocol {
var appDisplayName = "Element"

View file

@ -40,6 +40,8 @@ struct AnalyticsPrompt: View {
Text("\(viewModel.viewState.promptType.description)\n")
AnalyticsPromptTermsText(attributedString: viewModel.viewState.promptType.termsStrings)
.accessibilityLabel(Text(viewModel.viewState.promptType.termsStrings.string))
.accessibilityValue(Text(VectorL10n.accessibilityButtonLabel))
.onTapGesture {
viewModel.send(viewAction: .openTermsURL)
}
@ -50,10 +52,15 @@ struct AnalyticsPrompt: View {
private var checkmarkList: some View {
VStack(alignment: .leading) {
AnalyticsPromptCheckmarkItem(attributedString: viewModel.viewState.strings.point1)
.accessibilityLabel(Text(viewModel.viewState.strings.point1.string))
AnalyticsPromptCheckmarkItem(attributedString: viewModel.viewState.strings.point2)
.accessibilityLabel(Text(viewModel.viewState.strings.point2.string))
AnalyticsPromptCheckmarkItem(string: VectorL10n.analyticsPromptPoint3)
}
.font(theme.fonts.body)
.frame(maxWidth: .infinity)
}
/// The stack of enable/disable buttons.
@ -89,6 +96,7 @@ struct AnalyticsPrompt: View {
.padding(.bottom, 2)
descriptionText
.font(theme.fonts.body)
.foregroundColor(theme.colors.secondaryContent)
.multilineTextAlignment(.center)

View file

@ -28,8 +28,8 @@ class AnalyticsTests: XCTestCase {
let displayUpgradeMessage = Analytics.shared.promptShouldDisplayUpgradeMessage
// Then the regular prompt should be shown.
XCTAssertTrue(showPrompt, "A prompt should be shown when for a new user")
XCTAssertFalse(displayUpgradeMessage, "The prompt should not ask about upgrading from Matomo")
XCTAssertTrue(showPrompt, "A prompt should be shown for a new user.")
XCTAssertFalse(displayUpgradeMessage, "The prompt should not ask about upgrading from Matomo.")
}
func testAnalyticsPromptUpgradeFromMatomo() {
@ -42,8 +42,8 @@ class AnalyticsTests: XCTestCase {
let displayUpgradeMessage = Analytics.shared.promptShouldDisplayUpgradeMessage
// Then an upgrade prompt should be shown.
XCTAssertTrue(showPrompt, "A prompt should be shown when for a new user")
XCTAssertTrue(displayUpgradeMessage, "The prompt should not ask about upgrading from Matomo")
XCTAssertTrue(showPrompt, "A prompt should be shown to the user.")
XCTAssertTrue(displayUpgradeMessage, "The prompt should ask about upgrading from Matomo.")
}
func testAnalyticsPromptUserDeclinedMatomo() {
@ -53,9 +53,11 @@ class AnalyticsTests: XCTestCase {
// When the user is prompted for analytics
let showPrompt = Analytics.shared.shouldShowAnalyticsPrompt
let displayUpgradeMessage = Analytics.shared.promptShouldDisplayUpgradeMessage
// Then no prompt should be shown.
XCTAssertFalse(showPrompt, "A prompt should be shown when for a new user")
// Then the regular prompt should be shown.
XCTAssertTrue(showPrompt, "A prompt should be shown to the user.")
XCTAssertFalse(displayUpgradeMessage, "The prompt should not ask about upgrading from Matomo.")
}
func testAnalyticsPromptUserAcceptedPostHog() {
@ -66,6 +68,6 @@ class AnalyticsTests: XCTestCase {
let showPrompt = Analytics.shared.shouldShowAnalyticsPrompt
// Then no prompt should be shown.
XCTAssertFalse(showPrompt, "A prompt should be shown when for a new user")
XCTAssertFalse(showPrompt, "A prompt should not be shown any more.")
}
}