Commit 3460703f authored by Alexandre Lision's avatar Alexandre Lision Committed by gerrit2

ui: improve welcome wizard

- add more options to share ringID
- better animation during account creation
- 'OK' button becomes 'Next'
- allow user to create an account with 'Unknown' name
- enable notifications by default

Tuleap: #366
Change-Id: Iada3d83aa94313a0082363808c5eeb79a5e5f394
parent 861d0106
......@@ -179,6 +179,7 @@ SET_SOURCE_FILES_PROPERTIES(${myApp_ICON} PROPERTIES
SET(ring_ICONS
${CMAKE_CURRENT_SOURCE_DIR}/data/symbol_name.png
${CMAKE_CURRENT_SOURCE_DIR}/data/symbol_blue.png
${CMAKE_CURRENT_SOURCE_DIR}/data/background_tile.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_action_accept.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_arrow_back.png
......
......@@ -117,15 +117,37 @@
}
- (void) showIncomingNotification:(Call*) call{
NSUserNotification *notification = [[NSUserNotification alloc] init];
NSUserNotification* notification = [[NSUserNotification alloc] init];
NSString* localizedTitle = [NSString stringWithFormat:
NSLocalizedString(@"Incoming call from %@", @"Incoming call from {Name}"), call->peerName().toNSString()];
[notification setTitle:localizedTitle];
[notification setSoundName:NSUserNotificationDefaultSoundName];
// try to activate action button
@try {
[notification setValue:@YES forKey:@"_showsButtons"];
}
@catch (NSException *exception) {
// private API _showsButtons has changed...
NSLog(@"Action button not activable on notification");
}
[notification setActionButtonTitle:NSLocalizedString(@"Refuse", @"Button Action")];
[[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:notification];
}
- (void) userNotificationCenter:(NSUserNotificationCenter *)center didActivateNotification:(NSUserNotification *)notification
{
if(notification.activationType == NSUserNotificationActivationTypeActionButtonClicked) {
CallModel::instance().selectedCall() << Call::Action::REFUSE;
} else {
[NSApp activateIgnoringOtherApps:YES];
if ([self.ringWindowController.window isMiniaturized]) {
[self.ringWindowController.window deminiaturize:self];
}
}
}
/**
* click in MainMenu "Setup Ring"
*/
......
......@@ -29,9 +29,10 @@
#import <certificate.h>
#import "AppDelegate.h"
#import "Constants.h"
#import "views/NSColor+RingTheme.h"
@implementation RingWizardWC {
__unsafe_unretained IBOutlet NSButton* goToAppButton;
__unsafe_unretained IBOutlet NSTextField* nicknameField;
__unsafe_unretained IBOutlet NSProgressIndicator* progressBar;
__unsafe_unretained IBOutlet NSTextField* indicationLabel;
......@@ -39,6 +40,7 @@
__unsafe_unretained IBOutlet NSButton* showCustomCertsButton;
IBOutlet NSView *securityContainer;
__unsafe_unretained IBOutlet NSButton* shareButton;
__unsafe_unretained IBOutlet NSSecureTextField* passwordField;
__unsafe_unretained IBOutlet NSView* pvkContainer;
__unsafe_unretained IBOutlet NSPathControl* certificatePathControl;
......@@ -58,15 +60,14 @@ NSInteger const NICKNAME_TAG = 1;
[nicknameField setTag:NICKNAME_TAG];
isExpanded = false;
[self.window makeKeyAndOrderFront:nil];
[self.window setLevel:NSStatusWindowLevel];
[self.window makeMainWindow];
AppDelegate *appDelegate = (AppDelegate *)[[NSApplication sharedApplication] delegate];
[self.window setBackgroundColor:[NSColor ringGreyHighlight]];
AppDelegate* appDelegate = (AppDelegate *)[[NSApplication sharedApplication] delegate];
if(![appDelegate checkForRingAccount]) {
accountToCreate = AccountModel::instance().add("", Account::Protocol::RING);
accountToCreate = AccountModel::instance().add(QString::fromNSString(NSFullUserName()), Account::Protocol::RING);
[nicknameField setStringValue:NSFullUserName()];
[self toggleCreateButton:NSFullUserName()];
[self controlTextDidChange:[NSNotification notificationWithName:@"PlaceHolder" object:nicknameField]];
} else {
[indicationLabel setStringValue:NSLocalizedString(@"Ring is already ready to work",
@"Display message to user")];
......@@ -88,23 +89,29 @@ NSInteger const NICKNAME_TAG = 1;
[showCustomCertsButton setHidden:YES];
[goToAppButton setHidden:NO];
[shareButton setHidden:NO];
[shareButton sendActionOn:NSLeftMouseDownMask];
NSSharingService* emailSharingService = [NSSharingService sharingServiceNamed:NSSharingServiceNameComposeEmail];
[createButton setTitle:NSLocalizedString(@"Share by mail",
@"Share button")];
[createButton setAlternateImage:emailSharingService.alternateImage];
[createButton setEnabled:YES];
[createButton setTitle:NSLocalizedString(@"Continue",
@"Continue button")];
[createButton setAction:@selector(goToApp:)];
}
[createButton setAction:@selector(shareByEmail)];
- (IBAction)shareRingID:(id)sender {
NSSharingServicePicker* sharingServicePicker = [[NSSharingServicePicker alloc] initWithItems:[NSArray arrayWithObject:[nicknameField stringValue]]];
[sharingServicePicker showRelativeToRect:[sender bounds]
ofView:sender
preferredEdge:NSMinYEdge];
}
- (IBAction)createRingAccount:(id)sender
{
[nicknameField setHidden:YES];
[progressBar setHidden:NO];
[createButton setEnabled:NO];
[createButton setHidden:YES];
[progressBar startAnimation:nil];
[indicationLabel setStringValue:NSLocalizedString(@"Just a moment...",
@"Indication for user")];
......@@ -118,19 +125,23 @@ NSInteger const NICKNAME_TAG = 1;
[showCustomCertsButton setHidden:YES];
[self performSelector:@selector(saveAccount) withObject:nil afterDelay:1];
[self registerAutoStartup];
[self registerDefaultPreferences];
}
/**
* Enable launch at startup by default
* Set default values for preferences
*/
- (void) registerAutoStartup
- (void) registerDefaultPreferences
{
// enable AutoStartup
LSSharedFileListRef loginItemsRef = LSSharedFileListCreate(NULL, kLSSharedFileListSessionLoginItems, NULL);
if (loginItemsRef == nil) return;
CFURLRef appUrl = (__bridge CFURLRef)[NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]];
LSSharedFileListItemRef itemRef = LSSharedFileListInsertItemURL(loginItemsRef, kLSSharedFileListItemLast, NULL, NULL, appUrl, NULL, NULL);
if (itemRef) CFRelease(itemRef);
// enable Notifications
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:Preferences::Notifications];
}
- (void) saveAccount
......@@ -146,7 +157,7 @@ NSInteger const NICKNAME_TAG = 1;
[=](Account *account, const Account::RegistrationState state) {
NSLog(@"Account created!");
[progressBar setHidden:YES];
[createButton setEnabled:YES];
[createButton setHidden:NO];
[indicationLabel setStringValue:NSLocalizedString(@"This is your number, share it with your friends!", @"Indication to user")];
[self displayHash:account->username().toNSString()];
});
......@@ -175,27 +186,13 @@ NSInteger const NICKNAME_TAG = 1;
}
}
- (void) toggleCreateButton:(NSString*) alias
{
[createButton setEnabled:![alias isEqualToString:@""]];
accountToCreate->setAlias([alias UTF8String]);
accountToCreate->setDisplayName([alias UTF8String]);
}
- (IBAction)goToApp:(id)sender
{
[self.window close];
AppDelegate *appDelegate = (AppDelegate *)[[NSApplication sharedApplication] delegate];
AppDelegate* appDelegate = (AppDelegate *)[[NSApplication sharedApplication] delegate];
[appDelegate showMainWindow];
}
- (void) shareByEmail
{
NSMutableArray *shareItems = [[NSMutableArray alloc] initWithObjects:[nicknameField stringValue], nil];
NSSharingService* emailSharingService = [NSSharingService sharingServiceNamed:NSSharingServiceNameComposeEmail];
[emailSharingService performWithItems:shareItems];
}
#pragma mark - NSPathControl delegate methods
- (IBAction)caListPathControlSingleClick:(id)sender
......@@ -255,7 +252,6 @@ NSInteger const NICKNAME_TAG = 1;
*/
- (void)pathControl:(NSPathControl *)pathControl willDisplayOpenPanel:(NSOpenPanel *)openPanel
{
NSLog(@"willDisplayOpenPanel");
[openPanel setAllowsMultipleSelection:NO];
[openPanel setCanChooseDirectories:NO];
[openPanel setCanChooseFiles:YES];
......@@ -307,14 +303,19 @@ NSInteger const NICKNAME_TAG = 1;
}
// else it is NICKNAME_TAG field
[self toggleCreateButton:textField.stringValue];
NSString* alias = textField.stringValue;
if ([alias isEqualToString:@""]) {
alias = NSLocalizedString(@"Unknown", @"Name used when user leave field empty");
}
accountToCreate->setAlias([alias UTF8String]);
accountToCreate->setDisplayName([alias UTF8String]);
}
# pragma NSWindowDelegate methods
- (void)windowWillClose:(NSNotification *)notification
{
AppDelegate *appDelegate = (AppDelegate *)[[NSApplication sharedApplication] delegate];
AppDelegate* appDelegate = (AppDelegate *)[[NSApplication sharedApplication] delegate];
if ([appDelegate checkForRingAccount]) {
[appDelegate showMainWindow];
}
......
/* Class = "NSButtonCell"; title = "Play"; ObjectID = "8jq-XH-nJV"; */
"8jq-XH-nJV.title" = "Play";
/* Class = "NSButtonCell"; title = "Down"; ObjectID = "Bbz-hd-1CE"; */
"Bbz-hd-1CE.title" = "Down";
......
......@@ -28,6 +28,9 @@
/* Contextual menu entry */
"Choose file" = "Choose file";
/* Continue button */
"Continue" = "Continue";
/* No comment provided by engineer. */
"Copy" = "Copy";
......@@ -43,6 +46,15 @@
/* Message from {Name} */
"Message from %@" = "Message from %@";
/* Button label */
"Pause" = "Pause";
/* Button label */
"Play" = "Play";
/* Button Action */
"Refuse" = "Refuse";
/* Contextual menu entry */
"Remove value" = "Remove value";
......@@ -55,12 +67,12 @@
/* No comment provided by engineer. */
"Share" = "Share";
/* Share button */
"Share by mail" = "Share by mail";
/* No comment provided by engineer. */
"Text Actions" = "Text Actions";
/* Indication to user */
"This is your number, share it with your friends!" = "This is your number, share it with your friends!";
/* Name used when user leave field empty */
"Unknown" = "Unknown";
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9531" systemVersion="15B42" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9532" systemVersion="15D21" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9531"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9532"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="RingWindowController">
......@@ -19,7 +19,7 @@
<windowCollectionBehavior key="collectionBehavior" fullScreenPrimary="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="196" y="240" width="1053" height="658"/>
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1050"/>
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1027"/>
<view key="contentView" autoresizesSubviews="NO" id="se5-gp-TjO">
<rect key="frame" x="0.0" y="0.0" width="1053" height="658"/>
<autoresizingMask key="autoresizingMask"/>
......@@ -200,7 +200,7 @@
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" misplaced="YES" tag="500" translatesAutoresizingMaskIntoConstraints="NO" id="MYe-rn-qOP">
<rect key="frame" x="35" y="6" width="16" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="center" title="n" drawsBackground="YES" id="sGB-x7-gig">
<font key="font" metaFont="system" size="11"/>
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" red="0.98431372549019602" green="0.28627450980392155" blue="0.28235294117647058" alpha="0.90000000000000002" colorSpace="calibratedRGB"/>
</textFieldCell>
......
/* Class = "NSWindow"; title = "Ring"; ObjectID = "4LP-GX-BkH"; */
"4LP-GX-BkH.title" = "Ring";
/* Class = "NSTextFieldCell"; title = "Choose your own certificates"; ObjectID = "4ls-Yq-mDp"; */
"4ls-Yq-mDp.title" = "Choose your own certificates";
/* Class = "NSTextFieldCell"; placeholderString = "'Unknown' if empty..."; ObjectID = "5Z7-Wi-530"; */
"5Z7-Wi-530.placeholderString" = "'Unknown' if empty...";
/* Class = "NSTextFieldCell"; title = "Advanced security (optionnal)"; ObjectID = "Gnn-K9-PTH"; */
"Gnn-K9-PTH.title" = "Advanced security (optionnal)";
/* Class = "NSSecureTextFieldCell"; placeholderString = "Password..."; ObjectID = "Hsc-U9-2RV"; */
"Hsc-U9-2RV.placeholderString" = "Password...";
/* Class = "NSButtonCell"; title = "Continue"; ObjectID = "Kwr-LJ-K8C"; */
"Kwr-LJ-K8C.title" = "Continue";
/* Class = "NSButtonCell"; title = "Share"; ObjectID = "Kwr-LJ-K8C"; */
"Kwr-LJ-K8C.title" = "Share";
/* Class = "NSTextFieldCell"; title = "Certificate Authority list"; ObjectID = "SpA-zX-ytE"; */
"SpA-zX-ytE.title" = "Certificate Authority list";
......@@ -23,8 +23,8 @@
/* Class = "NSButton"; ibShadowedToolTip = "Choose custom certificates"; ObjectID = "aZl-bU-psB"; */
"aZl-bU-psB.ibShadowedToolTip" = "Choose custom certificates";
/* Class = "NSTextFieldCell"; title = "First tell us who you are"; ObjectID = "meL-TZ-VQO"; */
"meL-TZ-VQO.title" = "First tell us who you are";
/* Class = "NSTextFieldCell"; title = "Choose your username"; ObjectID = "meL-TZ-VQO"; */
"meL-TZ-VQO.title" = "Choose your username";
/* Class = "NSTextFieldCell"; title = "Private key"; ObjectID = "poP-JD-MDa"; */
"poP-JD-MDa.title" = "Private key";
......@@ -32,5 +32,5 @@
/* Class = "NSTextFieldCell"; title = "Welcome to Ring"; ObjectID = "uqu-uh-Wao"; */
"uqu-uh-Wao.title" = "Welcome to Ring";
/* Class = "NSButtonCell"; title = "OK"; ObjectID = "wDw-Ut-RUm"; */
"wDw-Ut-RUm.title" = "OK";
/* Class = "NSButtonCell"; title = "Next"; ObjectID = "wDw-Ut-RUm"; */
"wDw-Ut-RUm.title" = "Next";
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment