project: support iOS 12.2
Support iOS 12.2 and convert to swift5 syntax.
Also this patch removes framework Chameleon.
Change-Id: I4135c87b14c9c04dff86c3e7eede33162bb8ca34
diff --git a/Ring/Cartfile b/Ring/Cartfile
index 906ac4f..3ad280c 100644
--- a/Ring/Cartfile
+++ b/Ring/Cartfile
@@ -3,7 +3,6 @@
github "pkluz/PKHUD" ~> 5.0
github "AliSoftware/Reusable" ~> 4.0
github "SwiftyBeaver/SwiftyBeaver" ~> 1.0
-github "ViccAlexander/Chameleon"
github "andreamazz/AMPopTip"
github "ashleymills/Reachability.swift"
github "stephencelis/SQLite.swift" ~> 0.11.4
diff --git a/Ring/Cartfile.resolved b/Ring/Cartfile.resolved
index 2d8429f..787ada5 100644
--- a/Ring/Cartfile.resolved
+++ b/Ring/Cartfile.resolved
@@ -1,13 +1,12 @@
-github "AliSoftware/Reusable" "4.0.4"
-github "ReactiveX/RxSwift" "4.4.0"
+github "AliSoftware/Reusable" "4.1.0"
+github "ReactiveX/RxSwift" "4.5.0"
github "RxSwiftCommunity/RxDataSources" "3.1.0"
-github "RxSwiftCommunity/RxRealm" "0.7.6"
-github "SwiftyBeaver/SwiftyBeaver" "1.6.1"
-github "ViccAlexander/Chameleon" "2.2.0"
-github "andreamazz/AMPopTip" "3.5.0"
-github "ashleymills/Reachability.swift" "v4.3.0"
+github "RxSwiftCommunity/RxRealm" "0.7.7"
+github "SwiftyBeaver/SwiftyBeaver" "1.7.0"
+github "andreamazz/AMPopTip" "4.0.1"
+github "ashleymills/Reachability.swift" "v4.3.1"
github "gskbyte/GSKStretchyHeaderView" "1.0.4"
github "optonaut/ActiveLabel.swift" "1.0.1"
-github "pkluz/PKHUD" "5.2.0"
-github "realm/realm-cocoa" "v3.12.0"
-github "stephencelis/SQLite.swift" "0.11.5"
+github "pkluz/PKHUD" "5.3.0"
+github "realm/realm-cocoa" "v3.16.1"
+github "stephencelis/SQLite.swift" "0.11.6"
diff --git a/Ring/Ring.xcodeproj/project.pbxproj b/Ring/Ring.xcodeproj/project.pbxproj
index e3973db..068527d 100644
--- a/Ring/Ring.xcodeproj/project.pbxproj
+++ b/Ring/Ring.xcodeproj/project.pbxproj
@@ -150,7 +150,6 @@
0EAA9DB52029F0AA005E245C /* ProxyCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 0EAA9DB32029F0AA005E245C /* ProxyCell.xib */; };
0EB1A5CF1F8EBE03009923E2 /* DeviceCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 0EB1A5CE1F8EBE03009923E2 /* DeviceCell.xib */; };
0EB1A5D11F8EBE23009923E2 /* DeviceCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EB1A5D01F8EBE23009923E2 /* DeviceCell.swift */; };
- 0EB479951FA28A7300106AFD /* ButtonTransparentBackground.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EB479941FA28A7300106AFD /* ButtonTransparentBackground.swift */; };
0EBB72A92034F44200D88F46 /* ProfilesService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EBB72A82034F44200D88F46 /* ProfilesService.swift */; };
0EBCAA4E202E60F000E2A545 /* default.wav in Resources */ = {isa = PBXBuildFile; fileRef = 0EBCAA4D202E60F000E2A545 /* default.wav */; };
0ECEE9A3220D1935000E1CF4 /* VideoToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0ECEE9A2220D1935000E1CF4 /* VideoToolbox.framework */; };
@@ -217,8 +216,6 @@
1A2D18FD1F292DAD00B2C785 /* ConversationCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1A2D18FB1F292DAD00B2C785 /* ConversationCell.xib */; };
1A2D18FF1F29352D00B2C785 /* MeViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A2D18FE1F29352D00B2C785 /* MeViewModel.swift */; };
1A2D19011F29353A00B2C785 /* MeDetailViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A2D19001F29353A00B2C785 /* MeDetailViewModel.swift */; };
- 1A3CA32B1F102BB700283748 /* Chameleon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A3CA32A1F102BB700283748 /* Chameleon.framework */; };
- 1A3CA32D1F13DA7200283748 /* Chameleon+Ring.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A3CA32C1F13DA7200283748 /* Chameleon+Ring.swift */; };
1A3D28A71F0EB9DB00B524EE /* Bool+String.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A3D28A61F0EB9DB00B524EE /* Bool+String.swift */; };
1A3D28A91F0EBF0200B524EE /* UIView+Ring.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A3D28A81F0EBF0200B524EE /* UIView+Ring.swift */; };
1A5DC01E1F355DA70075E8EF /* ContactsAdapterDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A5DC01D1F355DA70075E8EF /* ContactsAdapterDelegate.swift */; };
@@ -478,7 +475,6 @@
0EB12451224AB1030025F8CA /* ContactsUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ContactsUI.framework; path = System/Library/Frameworks/ContactsUI.framework; sourceTree = SDKROOT; };
0EB1A5CE1F8EBE03009923E2 /* DeviceCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = DeviceCell.xib; sourceTree = "<group>"; };
0EB1A5D01F8EBE23009923E2 /* DeviceCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DeviceCell.swift; sourceTree = "<group>"; };
- 0EB479941FA28A7300106AFD /* ButtonTransparentBackground.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonTransparentBackground.swift; sourceTree = "<group>"; };
0EBB72A82034F44200D88F46 /* ProfilesService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfilesService.swift; sourceTree = "<group>"; };
0EBCAA4D202E60F000E2A545 /* default.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = default.wav; sourceTree = "<group>"; };
0ECEE9A2220D1935000E1CF4 /* VideoToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = VideoToolbox.framework; path = System/Library/Frameworks/VideoToolbox.framework; sourceTree = SDKROOT; };
@@ -546,7 +542,6 @@
1A2D18FE1F29352D00B2C785 /* MeViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MeViewModel.swift; sourceTree = "<group>"; };
1A2D19001F29353A00B2C785 /* MeDetailViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MeDetailViewModel.swift; sourceTree = "<group>"; };
1A3CA32A1F102BB700283748 /* Chameleon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Chameleon.framework; path = Carthage/Build/iOS/Chameleon.framework; sourceTree = "<group>"; };
- 1A3CA32C1F13DA7200283748 /* Chameleon+Ring.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Chameleon+Ring.swift"; sourceTree = "<group>"; };
1A3D28A61F0EB9DB00B524EE /* Bool+String.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Bool+String.swift"; sourceTree = "<group>"; };
1A3D28A81F0EBF0200B524EE /* UIView+Ring.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIView+Ring.swift"; sourceTree = "<group>"; };
1A5DC00A1F3558980075E8EF /* ContactsAdapter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ContactsAdapter.h; sourceTree = "<group>"; };
@@ -706,7 +701,6 @@
5C093F011FB495830011D90E /* Differentiator.framework in Frameworks */,
0ED666101F9FED1C00743D42 /* AMPopTip.framework in Frameworks */,
0EEFBA3C1F83DA21000EDBAD /* libsecp256k1.a in Frameworks */,
- 1A3CA32B1F102BB700283748 /* Chameleon.framework in Frameworks */,
1A1E476F1F0E894600EA9A36 /* SwiftyBeaver.framework in Frameworks */,
1A1E476D1F0E808500EA9A36 /* Reusable.framework in Frameworks */,
56559B0E1EE8777600BF20E1 /* RxRealm.framework in Frameworks */,
@@ -912,7 +906,6 @@
0273C3071E0C68BF00CF00BA /* DesignableButton.swift */,
56AC650D1E85694D00EA1AA9 /* DesignableTextField.swift */,
1A2041901F1FD46200C08435 /* DesignableView.swift */,
- 0EB479941FA28A7300106AFD /* ButtonTransparentBackground.swift */,
0E438A99204F47E700402900 /* SettingsTableView.swift */,
);
path = UI;
@@ -929,7 +922,6 @@
1A3D28A61F0EB9DB00B524EE /* Bool+String.swift */,
1A3D28A81F0EBF0200B524EE /* UIView+Ring.swift */,
1AABA7451F0FE9C000739605 /* UIColor+Ring.swift */,
- 1A3CA32C1F13DA7200283748 /* Chameleon+Ring.swift */,
1A2D18991F2642C000B2C785 /* NotificationCenter+Ring.swift */,
1A2D189B1F264AD900B2C785 /* UIViewController+Ring.swift */,
1A2D18A51F27F7A400B2C785 /* UIViewController+Rx.swift */,
@@ -1843,7 +1835,6 @@
"$(SRCROOT)/Carthage/Build/iOS/RxRealm.framework",
"$(SRCROOT)/Carthage/Build/iOS/Reusable.framework",
"$(SRCROOT)/Carthage/Build/iOS/SwiftyBeaver.framework",
- "$(SRCROOT)/Carthage/Build/iOS/Chameleon.framework",
"$(SRCROOT)/Carthage/build/iOS/AMPopTip.framework",
"$(SRCROOT)/Carthage/Build/iOS/Reachability.framework",
"$(SRCROOT)/Carthage/Build/iOS/Differentiator.framework",
@@ -1862,7 +1853,6 @@
"$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/RxRealm.framework",
"$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/Reusable.framework",
"$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/SwiftyBeaver.framework",
- "$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/Chameleon.framework",
"$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/AMPopTip.framework",
"$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/Differentiator.framework",
"$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/SQLite.framework",
@@ -1899,7 +1889,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
- shellScript = "${PROJECT_DIR}/swiftgen/swiftgen.sh";
+ shellScript = "${PROJECT_DIR}/swiftgen/swiftgen.sh\n";
};
6236602D200914C9002598C1 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
@@ -1986,7 +1976,6 @@
0EE1B54E1F75ACDE00BA98EE /* CNContactVCardSerialization+Helpers.swift in Sources */,
0E0FF1AA1FC3843E003898C2 /* DBContainer.swift in Sources */,
56308BA71EA00E5700660275 /* NameRegistrationResponse.m in Sources */,
- 1A3CA32D1F13DA7200283748 /* Chameleon+Ring.swift in Sources */,
0ED2B6FC1F96A158001572F0 /* LinkNewDeviceViewController.swift in Sources */,
1ABE07E21F0D924700D36361 /* Strings.swift in Sources */,
0E6F544D223BFE3E00ECC3CE /* DisposableCell.swift in Sources */,
@@ -2029,7 +2018,6 @@
0E0FF1AF1FC38CBC003898C2 /* ProfileDataHelper.swift in Sources */,
563AEC771EA664C0003A5641 /* RegistrationResponse.m in Sources */,
564C445B1E8EA44E000F92B1 /* Durations.swift in Sources */,
- 0EB479951FA28A7300106AFD /* ButtonTransparentBackground.swift in Sources */,
0E320D54224ADFD00070B515 /* DialpadViewModel.swift in Sources */,
0EB1A5D11F8EBE23009923E2 /* DeviceCell.swift in Sources */,
0E6949791FA7E71C0029B60A /* BaseViewController.swift in Sources */,
@@ -2237,7 +2225,7 @@
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
- SWIFT_VERSION = 4.0;
+ SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
@@ -2288,7 +2276,7 @@
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
- SWIFT_VERSION = 4.0;
+ SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
@@ -2328,7 +2316,7 @@
SWIFT_OBJC_BRIDGING_HEADER = "Ring/Bridging/Ring-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
- SWIFT_VERSION = 4.0;
+ SWIFT_VERSION = 5.0;
VALID_ARCHS = arm64;
VERSIONING_SYSTEM = "";
};
@@ -2367,7 +2355,7 @@
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_OBJC_BRIDGING_HEADER = "Ring/Bridging/Ring-Bridging-Header.h";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
- SWIFT_VERSION = 4.0;
+ SWIFT_VERSION = 5.0;
VALID_ARCHS = arm64;
VERSIONING_SYSTEM = "";
};
@@ -2494,7 +2482,7 @@
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
- SWIFT_VERSION = 4.0;
+ SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Development;
@@ -2533,7 +2521,7 @@
SWIFT_OBJC_BRIDGING_HEADER = "Ring/Bridging/Ring-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
- SWIFT_VERSION = 4.0;
+ SWIFT_VERSION = 5.0;
VALID_ARCHS = arm64;
VERSIONING_SYSTEM = "";
};
diff --git a/Ring/Ring/AppDelegate.swift b/Ring/Ring/AppDelegate.swift
index 1f26698..22a73ad 100644
--- a/Ring/Ring/AppDelegate.swift
+++ b/Ring/Ring/AppDelegate.swift
@@ -24,8 +24,6 @@
import UIKit
import SwiftyBeaver
import RxSwift
-import Chameleon
-//import Contacts
import PushKit
import ContactsUI
@@ -90,7 +88,7 @@
fileprivate let disposeBag = DisposeBag()
- func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
+ func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// ignore sigpipe
// swiftlint:disable nesting
@@ -131,9 +129,6 @@
})
.disposed(by: self.disposeBag)
- // themetize the app
- Chameleon.setRingThemeUsingPrimaryColor(UIColor.jamiMain, withSecondaryColor: UIColor.jamiSecondary, andContentStyle: .light)
-
self.interactionsManager = GeneratedInteractionsManager(accountService: self.accountService,
contactService: self.contactsService,
conversationService: self.conversationsService,
@@ -278,6 +273,8 @@
if !enabled { LocalNotificationsHelper.setNotification(enable: true)}
case .provisional:
if !enabled { LocalNotificationsHelper.setNotification(enable: true)}
+ @unknown default:
+ break
}
})
} else {
diff --git a/Ring/Ring/Bridging/Ring-Bridging-Header.h b/Ring/Ring/Bridging/Ring-Bridging-Header.h
index 25b9b2f..b465c9b 100644
--- a/Ring/Ring/Bridging/Ring-Bridging-Header.h
+++ b/Ring/Ring/Bridging/Ring-Bridging-Header.h
@@ -30,13 +30,11 @@
#import "RegistrationResponse.h"
#import "NameRegistrationResponse.h"
#import "MessagesAdapter.h"
-#import "Chameleon/Chameleon.h"
#import "ContactsAdapter.h"
#import "PresenceAdapter.h"
#import "VideoAdapter.h"
#import "AudioAdapter.h"
#import <CommonCrypto/CommonCrypto.h>
-//#import <Contacts/Contacts.h>
#import <ContactsUI/ContactsUI.h>
#import <UserNotifications/UserNotifications.h>
#import "CallsAdapter.h"
diff --git a/Ring/Ring/Bridging/SystemAdapter.mm b/Ring/Ring/Bridging/SystemAdapter.mm
index 1f87859..2bd64bc 100644
--- a/Ring/Ring/Bridging/SystemAdapter.mm
+++ b/Ring/Ring/Bridging/SystemAdapter.mm
@@ -18,8 +18,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#import "Chameleon/Chameleon-Swift.h"
-
#import "Ring-Swift.h"
#import "SystemAdapter.h"
diff --git a/Ring/Ring/Calls/CallViewController.swift b/Ring/Ring/Calls/CallViewController.swift
index 4bcda97..f7ee05b 100644
--- a/Ring/Ring/Calls/CallViewController.swift
+++ b/Ring/Ring/Calls/CallViewController.swift
@@ -21,7 +21,6 @@
*/
import UIKit
-import Chameleon
import RxSwift
import Reusable
import SwiftyBeaver
@@ -127,8 +126,8 @@
@objc func capturedVideoSwipped(gesture: UISwipeGestureRecognizer) {
if self.avatarView.isHidden == false { return }
- if gesture.direction == UISwipeGestureRecognizerDirection.left && (self.isVideoHidden == false) { return }
- if gesture.direction == UISwipeGestureRecognizerDirection.right && (self.isVideoHidden == true) { return }
+ if gesture.direction == UISwipeGestureRecognizer.Direction.left && (self.isVideoHidden == false) { return }
+ if gesture.direction == UISwipeGestureRecognizer.Direction.right && (self.isVideoHidden == true) { return }
self.hideCapturedVideo()
}
@@ -174,7 +173,7 @@
}
func setUpCallButtons() {
- self.mainView.bringSubview(toFront: self.buttonsContainer)
+ self.mainView.bringSubviewToFront(self.buttonsContainer)
self.buttonsContainer.viewModel = self.viewModel.containerViewModel
self.buttonsContainer.cancelButton.rx.tap
.subscribe(onNext: { [weak self] in
@@ -183,9 +182,10 @@
}).disposed(by: self.disposeBag)
self.buttonsContainer.acceptCallButton.rx.tap
- .subscribe(onNext: { [weak self] in
- self?.viewModel.answerCall()
+ .subscribe(onNext: { [unowned self] in
+ self.viewModel.answerCall()
.subscribe()
+ .disposed(by: self.disposeBag)
}).disposed(by: self.disposeBag)
self.buttonsContainer.dialpadButton.rx.tap
diff --git a/Ring/Ring/Database/DBManager.swift b/Ring/Ring/Database/DBManager.swift
index a991824..d579fcf 100644
--- a/Ring/Ring/Database/DBManager.swift
+++ b/Ring/Ring/Database/DBManager.swift
@@ -105,6 +105,8 @@
case .sent: self = .succeed
case .read: self = .read
case .failure: self = .failed
+ @unknown default:
+ self = .unknown
}
}
diff --git a/Ring/Ring/EditProfileViewController.swift b/Ring/Ring/EditProfileViewController.swift
index e3d90fe..6699200 100644
--- a/Ring/Ring/EditProfileViewController.swift
+++ b/Ring/Ring/EditProfileViewController.swift
@@ -80,15 +80,15 @@
message: nil,
preferredStyle: .actionSheet)
- let cameraAction = UIAlertAction(title: L10n.Alerts.profileTakePhoto, style: UIAlertActionStyle.default) { _ in
+ let cameraAction = UIAlertAction(title: L10n.Alerts.profileTakePhoto, style: UIAlertAction.Style.default) { _ in
self.takePicture()
}
- let pictureAction = UIAlertAction(title: L10n.Alerts.profileUploadPhoto, style: UIAlertActionStyle.default) { _ in
+ let pictureAction = UIAlertAction(title: L10n.Alerts.profileUploadPhoto, style: UIAlertAction.Style.default) { _ in
self.importPicture()
}
- let cancelAction = UIAlertAction(title: L10n.Alerts.profileCancelPhoto, style: UIAlertActionStyle.cancel)
+ let cancelAction = UIAlertAction(title: L10n.Alerts.profileCancelPhoto, style: UIAlertAction.Style.cancel)
alert.addAction(cameraAction)
alert.addAction(pictureAction)
@@ -100,11 +100,11 @@
}
func takePicture() {
- if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.camera) {
+ if UIImagePickerController.isSourceTypeAvailable(UIImagePickerController.SourceType.camera) {
let imagePicker = UIImagePickerController()
imagePicker.delegate = self
- imagePicker.sourceType = UIImagePickerControllerSourceType.camera
- imagePicker.cameraDevice = UIImagePickerControllerCameraDevice.front
+ imagePicker.sourceType = UIImagePickerController.SourceType.camera
+ imagePicker.cameraDevice = UIImagePickerController.CameraDevice.front
imagePicker.allowsEditing = true
imagePicker.modalPresentationStyle = .overFullScreen
self.present(imagePicker, animated: true, completion: nil)
@@ -115,19 +115,20 @@
let imagePicker = UIImagePickerController()
imagePicker.delegate = self
imagePicker.allowsEditing = true
- imagePicker.sourceType = UIImagePickerControllerSourceType.photoLibrary
+ imagePicker.sourceType = UIImagePickerController.SourceType.photoLibrary
imagePicker.modalPresentationStyle = .overFullScreen
self.present(imagePicker, animated: true, completion: nil)
}
// MARK: - Delegates
- func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String: Any]) {
+ internal func imagePickerController(_ picker: UIImagePickerController,
+ didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey: Any]) {
var image: UIImage!
- if let img = info[UIImagePickerControllerEditedImage] as? UIImage {
+ if let img = info[.editedImage] as? UIImage {
image = img
- } else if let img = info[UIImagePickerControllerOriginalImage] as? UIImage {
+ } else if let img = info[.originalImage] as? UIImage {
image = img
}
diff --git a/Ring/Ring/EditProfileViewModel.swift b/Ring/Ring/EditProfileViewModel.swift
index 932e09e..3863313 100644
--- a/Ring/Ring/EditProfileViewModel.swift
+++ b/Ring/Ring/EditProfileViewModel.swift
@@ -92,7 +92,7 @@
guard let account = self.accountService.currentAccount else {return}
var photo: String?
if let image = self.image, !image.isEqual(defaultImage),
- let imageData = UIImagePNGRepresentation(image) {
+ let imageData = image.pngData() {
photo = imageData.base64EncodedString()
}
self.profileService.updateAccountProfile(accountId: account.id,
diff --git a/Ring/Ring/Extensions/CNContactVCardSerialization+Helpers.swift b/Ring/Ring/Extensions/CNContactVCardSerialization+Helpers.swift
index bc4c474..41095a1 100644
--- a/Ring/Ring/Extensions/CNContactVCardSerialization+Helpers.swift
+++ b/Ring/Ring/Extensions/CNContactVCardSerialization+Helpers.swift
@@ -63,8 +63,8 @@
}
if let scaledImage = scaledImage {
- if UIImagePNGRepresentation(scaledImage) != nil {
- image = UIImagePNGRepresentation(scaledImage)!
+ if scaledImage.pngData() != nil {
+ image = scaledImage.pngData()!
}
}
diff --git a/Ring/Ring/Extensions/Chameleon+Ring.swift b/Ring/Ring/Extensions/Chameleon+Ring.swift
deleted file mode 100644
index 1266118..0000000
--- a/Ring/Ring/Extensions/Chameleon+Ring.swift
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2017-2019 Savoir-faire Linux Inc.
- *
- * Author: Thibault Wittemberg <thibault.wittemberg@savoirfairelinux.com>
- * Author: Quentin Muret <quentin.muret@savoirfairelinux.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-import Foundation
-import Chameleon
-
-extension Chameleon {
- static func setRingThemeUsingPrimaryColor (_ primaryColor: UIColor, withSecondaryColor secondaryColor: UIColor, andContentStyle contentStyle: UIContentStyle) {
- var contentColor: UIColor
- var secondaryContentColor: UIColor
-
- switch contentStyle {
- case .contrast:
- contentColor = ContrastColorOf(primaryColor, returnFlat: false)
- secondaryContentColor = ContrastColorOf(secondaryColor, returnFlat: false)
- case .light:
- contentColor = UIColor.white
- secondaryContentColor = UIColor.white
- case .dark:
- contentColor = UIColor.flatBlackColorDark()
- secondaryContentColor = UIColor.flatBlackColorDark()
- }
-
- MessageBubble.appearance().tintColor = secondaryContentColor
- MessageBubble.appearance().backgroundColor = secondaryColor
-
- MessageBubble.appearance(whenContainedInInstancesOf: [MessageCellSent.self]).tintColor = contentColor
- MessageBubble.appearance(whenContainedInInstancesOf: [MessageCellSent.self]).backgroundColor = UIColor.jamiMsgCellSent
- UILabel.appearance(whenContainedInInstancesOf: [MessageBubble.self, MessageCellSent.self]).textColor = UIColor.jamiMsgCellSentText
-
- MessageBubble.appearance(whenContainedInInstancesOf: [MessageCellReceived.self]).tintColor = secondaryContentColor
- MessageBubble.appearance(whenContainedInInstancesOf: [MessageCellReceived.self]).backgroundColor = UIColor.jamiMsgCellReceived
- UILabel.appearance(whenContainedInInstancesOf: [MessageBubble.self, MessageCellReceived.self]).textColor = UIColor.jamiMsgCellReceivedText
-
- MessageBubble.appearance(whenContainedInInstancesOf: [MessageCellGenerated.self]).tintColor = UIColor.clear
- MessageBubble.appearance(whenContainedInInstancesOf: [MessageCellGenerated.self]).backgroundColor = UIColor.clear
- }
-}
diff --git a/Ring/Ring/Extensions/NotificationCenter+Ring.swift b/Ring/Ring/Extensions/NotificationCenter+Ring.swift
index 73a97d6..13bcc86 100644
--- a/Ring/Ring/Extensions/NotificationCenter+Ring.swift
+++ b/Ring/Ring/Extensions/NotificationCenter+Ring.swift
@@ -25,11 +25,11 @@
static var keyboardHeight: Observable<CGFloat> {
return Observable
.from([
- NotificationCenter.default.rx.notification(NSNotification.Name.UIKeyboardWillShow)
+ NotificationCenter.default.rx.notification(UIResponder.keyboardWillShowNotification)
.map { notification -> CGFloat in
- return (notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue.height ?? 0
+ return (notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue.height ?? 0
},
- NotificationCenter.default.rx.notification(NSNotification.Name.UIKeyboardWillHide)
+ NotificationCenter.default.rx.notification(UIResponder.keyboardWillHideNotification)
.map { _ -> CGFloat in
0
}
diff --git a/Ring/Ring/Extensions/String+Helpers.swift b/Ring/Ring/Extensions/String+Helpers.swift
index e9d21e7..686c873 100644
--- a/Ring/Ring/Extensions/String+Helpers.swift
+++ b/Ring/Ring/Extensions/String+Helpers.swift
@@ -48,11 +48,14 @@
guard let messageData = self.data(using: .utf8) else {return ""}
var digestData = Data(count: Int(CC_MD5_DIGEST_LENGTH))
- _ = digestData.withUnsafeMutableBytes { digestBytes in
- messageData.withUnsafeBytes { messageBytes in
- CC_MD5(messageBytes, CC_LONG(messageData.count), digestBytes)
+ digestData.withUnsafeMutableBytes { (digestBytes: UnsafeMutableRawBufferPointer) -> Void in
+ messageData.withUnsafeBytes { (messageBytes: UnsafeRawBufferPointer) -> Void in
+ CC_MD5(messageBytes.baseAddress,
+ CC_LONG(messageData.count),
+ digestBytes.bindMemory(to: UInt8.self).baseAddress)
}
}
+
return digestData.map { String(format: "%02hhx", $0) }.joined()
}
diff --git a/Ring/Ring/Extensions/UIColor+Ring.swift b/Ring/Ring/Extensions/UIColor+Ring.swift
index 6a7dd81..1c175e9 100644
--- a/Ring/Ring/Extensions/UIColor+Ring.swift
+++ b/Ring/Ring/Extensions/UIColor+Ring.swift
@@ -35,6 +35,44 @@
self.init(red: (hex >> 16) & 0xff, green: (hex >> 8) & 0xff, blue: hex & 0xff, alpha: alpha)
}
+ func lighten(by percentage: CGFloat = 30.0) -> UIColor? {
+ return self.adjust(by: abs(percentage) )
+ }
+
+ func darker(by percentage: CGFloat) -> UIColor? {
+ return self.adjust(by: -1 * abs(percentage) )
+ }
+
+ func adjust(by percentage: CGFloat = 30.0) -> UIColor? {
+ var red: CGFloat = 0, green: CGFloat = 0, blue: CGFloat = 0, alpha: CGFloat = 0
+ if self.getRed(&red, green: &green, blue: &blue, alpha: &alpha) {
+ return UIColor(red: min(red + percentage/100, 1.0),
+ green: min(green + percentage/100, 1.0),
+ blue: min(blue + percentage/100, 1.0),
+ alpha: alpha)
+ } else {
+ return nil
+ }
+ }
+
+ public convenience init?(hexString: String) {
+ let hexString: String = hexString.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
+ let scanner = Scanner(string: hexString)
+ if hexString.hasPrefix("#") {
+ scanner.scanLocation = 1
+ }
+ var color: UInt32 = 0
+ scanner.scanHexInt32(&color)
+ let mask = 0x000000FF
+ let r = Int(color >> 16) & mask
+ let g = Int(color >> 8) & mask
+ let b = Int(color) & mask
+ let red = CGFloat(r) / 255.0
+ let green = CGFloat(g) / 255.0
+ let blue = CGFloat(b) / 255.0
+ self.init(red: red, green: green, blue: blue, alpha: 1)
+ }
+
static let jamiMain = UIColor(hex: 0x3F6DA7, alpha: 1.0)
static let jamiSecondary = UIColor(hex: 0x1F4971, alpha: 1.0)
static let jamiButtonLight = UIColor(hex: 0x285F97, alpha: 1.0)
diff --git a/Ring/Ring/Extensions/UIImage+Helpers.swift b/Ring/Ring/Extensions/UIImage+Helpers.swift
index f3b0066..7506038 100644
--- a/Ring/Ring/Extensions/UIImage+Helpers.swift
+++ b/Ring/Ring/Extensions/UIImage+Helpers.swift
@@ -83,13 +83,13 @@
}
func convertToData(ofMaxSize maxSize: Int) -> Data? {
- guard let imageData = UIImageJPEGRepresentation(self, 0.9) else {
+ guard let imageData = self.jpegData(compressionQuality: 0.9) else {
return nil
}
var fileSize = imageData.count
var i = 10
while fileSize > maxSize && i >= 0 {
- guard let imageData = UIImageJPEGRepresentation(self, CGFloat(0.1 * Double(i))) else {
+ guard let imageData = self.jpegData(compressionQuality: CGFloat(0.1 * Double(i))) else {
return nil
}
fileSize = imageData.count
@@ -125,10 +125,10 @@
newHeight = newWidth / ratio
} else if ratio < 1, ratio != 0 {
// android image orientation bug?
- if self.imageOrientation == UIImageOrientation.right ||
- self.imageOrientation == UIImageOrientation.left ||
- self.imageOrientation == UIImageOrientation.rightMirrored ||
- self.imageOrientation == UIImageOrientation.leftMirrored {
+ if self.imageOrientation == UIImage.Orientation.right ||
+ self.imageOrientation == UIImage.Orientation.left ||
+ self.imageOrientation == UIImage.Orientation.rightMirrored ||
+ self.imageOrientation == UIImage.Orientation.leftMirrored {
newHeight *= ratio
} else {
newWidth = newHeight * ratio
@@ -172,10 +172,10 @@
newHeight = newWidth / ratio
} else if ratio < 1, ratio != 0 {
// android image orientation bug?
- if self.imageOrientation == UIImageOrientation.right ||
- self.imageOrientation == UIImageOrientation.left ||
- self.imageOrientation == UIImageOrientation.rightMirrored ||
- self.imageOrientation == UIImageOrientation.leftMirrored {
+ if self.imageOrientation == UIImage.Orientation.right ||
+ self.imageOrientation == UIImage.Orientation.left ||
+ self.imageOrientation == UIImage.Orientation.rightMirrored ||
+ self.imageOrientation == UIImage.Orientation.leftMirrored {
newHeight *= ratio
} else {
newWidth = newHeight * ratio
@@ -198,8 +198,8 @@
//Setups up the font attributes that will be later used to dictate how the text should be drawn
let textFont = UIFont.systemFont(ofSize: 20, weight: .semibold)
let textFontAttributes = [
- NSAttributedStringKey.font: textFont,
- NSAttributedStringKey.foregroundColor: textColor]
+ NSAttributedString.Key.font: textFont,
+ NSAttributedString.Key.foregroundColor: textColor]
let rect = CGRect(x: 0, y: 0, width: size.width, height: size.height)
UIGraphicsBeginImageContextWithOptions(size, false, 0)
backgroundColor.setFill()
@@ -207,7 +207,7 @@
//Put the image into a rectangle as large as the original image.
self.draw(in: rect)
// Our drawing bounds
- let textSize = text.size(withAttributes: [NSAttributedStringKey.font: textFont])
+ let textSize = text.size(withAttributes: [NSAttributedString.Key.font: textFont])
let textRect = CGRect(x: rect.size.width/2 - textSize.width/2, y: rect.size.height/2 - textSize.height/2,
width: textSize.width, height: textSize.height)
text.draw(in: textRect, withAttributes: textFontAttributes)
diff --git a/Ring/Ring/Extensions/UILabel+Ring.swift b/Ring/Ring/Extensions/UILabel+Ring.swift
index 247fc1e..585751a 100644
--- a/Ring/Ring/Extensions/UILabel+Ring.swift
+++ b/Ring/Ring/Extensions/UILabel+Ring.swift
@@ -25,7 +25,7 @@
let attrString = NSMutableAttributedString(string: withText)
let style = NSMutableParagraphStyle()
style.lineSpacing = withLineSpacing
- attrString.addAttribute(NSAttributedStringKey.paragraphStyle,
+ attrString.addAttribute(NSAttributedString.Key.paragraphStyle,
value: style,
range: NSRange(location: 0, length: withText.utf16.count))
self.attributedText = attrString
diff --git a/Ring/Ring/Extensions/UIViewController+Ring.swift b/Ring/Ring/Extensions/UIViewController+Ring.swift
index 82f34b1..69aa643 100644
--- a/Ring/Ring/Extensions/UIViewController+Ring.swift
+++ b/Ring/Ring/Extensions/UIViewController+Ring.swift
@@ -132,7 +132,7 @@
self.navigationController?.navigationBar.layer.masksToBounds = false
self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: UIBarMetrics.default)
self.navigationController?.navigationBar.shadowImage = UIImage()
- let textAttributes = [NSAttributedStringKey.foregroundColor: UIColor.jamiMain]
+ let textAttributes = [NSAttributedString.Key.foregroundColor: UIColor.jamiMain]
self.navigationController?.navigationBar.titleTextAttributes = textAttributes
self.navigationController?.navigationBar.tintColor = UIColor.jamiMain
}
diff --git a/Ring/Ring/Features/ContactRequests/Cells/ContactRequestCell.swift b/Ring/Ring/Features/ContactRequests/Cells/ContactRequestCell.swift
index 9bb6ba4..e004ed0 100644
--- a/Ring/Ring/Features/ContactRequests/Cells/ContactRequestCell.swift
+++ b/Ring/Ring/Features/ContactRequests/Cells/ContactRequestCell.swift
@@ -35,7 +35,7 @@
override func setSelected(_ selected: Bool, animated: Bool) {
self.backgroundColor = UIColor.jamiUITableViewCellSelection
UIView.animate(withDuration: 0.35, animations: {
- self.backgroundColor = UIColor.jamiUITableViewCellSelection.lighten(byPercentage: 5.0)
+ self.backgroundColor = UIColor.jamiUITableViewCellSelection.lighten(by: 5.0)
})
}
diff --git a/Ring/Ring/Features/ContactRequests/ContactRequestsViewController.swift b/Ring/Ring/Features/ContactRequests/ContactRequestsViewController.swift
index 8de31aa..ed4349e 100644
--- a/Ring/Ring/Features/ContactRequests/ContactRequestsViewController.swift
+++ b/Ring/Ring/Features/ContactRequests/ContactRequestsViewController.swift
@@ -59,8 +59,8 @@
self.setupTableView()
self.setupBindings()
self.navigationController?.navigationBar
- .titleTextAttributes = [NSAttributedStringKey.font: UIFont(name: "HelveticaNeue-Light", size: 25)!,
- NSAttributedStringKey.foregroundColor: UIColor.jamiMain]
+ .titleTextAttributes = [NSAttributedString.Key.font: UIFont(name: "HelveticaNeue-Light", size: 25)!,
+ NSAttributedString.Key.foregroundColor: UIColor.jamiMain]
}
func applyL10n() {
@@ -70,7 +70,7 @@
func setupTableView() {
self.tableView.estimatedRowHeight = 100.0
- self.tableView.rowHeight = UITableViewAutomaticDimension
+ self.tableView.rowHeight = UITableView.automaticDimension
self.tableView.allowsSelection = true
//Register cell
diff --git a/Ring/Ring/Features/Conversations/Conversation/Cells/MessageCell.swift b/Ring/Ring/Features/Conversations/Conversation/Cells/MessageCell.swift
index d3f6cba..2b0f297 100644
--- a/Ring/Ring/Features/Conversations/Conversation/Cells/MessageCell.swift
+++ b/Ring/Ring/Features/Conversations/Conversation/Cells/MessageCell.swift
@@ -296,7 +296,7 @@
self.progressBar.tintColor = UIColor.jamiMain
} else if item.bubblePosition() == .sent {
self.cancelButton.tintColor = UIColor(hex: 0xf00000, alpha: 1.0)
- self.progressBar.tintColor = UIColor.jamiMain.lighten(byPercentage: 0.2)
+ self.progressBar.tintColor = UIColor.jamiMain.lighten(by: 0.2)
}
if item.shouldDisplayTransferedImage {
diff --git a/Ring/Ring/Features/Conversations/Conversation/ConversationViewController.swift b/Ring/Ring/Features/Conversations/Conversation/ConversationViewController.swift
index 7fa4955..15ac822 100644
--- a/Ring/Ring/Features/Conversations/Conversation/ConversationViewController.swift
+++ b/Ring/Ring/Features/Conversations/Conversation/ConversationViewController.swift
@@ -64,8 +64,8 @@
Register to keyboard notifications to adjust tableView insets when the keybaord appears
or disappears
*/
- NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow(withNotification:)), name: NSNotification.Name.UIKeyboardWillShow, object: nil)
- NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide(withNotification:)), name: NSNotification.Name.UIKeyboardWillHide, object: nil)
+ NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow(withNotification:)), name: UIResponder.keyboardWillShowNotification, object: nil)
+ NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide(withNotification:)), name: UIResponder.keyboardWillHideNotification, object: nil)
keyboardDismissTapRecognizer = UITapGestureRecognizer(target: self, action: #selector(dismissKeyboard))
}
@@ -90,15 +90,15 @@
message: nil,
preferredStyle: .alert)
- let pictureAction = UIAlertAction(title: "Upload photo or movie", style: UIAlertActionStyle.default) { _ in
+ let pictureAction = UIAlertAction(title: "Upload photo or movie", style: UIAlertAction.Style.default) { _ in
self.importImage()
}
- let documentsAction = UIAlertAction(title: "Upload file", style: UIAlertActionStyle.default) { _ in
+ let documentsAction = UIAlertAction(title: "Upload file", style: UIAlertAction.Style.default) { _ in
self.importDocument()
}
- let cancelAction = UIAlertAction(title: L10n.Alerts.profileCancelPhoto, style: UIAlertActionStyle.cancel)
+ let cancelAction = UIAlertAction(title: L10n.Alerts.profileCancelPhoto, style: UIAlertAction.Style.cancel)
alert.addAction(pictureAction)
alert.addAction(documentsAction)
alert.addAction(cancelAction)
@@ -109,11 +109,11 @@
}
func takePicture() {
- if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.camera) {
+ if UIImagePickerController.isSourceTypeAvailable(UIImagePickerController.SourceType.camera) {
let imagePicker = UIImagePickerController()
imagePicker.delegate = self
- imagePicker.sourceType = UIImagePickerControllerSourceType.camera
- imagePicker.cameraDevice = UIImagePickerControllerCameraDevice.rear
+ imagePicker.sourceType = UIImagePickerController.SourceType.camera
+ imagePicker.cameraDevice = UIImagePickerController.CameraDevice.rear
imagePicker.modalPresentationStyle = .overFullScreen
self.present(imagePicker, animated: false, completion: nil)
}
@@ -131,14 +131,14 @@
let imagePicker = UIImagePickerController()
imagePicker.delegate = self
imagePicker.allowsEditing = true
- imagePicker.sourceType = UIImagePickerControllerSourceType.photoLibrary
+ imagePicker.sourceType = UIImagePickerController.SourceType.photoLibrary
imagePicker.mediaTypes = [kUTTypeImage as String, kUTTypeMovie as String]
imagePicker.modalPresentationStyle = .overFullScreen
self.present(imagePicker, animated: true, completion: nil)
}
func copyImageToCache(image: UIImage, imagePath: String) {
- guard let imageData = UIImagePNGRepresentation(image) else { return }
+ guard let imageData = image.pngData() else { return }
do {
self.log.debug("copying image to: \(String(describing: imagePath))")
try imageData.write(to: URL(fileURLWithPath: imagePath), options: .atomic)
@@ -148,26 +148,27 @@
}
// swiftlint:disable cyclomatic_complexity
- func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String: Any]) {
+ internal func imagePickerController(_ picker: UIImagePickerController,
+ didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey: Any]) {
picker.dismiss(animated: true, completion: nil)
var image: UIImage!
- if picker.sourceType == UIImagePickerControllerSourceType.camera {
+ if picker.sourceType == UIImagePickerController.SourceType.camera {
// image from camera
- if let img = info[UIImagePickerControllerEditedImage] as? UIImage {
+ if let img = info[.editedImage] as? UIImage {
image = img
- } else if let img = info[UIImagePickerControllerOriginalImage] as? UIImage {
+ } else if let img = info[.originalImage] as? UIImage {
image = self.fixImageOrientation(image: img)
}
// copy image to tmp
let imageFileName = "IMG.png"
- guard let imageData = UIImagePNGRepresentation(image) else { return }
+ guard let imageData = image.pngData() else { return }
self.viewModel.sendAndSaveFile(displayName: imageFileName, imageData: imageData)
- } else if picker.sourceType == UIImagePickerControllerSourceType.photoLibrary {
+ } else if picker.sourceType == UIImagePickerController.SourceType.photoLibrary {
// image from library
- guard let imageURL = info[UIImagePickerControllerReferenceURL] as? URL else { return }
+ guard let imageURL = info[UIImagePickerController.InfoKey.referenceURL] as? URL else { return }
self.log.debug("imageURL: \(String(describing: imageURL))")
let result = PHAsset.fetchAssets(withALAssetURLs: [imageURL], options: nil)
@@ -190,9 +191,9 @@
guard let phAsset = result.firstObject else { return }
if phAsset.mediaType == .image {
- if let img = info[UIImagePickerControllerEditedImage] as? UIImage {
+ if let img = info[.editedImage] as? UIImage {
image = img
- } else if let img = info[UIImagePickerControllerOriginalImage] as? UIImage {
+ } else if let img = info[.originalImage] as? UIImage {
image = img
}
// copy image to tmp
@@ -230,7 +231,7 @@
guard let userInfo: Dictionary = notification.userInfo else {
return
}
- guard let keyboardFrame: NSValue = userInfo[UIKeyboardFrameEndUserInfoKey] as? NSValue else { return }
+ guard let keyboardFrame: NSValue = userInfo[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue else { return }
let keyboardRectangle = keyboardFrame.cgRectValue
let keyboardHeight = keyboardRectangle.height
@@ -272,7 +273,7 @@
// Replace "< Home" with a back arrow while we are crunching everything to the left side of the bar for now.
self.navigationController?.navigationBar.backIndicatorImage = UIImage(named: "back_button")
self.navigationController?.navigationBar.backIndicatorTransitionMaskImage = UIImage(named: "back_button")
- self.navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: UIBarButtonItemStyle.plain, target: nil, action: nil)
+ self.navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: UIBarButtonItem.Style.plain, target: nil, action: nil)
let titleView: UIView = UIView.init(frame: CGRect(x: 0, y: 0, width: view.frame.width - 32, height: totalHeight))
@@ -462,7 +463,7 @@
self.tableView.dataSource = self
self.tableView.estimatedRowHeight = 50
- self.tableView.rowHeight = UITableViewAutomaticDimension
+ self.tableView.rowHeight = UITableView.automaticDimension
self.tableView.separatorStyle = .none
//Register cell
@@ -761,7 +762,7 @@
activityViewController.popoverPresentationController?.sourceView = self.view
activityViewController.popoverPresentationController?.permittedArrowDirections = UIPopoverArrowDirection()
activityViewController.popoverPresentationController?.sourceRect = CGRect(x: self.view.bounds.midX, y: self.view.bounds.maxX, width: 0, height: 0)
- activityViewController.excludedActivityTypes = [UIActivityType.airDrop]
+ activityViewController.excludedActivityTypes = [UIActivity.ActivityType.airDrop]
self.present(activityViewController, animated: true, completion: nil)
}
}
diff --git a/Ring/Ring/Features/Conversations/Conversation/GrowingTextView.swift b/Ring/Ring/Features/Conversations/Conversation/GrowingTextView.swift
index 4a2dbd4..380ef23 100644
--- a/Ring/Ring/Features/Conversations/Conversation/GrowingTextView.swift
+++ b/Ring/Ring/Features/Conversations/Conversation/GrowingTextView.swift
@@ -55,8 +55,8 @@
private func commonInit() {
contentMode = .redraw
associateConstraints()
- NotificationCenter.default.addObserver(self, selector: #selector(textDidChange), name: NSNotification.Name.UITextViewTextDidChange, object: self)
- NotificationCenter.default.addObserver(self, selector: #selector(textDidEndEditing), name: NSNotification.Name.UITextViewTextDidEndEditing, object: self)
+ NotificationCenter.default.addObserver(self, selector: #selector(textDidChange), name: UITextView.textDidChangeNotification, object: self)
+ NotificationCenter.default.addObserver(self, selector: #selector(textDidEndEditing), name: UITextView.textDidEndEditingNotification, object: self)
}
deinit {
@@ -64,7 +64,7 @@
}
open override var intrinsicContentSize: CGSize {
- return CGSize(width: UIViewNoIntrinsicMetric, height: 30)
+ return CGSize(width: UIView.noIntrinsicMetric, height: 30)
}
private func associateConstraints() {
diff --git a/Ring/Ring/Features/Conversations/Conversation/MessageAccessoryView.swift b/Ring/Ring/Features/Conversations/Conversation/MessageAccessoryView.swift
index f2ff062..e1b1987 100644
--- a/Ring/Ring/Features/Conversations/Conversation/MessageAccessoryView.swift
+++ b/Ring/Ring/Features/Conversations/Conversation/MessageAccessoryView.swift
@@ -45,7 +45,7 @@
return
}
self.bottomAnchor
- .constraintLessThanOrEqualToSystemSpacingBelow(window.safeAreaLayoutGuide.bottomAnchor,
+ .constraint(lessThanOrEqualToSystemSpacingBelow: window.safeAreaLayoutGuide.bottomAnchor,
multiplier: 1)
.isActive = true
}
diff --git a/Ring/Ring/Features/Conversations/Conversation/MessageViewModel.swift b/Ring/Ring/Features/Conversations/Conversation/MessageViewModel.swift
index d903f9e..b713a3a 100644
--- a/Ring/Ring/Features/Conversations/Conversation/MessageViewModel.swift
+++ b/Ring/Ring/Features/Conversations/Conversation/MessageViewModel.swift
@@ -57,7 +57,6 @@
private let disposeBag = DisposeBag()
- // swiftlint:disable cyclomatic_complexity
init(withInjectionBag injectionBag: InjectionBag,
withMessage message: MessageModel) {
self.accountService = injectionBag.accountService
diff --git a/Ring/Ring/Features/Conversations/SmartList/Cells/AccountPickerAdapter.swift b/Ring/Ring/Features/Conversations/SmartList/Cells/AccountPickerAdapter.swift
index ae47f23..098ffff 100644
--- a/Ring/Ring/Features/Conversations/SmartList/Cells/AccountPickerAdapter.swift
+++ b/Ring/Ring/Features/Conversations/SmartList/Cells/AccountPickerAdapter.swift
@@ -48,7 +48,7 @@
}
public func rowForAccountId(account: AccountModel) -> Int? {
- return self.items.index { $0.account === account }
+ return self.items.firstIndex { $0.account === account }
}
func pickerView(_ pickerView: UIPickerView, viewForRow row: Int, forComponent component: Int, reusing view: UIView?) -> UIView {
diff --git a/Ring/Ring/Features/Conversations/SmartList/Cells/ConversationCell.swift b/Ring/Ring/Features/Conversations/SmartList/Cells/ConversationCell.swift
index f4c7721..e2f4ddd 100644
--- a/Ring/Ring/Features/Conversations/SmartList/Cells/ConversationCell.swift
+++ b/Ring/Ring/Features/Conversations/SmartList/Cells/ConversationCell.swift
@@ -37,7 +37,7 @@
override func setSelected(_ selected: Bool, animated: Bool) {
self.backgroundColor = UIColor.jamiUITableViewCellSelection
UIView.animate(withDuration: 0.35, animations: {
- self.backgroundColor = UIColor.jamiUITableViewCellSelection.lighten(byPercentage: 5.0)
+ self.backgroundColor = UIColor.jamiUITableViewCellSelection.lighten(by: 5.0)
})
}
diff --git a/Ring/Ring/Features/Conversations/SmartList/SmartlistViewController.swift b/Ring/Ring/Features/Conversations/SmartList/SmartlistViewController.swift
index 4c63cfc..aeb4efb 100644
--- a/Ring/Ring/Features/Conversations/SmartList/SmartlistViewController.swift
+++ b/Ring/Ring/Features/Conversations/SmartList/SmartlistViewController.swift
@@ -101,8 +101,8 @@
Register to keyboard notifications to adjust tableView insets when the keybaord appears
or disappears
*/
- NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow(withNotification:)), name: NSNotification.Name.UIKeyboardDidShow, object: nil)
- NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide(withNotification:)), name: NSNotification.Name.UIKeyboardWillHide, object: nil)
+ NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow(withNotification:)), name: UIResponder.keyboardDidShowNotification, object: nil)
+ NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide(withNotification:)), name: UIResponder.keyboardWillHideNotification, object: nil)
}
@objc func dismissKeyboard() {
@@ -118,8 +118,8 @@
self.navigationController?.navigationBar.layer.shadowColor = UIColor.clear.cgColor
self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: UIBarMetrics.default)
self.navigationController?.navigationBar
- .titleTextAttributes = [NSAttributedStringKey.font: UIFont(name: "HelveticaNeue-Light", size: 25)!,
- NSAttributedStringKey.foregroundColor: UIColor.jamiMain]
+ .titleTextAttributes = [NSAttributedString.Key.font: UIFont(name: "HelveticaNeue-Light", size: 25)!,
+ NSAttributedString.Key.foregroundColor: UIColor.jamiMain]
}
func applyL10n() {
@@ -154,7 +154,7 @@
self.settingsButton.backgroundColor = nil
self.settingsButton.rx.tap.subscribe(onNext: { _ in
- if let url = URL(string: UIApplicationOpenSettingsURLString) {
+ if let url = URL(string: UIApplication.openSettingsURLString) {
if #available(iOS 10.0, *) {
UIApplication.shared.open(url, completionHandler: nil)
} else {
@@ -164,7 +164,7 @@
}).disposed(by: self.disposeBag)
let imageSettings = UIImage(asset: Asset.settings) as UIImage?
- let generalSettingsButton = UIButton(type: UIButtonType.system) as UIButton
+ let generalSettingsButton = UIButton(type: UIButton.ButtonType.system) as UIButton
generalSettingsButton.setImage(imageSettings, for: .normal)
generalSettingsButton.contentMode = .scaleAspectFill
let settingsButtonItem = UIBarButtonItem(customView: generalSettingsButton)
@@ -323,7 +323,7 @@
addAccountButton.setTitle(L10n.Smartlist.addAccountButton, for: .normal)
addAccountButton.setTitleColor(.jamiMain, for: .normal)
addAccountButton.titleLabel?.font = UIFont(name: "HelveticaNeue-Light", size: 25)
- let flexibleBarButton = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.flexibleSpace, target: self, action: nil)
+ let flexibleBarButton = UIBarButtonItem(barButtonSystemItem: UIBarButtonItem.SystemItem.flexibleSpace, target: self, action: nil)
let addBarButton = UIBarButtonItem(customView: addAccountButton)
let toolbar = UIToolbar()
toolbar.barTintColor = .jamiNavigationBar
@@ -342,7 +342,7 @@
@objc func keyboardWillShow(withNotification notification: Notification) {
guard let userInfo: Dictionary = notification.userInfo else {return}
- guard let keyboardFrame: NSValue = userInfo[UIKeyboardFrameEndUserInfoKey] as? NSValue else { return }
+ guard let keyboardFrame: NSValue = userInfo[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue else { return }
let keyboardRectangle = keyboardFrame.cgRectValue
let keyboardHeight = keyboardRectangle.height
guard let tabBarHeight = (self.tabBarController?.tabBar.frame.size.height) else {
@@ -441,7 +441,7 @@
self.searchBar.tintColor = UIColor.jamiMain
self.searchBar.barTintColor = UIColor.jamiNavigationBar
- self.view.bringSubview(toFront: self.searchBarShadow)
+ self.view.bringSubviewToFront(self.searchBarShadow)
self.searchBarShadow.layer.shadowColor = UIColor.black.cgColor
self.searchBarShadow.layer.shadowOffset = CGSize(width: 0.0, height: 2.5)
diff --git a/Ring/Ring/Features/Conversations/SmartList/SmartlistViewModel.swift b/Ring/Ring/Features/Conversations/SmartList/SmartlistViewModel.swift
index 500589a..a780fb0 100644
--- a/Ring/Ring/Features/Conversations/SmartList/SmartlistViewModel.swift
+++ b/Ring/Ring/Features/Conversations/SmartList/SmartlistViewModel.swift
@@ -324,7 +324,7 @@
func delete(conversationViewModel: ConversationViewModel) {
- if let index = self.conversationViewModels.index(where: ({ cvm in
+ if let index = self.conversationViewModels.firstIndex(where: ({ cvm in
cvm.conversation.value == conversationViewModel.conversation.value
})) {
@@ -337,7 +337,7 @@
func clear(conversationViewModel: ConversationViewModel) {
- if let index = self.conversationViewModels.index(where: ({ cvm in
+ if let index = self.conversationViewModels.firstIndex(where: ({ cvm in
cvm.conversation.value == conversationViewModel.conversation.value
})) {
@@ -349,7 +349,7 @@
}
func blockConversationsContact(conversationViewModel: ConversationViewModel) {
- if let index = self.conversationViewModels.index(where: ({ cvm in
+ if let index = self.conversationViewModels.firstIndex(where: ({ cvm in
cvm.conversation.value == conversationViewModel.conversation.value
})) {
let contactUri = conversationViewModel.conversation.value.participantUri
@@ -392,11 +392,11 @@
}
func showQRCode() {
- self.stateSubject.onNext(ConversationState.qrCode())
+ self.stateSubject.onNext(ConversationState.qrCode)
}
func createAccount() {
- self.stateSubject.onNext(ConversationState.createNewAccount())
+ self.stateSubject.onNext(ConversationState.createNewAccount)
}
func changeCurrentAccount(accountId: String) {
@@ -411,7 +411,7 @@
}
func showGeneralSettings() {
- self.stateSubject.onNext(ConversationState.showGeneralSettings())
+ self.stateSubject.onNext(ConversationState.showGeneralSettings)
}
lazy var callButtonTitle: Observable<String> = { [unowned self] in
diff --git a/Ring/Ring/Features/Me/Me/BlockListViewController.swift b/Ring/Ring/Features/Me/Me/BlockListViewController.swift
index dd55000..351ef8f 100644
--- a/Ring/Ring/Features/Me/Me/BlockListViewController.swift
+++ b/Ring/Ring/Features/Me/Me/BlockListViewController.swift
@@ -54,8 +54,8 @@
.disposed(by: self.disposeBag)
self.navigationController?.navigationBar
- .titleTextAttributes = [NSAttributedStringKey.font: UIFont(name: "HelveticaNeue-Light", size: 25)!,
- NSAttributedStringKey.foregroundColor: UIColor.jamiMain]
+ .titleTextAttributes = [NSAttributedString.Key.font: UIFont(name: "HelveticaNeue-Light", size: 25)!,
+ NSAttributedString.Key.foregroundColor: UIColor.jamiMain]
}
func setupTableView() {
diff --git a/Ring/Ring/Features/Me/Me/MeViewController.swift b/Ring/Ring/Features/Me/Me/MeViewController.swift
index 5363aeb..b9eecbb 100644
--- a/Ring/Ring/Features/Me/Me/MeViewController.swift
+++ b/Ring/Ring/Features/Me/Me/MeViewController.swift
@@ -59,8 +59,8 @@
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.navigationController?.navigationBar
- .titleTextAttributes = [NSAttributedStringKey.font: UIFont(name: "HelveticaNeue-Light", size: 25)!,
- NSAttributedStringKey.foregroundColor: UIColor.jamiMain]
+ .titleTextAttributes = [NSAttributedString.Key.font: UIFont(name: "HelveticaNeue-Light", size: 25)!,
+ NSAttributedString.Key.foregroundColor: UIColor.jamiMain]
}
func applyL10n() {
@@ -98,7 +98,7 @@
private func configureBindings() {
let infoButton = UIButton(type: .infoLight)
let imageQrCode = UIImage(asset: Asset.qrCode) as UIImage?
- let qrCodeButton = UIButton(type: UIButtonType.custom) as UIButton
+ let qrCodeButton = UIButton(type: UIButton.ButtonType.custom) as UIButton
qrCodeButton.setImage(imageQrCode, for: .normal)
self.viewModel.isAccountSip
.asObservable()
@@ -140,7 +140,7 @@
//setup Table
self.settingsTable.estimatedRowHeight = 35
- self.settingsTable.rowHeight = UITableViewAutomaticDimension
+ self.settingsTable.rowHeight = UITableView.automaticDimension
self.settingsTable.tableFooterView = UIView()
//Register cell
diff --git a/Ring/Ring/Features/Me/Me/MeViewModel.swift b/Ring/Ring/Features/Me/Me/MeViewModel.swift
index ccf26d8..84f2968 100644
--- a/Ring/Ring/Features/Me/Me/MeViewModel.swift
+++ b/Ring/Ring/Features/Me/Me/MeViewModel.swift
@@ -518,7 +518,7 @@
self.accountService.changeProxyStatus(accountID: account.id, enable: enable)
// if notiications not allowed open application settings
if enable == true && enable != notificationsPermitted.value {
- if let url = URL(string: UIApplicationOpenSettingsURLString) {
+ if let url = URL(string: UIApplication.openSettingsURLString) {
if #available(iOS 10.0, *) {
UIApplication.shared.open(url, completionHandler: nil)
} else {
diff --git a/Ring/Ring/Features/Walkthrough/CreateAccount/CreateAccountViewController.swift b/Ring/Ring/Features/Walkthrough/CreateAccount/CreateAccountViewController.swift
index c71b63c..f1f51b3 100644
--- a/Ring/Ring/Features/Walkthrough/CreateAccount/CreateAccountViewController.swift
+++ b/Ring/Ring/Features/Walkthrough/CreateAccount/CreateAccountViewController.swift
@@ -95,8 +95,8 @@
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
- NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillAppear(withNotification:)), name: NSNotification.Name.UIKeyboardWillShow, object: nil)
- NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillDisappear(withNotification:)), name: NSNotification.Name.UIKeyboardWillHide, object: nil)
+ NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillAppear(withNotification:)), name: UIResponder.keyboardWillShowNotification, object: nil)
+ NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillDisappear(withNotification:)), name: UIResponder.keyboardWillHideNotification, object: nil)
}
func setContentInset() {
@@ -182,18 +182,18 @@
// handle password error
self.viewModel.passwordValidationState.map { $0.isValidated }
- .skipUntil(self.passwordTextField.rx.controlEvent(UIControlEvents.editingDidEnd))
+ .skipUntil(self.passwordTextField.rx.controlEvent(UIControl.Event.editingDidEnd))
.bind(to: self.passwordErrorLabel.rx.isHidden).disposed(by: self.disposeBag)
self.viewModel.passwordValidationState.map { $0.message }
- .skipUntil(self.passwordTextField.rx.controlEvent(UIControlEvents.editingDidEnd))
+ .skipUntil(self.passwordTextField.rx.controlEvent(UIControl.Event.editingDidEnd))
.bind(to: self.passwordErrorLabel.rx.text).disposed(by: self.disposeBag)
// handle registration error
self.viewModel.usernameValidationState.asObservable().map { $0.isAvailable }
- .skipUntil(self.usernameTextField.rx.controlEvent(UIControlEvents.editingDidBegin))
+ .skipUntil(self.usernameTextField.rx.controlEvent(UIControl.Event.editingDidBegin))
.bind(to: self.registerUsernameErrorLabel.rx.isHidden).disposed(by: self.disposeBag)
self.viewModel.usernameValidationState.asObservable().map { $0.message }
- .skipUntil(self.usernameTextField.rx.controlEvent(UIControlEvents.editingDidBegin))
+ .skipUntil(self.usernameTextField.rx.controlEvent(UIControl.Event.editingDidBegin))
.bind(to: self.registerUsernameErrorLabel.rx.text).disposed(by: self.disposeBag)
// handle creation state
diff --git a/Ring/Ring/Features/Walkthrough/CreateProfile/CreateProfileViewController.swift b/Ring/Ring/Features/Walkthrough/CreateProfile/CreateProfileViewController.swift
index 2172d57..c59ebf5 100644
--- a/Ring/Ring/Features/Walkthrough/CreateProfile/CreateProfileViewController.swift
+++ b/Ring/Ring/Features/Walkthrough/CreateProfile/CreateProfileViewController.swift
@@ -199,7 +199,7 @@
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.navigationController?.isNavigationBarHidden = true
- NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillAppear(withNotification:)), name: NSNotification.Name.UIKeyboardWillShow, object: nil)
- NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillDisappear(withNotification:)), name: NSNotification.Name.UIKeyboardWillHide, object: nil)
+ NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillAppear(withNotification:)), name: UIResponder.keyboardWillShowNotification, object: nil)
+ NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillDisappear(withNotification:)), name: UIResponder.keyboardWillHideNotification, object: nil)
}
}
diff --git a/Ring/Ring/Features/Walkthrough/LinkDevice/LinkDeviceViewController.swift b/Ring/Ring/Features/Walkthrough/LinkDevice/LinkDeviceViewController.swift
index 22b8dda..a5ef5a9 100644
--- a/Ring/Ring/Features/Walkthrough/LinkDevice/LinkDeviceViewController.swift
+++ b/Ring/Ring/Features/Walkthrough/LinkDevice/LinkDeviceViewController.swift
@@ -152,8 +152,8 @@
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
- NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillAppear(withNotification:)), name: NSNotification.Name.UIKeyboardWillShow, object: nil)
- NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillDisappear(withNotification:)), name: NSNotification.Name.UIKeyboardWillHide, object: nil)
+ NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillAppear(withNotification:)), name: UIResponder.keyboardWillShowNotification, object: nil)
+ NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillDisappear(withNotification:)), name: UIResponder.keyboardWillHideNotification, object: nil)
}
private func applyL10n() {
diff --git a/Ring/Ring/GeneralSettings/GeneralSettingsViewController.swift b/Ring/Ring/GeneralSettings/GeneralSettingsViewController.swift
index 2c85f39..434b707 100644
--- a/Ring/Ring/GeneralSettings/GeneralSettingsViewController.swift
+++ b/Ring/Ring/GeneralSettings/GeneralSettingsViewController.swift
@@ -46,7 +46,7 @@
func setUpTable() {
self.settingsTable.estimatedRowHeight = 35
- self.settingsTable.rowHeight = UITableViewAutomaticDimension
+ self.settingsTable.rowHeight = UITableView.automaticDimension
self.settingsTable.tableFooterView = UIView()
self.setUpDataSource()
}
diff --git a/Ring/Ring/Helpers/LocalNotificationsHelper.swift b/Ring/Ring/Helpers/LocalNotificationsHelper.swift
index d78c45d..df3f791 100644
--- a/Ring/Ring/Helpers/LocalNotificationsHelper.swift
+++ b/Ring/Ring/Helpers/LocalNotificationsHelper.swift
@@ -78,7 +78,7 @@
content.title = title
content.body = body
content.userInfo = data
- content.sound = UNNotificationSound.default()
+ content.sound = UNNotificationSound.default
content.badge = UIApplication.shared.applicationIconBadgeNumber + 1 as NSNumber
let notificationTrigger = UNTimeIntervalNotificationTrigger(timeInterval: 0.01, repeats: false)
let identifier = Int64(arc4random_uniform(10000000))
@@ -186,7 +186,7 @@
let content = UNMutableNotificationContent()
content.title = NotificationCallTitle.missedCall.getString()
content.body = name
- content.sound = UNNotificationSound.default()
+ content.sound = UNNotificationSound.default
content.badge = UIApplication.shared.applicationIconBadgeNumber + 1 as NSNumber
let notificationTrigger = UNTimeIntervalNotificationTrigger(timeInterval: 0.01, repeats: false)
let notificationRequest = UNNotificationRequest(identifier: callID, content: content, trigger: notificationTrigger)
diff --git a/Ring/Ring/Protocols/ConversationNavigation.swift b/Ring/Ring/Protocols/ConversationNavigation.swift
index 23da1cf..ec9b1ec 100644
--- a/Ring/Ring/Protocols/ConversationNavigation.swift
+++ b/Ring/Ring/Protocols/ConversationNavigation.swift
@@ -26,10 +26,10 @@
case startAudioCall(contactRingId: String, userName: String)
case conversationDetail(conversationViewModel: ConversationViewModel)
case contactDetail(conversationViewModel: ConversationModel)
- case qrCode()
- case createNewAccount()
+ case qrCode
+ case createNewAccount
case showDialpad(inCall: Bool)
- case showGeneralSettings()
+ case showGeneralSettings
case navigateToCall(call: CallModel)
}
diff --git a/Ring/Ring/QRCode/ScanViewController.swift b/Ring/Ring/QRCode/ScanViewController.swift
index 79c60ad..da163c2 100644
--- a/Ring/Ring/QRCode/ScanViewController.swift
+++ b/Ring/Ring/QRCode/ScanViewController.swift
@@ -105,8 +105,8 @@
videoPreviewLayer?.frame = view.layer.bounds
self.searchTitle.text = L10n.Scan.search
view.layer.addSublayer(videoPreviewLayer!)
- view.bringSubview(toFront: header)
- view.bringSubview(toFront: self.scanImage)
+ view.bringSubviewToFront(header)
+ view.bringSubviewToFront(self.scanImage)
} catch { print("Error") }
}
diff --git a/Ring/Ring/Services/AccountsService.swift b/Ring/Ring/Services/AccountsService.swift
index 390f8a7..b0c315d 100644
--- a/Ring/Ring/Services/AccountsService.swift
+++ b/Ring/Ring/Services/AccountsService.swift
@@ -138,7 +138,7 @@
//If current account already exists in the list, move it to the first index
if let currentAccount = currentAccount,
- let index = self.accountList.index(of: currentAccount) {
+ let index = self.accountList.firstIndex(of: currentAccount) {
self.accountList.remove(at: index)
self.accountList.insert(currentAccount, at: 0)
} else {
@@ -178,7 +178,7 @@
return account == selectedAccount
}).first
if let currentAccount = currentAccount,
- let index = self.accountList.index(of: currentAccount) {
+ let index = self.accountList.firstIndex(of: currentAccount) {
self.accountList.remove(at: index)
self.accountList.insert(currentAccount, at: 0)
}
diff --git a/Ring/Ring/Services/AudioService.swift b/Ring/Ring/Services/AudioService.swift
index 12899b4..c372d0b 100644
--- a/Ring/Ring/Services/AudioService.swift
+++ b/Ring/Ring/Services/AudioService.swift
@@ -49,14 +49,17 @@
NotificationCenter.default.addObserver(
self,
selector: #selector(audioRouteChangeListener(_:)),
- name: NSNotification.Name.AVAudioSessionRouteChange,
+ name: AVAudioSession.routeChangeNotification,
object: nil)
}
func startAVAudioSession() {
do {
- try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayAndRecord,
- with: AVAudioSessionCategoryOptions.allowBluetooth)
+ if #available(iOS 10.0, *) {
+ try AVAudioSession.sharedInstance().setCategory(.playAndRecord, mode: .default, options: [AVAudioSession.CategoryOptions.allowBluetooth])
+ } else {
+ try AVAudioSession.sharedInstance().setCategory(.playAndRecord, options: [AVAudioSession.CategoryOptions.allowBluetooth])
+ }
try AVAudioSession.sharedInstance().setActive(true)
} catch {
log.error("\(error)")
@@ -68,14 +71,14 @@
@objc private func audioRouteChangeListener(_ notification: Notification) {
let reasonRaw = notification.userInfo![AVAudioSessionRouteChangeReasonKey] as! UInt
self.log.debug("Audio route change: \(reasonRaw)")
- guard let reason = AVAudioSessionRouteChangeReason(rawValue: reasonRaw) else {
+ guard let reason = AVAudioSession.RouteChangeReason(rawValue: reasonRaw) else {
return
}
overrideAudioRoute(reason)
}
// swiftlint:enable force_cast
- func overrideAudioRoute(_ reason: AVAudioSessionRouteChangeReason) {
+ func overrideAudioRoute(_ reason: AVAudioSession.RouteChangeReason) {
let wasHeadsetConnected = isHeadsetConnected.value
let bluetoothConnected = bluetoothAudioConnected()
let headphonesConnected = headphoneAudioConnected()
@@ -125,9 +128,9 @@
func bluetoothAudioConnected() -> Bool {
let outputs = AVAudioSession.sharedInstance().currentRoute.outputs
for output in outputs {
- if output.portType == AVAudioSessionPortBluetoothA2DP ||
- output.portType == AVAudioSessionPortBluetoothHFP ||
- output.portType == AVAudioSessionPortBluetoothLE {
+ if output.portType == AVAudioSession.Port.bluetoothA2DP ||
+ output.portType == AVAudioSession.Port.bluetoothHFP ||
+ output.portType == AVAudioSession.Port.bluetoothLE {
return true
}
}
@@ -136,7 +139,7 @@
func headphoneAudioConnected() -> Bool {
let outputs = AVAudioSession.sharedInstance().currentRoute.outputs
- for output in outputs where output.portType == AVAudioSessionPortHeadphones {
+ for output in outputs where output.portType == AVAudioSession.Port.headphones {
return true
}
return false
@@ -144,7 +147,7 @@
func speakerIsActive() -> Bool? {
if let output = AVAudioSession.sharedInstance().currentRoute.outputs.first {
- return output.uid == AVAudioSessionPortBuiltInSpeaker
+ return output.uid == AVAudioSession.Port.builtInSpeaker.rawValue
}
return nil
}
diff --git a/Ring/Ring/Services/ContactsService.swift b/Ring/Ring/Services/ContactsService.swift
index 497fa1f..1108833 100644
--- a/Ring/Ring/Services/ContactsService.swift
+++ b/Ring/Ring/Services/ContactsService.swift
@@ -85,7 +85,7 @@
})
self.contacts.value.removeAll()
for contact in contacts {
- if self.contacts.value.index(of: contact) == nil {
+ if self.contacts.value.firstIndex(of: contact) == nil {
self.contacts.value.append(contact)
self.log.debug("contact: \(String(describing: contact.userName))")
}
@@ -102,7 +102,7 @@
}) {
self.contacts.value.removeAll()
for contact in contacts {
- if self.contacts.value.index(of: contact) == nil {
+ if self.contacts.value.firstIndex(of: contact) == nil {
self.contacts.value.append(contact)
self.log.debug("contact: \(String(describing: contact.userName))")
}
@@ -243,7 +243,7 @@
guard let contactRequestToRemove = self.contactRequests.value.filter({ $0.ringId == ringId}).first else {
return
}
- guard let index = self.contactRequests.value.index(where: { $0 === contactRequestToRemove }) else {
+ guard let index = self.contactRequests.value.firstIndex(where: { $0 === contactRequestToRemove }) else {
return
}
self.contactRequests.value.remove(at: index)
@@ -319,7 +319,7 @@
return ContactModel(withDictionary: contactDict)
}) {
for contact in contacts {
- if self.contacts.value.index(of: contact) == nil {
+ if self.contacts.value.firstIndex(of: contact) == nil {
self.contacts.value.append(contact)
contactStatus.onNext(contact)
}
diff --git a/Ring/Ring/Services/ConversationsManager.swift b/Ring/Ring/Services/ConversationsManager.swift
index 4e6eab4..769336e 100644
--- a/Ring/Ring/Services/ConversationsManager.swift
+++ b/Ring/Ring/Services/ConversationsManager.swift
@@ -92,6 +92,8 @@
self.conversationService.dataTransferMessageMap.removeValue(forKey: transferId)
case .created:
break
+ @unknown default:
+ break
}
self.conversationService.transferStatusChanged(status, for: transferId, accountId: transferInfo.accountId, to: transferInfo.peer)
default:
diff --git a/Ring/Ring/Services/DataTransferService.swift b/Ring/Ring/Services/DataTransferService.swift
index dd29f60..6925777 100644
--- a/Ring/Ring/Services/DataTransferService.swift
+++ b/Ring/Ring/Services/DataTransferService.swift
@@ -69,6 +69,8 @@
case .closed_by_peer: return "closed by peer"
case .invalid_pathname: return "invalid pathname"
case .unjoinable_peer: return "unjoinable peer"
+ @unknown default:
+ return "Invalid"
}
}
// swiftlint:enable cyclomatic_complexity
diff --git a/Ring/Ring/Services/VideoService.swift b/Ring/Ring/Services/VideoService.swift
index 675a0bf..9c5b3ee 100644
--- a/Ring/Ring/Services/VideoService.swift
+++ b/Ring/Ring/Services/VideoService.swift
@@ -489,16 +489,18 @@
self.incomingVideoFrame.onNext(image)
}
- func getImageOrienation() -> UIImageOrientation {
+ func getImageOrienation() -> UIImage.Orientation {
switch self.currentOrientation {
case AVCaptureVideoOrientation.portrait:
- return UIImageOrientation.up
+ return UIImage.Orientation.up
case AVCaptureVideoOrientation.portraitUpsideDown:
- return UIImageOrientation.down
+ return UIImage.Orientation.down
case AVCaptureVideoOrientation.landscapeRight:
- return UIImageOrientation.right
+ return UIImage.Orientation.right
case AVCaptureVideoOrientation.landscapeLeft:
- return UIImageOrientation.left
+ return UIImage.Orientation.left
+ @unknown default:
+ return UIImage.Orientation.up
}
}
diff --git a/Ring/Ring/UI/ButtonTransparentBackground.swift b/Ring/Ring/UI/ButtonTransparentBackground.swift
deleted file mode 100644
index 3fa9d66..0000000
--- a/Ring/Ring/UI/ButtonTransparentBackground.swift
+++ /dev/null
@@ -1,13 +0,0 @@
-//
-// ButtonTransparentBackground.swift
-// Ring
-//
-// Created by Kateryna Kostiuk on 2017-10-26.
-// Copyright © 2017 Savoir-faire Linux. All rights reserved.
-//
-
-import Foundation
-// to set teming in Chameleon extension
-class ButtonTransparentBackground: DesignableButton {
-
-}