From fd7bbaf4d77b5373938f451e434008f944a0357a Mon Sep 17 00:00:00 2001 From: Norbel AMBANUMBEN Date: Mon, 24 Jun 2024 14:43:17 +0100 Subject: [PATCH] feat (OONI Run v2): update preference screens to match new designs (#563) Fixes https://github.com/ooni/ooni.org/issues/1516 ## Proposed Changes - Updated Preference view. - Remove cell separators. |.|.|.| |-|-|-| | ![Simulator Screenshot - iPhone 15 Pro Max - 2024-06-17 at 12 16 22](https://github.com/ooni/probe-ios/assets/17911892/da283012-625f-4aae-a679-2c0e81240ef9)| ![Simulator Screenshot - iPhone 15 Pro Max - 2024-06-17 at 12 16 27](https://github.com/ooni/probe-ios/assets/17911892/65429962-8fe5-4274-ac4a-377b9db6c40e) | ![Simulator Screenshot - iPhone 15 Pro Max - 2024-06-17 at 12 16 31](https://github.com/ooni/probe-ios/assets/17911892/6508f17d-cca2-4364-93c2-b6cdae21d443) | | ![Simulator Screenshot - iPhone 15 Pro Max - 2024-06-17 at 12 16 36](https://github.com/ooni/probe-ios/assets/17911892/861ae3db-3707-4442-a567-300983434b32) | ![Simulator Screenshot - iPhone 15 Pro Max - 2024-06-17 at 12 16 42](https://github.com/ooni/probe-ios/assets/17911892/63c8f7a5-5ca2-4abc-acc4-3daa28881bea) | ![Simulator Screenshot - iPhone 15 Pro Max - 2024-06-17 at 12 16 58](https://github.com/ooni/probe-ios/assets/17911892/2ec2163e-28c8-4b3b-bb0d-db4abd9bc07b) | | ![Simulator Screenshot - iPhone 15 Pro Max - 2024-06-17 at 12 17 04](https://github.com/ooni/probe-ios/assets/17911892/e152614c-d4bc-4115-9eea-54e284ed2254) |. |.| --- OONIProbeUITests/OONIProbeUITests.swift | 6 ++-- ooniprobe/Storyboards/Settings.storyboard | 10 +++---- ooniprobe/Utility/SettingsUtility.m | 29 ++++++++++--------- .../SettingsCategoriesTableViewController.m | 3 ++ .../Settings/SettingsTableViewController.m | 17 ++++------- .../WebsiteCategoriesTableViewController.m | 4 +++ 6 files changed, 36 insertions(+), 33 deletions(-) diff --git a/OONIProbeUITests/OONIProbeUITests.swift b/OONIProbeUITests/OONIProbeUITests.swift index 4485a9cb..5ea6c1dc 100644 --- a/OONIProbeUITests/OONIProbeUITests.swift +++ b/OONIProbeUITests/OONIProbeUITests.swift @@ -149,11 +149,11 @@ class OONIProbeUITests: XCTestCase { XCTAssertFalse(tablesQuery.cells.element(boundBy: 0).images["not_uploaded_icon"].exists) settingsButton.tap() - tablesQuery.cells.element(boundBy: 3).tap() - let resultSwitch = tablesQuery.cells.element(boundBy: 0).children(matching: .switch).element + tablesQuery.cells.element(boundBy: 2).tap() // Privacy Settings + let resultSwitch = tablesQuery.cells.element(boundBy: 0).children(matching: .switch).element // Automatically publish results if ((resultSwitch.value as? String) == "1"){ - resultSwitch.tap() + resultSwitch.tap() // turn off automatic publishing of results } //From https://stackoverflow.com/questions/44222966/from-an-xcuitest-how-can-i-check-the-on-off-state-of-a-uiswitch diff --git a/ooniprobe/Storyboards/Settings.storyboard b/ooniprobe/Storyboards/Settings.storyboard index 08b0367f..95d5eb12 100644 --- a/ooniprobe/Storyboards/Settings.storyboard +++ b/ooniprobe/Storyboards/Settings.storyboard @@ -1,9 +1,9 @@ - + - + @@ -485,7 +485,7 @@ measurement-kit: x.y.z - + @@ -511,7 +511,7 @@ measurement-kit: x.y.z - + @@ -522,7 +522,7 @@ measurement-kit: x.y.z - + diff --git a/ooniprobe/Utility/SettingsUtility.m b/ooniprobe/Utility/SettingsUtility.m index b24257cd..bab78e54 100644 --- a/ooniprobe/Utility/SettingsUtility.m +++ b/ooniprobe/Utility/SettingsUtility.m @@ -6,7 +6,7 @@ @implementation SettingsUtility + (NSArray*)getSettingsCategories{ - return @[@"notifications", @"automated_testing", @"test_options", @"privacy", @"advanced", @"ooni_backend_proxy", @"send_email", @"about_ooni"]; + return @[@"notifications", @"test_options", @"privacy", @"advanced", @"ooni_backend_proxy", @"send_email", @"about_ooni"]; } + (NSArray*)getSettingsForCategory:(NSString*)categoryName{ @@ -15,10 +15,11 @@ + (NSArray*)getSettingsForCategory:(NSString*)categoryName{ return @[@"notifications_enabled"]; } if ([categoryName isEqualToString:@"automated_testing"]) { - if ([SettingsUtility isAutomatedTestEnabled]) + if ([SettingsUtility isAutomatedTestEnabled]) { return @[@"automated_testing_enabled", @"automated_testing_wifionly", @"automated_testing_charging"]; - else + } else { return @[@"automated_testing_enabled"]; + } } else if ([categoryName isEqualToString:@"privacy"]) { return @[@"upload_results", @"send_crash"]; @@ -28,25 +29,25 @@ + (NSArray*)getSettingsForCategory:(NSString*)categoryName{ return @[@"AppleLanguages", @"debug_logs", @"storage_usage" , @"warn_vpn_in_use"]; } else if ([categoryName isEqualToString:@"test_options"]) { - return [TestUtility getTestOptionTypes]; - } - else if ([[TestUtility getTestOptionTypes] containsObject:categoryName]) - return [SettingsUtility getSettingsForTest:categoryName :YES]; - else + return @[@"automated_testing_enabled", @"automated_testing_wifionly", @"automated_testing_charging", @"website_categories", @"max_runtime_enabled", @"max_runtime"]; + } else { return nil; + } } + (NSString*)getTypeForSetting:(NSString*)setting{ - if ([setting isEqualToString:@"experimental"] || [setting isEqualToString:@"long_running_tests_in_foreground"]) + if ([setting isEqualToString:@"experimental"] || [setting isEqualToString:@"long_running_tests_in_foreground"]) { return @"bool"; - else if ([setting isEqualToString:@"website_categories"] || [[TestUtility getTestOptionTypes] containsObject:setting]) + } else if ([setting isEqualToString:@"website_categories"]) { return @"segue"; - else if ([setting isEqualToString:@"monthly_mobile_allowance"] || - [setting isEqualToString:@"monthly_wifi_allowance"] || - [setting isEqualToString:@"max_runtime"]) + } else if ([setting isEqualToString:@"monthly_mobile_allowance"] || + [setting isEqualToString:@"monthly_wifi_allowance"] || + [setting isEqualToString:@"max_runtime"]) { return @"int"; - if ([setting isEqualToString:@"storage_usage"] || [setting isEqualToString:@"AppleLanguages"]) + } + if ([setting isEqualToString:@"storage_usage"] || [setting isEqualToString:@"AppleLanguages"]) { return @"button"; + } return @"bool"; } diff --git a/ooniprobe/View/Settings/SettingsCategoriesTableViewController.m b/ooniprobe/View/Settings/SettingsCategoriesTableViewController.m index c9979530..b4858e2f 100644 --- a/ooniprobe/View/Settings/SettingsCategoriesTableViewController.m +++ b/ooniprobe/View/Settings/SettingsCategoriesTableViewController.m @@ -14,6 +14,8 @@ - (void)awakeFromNib{ - (void)viewDidLoad { [super viewDidLoad]; + self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone; // remove separator + self.tableView.backgroundColor = [UIColor colorNamed:@"color_gray1"]; [NavigationBarUtility setNavigationBar:self.navigationController.navigationBar]; categories = [SettingsUtility getSettingsCategories]; } @@ -45,6 +47,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N cell.textLabel.text = [LocalizationUtility getNameForSetting:current]; cell.textLabel.textColor = [UIColor colorNamed:@"color_gray9"]; cell.imageView.image = [UIImage imageNamed:current]; + cell.backgroundColor = [UIColor colorNamed:@"color_gray1"]; return cell; } diff --git a/ooniprobe/View/Settings/SettingsTableViewController.m b/ooniprobe/View/Settings/SettingsTableViewController.m index d53c24a8..83d2a847 100644 --- a/ooniprobe/View/Settings/SettingsTableViewController.m +++ b/ooniprobe/View/Settings/SettingsTableViewController.m @@ -54,6 +54,8 @@ -(void)reloadSettings { //hide rows smooth dispatch_async(dispatch_get_main_queue(), ^{ [self.tableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationFade]; + self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone; // remove separator + self.tableView.backgroundColor = [UIColor colorNamed:@"color_gray1"]; }); } @@ -63,8 +65,9 @@ -(void)viewWillDisappear:(BOOL)animated{ [testSuite.testList removeAllObjects]; [testSuite getTestList]; } - if (testSuite != nil || [[TestUtility getTestOptionTypes] containsObject:category]) + if (testSuite != nil) { [[NSNotificationCenter defaultCenter] postNotificationName:@"settingsChanged" object:nil]; + } } #pragma mark - Table view data source @@ -113,9 +116,6 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N else { cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath]; } - if ([[TestUtility getTestOptionTypes] containsObject:current]){ - cell.imageView.image = [UIImage imageNamed:current]; - } cell.textLabel.text = [LocalizationUtility getNameForSetting:current]; cell.textLabel.textColor = [UIColor colorNamed:@"color_gray9"]; UISwitch *switchview = [[UISwitch alloc] initWithFrame:CGRectZero]; @@ -132,13 +132,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N } else cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath]; - if ([[TestUtility getTestOptionTypes] containsObject:current]){ - if ([NSLocale characterDirectionForLanguage:[NSLocale preferredLanguages][0]] == NSLocaleLanguageDirectionRightToLeft) { - cell.imageView.image = [self imageWithImage:[UIImage imageNamed:current] convertToSize:CGSizeMake(32, 32)]; - } else { - cell.imageView.image = [UIImage imageNamed:current]; - } - } + cell.textLabel.text = [LocalizationUtility getNameForSetting:current]; cell.textLabel.textColor = [UIColor colorNamed:@"color_gray9"]; cell.accessoryView = nil; @@ -188,6 +182,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N cell.accessoryView = cleanButton; } } + cell.backgroundColor = [UIColor colorNamed:@"color_gray1"]; return cell; } diff --git a/ooniprobe/View/Settings/WebsiteCategoriesTableViewController.m b/ooniprobe/View/Settings/WebsiteCategoriesTableViewController.m index a63099fc..bacfcf0c 100644 --- a/ooniprobe/View/Settings/WebsiteCategoriesTableViewController.m +++ b/ooniprobe/View/Settings/WebsiteCategoriesTableViewController.m @@ -12,6 +12,8 @@ - (void)viewDidLoad { self.navigationController.navigationBar.topItem.title = @""; self.tableView.estimatedRowHeight = 60.0; self.tableView.rowHeight = UITableViewAutomaticDimension; + self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone; // remove separator + self.tableView.backgroundColor = [UIColor colorNamed:@"color_gray1"]; } -(void)viewWillAppear:(BOOL)animated{ @@ -53,6 +55,8 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N else switchview.on = YES; cell.accessoryView = switchview; + cell.backgroundColor = [UIColor colorNamed:@"color_gray1"]; + return cell; }