Add show seed button

This commit is contained in:
Niels Andriesse 2019-05-28 09:57:54 +10:00
parent e6962dcb95
commit f1bb306438
5 changed files with 40 additions and 9 deletions

View File

@ -232,6 +232,12 @@
selector:@selector(sharePublicKey)
color:[UIColor ows_materialBlueColor]]];
[section
addItem:[self destructiveButtonItemWithTitle:NSLocalizedString(@"Show Seed", @"")
accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"show_seed")
selector:@selector(showSeed)
color:[UIColor ows_materialBlueColor]]];
if (TSAccountManager.sharedInstance.isDeregistered) {
[section addItem:[self destructiveButtonItemWithTitle:NSLocalizedString(@"SETTINGS_REREGISTER_BUTTON",
@"Label for re-registration button.")
@ -244,11 +250,14 @@
selector:@selector(deleteUnregisterUserData)
color:[UIColor ows_destructiveRedColor]]];
} else {
[section
addItem:[self destructiveButtonItemWithTitle:NSLocalizedString(@"SETTINGS_DELETE_ACCOUNT_BUTTON", @"")
accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"delete_account")
selector:@selector(unregisterUser)
color:[UIColor ows_destructiveRedColor]]];
// Loki: Original code
// ========
// [section
// addItem:[self destructiveButtonItemWithTitle:NSLocalizedString(@"SETTINGS_DELETE_ACCOUNT_BUTTON", @"")
// accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"delete_account")
// selector:@selector(unregisterUser)
// color:[UIColor ows_destructiveRedColor]]];
// ========
}
[contents addSection:section];
@ -488,6 +497,17 @@
[self presentViewController:shareVC animated:YES completion:nil];
}
- (void)showSeed
{
NSString *title = NSLocalizedString(@"Your Seed", @"");
ECKeyPair *keyPair = OWSIdentityManager.sharedManager.identityKeyPair;
NSString *mnemonic = [LKMnemonic encodeHexEncodedString:keyPair.hexEncodedPrivateKey];
UIAlertController *alert = [UIAlertController alertControllerWithTitle:title message:mnemonic preferredStyle:UIAlertControllerStyleAlert];
[alert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"OK", @"") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { /* Do nothing */ }]];
[alert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"Copy", @"") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { UIPasteboard.generalPasteboard.string = mnemonic; }]];
[self presentAlert:alert];
}
- (void)reregisterUser
{
[RegistrationUtils showReregistrationUIFromViewController:self];

View File

@ -2585,3 +2585,4 @@
"%@ accepted your friend request" = "%@ accepted your friend request";
"%@'s friend request has expired" = "%@'s friend request has expired";
"Your friend request to %@ has expired" = "Your friend request to %@ has expired";
"Show Seed" = "Show Seed";

View File

@ -24,7 +24,7 @@ import PromiseKit
}
}
public typealias MessagePromise = Promise<[SSKProtoEnvelope]>
public typealias MessageListPromise = Promise<[SSKProtoEnvelope]>
public typealias RawResponsePromise = Promise<RawResponse>
// MARK: Lifecycle
@ -39,7 +39,7 @@ import PromiseKit
}
// MARK: Public API
public static func getMessages() -> Promise<Set<MessagePromise>> {
public static func getMessages() -> Promise<Set<MessageListPromise>> {
let hexEncodedPublicKey = OWSIdentityManager.shared().identityKeyPair()!.hexEncodedPublicKey
return getTargetSnodes(for: hexEncodedPublicKey).mapValues { targetSnode in
let lastHash = getLastMessageHashValue(for: targetSnode) ?? ""

View File

@ -140,3 +140,14 @@ private extension String {
return String(self[startIndex..<index(startIndex, offsetBy: Int(length))])
}
}
@objc(LKMnemonic)
public final class ObjCMnemonic : NSObject {
override private init() { }
@objc(encodeHexEncodedString:)
public static func encode(hexEncodedString string: String) -> String {
return Mnemonic.encode(hexEncodedString: string)
}
}

View File

@ -1521,8 +1521,7 @@ NS_ASSUME_NONNULL_BEGIN
if (existingFriendRequestMessage != nil && existingFriendRequestMessage.isFriendRequest) {
[existingFriendRequestMessage saveFriendRequestStatus:LKMessageFriendRequestStatusAccepted withTransaction:transaction];
}
// Send our p2p details to the other user
// Send our P2P details
LKAddressMessage *_Nullable onlineMessage = [LokiP2PManager onlineBroadcastMessageForThread:thread];
if (onlineMessage != nil) {
[self.messageSenderJobQueue addMessage:onlineMessage transaction:transaction];