Display fingerprints.

pull/1/head
Frederic Jacobs 11 years ago
parent 901640507c
commit 67a1a41330

@ -7,9 +7,12 @@
// //
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import "TSContactThread.h"
@interface FingerprintViewController : UIViewController @interface FingerprintViewController : UIViewController
- (void)configWithThread:(TSThread*)thread;
@property (nonatomic, strong) IBOutlet UILabel * presentationLabel; @property (nonatomic, strong) IBOutlet UILabel * presentationLabel;
@property (nonatomic, strong) IBOutlet UIImageView * contactImageView; @property (nonatomic, strong) IBOutlet UIImageView * contactImageView;

@ -8,14 +8,44 @@
#import "FingerprintViewController.h" #import "FingerprintViewController.h"
#import "Cryptography.h"
#import <AxolotlKit/NSData+keyVersionByte.h>
#import <25519/Curve25519.h>
#import "NSData+hexString.h"
#import "DJWActionSheet.h" #import "DJWActionSheet.h"
#import "TSStorageManager.h"
#import "TSStorageManager+IdentityKeyStore.h"
@interface FingerprintViewController () @interface FingerprintViewController ()
@property TSContactThread *thread;
@end @end
@implementation FingerprintViewController @implementation FingerprintViewController
- (void)configWithThread:(TSThread *)thread{
self.thread = (TSContactThread*)thread;
}
- (NSString*)getFingerprintForDisplay:(NSData*)identityKey {
// idea here is to insert a space every two characters. there is probably a cleverer/more native way to do this.
identityKey = [identityKey prependKeyType];
NSString *fingerprint = [identityKey hexadecimalString];
__block NSString* formattedFingerprint = @"";
[fingerprint enumerateSubstringsInRange:NSMakeRange(0, [fingerprint length])
options:NSStringEnumerationByComposedCharacterSequences
usingBlock:
^(NSString *substring, NSRange substringRange, NSRange enclosingRange, BOOL *stop) {
if (substringRange.location % 2 != 0 && substringRange.location != [fingerprint length]-1) {
substring = [substring stringByAppendingString:@" "];
}
formattedFingerprint = [formattedFingerprint stringByAppendingString:substring];
}];
return formattedFingerprint;
}
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
@ -25,8 +55,15 @@
} }
-(void)viewWillAppear:(BOOL)animated - (void)viewWillAppear:(BOOL)animated
{ {
self.contactFingerprintTitleLabel.text = self.thread.name;
NSData *identityKey = [[TSStorageManager sharedManager] identityKeyForRecipientId:self.thread.contactIdentifier];
self.contactFingerprintLabel.text = [self getFingerprintForDisplay:identityKey];
NSData *myPublicKey = [[TSStorageManager sharedManager] identityKeyPair].publicKey;
self.userFingerprintLabel.text = [self getFingerprintForDisplay:myPublicKey];
[UIView animateWithDuration:0.6 delay:0. options:UIViewAnimationOptionCurveEaseInOut animations:^{ [UIView animateWithDuration:0.6 delay:0. options:UIViewAnimationOptionCurveEaseInOut animations:^{
[self.view setAlpha:1]; [self.view setAlpha:1];
} completion:nil]; } completion:nil];
@ -38,7 +75,7 @@
} }
#pragma mark - Initializers #pragma mark - Initializers
-(void)initializeImageViews - (void)initializeImageViews
{ {
_contactImageView.image = [UIImage imageNamed:@"defaultConctact_light"]; _contactImageView.image = [UIImage imageNamed:@"defaultConctact_light"];
_contactImageView.layer.cornerRadius = 75.f/2; _contactImageView.layer.cornerRadius = 75.f/2;
@ -54,7 +91,7 @@
} }
#pragma mark - Action #pragma mark - Action
-(IBAction)closeButtonAction:(id)sender - (IBAction)closeButtonAction:(id)sender
{ {
[UIView animateWithDuration:0.6 delay:0. options:UIViewAnimationOptionCurveEaseInOut animations:^{ [UIView animateWithDuration:0.6 delay:0. options:UIViewAnimationOptionCurveEaseInOut animations:^{
[self.view setAlpha:0]; [self.view setAlpha:0];
@ -64,7 +101,7 @@
} }
-(IBAction)shredAndDelete:(id)sender - (IBAction)shredAndDelete:(id)sender
{ {
[DJWActionSheet showInView:self.view withTitle:@"Are you sure wou want to shred all communications with this contact ? This action is irreversible." [DJWActionSheet showInView:self.view withTitle:@"Are you sure wou want to shred all communications with this contact ? This action is irreversible."
cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@[@"Shred all communications & delete contact"] cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@[@"Shred all communications & delete contact"]
@ -81,19 +118,9 @@
#pragma mark - Shredding & Deleting #pragma mark - Shredding & Deleting
-(void)shredAndDelete - (void)shredAndDelete
{ {
} }
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end @end

@ -10,6 +10,7 @@
#import "MessagesViewController.h" #import "MessagesViewController.h"
#import "FullImageViewController.h" #import "FullImageViewController.h"
#import "FingerprintViewController.h"
#import "JSQCallCollectionViewCell.h" #import "JSQCallCollectionViewCell.h"
#import "JSQCall.h" #import "JSQCall.h"
@ -195,6 +196,7 @@ typedef enum : NSUInteger {
[self performSegueWithIdentifier:@"fingerprintSegue" sender:self]; [self performSegueWithIdentifier:@"fingerprintSegue" sender:self];
} }
#pragma mark - Calls #pragma mark - Calls
-(BOOL)isRedPhoneReachable -(BOOL)isRedPhoneReachable
@ -508,6 +510,12 @@ typedef enum : NSUInteger {
FullImageViewController* dest = [segue destinationViewController]; FullImageViewController* dest = [segue destinationViewController];
dest.image = tappedImage; dest.image = tappedImage;
} else if ([segue.identifier isEqualToString:@"fingerprintSegue"]){
FingerprintViewController *vc = [segue destinationViewController];
TSContactThread *thread = (TSContactThread*) self.thread;
[self.uiDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
[vc configWithThread:self.thread];
}];
} }
} }

Loading…
Cancel
Save