From 43bdc197f9e481eae7037b5bb73c84986de793a6 Mon Sep 17 00:00:00 2001 From: Lorenzo Primiterra Date: Tue, 30 May 2017 13:54:07 +0200 Subject: [PATCH] More fixes for #107 --- ooniprobe/View/AboutViewController.h | 2 ++ ooniprobe/View/AboutViewController.mm | 9 +++++++++ ooniprobe/View/LeftMenuTableViewController.mm | 8 ++++++-- ooniprobe/View/SettingsTableViewController.h | 2 ++ ooniprobe/View/SettingsTableViewController.mm | 9 +++++++++ 5 files changed, 28 insertions(+), 2 deletions(-) diff --git a/ooniprobe/View/AboutViewController.h b/ooniprobe/View/AboutViewController.h index 9395bbdb1..855f80513 100644 --- a/ooniprobe/View/AboutViewController.h +++ b/ooniprobe/View/AboutViewController.h @@ -6,6 +6,8 @@ #import "PBRevealViewController.h" #import "RoundedButton.h" #import "AppDelegate.h" +#import "TestStorage.h" +#import "UIBarButtonItem+Badge.h" @interface AboutViewController : UIViewController @property (nonatomic, strong) IBOutlet UILabel *titleLabel; diff --git a/ooniprobe/View/AboutViewController.mm b/ooniprobe/View/AboutViewController.mm index a0420a6ed..1411c0bdc 100644 --- a/ooniprobe/View/AboutViewController.mm +++ b/ooniprobe/View/AboutViewController.mm @@ -33,9 +33,18 @@ - (void)viewDidLoad { [self.textLabel setText:[NSString stringWithFormat:@"%@\n%@",NSLocalizedString(@"about_text_1", nil), NSLocalizedString(@"about_text_2", nil)]]; [self.ppButton setTitle:[NSString stringWithFormat:@"%@", NSLocalizedString(@"view_data_policy", nil)] forState:UIControlStateNormal]; [self.versionLabel setText:[NSString stringWithFormat:@"ooniprobe: %@\nmeasurement-kit: %s", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"], mk_version()]]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadDot) name:@"reloadTable" object:nil]; + [self reloadDot]; +} +- (void)reloadDot{ + if ([TestStorage new_tests]){ + self.navigationItem.leftBarButtonItem.badgeValue = @" "; + self.navigationItem.leftBarButtonItem.badgeBGColor = color_ok_green; + } } + -(IBAction)learn_more:(id)sender{ [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://ooni.torproject.org/"]]; } diff --git a/ooniprobe/View/LeftMenuTableViewController.mm b/ooniprobe/View/LeftMenuTableViewController.mm index 51c8a4e71..149784090 100644 --- a/ooniprobe/View/LeftMenuTableViewController.mm +++ b/ooniprobe/View/LeftMenuTableViewController.mm @@ -3,6 +3,7 @@ // information on the copying conditions. #import "LeftMenuTableViewController.h" +#import "PastTestsViewController.h" @interface LeftMenuTableViewController () @property (nonatomic, strong) NSArray *menuItems; @@ -56,8 +57,11 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N } - (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { - if ([[segue identifier] isEqualToString:@"toRun_tests"] || [[segue identifier] isEqualToString:@"toSettings"] || [[segue identifier] isEqualToString:@"toAbout"]) - [TestStorage set_all_viewed]; + if ([[segue identifier] isEqualToString:@"toRun_tests"] || [[segue identifier] isEqualToString:@"toSettings"] || [[segue identifier] isEqualToString:@"toAbout"]){ + UINavigationController *navController = (UINavigationController*)self.revealViewController.mainViewController; + if ([([navController viewControllers][0]) isKindOfClass:[PastTestsViewController class]]) + [TestStorage set_all_viewed]; + } } @end diff --git a/ooniprobe/View/SettingsTableViewController.h b/ooniprobe/View/SettingsTableViewController.h index 3a8e74baf..369ab323b 100644 --- a/ooniprobe/View/SettingsTableViewController.h +++ b/ooniprobe/View/SettingsTableViewController.h @@ -6,6 +6,8 @@ #import "PBRevealViewController.h" #import "UIView+Toast.h" #import "AppDelegate.h" +#import "TestStorage.h" +#import "UIBarButtonItem+Badge.h" @interface SettingsTableViewController : UITableViewController { NSArray *privacyItems; diff --git a/ooniprobe/View/SettingsTableViewController.mm b/ooniprobe/View/SettingsTableViewController.mm index 814b1b6a3..c4ff9fe02 100644 --- a/ooniprobe/View/SettingsTableViewController.mm +++ b/ooniprobe/View/SettingsTableViewController.mm @@ -43,6 +43,15 @@ - (void)viewDidLoad { initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self.view action:@selector(endEditing:)]; keyboardToolbar.items = @[flexBarButton, doneBarButton]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadDot) name:@"reloadTable" object:nil]; + [self reloadDot]; +} + +- (void)reloadDot{ + if ([TestStorage new_tests]){ + self.navigationItem.leftBarButtonItem.badgeValue = @" "; + self.navigationItem.leftBarButtonItem.badgeBGColor = color_ok_green; + } } - (void)didReceiveMemoryWarning {