Sketch out incremental backup manager and settings view.
This commit is contained in:
parent
b296cfb893
commit
d06ad25d77
|
@ -24,7 +24,7 @@
|
|||
340FC8B1204DAC8D007AEB0F /* BlockListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 340FC887204DAC8C007AEB0F /* BlockListViewController.m */; };
|
||||
340FC8B2204DAC8D007AEB0F /* AdvancedSettingsTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 340FC88C204DAC8C007AEB0F /* AdvancedSettingsTableViewController.m */; };
|
||||
340FC8B3204DAC8D007AEB0F /* AppSettingsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 340FC88D204DAC8C007AEB0F /* AppSettingsViewController.m */; };
|
||||
340FC8B4204DAC8D007AEB0F /* OWSBackupExportViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 340FC88E204DAC8C007AEB0F /* OWSBackupExportViewController.m */; };
|
||||
340FC8B4204DAC8D007AEB0F /* OWSBackupSettingsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 340FC88E204DAC8C007AEB0F /* OWSBackupSettingsViewController.m */; };
|
||||
340FC8B5204DAC8D007AEB0F /* AboutTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 340FC893204DAC8C007AEB0F /* AboutTableViewController.m */; };
|
||||
340FC8B6204DAC8D007AEB0F /* OWSQRCodeScanningViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 340FC896204DAC8C007AEB0F /* OWSQRCodeScanningViewController.m */; };
|
||||
340FC8B7204DAC8D007AEB0F /* OWSConversationSettingsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 340FC89A204DAC8D007AEB0F /* OWSConversationSettingsViewController.m */; };
|
||||
|
@ -543,7 +543,7 @@
|
|||
340FC88B204DAC8C007AEB0F /* NotificationSettingsOptionsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NotificationSettingsOptionsViewController.h; sourceTree = "<group>"; };
|
||||
340FC88C204DAC8C007AEB0F /* AdvancedSettingsTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AdvancedSettingsTableViewController.m; sourceTree = "<group>"; };
|
||||
340FC88D204DAC8C007AEB0F /* AppSettingsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppSettingsViewController.m; sourceTree = "<group>"; };
|
||||
340FC88E204DAC8C007AEB0F /* OWSBackupExportViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSBackupExportViewController.m; sourceTree = "<group>"; };
|
||||
340FC88E204DAC8C007AEB0F /* OWSBackupSettingsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSBackupSettingsViewController.m; sourceTree = "<group>"; };
|
||||
340FC88F204DAC8C007AEB0F /* PrivacySettingsTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrivacySettingsTableViewController.h; sourceTree = "<group>"; };
|
||||
340FC890204DAC8C007AEB0F /* BlockListViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BlockListViewController.h; sourceTree = "<group>"; };
|
||||
340FC891204DAC8C007AEB0F /* OWSLinkDeviceViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSLinkDeviceViewController.h; sourceTree = "<group>"; };
|
||||
|
@ -1240,7 +1240,7 @@
|
|||
340FC88A204DAC8C007AEB0F /* NotificationSettingsViewController.h */,
|
||||
340FC87C204DAC8C007AEB0F /* NotificationSettingsViewController.m */,
|
||||
340FC87F204DAC8C007AEB0F /* OWSBackupSettingsViewController.h */,
|
||||
340FC88E204DAC8C007AEB0F /* OWSBackupExportViewController.m */,
|
||||
340FC88E204DAC8C007AEB0F /* OWSBackupSettingsViewController.m */,
|
||||
340FC891204DAC8C007AEB0F /* OWSLinkDeviceViewController.h */,
|
||||
340FC885204DAC8C007AEB0F /* OWSLinkDeviceViewController.m */,
|
||||
340FC895204DAC8C007AEB0F /* OWSLinkedDevicesTableViewController.h */,
|
||||
|
@ -3059,7 +3059,7 @@
|
|||
341F2C0F1F2B8AE700D07D6B /* DebugUIMisc.m in Sources */,
|
||||
340FC8AF204DAC8D007AEB0F /* OWSLinkDeviceViewController.m in Sources */,
|
||||
34E3EF0D1EFC235B007F6822 /* DebugUIDiskUsage.m in Sources */,
|
||||
340FC8B4204DAC8D007AEB0F /* OWSBackupExportViewController.m in Sources */,
|
||||
340FC8B4204DAC8D007AEB0F /* OWSBackupSettingsViewController.m in Sources */,
|
||||
34D1F0871F8678AA0066283D /* ConversationViewItem.m in Sources */,
|
||||
B6DA6B071B8A2F9A00CA6F98 /* AppStoreRating.m in Sources */,
|
||||
451A13B11E13DED2000A50FD /* CallNotificationsAdapter.swift in Sources */,
|
||||
|
|
|
@ -90,6 +90,10 @@
|
|||
self.title = NSLocalizedString(@"SETTINGS_NAV_BAR_TITLE", @"Title for settings activity");
|
||||
|
||||
[self updateTableContents];
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self showBackup];
|
||||
});
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
|
@ -365,7 +369,6 @@
|
|||
{
|
||||
OWSBackupSettingsViewController *vc = [OWSBackupSettingsViewController new];
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}]];
|
||||
}
|
||||
|
||||
- (void)showDebugUI
|
||||
|
|
|
@ -2,17 +2,11 @@
|
|||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import <SignalMessaging/OWSViewController.h>
|
||||
#import <SignalMessaging/OWSTableViewController.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
//@class TSThread;
|
||||
|
||||
@interface OWSBackupSettingsViewController : OWSViewController
|
||||
|
||||
//// If currentThread is non-nil, we should offer to let users send the
|
||||
//// backup in that thread.
|
||||
//- (void)exportBackup:(TSThread *_Nullable)currentThread skipPassword:(BOOL)skipPassword;
|
||||
@interface OWSBackupSettingsViewController : OWSTableViewController
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSBackup.h"
|
||||
#import "OWSBackupSettingsViewController.h"
|
||||
#import "OWSBackup.h"
|
||||
#import "OWSProgressView.h"
|
||||
#import "Signal-Swift.h"
|
||||
#import "ThreadUtil.h"
|
||||
|
@ -30,6 +30,66 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
@implementation OWSBackupSettingsViewController
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
self.title = NSLocalizedString(@"SETTINGS_BACKUP", @"Label for the backup view in app settings.");
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(backupStateDidChange:)
|
||||
name:NSNotificationNameBackupStateDidChange
|
||||
object:nil];
|
||||
|
||||
[self updateTableContents];
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
}
|
||||
|
||||
- (void)viewDidAppear:(BOOL)animated
|
||||
{
|
||||
[self updateTableContents];
|
||||
}
|
||||
|
||||
#pragma mark - Table Contents
|
||||
|
||||
- (void)updateTableContents
|
||||
{
|
||||
OWSTableContents *contents = [OWSTableContents new];
|
||||
|
||||
BOOL isBackupEnabled = [OWSBackup.sharedManager isBackupEnabled];
|
||||
|
||||
// TODO: This UI is temporary.
|
||||
// Enabling backup will involve entering and registering a PIN.
|
||||
OWSTableSection *enableSection = [OWSTableSection new];
|
||||
enableSection.headerTitle = NSLocalizedString(@"SETTINGS_BACKUP", @"Label for the backup view in app settings.");
|
||||
[enableSection
|
||||
addItem:[OWSTableItem switchItemWithText:
|
||||
NSLocalizedString(@"SETTINGS_BACKUP_ENABLING_SWITCH",
|
||||
@"Label for switch in settings that controls whether or not backup is enabled.")
|
||||
isOn:isBackupEnabled
|
||||
target:self
|
||||
selector:@selector(isBackupEnabledDidChange:)]];
|
||||
[contents addSection:enableSection];
|
||||
|
||||
self.contents = contents;
|
||||
}
|
||||
|
||||
- (void)isBackupEnabledDidChange:(UISwitch *)sender
|
||||
{
|
||||
[OWSBackup.sharedManager setIsBackupEnabled:sender.isOn];
|
||||
}
|
||||
|
||||
#pragma mark - Events
|
||||
|
||||
- (void)backupStateDidChange:(NSNotification *)notification
|
||||
{
|
||||
[self updateTableContents];
|
||||
}
|
||||
|
||||
//- (void)loadView
|
||||
//{
|
||||
// [super loadView];
|
|
@ -426,6 +426,10 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
|
|||
}
|
||||
|
||||
[self checkIfEmptyView];
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self settingsButtonPressed:nil];
|
||||
});
|
||||
}
|
||||
|
||||
- (void)viewWillDisappear:(BOOL)animated
|
||||
|
|
|
@ -46,6 +46,9 @@ typedef NS_ENUM(NSUInteger, OWSBackupState) {
|
|||
|
||||
+ (instancetype)sharedManager;
|
||||
|
||||
- (BOOL)isBackupEnabled;
|
||||
- (void)setIsBackupEnabled:(BOOL)value;
|
||||
|
||||
//- (void)exportBackup:(nullable TSThread *)currentThread skipPassword:(BOOL)skipPassword;
|
||||
//
|
||||
//- (void)importBackup:(NSString *)backupZipPath password:(NSString *_Nullable)password;
|
||||
|
|
|
@ -18,9 +18,13 @@
|
|||
//#import <SignalServiceKit/OWSPrimaryStorage.h>
|
||||
#import "NSNotificationCenter+OWS.h"
|
||||
#import <SignalServiceKit/OWSBackupStorage.h>
|
||||
#import <SignalServiceKit/YapDatabaseConnection+OWS.h>
|
||||
|
||||
NSString *const NSNotificationNameBackupStateDidChange = @"NSNotificationNameBackupStateDidChange";
|
||||
|
||||
NSString *const OWSPrimaryStorage_OWSBackupCollection = @"OWSPrimaryStorage_OWSBackupCollection";
|
||||
NSString *const OWSBackup_IsBackupEnabledKey = @"OWSBackup_IsBackupEnabledKey";
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
//// Hide the "import" directories from exports, etc. by prefixing their name with a period.
|
||||
|
@ -42,7 +46,9 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
// NSString *const Keychain_ImportBackupService = @"OWSKeychainService";
|
||||
// NSString *const Keychain_ImportBackupKey = @"ImportBackupKey";
|
||||
|
||||
@interface OWSStorage (OWSBackup)
|
||||
@interface OWSBackup ()
|
||||
|
||||
@property (nonatomic, readonly) YapDatabaseConnection *dbConnection;
|
||||
|
||||
//- (NSData *)databasePassword;
|
||||
//
|
||||
|
@ -73,6 +79,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
@implementation OWSBackup
|
||||
|
||||
@synthesize dbConnection = _dbConnection;
|
||||
|
||||
+ (instancetype)sharedManager
|
||||
{
|
||||
static OWSBackup *sharedMyManager = nil;
|
||||
|
@ -85,26 +93,22 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
- (instancetype)initDefault
|
||||
{
|
||||
// OWSPrimaryStorage *primaryStorage = [OWSPrimaryStorage sharedManager];
|
||||
// OWSMessageSender *messageSender = [TextSecureKitEnv sharedEnv].messageSender;
|
||||
//
|
||||
// return [self initWithPrimaryStorage:primaryStorage messageSender:messageSender];
|
||||
//}
|
||||
//
|
||||
//- (instancetype)initWithPrimaryStorage:(OWSPrimaryStorage *)primaryStorage
|
||||
// messageSender:(OWSMessageSender *)messageSender
|
||||
//{
|
||||
OWSPrimaryStorage *primaryStorage = [OWSPrimaryStorage sharedManager];
|
||||
|
||||
return [self initWithPrimaryStorage:primaryStorage];
|
||||
}
|
||||
|
||||
- (instancetype)initWithPrimaryStorage:(OWSPrimaryStorage *)primaryStorage
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
if (!self) {
|
||||
return self;
|
||||
}
|
||||
|
||||
// OWSAssert(primaryStorage);
|
||||
// OWSAssert(messageSender);
|
||||
//
|
||||
// _dbConnection = primaryStorage.newDatabaseConnection;
|
||||
// _messageSender = messageSender;
|
||||
OWSAssert(primaryStorage);
|
||||
|
||||
_dbConnection = primaryStorage.newDatabaseConnection;
|
||||
|
||||
_backupExportState = OWSBackupState_AtRest;
|
||||
|
||||
|
@ -145,6 +149,24 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
userInfo:nil];
|
||||
}
|
||||
|
||||
- (BOOL)isBackupEnabled
|
||||
{
|
||||
return [self.dbConnection boolForKey:OWSBackup_IsBackupEnabledKey
|
||||
inCollection:OWSPrimaryStorage_OWSBackupCollection
|
||||
defaultValue:NO];
|
||||
}
|
||||
|
||||
- (void)setIsBackupEnabled:(BOOL)value
|
||||
{
|
||||
[self.dbConnection setBool:value
|
||||
forKey:OWSBackup_IsBackupEnabledKey
|
||||
inCollection:OWSPrimaryStorage_OWSBackupCollection];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationNameAsync:NSNotificationNameBackupStateDidChange
|
||||
object:nil
|
||||
userInfo:nil];
|
||||
}
|
||||
|
||||
//- (void)setBackupProgress:(CGFloat)backupProgress
|
||||
//{
|
||||
// _backupProgress = backupProgress;
|
||||
|
|
|
@ -163,7 +163,8 @@
|
|||
/* Message indicating that backup export is complete. */
|
||||
"BACKUP_EXPORT_COMPLETE_MESSAGE" = "Backup complete.";
|
||||
|
||||
/* Label for button that copies backup password to the pasteboard. */
|
||||
/* Label for button that copies backup password to the
|
||||
// pasteboard. */
|
||||
"BACKUP_EXPORT_COPY_PASSWORD_BUTTON" = "Copy Password";
|
||||
|
||||
/* Message indicating that backup export failed. */
|
||||
|
@ -175,10 +176,12 @@
|
|||
/* Format for message indicating that backup export is complete. Embeds: {{the backup password}}. */
|
||||
"BACKUP_EXPORT_PASSWORD_MESSAGE_FORMAT" = "Your backup password is: %@. Make sure to keep a copy of this password or you won't be able to restore from this backup.";
|
||||
|
||||
/* Label for button that 'send backup' in the current conversation. */
|
||||
/* Label for button that 'send backup' in the current
|
||||
// conversation. */
|
||||
"BACKUP_EXPORT_SEND_BACKUP_BUTTON" = "Send Backup as Message";
|
||||
|
||||
/* Message indicating that sending the backup failed. */
|
||||
/* Message indicating that sending
|
||||
// the backup failed. */
|
||||
"BACKUP_EXPORT_SEND_BACKUP_FAILED" = "Sending Backup Failed.";
|
||||
|
||||
/* Message indicating that sending the backup succeeded. */
|
||||
|
@ -187,7 +190,8 @@
|
|||
/* Label for button that opens share UI for backup. */
|
||||
"BACKUP_EXPORT_SHARE_BACKUP_BUTTON" = "Share Backup";
|
||||
|
||||
/* Title for the 'backup export' view. */
|
||||
/* Title for the 'backup export'
|
||||
// view. */
|
||||
"BACKUP_EXPORT_VIEW_TITLE" = "Backup";
|
||||
|
||||
/* Format for backup filenames. Embeds: {{the date and time of the backup}}. Should not include characters like slash (/ or \\) or colon (:). */
|
||||
|
@ -1580,7 +1584,10 @@
|
|||
"SETTINGS_AUDIO_DEFAULT_TONE_LABEL_FORMAT" = "%@ (default)";
|
||||
|
||||
/* Label for the backup view in app settings. */
|
||||
"SETTINGS_BACKUP" = "SETTINGS_BACKUP";
|
||||
"SETTINGS_BACKUP" = "Backup";
|
||||
|
||||
/* Label for switch in settings that controls whether or not backup is enabled. */
|
||||
"SETTINGS_BACKUP_ENABLING_SWITCH" = "Backup Enabled";
|
||||
|
||||
/* A label for the 'add phone number' button in the block list table. */
|
||||
"SETTINGS_BLOCK_LIST_ADD_BUTTON" = "Add…";
|
||||
|
|
Loading…
Reference in New Issue