Settings: Share fingerprint in tweet (close #210)

This commit is contained in:
dtsbourg 2014-12-04 15:54:43 +01:00 committed by Frederic Jacobs
parent 5cf96b2b05
commit 4cb3231bb1
4 changed files with 157 additions and 5 deletions

View File

@ -497,6 +497,9 @@
FC3196301A0814130094C78E /* SettingsTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FC31962F1A0814130094C78E /* SettingsTableViewController.m */; };
FC3BD97B1A2CD385005B96BB /* call_dotted@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = FC3BD9791A2CD385005B96BB /* call_dotted@2x.png */; };
FC3BD97C1A2CD385005B96BB /* signal_dotted@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = FC3BD97A1A2CD385005B96BB /* signal_dotted@2x.png */; };
FC3BD9841A306483005B96BB /* signals_error@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = FC3BD9831A306483005B96BB /* signals_error@2x.png */; };
FC3BD9861A30A62D005B96BB /* twitter@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = FC3BD9851A30A62D005B96BB /* twitter@2x.png */; };
FC3BD9881A30A790005B96BB /* Social.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FC3BD9871A30A790005B96BB /* Social.framework */; };
FC4FA0261A1B9DC600DA100A /* SignalsNavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = FC4FA0251A1B9DC600DA100A /* SignalsNavigationController.m */; };
FC4FA0331A1D46AE00DA100A /* InitialViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FC4FA0321A1D46AE00DA100A /* InitialViewController.m */; };
FC5CDF391A3393DD00B47253 /* error_white@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = FC5CDF371A3393DD00B47253 /* error_white@2x.png */; };
@ -1195,6 +1198,9 @@
FC31962F1A0814130094C78E /* SettingsTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SettingsTableViewController.m; sourceTree = "<group>"; };
FC3BD9791A2CD385005B96BB /* call_dotted@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "call_dotted@2x.png"; sourceTree = "<group>"; };
FC3BD97A1A2CD385005B96BB /* signal_dotted@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "signal_dotted@2x.png"; sourceTree = "<group>"; };
FC3BD9831A306483005B96BB /* signals_error@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "signals_error@2x.png"; sourceTree = "<group>"; };
FC3BD9851A30A62D005B96BB /* twitter@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "twitter@2x.png"; sourceTree = "<group>"; };
FC3BD9871A30A790005B96BB /* Social.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Social.framework; path = System/Library/Frameworks/Social.framework; sourceTree = SDKROOT; };
FC4FA0241A1B9DC600DA100A /* SignalsNavigationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SignalsNavigationController.h; sourceTree = "<group>"; };
FC4FA0251A1B9DC600DA100A /* SignalsNavigationController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SignalsNavigationController.m; sourceTree = "<group>"; };
FC4FA0311A1D46AE00DA100A /* InitialViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InitialViewController.h; sourceTree = "<group>"; };
@ -1255,6 +1261,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FC3BD9881A30A790005B96BB /* Social.framework in Frameworks */,
FCB11D8C1A129A76002F93FB /* CoreMedia.framework in Frameworks */,
70377AAB1918450100CAF501 /* MobileCoreServices.framework in Frameworks */,
70B800AF190C548D0042E3F0 /* libspeex.a in Frameworks */,
@ -2148,6 +2155,8 @@
B633C4FD1A1D190B0059AC12 /* Images */ = {
isa = PBXGroup;
children = (
FC3BD9851A30A62D005B96BB /* twitter@2x.png */,
FC3BD9831A306483005B96BB /* signals_error@2x.png */,
B633C4FE1A1D190B0059AC12 /* archive@2x.png */,
FCB626B11A3B067900FDB504 /* ArrowBottom@2x.png */,
FCB626B21A3B067900FDB504 /* ArrowBottom@3x.png */,
@ -2523,6 +2532,8 @@
D221A08C169C9E5E00537ABF /* Frameworks */ = {
isa = PBXGroup;
children = (
FC3BD9871A30A790005B96BB /* Social.framework */,
B60EDE031A05A01700D73516 /* AudioToolbox.framework */,
FCB11D8B1A129A76002F93FB /* CoreMedia.framework */,
B69CD25019773E79005CE69A /* XCTest.framework */,
70377AAA1918450100CAF501 /* MobileCoreServices.framework */,
@ -2990,7 +3001,9 @@
B633C5961A1D190B0059AC12 /* DefaultContactImage.png in Resources */,
E148751218A06AFD002CC4F3 /* HelveticaNeueLTStd-Bd.otf in Resources */,
FCA52AE61A2B676C00CCADFA /* call_canceled@2x.png in Resources */,
FC3BD9861A30A62D005B96BB /* twitter@2x.png in Resources */,
E148751318A06AFD002CC4F3 /* HelveticaNeueLTStd-Th.otf in Resources */,
FC3BD9841A306483005B96BB /* signals_error@2x.png in Resources */,
E148751418A06AFD002CC4F3 /* HelveticaNeueLTStd-Lt.otf in Resources */,
E148751518A06AFD002CC4F3 /* HelveticaNeueLTStd-Md.otf in Resources */,
FC3BD97B1A2CD385005B96BB /* call_dotted@2x.png in Resources */,

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

View File

@ -806,6 +806,7 @@ A0 09 9A FF A8 8A 09 99</string>
<objects>
<tableViewController id="JeZ-9g-U61" customClass="ShowGroupMembersViewController" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="Fdx-Zk-e27">
<rect key="frame" x="0.0" y="0.0" width="600" height="551"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<prototypes>
@ -3072,6 +3073,95 @@ Licensed under the GPLv3</string>
</variation>
</tableViewCellContentView>
</tableViewCell>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" rowHeight="60" id="PJJ-QW-SVN">
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="PJJ-QW-SVN" id="WKr-Kw-POd">
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Share Fingerprint" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Isc-5e-9wS">
<rect key="frame" x="0.0" y="-21" width="42" height="21"/>
<constraints>
<constraint firstAttribute="width" constant="307" id="STc-5Y-3O1"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
<variation key="default">
<mask key="constraints">
<exclude reference="STc-5Y-3O1"/>
</mask>
</variation>
<variation key="heightClass=regular-widthClass=compact">
<mask key="constraints">
<include reference="STc-5Y-3O1"/>
</mask>
</variation>
</label>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="twitter.png" translatesAutoresizingMaskIntoConstraints="NO" id="X9f-FA-r0E">
<rect key="frame" x="0.0" y="0.0" width="240" height="128"/>
<constraints>
<constraint firstAttribute="width" constant="30" id="1Gh-JL-Aw5"/>
<constraint firstAttribute="height" constant="30" id="uJT-pA-QPp"/>
</constraints>
<variation key="default">
<mask key="constraints">
<exclude reference="1Gh-JL-Aw5"/>
<exclude reference="uJT-pA-QPp"/>
</mask>
</variation>
<variation key="heightClass=regular-widthClass=compact">
<mask key="constraints">
<include reference="1Gh-JL-Aw5"/>
<include reference="uJT-pA-QPp"/>
</mask>
</variation>
</imageView>
</subviews>
<constraints>
<constraint firstItem="Isc-5e-9wS" firstAttribute="leading" secondItem="WKr-Kw-POd" secondAttribute="leadingMargin" id="2mI-eK-MSj">
<variation key="heightClass=regular-widthClass=compact" constant="7"/>
</constraint>
<constraint firstItem="Isc-5e-9wS" firstAttribute="leading" secondItem="X9f-FA-r0E" secondAttribute="trailing" constant="9" id="36G-Jr-Gqt"/>
<constraint firstItem="Isc-5e-9wS" firstAttribute="centerY" secondItem="X9f-FA-r0E" secondAttribute="centerY" constant="-0.75" id="MtU-PY-R19"/>
<constraint firstAttribute="trailingMargin" secondItem="Isc-5e-9wS" secondAttribute="trailing" constant="70" id="OEp-cY-Gp3"/>
<constraint firstItem="X9f-FA-r0E" firstAttribute="leading" secondItem="WKr-Kw-POd" secondAttribute="leadingMargin" constant="8" id="eni-Cn-6m6"/>
<constraint firstItem="Isc-5e-9wS" firstAttribute="top" secondItem="WKr-Kw-POd" secondAttribute="topMargin" constant="3" id="uXT-IG-VvM">
<variation key="heightClass=regular-widthClass=compact" constant="11"/>
</constraint>
<constraint firstItem="X9f-FA-r0E" firstAttribute="top" secondItem="WKr-Kw-POd" secondAttribute="topMargin" constant="7" id="uhI-4g-8rH"/>
</constraints>
<variation key="default">
<mask key="subviews">
<exclude reference="Isc-5e-9wS"/>
<exclude reference="X9f-FA-r0E"/>
</mask>
<mask key="constraints">
<exclude reference="2mI-eK-MSj"/>
<exclude reference="36G-Jr-Gqt"/>
<exclude reference="MtU-PY-R19"/>
<exclude reference="OEp-cY-Gp3"/>
<exclude reference="uXT-IG-VvM"/>
<exclude reference="eni-Cn-6m6"/>
<exclude reference="uhI-4g-8rH"/>
</mask>
</variation>
<variation key="heightClass=regular-widthClass=compact">
<mask key="subviews">
<include reference="Isc-5e-9wS"/>
<include reference="X9f-FA-r0E"/>
</mask>
<mask key="constraints">
<exclude reference="2mI-eK-MSj"/>
<include reference="36G-Jr-Gqt"/>
<include reference="MtU-PY-R19"/>
<exclude reference="OEp-cY-Gp3"/>
<include reference="uXT-IG-VvM"/>
<include reference="eni-Cn-6m6"/>
<include reference="uhI-4g-8rH"/>
</mask>
</variation>
</tableViewCellContentView>
</tableViewCell>
<tableViewCell contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" rowHeight="60" id="xqr-ce-rni">
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="xqr-ce-rni" id="b4l-um-jXd">
@ -3783,6 +3873,7 @@ Licensed under the GPLv3</string>
<image name="shred.png" width="200" height="200"/>
<image name="signal.png" width="50" height="50"/>
<image name="signals_tab.png" width="24" height="24"/>
<image name="twitter.png" width="50" height="50"/>
</resources>
<inferredMetricsTieBreakers>
<segue reference="gZ1-lh-srF"/>

View File

@ -14,10 +14,19 @@
#import "TSStorageManager.h"
#import "Environment.h"
#import "PreferencesUtil.h"
#import <Social/Social.h>
#import "RPServerRequestsManager.h"
#import <PastelogKit/Pastelog.h>
#import "Cryptography.h"
#import <AxolotlKit/NSData+keyVersionByte.h>
#import <25519/Curve25519.h>
#import "NSData+hexString.h"
#import "TSStorageManager.h"
#import "TSStorageManager+IdentityKeyStore.h"
#define kProfileCellHeight 87.0f
#define kStandardCellHeight 60.0f
@ -26,13 +35,13 @@
#define kMessageDisplayCellRow 1
#define kImageQualitySettingRow 2
#define kClearHistoryLogCellRow 3
#define kSendDebugLogCellRow 5
#define kUnregisterCell 6
#define kShareFingerpintCellRow 4
#define kSendDebugLogCellRow 6
#define kUnregisterCell 7
typedef enum {
kProfileRows = 1,
kSecurityRows = 7,
kSecurityRows = 8,
} kRowsForSection;
typedef enum {
@ -157,7 +166,24 @@ typedef enum {
}];
break;
}
case kShareFingerpintCellRow: {
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter])
{
SLComposeViewController *tweetSheet = [SLComposeViewController
composeViewControllerForServiceType:SLServiceTypeTwitter];
NSData *myPublicKey = [[TSStorageManager sharedManager] identityKeyPair].publicKey;
NSString * tweetString = [NSString stringWithFormat:@"Verifying myself on Signal : %@", [self getFingerprintForTweet:myPublicKey]];
[tweetSheet setInitialText:tweetString];
[tweetSheet addURL:[NSURL URLWithString:@"https://whispersystems.org/signal/install/"]];
tweetSheet.completionHandler = ^(SLComposeViewControllerResult result) {
if (result == SLComposeViewControllerResultCancelled) {
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
}
};
[self presentViewController:tweetSheet animated:YES completion:nil];
}
break;
}
case kSendDebugLogCellRow:
[Pastelog submitLogs];
break;
@ -177,4 +203,26 @@ typedef enum {
}
}
#pragma mark - Fingerprint Util
- (NSString*)getFingerprintForTweet:(NSData*)identityKey {
// idea here is to insert a space every six 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 % 5 == 0 && substringRange.location != [fingerprint length]-1&& substringRange.location != 0) {
substring = [substring stringByAppendingString:@" "];
}
formattedFingerprint = [formattedFingerprint stringByAppendingString:substring];
}];
return formattedFingerprint;
}
@end