Skip to content

Commit

Permalink
feat (OONI Run v2): update preference screens to match new designs (#563
Browse files Browse the repository at this point in the history
)

Fixes ooni/ooni.org#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)
|. |.|
  • Loading branch information
aanorbel authored Jun 24, 2024
1 parent 0ef1aea commit fd7bbaf
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 33 deletions.
6 changes: 3 additions & 3 deletions OONIProbeUITests/OONIProbeUITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions ooniprobe/Storyboards/Settings.storyboard
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="22505" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="32700.99.1234" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22504"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22685"/>
<capability name="Named colors" minToolsVersion="9.0"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
Expand Down Expand Up @@ -485,7 +485,7 @@ measurement-kit: x.y.z</string>
</connections>
</button>
</subviews>
<color key="backgroundColor" name="color_white"/>
<color key="backgroundColor" name="color_gray1"/>
<constraints>
<constraint firstItem="Iza-Qi-7Xv" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="xfk-C4-Iuo" secondAttribute="leading" constant="20" id="4Kw-WJ-ueF"/>
<constraint firstItem="fJM-Cs-r96" firstAttribute="leading" secondItem="xfk-C4-Iuo" secondAttribute="leading" constant="50" id="4pO-eI-vIW"/>
Expand All @@ -511,7 +511,7 @@ measurement-kit: x.y.z</string>
</constraints>
</view>
</subviews>
<color key="backgroundColor" name="color_white"/>
<color key="backgroundColor" name="color_gray1"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="xfk-C4-Iuo" secondAttribute="trailing" id="2Kd-OF-Z7Y"/>
<constraint firstItem="xfk-C4-Iuo" firstAttribute="centerX" secondItem="3N7-0b-kY4" secondAttribute="centerX" id="9Fe-x9-m9l"/>
Expand All @@ -522,7 +522,7 @@ measurement-kit: x.y.z</string>
</scrollView>
</subviews>
<viewLayoutGuide key="safeArea" id="fbM-Vh-umg"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<color key="backgroundColor" name="color_gray1"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="3N7-0b-kY4" secondAttribute="trailing" id="FPu-ao-rZn"/>
<constraint firstItem="HIX-ry-9k4" firstAttribute="top" secondItem="3N7-0b-kY4" secondAttribute="bottom" id="Ma8-Oi-BT9"/>
Expand Down
29 changes: 15 additions & 14 deletions ooniprobe/Utility/SettingsUtility.m
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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"];
Expand All @@ -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";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down Expand Up @@ -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;
}

Expand Down
17 changes: 6 additions & 11 deletions ooniprobe/View/Settings/SettingsTableViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -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"];
});
}

Expand All @@ -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
Expand Down Expand Up @@ -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];
Expand All @@ -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;
Expand Down Expand Up @@ -188,6 +182,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
cell.accessoryView = cleanButton;
}
}
cell.backgroundColor = [UIColor colorNamed:@"color_gray1"];
return cell;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit fd7bbaf

Please sign in to comment.