mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 10:33:45 +00:00
Enable the Optimised Media Uploads feature. (#3467)
* Enable the Optimised Media Uploads feature.
(Well move the toggle from Developer Options to Advanced Settings)
* Add OptimizeMediaUploads analytics.
* Final strings.
* Upload reduced quality media by default 😢
Move the setting out of the feature flags section in the file.
* Fix unit tests now the default has changed.
* Pull in updated string, fix snapshots.
This commit is contained in:
@@ -7874,7 +7874,7 @@
|
|||||||
repositoryURL = "https://github.com/matrix-org/matrix-analytics-events";
|
repositoryURL = "https://github.com/matrix-org/matrix-analytics-events";
|
||||||
requirement = {
|
requirement = {
|
||||||
kind = upToNextMinorVersion;
|
kind = upToNextMinorVersion;
|
||||||
minimumVersion = 0.27.0;
|
minimumVersion = 0.28.0;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
C13F55E4518415CB4C278E73 /* XCRemoteSwiftPackageReference "DTCoreText" */ = {
|
C13F55E4518415CB4C278E73 /* XCRemoteSwiftPackageReference "DTCoreText" */ = {
|
||||||
|
|||||||
@@ -131,8 +131,8 @@
|
|||||||
"kind" : "remoteSourceControl",
|
"kind" : "remoteSourceControl",
|
||||||
"location" : "https://github.com/matrix-org/matrix-analytics-events",
|
"location" : "https://github.com/matrix-org/matrix-analytics-events",
|
||||||
"state" : {
|
"state" : {
|
||||||
"revision" : "9bd3c57e84f87d56b69862369f3b9da714d1d151",
|
"revision" : "632f4266d5ebd5b87b9eb52522f5117723fcd338",
|
||||||
"version" : "0.27.0"
|
"version" : "0.28.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -391,8 +391,8 @@
|
|||||||
"screen_account_provider_signup_title" = "You’re about to create an account on %@";
|
"screen_account_provider_signup_title" = "You’re about to create an account on %@";
|
||||||
"screen_advanced_settings_developer_mode" = "Developer mode";
|
"screen_advanced_settings_developer_mode" = "Developer mode";
|
||||||
"screen_advanced_settings_developer_mode_description" = "Enable to have access to features and functionality for developers.";
|
"screen_advanced_settings_developer_mode_description" = "Enable to have access to features and functionality for developers.";
|
||||||
"screen_advanced_settings_media_compression_description" = "Optimize for upload";
|
"screen_advanced_settings_media_compression_description" = "Upload photos and videos faster and reduce data usage";
|
||||||
"screen_advanced_settings_media_compression_title" = "Media";
|
"screen_advanced_settings_media_compression_title" = "Optimise media quality";
|
||||||
"screen_advanced_settings_rich_text_editor_description" = "Disable the rich text editor to type Markdown manually.";
|
"screen_advanced_settings_rich_text_editor_description" = "Disable the rich text editor to type Markdown manually.";
|
||||||
"screen_advanced_settings_send_read_receipts" = "Read receipts";
|
"screen_advanced_settings_send_read_receipts" = "Read receipts";
|
||||||
"screen_advanced_settings_send_read_receipts_description" = "If turned off, your read receipts won't be sent to anyone. You will still receive read receipts from other users.";
|
"screen_advanced_settings_send_read_receipts_description" = "If turned off, your read receipts won't be sent to anyone. You will still receive read receipts from other users.";
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ final class AppSettings {
|
|||||||
case pusherProfileTag
|
case pusherProfileTag
|
||||||
case logLevel
|
case logLevel
|
||||||
case viewSourceEnabled
|
case viewSourceEnabled
|
||||||
|
case optimizeMediaUploads
|
||||||
case appAppearance
|
case appAppearance
|
||||||
case sharePresence
|
case sharePresence
|
||||||
case hideUnreadMessagesBadge
|
case hideUnreadMessagesBadge
|
||||||
@@ -42,7 +43,6 @@ final class AppSettings {
|
|||||||
|
|
||||||
// Feature flags
|
// Feature flags
|
||||||
case slidingSyncDiscovery
|
case slidingSyncDiscovery
|
||||||
case optimizeMediaUploads
|
|
||||||
case publicSearchEnabled
|
case publicSearchEnabled
|
||||||
case fuzzyRoomListSearchEnabled
|
case fuzzyRoomListSearchEnabled
|
||||||
case enableOnlySignedDeviceIsolationMode
|
case enableOnlySignedDeviceIsolationMode
|
||||||
@@ -238,6 +238,9 @@ final class AppSettings {
|
|||||||
@UserPreference(key: UserDefaultsKeys.viewSourceEnabled, defaultValue: isDevelopmentBuild, storageType: .userDefaults(store))
|
@UserPreference(key: UserDefaultsKeys.viewSourceEnabled, defaultValue: isDevelopmentBuild, storageType: .userDefaults(store))
|
||||||
var viewSourceEnabled
|
var viewSourceEnabled
|
||||||
|
|
||||||
|
@UserPreference(key: UserDefaultsKeys.optimizeMediaUploads, defaultValue: true, storageType: .userDefaults(store))
|
||||||
|
var optimizeMediaUploads
|
||||||
|
|
||||||
// MARK: - Element Call
|
// MARK: - Element Call
|
||||||
|
|
||||||
let elementCallBaseURL: URL = "https://call.element.io"
|
let elementCallBaseURL: URL = "https://call.element.io"
|
||||||
@@ -275,9 +278,6 @@ final class AppSettings {
|
|||||||
@UserPreference(key: UserDefaultsKeys.slidingSyncDiscovery, defaultValue: .native, storageType: .userDefaults(store))
|
@UserPreference(key: UserDefaultsKeys.slidingSyncDiscovery, defaultValue: .native, storageType: .userDefaults(store))
|
||||||
var slidingSyncDiscovery: SlidingSyncDiscovery
|
var slidingSyncDiscovery: SlidingSyncDiscovery
|
||||||
|
|
||||||
@UserPreference(key: UserDefaultsKeys.optimizeMediaUploads, defaultValue: false, storageType: .userDefaults(store))
|
|
||||||
var optimizeMediaUploads
|
|
||||||
|
|
||||||
@UserPreference(key: UserDefaultsKeys.knockingEnabled, defaultValue: false, storageType: .userDefaults(store))
|
@UserPreference(key: UserDefaultsKeys.knockingEnabled, defaultValue: false, storageType: .userDefaults(store))
|
||||||
var knockingEnabled
|
var knockingEnabled
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ struct SettingsFlowCoordinatorParameters {
|
|||||||
let appSettings: AppSettings
|
let appSettings: AppSettings
|
||||||
let navigationSplitCoordinator: NavigationSplitCoordinator
|
let navigationSplitCoordinator: NavigationSplitCoordinator
|
||||||
let userIndicatorController: UserIndicatorControllerProtocol
|
let userIndicatorController: UserIndicatorControllerProtocol
|
||||||
|
let analytics: AnalyticsService
|
||||||
}
|
}
|
||||||
|
|
||||||
class SettingsFlowCoordinator: FlowCoordinatorProtocol {
|
class SettingsFlowCoordinator: FlowCoordinatorProtocol {
|
||||||
@@ -174,7 +175,7 @@ class SettingsFlowCoordinator: FlowCoordinatorProtocol {
|
|||||||
|
|
||||||
private func presentAnalyticsScreen() {
|
private func presentAnalyticsScreen() {
|
||||||
let coordinator = AnalyticsSettingsScreenCoordinator(parameters: .init(appSettings: parameters.appSettings,
|
let coordinator = AnalyticsSettingsScreenCoordinator(parameters: .init(appSettings: parameters.appSettings,
|
||||||
analytics: ServiceLocator.shared.analytics))
|
analytics: parameters.analytics))
|
||||||
navigationStackCoordinator?.push(coordinator)
|
navigationStackCoordinator?.push(coordinator)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,7 +222,8 @@ class SettingsFlowCoordinator: FlowCoordinatorProtocol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func presentAdvancedSettings() {
|
private func presentAdvancedSettings() {
|
||||||
let coordinator = AdvancedSettingsScreenCoordinator()
|
let coordinator = AdvancedSettingsScreenCoordinator(parameters: .init(appSettings: parameters.appSettings,
|
||||||
|
analytics: parameters.analytics))
|
||||||
navigationStackCoordinator.push(coordinator)
|
navigationStackCoordinator.push(coordinator)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -99,7 +99,8 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
|
|||||||
secureBackupController: userSession.clientProxy.secureBackupController,
|
secureBackupController: userSession.clientProxy.secureBackupController,
|
||||||
appSettings: appSettings,
|
appSettings: appSettings,
|
||||||
navigationSplitCoordinator: navigationSplitCoordinator,
|
navigationSplitCoordinator: navigationSplitCoordinator,
|
||||||
userIndicatorController: ServiceLocator.shared.userIndicatorController))
|
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||||
|
analytics: analytics))
|
||||||
|
|
||||||
onboardingFlowCoordinator = OnboardingFlowCoordinator(userSession: userSession,
|
onboardingFlowCoordinator = OnboardingFlowCoordinator(userSession: userSession,
|
||||||
appLockService: appLockService,
|
appLockService: appLockService,
|
||||||
|
|||||||
@@ -846,9 +846,9 @@ internal enum L10n {
|
|||||||
internal static var screenAdvancedSettingsElementCallBaseUrlDescription: String { return L10n.tr("Localizable", "screen_advanced_settings_element_call_base_url_description") }
|
internal static var screenAdvancedSettingsElementCallBaseUrlDescription: String { return L10n.tr("Localizable", "screen_advanced_settings_element_call_base_url_description") }
|
||||||
/// Invalid URL, please make sure you include the protocol (http/https) and the correct address.
|
/// Invalid URL, please make sure you include the protocol (http/https) and the correct address.
|
||||||
internal static var screenAdvancedSettingsElementCallBaseUrlValidationError: String { return L10n.tr("Localizable", "screen_advanced_settings_element_call_base_url_validation_error") }
|
internal static var screenAdvancedSettingsElementCallBaseUrlValidationError: String { return L10n.tr("Localizable", "screen_advanced_settings_element_call_base_url_validation_error") }
|
||||||
/// Optimize for upload
|
/// Upload photos and videos faster and reduce data usage
|
||||||
internal static var screenAdvancedSettingsMediaCompressionDescription: String { return L10n.tr("Localizable", "screen_advanced_settings_media_compression_description") }
|
internal static var screenAdvancedSettingsMediaCompressionDescription: String { return L10n.tr("Localizable", "screen_advanced_settings_media_compression_description") }
|
||||||
/// Media
|
/// Optimise media quality
|
||||||
internal static var screenAdvancedSettingsMediaCompressionTitle: String { return L10n.tr("Localizable", "screen_advanced_settings_media_compression_title") }
|
internal static var screenAdvancedSettingsMediaCompressionTitle: String { return L10n.tr("Localizable", "screen_advanced_settings_media_compression_title") }
|
||||||
/// Disable the rich text editor to type Markdown manually.
|
/// Disable the rich text editor to type Markdown manually.
|
||||||
internal static var screenAdvancedSettingsRichTextEditorDescription: String { return L10n.tr("Localizable", "screen_advanced_settings_rich_text_editor_description") }
|
internal static var screenAdvancedSettingsRichTextEditorDescription: String { return L10n.tr("Localizable", "screen_advanced_settings_rich_text_editor_description") }
|
||||||
|
|||||||
+7
-2
@@ -8,11 +8,16 @@
|
|||||||
import Combine
|
import Combine
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
|
struct AdvancedSettingsScreenCoordinatorParameters {
|
||||||
|
let appSettings: AppSettings
|
||||||
|
let analytics: AnalyticsService
|
||||||
|
}
|
||||||
|
|
||||||
final class AdvancedSettingsScreenCoordinator: CoordinatorProtocol {
|
final class AdvancedSettingsScreenCoordinator: CoordinatorProtocol {
|
||||||
private var viewModel: AdvancedSettingsScreenViewModelProtocol
|
private var viewModel: AdvancedSettingsScreenViewModelProtocol
|
||||||
|
|
||||||
init() {
|
init(parameters: AdvancedSettingsScreenCoordinatorParameters) {
|
||||||
viewModel = AdvancedSettingsScreenViewModel(advancedSettings: ServiceLocator.shared.settings)
|
viewModel = AdvancedSettingsScreenViewModel(advancedSettings: parameters.appSettings, analytics: parameters.analytics)
|
||||||
}
|
}
|
||||||
|
|
||||||
func toPresentable() -> AnyView {
|
func toPresentable() -> AnyView {
|
||||||
|
|||||||
+5
-1
@@ -26,12 +26,16 @@ struct AdvancedSettingsScreenViewStateBindings {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum AdvancedSettingsScreenViewAction { }
|
enum AdvancedSettingsScreenViewAction {
|
||||||
|
case optimizeMediaUploadsChanged
|
||||||
|
}
|
||||||
|
|
||||||
protocol AdvancedSettingsProtocol: AnyObject {
|
protocol AdvancedSettingsProtocol: AnyObject {
|
||||||
var viewSourceEnabled: Bool { get set }
|
var viewSourceEnabled: Bool { get set }
|
||||||
var appAppearance: AppAppearance { get set }
|
var appAppearance: AppAppearance { get set }
|
||||||
var sharePresence: Bool { get set }
|
var sharePresence: Bool { get set }
|
||||||
|
|
||||||
|
var optimizeMediaUploads: Bool { get set }
|
||||||
}
|
}
|
||||||
|
|
||||||
extension AppSettings: AdvancedSettingsProtocol { }
|
extension AppSettings: AdvancedSettingsProtocol { }
|
||||||
|
|||||||
+12
-4
@@ -11,12 +11,20 @@ import SwiftUI
|
|||||||
typealias AdvancedSettingsScreenViewModelType = StateStoreViewModel<AdvancedSettingsScreenViewState, AdvancedSettingsScreenViewAction>
|
typealias AdvancedSettingsScreenViewModelType = StateStoreViewModel<AdvancedSettingsScreenViewState, AdvancedSettingsScreenViewAction>
|
||||||
|
|
||||||
class AdvancedSettingsScreenViewModel: AdvancedSettingsScreenViewModelType, AdvancedSettingsScreenViewModelProtocol {
|
class AdvancedSettingsScreenViewModel: AdvancedSettingsScreenViewModelType, AdvancedSettingsScreenViewModelProtocol {
|
||||||
init(advancedSettings: AdvancedSettingsProtocol) {
|
private let analytics: AnalyticsService
|
||||||
let bindings = AdvancedSettingsScreenViewStateBindings(advancedSettings: advancedSettings)
|
|
||||||
let state = AdvancedSettingsScreenViewState(bindings: bindings)
|
|
||||||
|
|
||||||
|
init(advancedSettings: AdvancedSettingsProtocol, analytics: AnalyticsService) {
|
||||||
|
self.analytics = analytics
|
||||||
|
|
||||||
|
let state = AdvancedSettingsScreenViewState(bindings: .init(advancedSettings: advancedSettings))
|
||||||
super.init(initialViewState: state)
|
super.init(initialViewState: state)
|
||||||
}
|
}
|
||||||
|
|
||||||
override func process(viewAction: AdvancedSettingsScreenViewAction) { }
|
override func process(viewAction: AdvancedSettingsScreenViewAction) {
|
||||||
|
switch viewAction {
|
||||||
|
case .optimizeMediaUploadsChanged:
|
||||||
|
// Note: Using a view action here as sinking the AppSettings publisher tracks the initial value.
|
||||||
|
analytics.trackInteraction(name: state.bindings.optimizeMediaUploads ? .MobileSettingsOptimizeMediaUploadsEnabled : .MobileSettingsOptimizeMediaUploadsDisabled)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-2
@@ -18,12 +18,20 @@ struct AdvancedSettingsScreen: View {
|
|||||||
kind: .picker(selection: $context.appAppearance,
|
kind: .picker(selection: $context.appAppearance,
|
||||||
items: AppAppearance.allCases.map { (title: $0.name, tag: $0) }))
|
items: AppAppearance.allCases.map { (title: $0.name, tag: $0) }))
|
||||||
|
|
||||||
ListRow(label: .plain(title: L10n.actionViewSource),
|
ListRow(label: .plain(title: L10n.actionViewSource,
|
||||||
|
description: L10n.screenAdvancedSettingsViewSourceDescription),
|
||||||
kind: .toggle($context.viewSourceEnabled))
|
kind: .toggle($context.viewSourceEnabled))
|
||||||
|
|
||||||
ListRow(label: .plain(title: L10n.screenAdvancedSettingsSharePresence,
|
ListRow(label: .plain(title: L10n.screenAdvancedSettingsSharePresence,
|
||||||
description: L10n.screenAdvancedSettingsSharePresenceDescription),
|
description: L10n.screenAdvancedSettingsSharePresenceDescription),
|
||||||
kind: .toggle($context.sharePresence))
|
kind: .toggle($context.sharePresence))
|
||||||
|
|
||||||
|
ListRow(label: .plain(title: L10n.screenAdvancedSettingsMediaCompressionTitle,
|
||||||
|
description: L10n.screenAdvancedSettingsMediaCompressionDescription),
|
||||||
|
kind: .toggle($context.optimizeMediaUploads))
|
||||||
|
.onChange(of: context.optimizeMediaUploads) {
|
||||||
|
context.send(viewAction: .optimizeMediaUploadsChanged)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.compoundList()
|
.compoundList()
|
||||||
@@ -48,7 +56,8 @@ private extension AppAppearance {
|
|||||||
// MARK: - Previews
|
// MARK: - Previews
|
||||||
|
|
||||||
struct AdvancedSettingsScreen_Previews: PreviewProvider, TestablePreview {
|
struct AdvancedSettingsScreen_Previews: PreviewProvider, TestablePreview {
|
||||||
static let viewModel = AdvancedSettingsScreenViewModel(advancedSettings: ServiceLocator.shared.settings)
|
static let viewModel = AdvancedSettingsScreenViewModel(advancedSettings: ServiceLocator.shared.settings,
|
||||||
|
analytics: ServiceLocator.shared.analytics)
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
NavigationStack {
|
NavigationStack {
|
||||||
AdvancedSettingsScreen(context: viewModel.context)
|
AdvancedSettingsScreen(context: viewModel.context)
|
||||||
|
|||||||
-1
@@ -46,7 +46,6 @@ protocol DeveloperOptionsProtocol: AnyObject {
|
|||||||
var hideUnreadMessagesBadge: Bool { get set }
|
var hideUnreadMessagesBadge: Bool { get set }
|
||||||
var fuzzyRoomListSearchEnabled: Bool { get set }
|
var fuzzyRoomListSearchEnabled: Bool { get set }
|
||||||
var hideTimelineMedia: Bool { get set }
|
var hideTimelineMedia: Bool { get set }
|
||||||
var optimizeMediaUploads: Bool { get set }
|
|
||||||
var enableOnlySignedDeviceIsolationMode: Bool { get set }
|
var enableOnlySignedDeviceIsolationMode: Bool { get set }
|
||||||
var elementCallBaseURLOverride: URL? { get set }
|
var elementCallBaseURLOverride: URL? { get set }
|
||||||
var knockingEnabled: Bool { get set }
|
var knockingEnabled: Bool { get set }
|
||||||
|
|||||||
-6
@@ -62,12 +62,6 @@ struct DeveloperOptionsScreen: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Section("Media") {
|
|
||||||
Toggle(isOn: $context.optimizeMediaUploads) {
|
|
||||||
Text("Optimise for upload")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Section {
|
Section {
|
||||||
Toggle(isOn: $context.enableOnlySignedDeviceIsolationMode) {
|
Toggle(isOn: $context.enableOnlySignedDeviceIsolationMode) {
|
||||||
Text("Exclude insecure devices when sending/receiving messages")
|
Text("Exclude insecure devices when sending/receiving messages")
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:484136606f2b3dd8cdc29f5b4f943622c2e770672c5a1980ff0e7db55a499c09
|
oid sha256:7dbc230120926d73fde55e42c43e36ef868bd893e600e749c66f979daa3f5659
|
||||||
size 114860
|
size 139055
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:bdfd7ebbf5f14f045bdaf416aa405d277edce74fdd3f7040f82b488e60074dc1
|
oid sha256:e71fa4df1e53f4fde23993f2242cc6c1cf239a78bf4a9b46aa1f982f32ae680d
|
||||||
size 126470
|
size 159915
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:987c192f5c1ab4c07fc198c190b3867843d9b459e6edf71a5057102853fe9941
|
oid sha256:a505289fc465bfdb3a40660c5fff6828c528574669cd4967fd9c63ce810043f8
|
||||||
size 66997
|
size 89637
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:fd509058af6af0c07b4350bf19e33dc16ca76c977be0c99d03614f4810374235
|
oid sha256:94b8e86129726c0f05a02136b7afa70cb0ae080896d4bc67841dbfa81e7fc3ac
|
||||||
size 84485
|
size 127155
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ final class MediaUploadingPreprocessorTests: XCTestCase {
|
|||||||
override func setUp() {
|
override func setUp() {
|
||||||
AppSettings.resetAllSettings()
|
AppSettings.resetAllSettings()
|
||||||
appSettings = AppSettings()
|
appSettings = AppSettings()
|
||||||
|
appSettings.optimizeMediaUploads = false
|
||||||
ServiceLocator.shared.register(appSettings: appSettings)
|
ServiceLocator.shared.register(appSettings: appSettings)
|
||||||
mediaUploadingPreprocessor = MediaUploadingPreprocessor(appSettings: appSettings)
|
mediaUploadingPreprocessor = MediaUploadingPreprocessor(appSettings: appSettings)
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -68,7 +68,7 @@ packages:
|
|||||||
# path: ../compound-ios
|
# path: ../compound-ios
|
||||||
AnalyticsEvents:
|
AnalyticsEvents:
|
||||||
url: https://github.com/matrix-org/matrix-analytics-events
|
url: https://github.com/matrix-org/matrix-analytics-events
|
||||||
minorVersion: 0.27.0
|
minorVersion: 0.28.0
|
||||||
# path: ../matrix-analytics-events
|
# path: ../matrix-analytics-events
|
||||||
Emojibase:
|
Emojibase:
|
||||||
url: https://github.com/matrix-org/emojibase-bindings
|
url: https://github.com/matrix-org/emojibase-bindings
|
||||||
|
|||||||
Reference in New Issue
Block a user