assistant: update

This commit is contained in:
Gautier Pelloux-Prayer 2016-08-05 16:16:08 +02:00
parent 3752210167
commit 43f381b90a
11 changed files with 69 additions and 69 deletions

View file

@ -167,7 +167,8 @@ static UICompositeViewDescription *compositeDescription = nil;
assistant_link_phone_number_with_account);
linphone_account_creator_cbs_set_activate_phone_number_link(linphone_account_creator_get_callbacks(account_creator),
assistant_activate_phone_number_link);
linphone_account_creator_cbs_set_recover_phone_account(linphone_account_creator_get_callbacks(account_creator),
assistant_recover_phone_account);
}
- (void)loadAssistantConfig:(NSString *)rcFilename {
NSString *fullPath = [@"file://" stringByAppendingString:[LinphoneManager bundleFile:rcFilename]];
@ -189,22 +190,17 @@ static UICompositeViewDescription *compositeDescription = nil;
}
+ (NSString *)errorForStatus:(LinphoneAccountCreatorStatus)status {
BOOL usePhoneNumber = [LinphoneManager.instance lpConfigBoolForKey:@"use_phone_number" inSection:@"assistant"];
switch (status) {
case LinphoneAccountCreatorEmailInvalid:
return NSLocalizedString(@"Invalid email.", nil);
case LinphoneAccountCreatorUsernameInvalid:
return usePhoneNumber ? NSLocalizedString(@"Invalid phone number.", nil)
: NSLocalizedString(@"Invalid username.", nil);
return NSLocalizedString(@"Invalid username.", nil);
case LinphoneAccountCreatorUsernameTooShort:
return usePhoneNumber ? NSLocalizedString(@"Phone number too short.", nil)
: NSLocalizedString(@"Username too short.", nil);
return NSLocalizedString(@"Username too short.", nil);
case LinphoneAccountCreatorUsernameTooLong:
return usePhoneNumber ? NSLocalizedString(@"Phone number too long.", nil)
: NSLocalizedString(@"Username too long.", nil);
return NSLocalizedString(@"Username too long.", nil);
case LinphoneAccountCreatorUsernameInvalidSize:
return usePhoneNumber ? NSLocalizedString(@"Phone number length invalid.", nil)
: NSLocalizedString(@"Username length invalid.", nil);
return NSLocalizedString(@"Username length invalid.", nil);
case LinphoneAccountCreatorPhoneNumberTooShort:
case LinphoneAccountCreatorPhoneNumberTooLong:
return nil; /* this is not an error, just user has to finish typing */
@ -226,6 +222,7 @@ static UICompositeViewDescription *compositeDescription = nil;
return NSLocalizedString(@"Unsupported transport", nil);
case LinphoneAccountCreatorAccountCreated:
case LinphoneAccountCreatorAccountExist:
case LinphoneAccountCreatorAccountExistWithAlias:
case LinphoneAccountCreatorAccountNotCreated:
case LinphoneAccountCreatorAccountNotExist:
case LinphoneAccountCreatorAccountNotActivated:
@ -276,21 +273,6 @@ static UICompositeViewDescription *compositeDescription = nil;
new_config = linphone_account_creator_configure(account_creator);
if (new_config) {
BOOL usePhoneNumber = [LinphoneManager.instance lpConfigBoolForKey:@"use_phone_number"];
if (usePhoneNumber) {
char *user = linphone_proxy_config_normalize_phone_number(
new_config, linphone_account_creator_get_username(account_creator));
if (user) {
LinphoneAddress *addr = linphone_address_clone(linphone_proxy_config_get_identity_address(new_config));
linphone_address_set_username(addr, user);
linphone_proxy_config_edit(new_config);
linphone_proxy_config_set_identity_address(new_config, addr);
linphone_proxy_config_done(new_config);
linphone_address_destroy(addr);
ms_free(user);
}
}
[lm configurePushTokenForProxyConfig:new_config];
linphone_core_set_default_proxy_config(LC, new_config);
// reload address book to prepend proxy config domain to contacts' phone number
@ -318,8 +300,6 @@ static UICompositeViewDescription *compositeDescription = nil;
_backButton.hidden = (view == _welcomeView);
[self displayUsernameAsPhoneOrUsername];
if (view == _welcomeView) {
BOOL show_logo = [LinphoneManager.instance lpConfigBoolForKey:@"show_assistant_logo_in_choice_view_preference"];
BOOL show_extern = ![LinphoneManager.instance lpConfigBoolForKey:@"hide_assistant_custom_account"];
@ -462,21 +442,6 @@ static UICompositeViewDescription *compositeDescription = nil;
phone_number_length = 0;
}
- (void)displayUsernameAsPhoneOrUsername {
BOOL usePhoneNumber = [LinphoneManager.instance lpConfigBoolForKey:@"use_phone_number"];
NSString *label = usePhoneNumber ? NSLocalizedString(@"PHONE NUMBER", nil) : NSLocalizedString(@"USERNAME", nil);
[self findLabel:ViewElement_Username_Label].text = label;
UITextField *text = [self findTextField:ViewElement_Username];
if (usePhoneNumber) {
text.keyboardType = UIKeyboardTypePhonePad;
[text addDoneButton];
} else {
text.keyboardType = UIKeyboardTypeDefault;
}
}
+ (void)cleanTextField:(UIView *)view {
if ([view isKindOfClass:UIAssistantTextField.class]) {
[(UIAssistantTextField *)view setText:@""];
@ -719,20 +684,36 @@ static UICompositeViewDescription *compositeDescription = nil;
[errorView show];
}
- (void)isAccountUsed:(LinphoneAccountCreatorStatus)status {
if (currentView == _createAccountView) {
if (status == LinphoneAccountCreatorAccountExist || status == LinphoneAccountCreatorAccountExistWithAlias) {
ViewElement ve = ([self findTextField:ViewElement_Username].isVisible) ? ViewElement_Username : ViewElement_Phone;
[[self findTextField:ve] showError:NSLocalizedString(@"This account already exists.", nil)];
[self findButton:ViewElement_NextButton].enabled = NO;
} else if (status == LinphoneAccountCreatorAccountNotExist) {
linphone_account_creator_create_account(account_creator);
} else {
[self genericError];
}
} else if (currentView == _linphoneLoginView) {
[self findTextField:ViewElement_PhoneCC].enabled =
[self findTextField:ViewElement_Phone].enabled =
[self findTextField:ViewElement_DisplayName].enabled =
[self findTextField:ViewElement_Password].enabled = (status == LinphoneAccountCreatorAccountExist);
if (status == LinphoneAccountCreatorAccountExistWithAlias) {
[self findButton:ViewElement_NextButton].enabled = YES;
} else {
[self shouldEnableNextButton];
}
}
}
#pragma mark - Account creator callbacks
void assistant_is_account_used(LinphoneAccountCreator *creator, LinphoneAccountCreatorStatus status) {
AssistantView *thiz = (__bridge AssistantView *)(linphone_account_creator_get_user_data(creator));
thiz.waitView.hidden = YES;
if (status == LinphoneAccountCreatorAccountExist) {
ViewElement ve = ([thiz findTextField:ViewElement_Username].isVisible) ? ViewElement_Username : ViewElement_Phone;
[[thiz findTextField:ve] showError:NSLocalizedString(@"This account already exists.", nil)];
[thiz findButton:ViewElement_NextButton].enabled = NO;
} else if (status == LinphoneAccountCreatorAccountNotExist) {
linphone_account_creator_create_account(thiz->account_creator);
} else {
[thiz genericError];
}
[thiz isAccountUsed:status];
}
void assistant_create_account(LinphoneAccountCreator *creator, LinphoneAccountCreatorStatus status) {
@ -749,6 +730,16 @@ void assistant_create_account(LinphoneAccountCreator *creator, LinphoneAccountCr
}
}
void assistant_recover_phone_account(LinphoneAccountCreator *creator, LinphoneAccountCreatorStatus status) {
AssistantView *thiz = (__bridge AssistantView *)(linphone_account_creator_get_user_data(creator));
thiz.waitView.hidden = YES;
if (status == LinphoneAccountCreatorOK) {
[thiz changeView:thiz.createAccountActivateSMSView back:FALSE animation:TRUE];
} else {
[thiz genericError];
}
}
void assistant_activate_account(LinphoneAccountCreator *creator, LinphoneAccountCreatorStatus status) {
AssistantView *thiz = (__bridge AssistantView *)(linphone_account_creator_get_user_data(creator));
thiz.waitView.hidden = YES;
@ -836,6 +827,11 @@ void assistant_activate_phone_number_link(LinphoneAccountCreator *creator, Linph
- (void)textFieldDidEndEditing:(UITextField *)textField {
UIAssistantTextField *atf = (UIAssistantTextField *)textField;
[atf textFieldDidEndEditing:atf];
if (textField.tag == ViewElement_Username && currentView == _linphoneLoginView) {
linphone_account_creator_is_account_used(account_creator);
}
[self shouldEnableNextButton];
}
@ -950,7 +946,12 @@ void assistant_activate_phone_number_link(LinphoneAccountCreator *creator, Linph
if (phone.length > 0) {
linphone_account_creator_link_phone_number_with_account(account_creator);
} else {
[self configureProxyConfig];
if ((linphone_account_creator_get_phone_number(account_creator) != NULL)
&& [self findTextField:ViewElement_Password].text.length == 0) {
linphone_account_creator_recover_phone_account(account_creator);
} else {
[self configureProxyConfig];
}
}
});
}

View file

@ -743,7 +743,7 @@ Once it is done, come back here and click on the button.</string>
<nil key="highlightedColor"/>
<size key="shadowOffset" width="-1" height="-1"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" tag="120" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="USERNAME" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="zRE-5W-snR" userLabel="usernameLabel">
<label opaque="NO" userInteractionEnabled="NO" tag="120" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="PHONE NUMBER OR USERNAME" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="zRE-5W-snR" userLabel="usernameLabel">
<rect key="frame" x="38" y="131" width="299" height="14"/>
<constraints>
<constraint firstAttribute="height" constant="14" id="4OT-28-nzB"/>
@ -786,7 +786,7 @@ Once it is done, come back here and click on the button.</string>
<color key="textColor" red="0.50196078430000002" green="0.50196078430000002" blue="0.50196078430000002" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<textField opaque="NO" clipsSubviews="YES" tag="101" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" adjustsFontSizeToFit="NO" minimumFontSize="10" translatesAutoresizingMaskIntoConstraints="NO" id="ap4-xh-CVK" userLabel="passwordField" customClass="UIAssistantTextField">
<textField opaque="NO" clipsSubviews="YES" tag="101" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" adjustsFontSizeToFit="NO" minimumFontSize="10" translatesAutoresizingMaskIntoConstraints="NO" id="ap4-xh-CVK" userLabel="passwordField" customClass="UIAssistantTextField">
<rect key="frame" x="38" y="227" width="299" height="30"/>
<color key="backgroundColor" red="0.88235294119999996" green="0.88235294119999996" blue="0.88235294119999996" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<accessibility key="accessibilityConfiguration" label="Password"/>
@ -841,7 +841,7 @@ Once it is done, come back here and click on the button.</string>
<color key="textColor" red="1" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<textField opaque="NO" clipsSubviews="YES" tag="106" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" adjustsFontSizeToFit="NO" minimumFontSize="10" translatesAutoresizingMaskIntoConstraints="NO" id="buh-Vp-YwP" userLabel="displayNameField" customClass="UIAssistantTextField">
<textField opaque="NO" clipsSubviews="YES" tag="106" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" adjustsFontSizeToFit="NO" minimumFontSize="10" translatesAutoresizingMaskIntoConstraints="NO" id="buh-Vp-YwP" userLabel="displayNameField" customClass="UIAssistantTextField">
<rect key="frame" x="38" y="301" width="299" height="30"/>
<color key="backgroundColor" red="0.88235294119999996" green="0.88235294119999996" blue="0.88235294119999996" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<accessibility key="accessibilityConfiguration" label="Display name"/>
@ -866,7 +866,7 @@ Once it is done, come back here and click on the button.</string>
<color key="textColor" red="0.50196078430000002" green="0.50196078430000002" blue="0.50196078430000002" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<textField opaque="NO" clipsSubviews="YES" tag="109" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="+1" textAlignment="center" minimumFontSize="5" translatesAutoresizingMaskIntoConstraints="NO" id="y6x-Aq-16J" userLabel="countryCodeField" customClass="UIAssistantTextField">
<textField opaque="NO" clipsSubviews="YES" tag="109" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="+1" textAlignment="center" minimumFontSize="5" translatesAutoresizingMaskIntoConstraints="NO" id="y6x-Aq-16J" userLabel="countryCodeField" customClass="UIAssistantTextField">
<rect key="frame" x="38" y="378" width="54" height="30"/>
<color key="backgroundColor" red="0.88235294119999996" green="0.88235294119999996" blue="0.88235294119999996" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
@ -880,7 +880,7 @@ Once it is done, come back here and click on the button.</string>
<outlet property="nextFieldResponder" destination="eD1-BU-COs" id="KxJ-UV-0Ot"/>
</connections>
</textField>
<textField opaque="NO" clipsSubviews="YES" tag="107" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" adjustsFontSizeToFit="NO" minimumFontSize="10" translatesAutoresizingMaskIntoConstraints="NO" id="eD1-BU-COs" userLabel="phoneField" customClass="UIAssistantTextField">
<textField opaque="NO" clipsSubviews="YES" tag="107" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" adjustsFontSizeToFit="NO" minimumFontSize="10" translatesAutoresizingMaskIntoConstraints="NO" id="eD1-BU-COs" userLabel="phoneField" customClass="UIAssistantTextField">
<rect key="frame" x="95" y="378" width="242" height="30"/>
<color key="backgroundColor" red="0.88235294119999996" green="0.88235294119999996" blue="0.88235294119999996" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<accessibility key="accessibilityConfiguration" label="Username"/>

View file

@ -154,6 +154,7 @@ static UICompositeViewDescription *compositeDescription = nil;
return NSLocalizedString(@"Unsupported transport", nil);
case LinphoneAccountCreatorAccountCreated:
case LinphoneAccountCreatorAccountExist:
case LinphoneAccountCreatorAccountExistWithAlias:
case LinphoneAccountCreatorAccountNotCreated:
case LinphoneAccountCreatorAccountNotExist:
case LinphoneAccountCreatorAccountNotActivated:

View file

@ -18,7 +18,6 @@
*/
#import <Foundation/Foundation.h>
#import <AVFoundation/AVAudioSession.h>
#import <SystemConfiguration/SCNetworkReachability.h>
#import <AudioToolbox/AudioToolbox.h>
#import <AssetsLibrary/ALAssetsLibrary.h>

View file

@ -13,6 +13,7 @@
INIT_WITH_COMMON_CF {
self.delegate = self;
self.enabled = self.isEnabled; //force refresh bg color
return self;
}
@ -52,7 +53,8 @@ INIT_WITH_COMMON_CF {
}
- (void)setEnabled:(BOOL)enabled {
self.backgroundColor = [self.backgroundColor colorWithAlphaComponent:enabled?1:0.5];
[super setEnabled:enabled];
self.backgroundColor = [self.backgroundColor colorWithAlphaComponent:enabled?1:0.3];
}
#pragma mark - UITextFieldDelegate Functions

View file

@ -17,6 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#import <AVFoundation/AVAudioSession.h>
#import <AudioToolbox/AudioToolbox.h>
#import "UISpeakerButton.h"
#import "Utils.h"

View file

@ -27,7 +27,7 @@
<entry name="username_length" overwrite="true">-1</entry>
<entry name="username_max_length" overwrite="true">64</entry>
<entry name="username_min_length" overwrite="true">1</entry>
<entry name="username_regex" overwrite="true">^[a-z0-9_.\-]*$</entry>
<entry name="xmlrpc_url" overwrite="true">https://sip3.linphone.org:444/xmlrpc.php</entry>
<entry name="username_regex" overwrite="true">^[a-z0-9+_.\-]*$</entry>
<entry name="xmlrpc_url" overwrite="true">https://sip3.linphone.org:444/wizard.php</entry>
</section>
</config>

View file

@ -27,7 +27,7 @@
<entry name="username_length" overwrite="true">-1</entry>
<entry name="username_max_length" overwrite="true">64</entry>
<entry name="username_min_length" overwrite="true">1</entry>
<entry name="username_regex" overwrite="true">^[a-z0-9_.\-]*$</entry>
<entry name="xmlrpc_url" overwrite="true">https://sip3.linphone.org:444/xmlrpc.php</entry>
<entry name="username_regex" overwrite="true">^[a-z0-9+_.\-]*$</entry>
<entry name="xmlrpc_url" overwrite="true">https://sip3.linphone.org:444/wizard.php</entry>
</section>
</config>

View file

@ -4401,7 +4401,6 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD)";
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
CLANG_ENABLE_OBJC_ARC = YES;
@ -4490,7 +4489,6 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD)";
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
CLANG_ENABLE_OBJC_ARC = YES;
@ -4579,7 +4577,6 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD)";
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
CLANG_ENABLE_OBJC_ARC = YES;
@ -4667,7 +4664,6 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD)";
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
CLANG_ENABLE_OBJC_ARC = YES;

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0720"
LastUpgradeVersion = "0730"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"

@ -1 +1 @@
Subproject commit 97c8f0d0d885a020d98be3a35b6fac4c0736c554
Subproject commit 7b2e4bd4e200add58c5e37438e46ccf906bb3d29