Add show seed button

pull/26/head
Niels Andriesse 6 years ago
parent e6962dcb95
commit f1bb306438

@ -232,6 +232,12 @@
selector:@selector(sharePublicKey) selector:@selector(sharePublicKey)
color:[UIColor ows_materialBlueColor]]]; 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) { if (TSAccountManager.sharedInstance.isDeregistered) {
[section addItem:[self destructiveButtonItemWithTitle:NSLocalizedString(@"SETTINGS_REREGISTER_BUTTON", [section addItem:[self destructiveButtonItemWithTitle:NSLocalizedString(@"SETTINGS_REREGISTER_BUTTON",
@"Label for re-registration button.") @"Label for re-registration button.")
@ -244,11 +250,14 @@
selector:@selector(deleteUnregisterUserData) selector:@selector(deleteUnregisterUserData)
color:[UIColor ows_destructiveRedColor]]]; color:[UIColor ows_destructiveRedColor]]];
} else { } else {
[section // Loki: Original code
addItem:[self destructiveButtonItemWithTitle:NSLocalizedString(@"SETTINGS_DELETE_ACCOUNT_BUTTON", @"") // ========
accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"delete_account") // [section
selector:@selector(unregisterUser) // addItem:[self destructiveButtonItemWithTitle:NSLocalizedString(@"SETTINGS_DELETE_ACCOUNT_BUTTON", @"")
color:[UIColor ows_destructiveRedColor]]]; // accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"delete_account")
// selector:@selector(unregisterUser)
// color:[UIColor ows_destructiveRedColor]]];
// ========
} }
[contents addSection:section]; [contents addSection:section];
@ -488,6 +497,17 @@
[self presentViewController:shareVC animated:YES completion:nil]; [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 - (void)reregisterUser
{ {
[RegistrationUtils showReregistrationUIFromViewController:self]; [RegistrationUtils showReregistrationUIFromViewController:self];

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

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

@ -140,3 +140,14 @@ private extension String {
return String(self[startIndex..<index(startIndex, offsetBy: Int(length))]) 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)
}
}

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

Loading…
Cancel
Save