diff --git a/Riot.xcodeproj/project.pbxproj b/Riot.xcodeproj/project.pbxproj index c7682c902..0d6038399 100644 --- a/Riot.xcodeproj/project.pbxproj +++ b/Riot.xcodeproj/project.pbxproj @@ -450,6 +450,7 @@ F0A4A1671EF7CB66003630DB /* members_list_icon.png in Resources */ = {isa = PBXBuildFile; fileRef = F0A4A1641EF7CB66003630DB /* members_list_icon.png */; }; F0A4A1681EF7CB66003630DB /* members_list_icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = F0A4A1651EF7CB66003630DB /* members_list_icon@2x.png */; }; F0A4A1691EF7CB66003630DB /* members_list_icon@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = F0A4A1661EF7CB66003630DB /* members_list_icon@3x.png */; }; + F0B4CBA51F418D0B008E99C5 /* WebViewViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F0B4CBA41F418D0B008E99C5 /* WebViewViewController.m */; }; F0D869EB1EC455A100BB0A2B /* create_direct_chat.png in Resources */ = {isa = PBXBuildFile; fileRef = F0D869E81EC455A100BB0A2B /* create_direct_chat.png */; }; F0D869EC1EC455A100BB0A2B /* create_direct_chat@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = F0D869E91EC455A100BB0A2B /* create_direct_chat@2x.png */; }; F0D869ED1EC455A100BB0A2B /* create_direct_chat@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = F0D869EA1EC455A100BB0A2B /* create_direct_chat@3x.png */; }; @@ -1071,6 +1072,8 @@ F0A4A1641EF7CB66003630DB /* members_list_icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = members_list_icon.png; sourceTree = ""; }; F0A4A1651EF7CB66003630DB /* members_list_icon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "members_list_icon@2x.png"; sourceTree = ""; }; F0A4A1661EF7CB66003630DB /* members_list_icon@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "members_list_icon@3x.png"; sourceTree = ""; }; + F0B4CBA31F418D0B008E99C5 /* WebViewViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebViewViewController.h; sourceTree = ""; }; + F0B4CBA41F418D0B008E99C5 /* WebViewViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebViewViewController.m; sourceTree = ""; }; F0D869E81EC455A100BB0A2B /* create_direct_chat.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = create_direct_chat.png; sourceTree = ""; }; F0D869E91EC455A100BB0A2B /* create_direct_chat@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "create_direct_chat@2x.png"; sourceTree = ""; }; F0D869EA1EC455A100BB0A2B /* create_direct_chat@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "create_direct_chat@3x.png"; sourceTree = ""; }; @@ -1692,6 +1695,8 @@ 24B5103C1EFA7083004C6AD2 /* ReadReceiptsViewController.h */, 24B5103D1EFA7083004C6AD2 /* ReadReceiptsViewController.m */, 24B5103F1EFA88CC004C6AD2 /* ReadReceiptsViewController.xib */, + F0B4CBA31F418D0B008E99C5 /* WebViewViewController.h */, + F0B4CBA41F418D0B008E99C5 /* WebViewViewController.m */, ); path = ViewController; sourceTree = ""; @@ -2645,6 +2650,7 @@ 32AE61E91F0CE099007255F4 /* RoomMembershipWithPaginationTitleBubbleCell.m in Sources */, F083BDFD1E7009ED00A9B29C /* PublicRoomsDirectoryDataSource.m in Sources */, F083BE191E7009ED00A9B29C /* RecentsViewController.m in Sources */, + F0B4CBA51F418D0B008E99C5 /* WebViewViewController.m in Sources */, F083BE351E7009ED00A9B29C /* MediaAlbumTableCell.m in Sources */, F083BE4C1E7009ED00A9B29C /* RoomOutgoingEncryptedAttachmentWithoutSenderInfoBubbleCell.m in Sources */, F075BEDB1EBB26F100A7B68A /* TableViewCellWithCollectionView.m in Sources */, diff --git a/Riot/ViewController/SettingsViewController.m b/Riot/ViewController/SettingsViewController.m index 0f8f8043e..86082eefa 100644 --- a/Riot/ViewController/SettingsViewController.m +++ b/Riot/ViewController/SettingsViewController.m @@ -28,6 +28,8 @@ #import "MXKEncryptionKeysExportView.h" #import "BugReportViewController.h" +#import "WebViewViewController.h" + #import "CountryPickerViewController.h" #import "LanguagePickerViewController.h" #import "TableViewCellWithPhoneNumberTextField.h" @@ -2239,7 +2241,7 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)(); { if (row == OTHER_COPYRIGHT_INDEX) { - MXKWebViewViewController *webViewViewController = [[MXKWebViewViewController alloc] initWithURL:NSLocalizedStringFromTable(@"settings_copyright_url", @"Vector", nil)]; + WebViewViewController *webViewViewController = [[WebViewViewController alloc] initWithURL:NSLocalizedStringFromTable(@"settings_copyright_url", @"Vector", nil)]; webViewViewController.title = NSLocalizedStringFromTable(@"settings_copyright", @"Vector", nil); @@ -2247,7 +2249,7 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)(); } else if (row == OTHER_TERM_CONDITIONS_INDEX) { - MXKWebViewViewController *webViewViewController = [[MXKWebViewViewController alloc] initWithURL:NSLocalizedStringFromTable(@"settings_term_conditions_url", @"Vector", nil)]; + WebViewViewController *webViewViewController = [[WebViewViewController alloc] initWithURL:NSLocalizedStringFromTable(@"settings_term_conditions_url", @"Vector", nil)]; webViewViewController.title = NSLocalizedStringFromTable(@"settings_term_conditions", @"Vector", nil); @@ -2255,7 +2257,7 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)(); } else if (row == OTHER_PRIVACY_INDEX) { - MXKWebViewViewController *webViewViewController = [[MXKWebViewViewController alloc] initWithURL:NSLocalizedStringFromTable(@"settings_privacy_policy_url", @"Vector", nil)]; + WebViewViewController *webViewViewController = [[WebViewViewController alloc] initWithURL:NSLocalizedStringFromTable(@"settings_privacy_policy_url", @"Vector", nil)]; webViewViewController.title = NSLocalizedStringFromTable(@"settings_privacy_policy", @"Vector", nil); @@ -2265,7 +2267,7 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)(); { NSString *htmlFile = [[NSBundle mainBundle] pathForResource:@"third_party_licenses" ofType:@"html" inDirectory:nil]; - MXKWebViewViewController *webViewViewController = [[MXKWebViewViewController alloc] initWithLocalHTMLFile:htmlFile]; + WebViewViewController *webViewViewController = [[WebViewViewController alloc] initWithLocalHTMLFile:htmlFile]; webViewViewController.title = NSLocalizedStringFromTable(@"settings_third_party_notices", @"Vector", nil); diff --git a/Riot/ViewController/WebViewViewController.h b/Riot/ViewController/WebViewViewController.h new file mode 100644 index 000000000..8426ae613 --- /dev/null +++ b/Riot/ViewController/WebViewViewController.h @@ -0,0 +1,26 @@ +/* + Copyright 2017 Vector Creations Ltd + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +#import + +/** + WebViewViewController extends MXKWebViewViewController to handle customization. + */ + +@interface WebViewViewController : MXKWebViewViewController + +@end + diff --git a/Riot/ViewController/WebViewViewController.m b/Riot/ViewController/WebViewViewController.m new file mode 100644 index 000000000..b53ac97a3 --- /dev/null +++ b/Riot/ViewController/WebViewViewController.m @@ -0,0 +1,66 @@ +/* + Copyright 2017 Vector Creations Ltd + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +#import "WebViewViewController.h" +#import "AppDelegate.h" + +@interface WebViewViewController () +{ + // Observe kRiotDesignValuesDidChangeThemeNotification to handle user interface theme change. + id kRiotDesignValuesDidChangeThemeNotificationObserver; +} + +@end + +@implementation WebViewViewController + +- (void)finalizeInit +{ + [super finalizeInit]; + + // Setup `MXKViewControllerHandling` properties + self.enableBarTintColorStatusChange = NO; + self.rageShakeManager = [RageShakeManager sharedManager]; +} + +- (void)viewDidLoad +{ + [super viewDidLoad]; + + // Observe user interface theme change. + kRiotDesignValuesDidChangeThemeNotificationObserver = [[NSNotificationCenter defaultCenter] addObserverForName:kRiotDesignValuesDidChangeThemeNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notif) { + + [self userInterfaceThemeDidChange]; + + }]; + [self userInterfaceThemeDidChange]; +} + +- (void)userInterfaceThemeDidChange +{ + self.view.backgroundColor = kRiotPrimaryBgColor; + self.defaultBarTintColor = kRiotSecondaryBgColor; + self.barTitleColor = kRiotPrimaryTextColor; + + webView.backgroundColor = kRiotPrimaryBgColor; +} + +- (UIStatusBarStyle)preferredStatusBarStyle +{ + return kRiotDesignStatusBarStyle; +} + +@end