From a9607f6ae283f9b770254a5bb32861602d6ad1e9 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Thu, 1 Jun 2017 15:52:43 +0200 Subject: [PATCH] feat(ui/views/App/Main/Assistant): supports activation on phone number --- linphone-desktop/assets/languages/en.ts | 17 ++++- linphone-desktop/assets/languages/fr.ts | 17 ++++- linphone-desktop/resources.qrc | 2 + .../components/assistant/AssistantModel.cpp | 47 +++---------- .../components/assistant/AssistantModel.hpp | 5 ++ ...ivateLinphoneSipAccountWithPhoneNumber.qml | 70 +++++++++++++++++++ ...LinphoneSipAccountWithPhoneNumberStyle.qml | 15 ++++ linphone-desktop/ui/views/App/Styles/qmldir | 51 +++++++------- 8 files changed, 161 insertions(+), 63 deletions(-) create mode 100644 linphone-desktop/ui/views/App/Main/Assistant/ActivateLinphoneSipAccountWithPhoneNumber.qml create mode 100644 linphone-desktop/ui/views/App/Styles/Main/Assistant/ActivateLinphoneSipAccountWithPhoneNumberStyle.qml diff --git a/linphone-desktop/assets/languages/en.ts b/linphone-desktop/assets/languages/en.ts index b9ddc418c..8bacaaf34 100644 --- a/linphone-desktop/assets/languages/en.ts +++ b/linphone-desktop/assets/languages/en.ts @@ -23,6 +23,21 @@ To activate your account: Follow the instructions that we sent you at %1, then click on the button below. + + ActivateLinphoneSipAccountWithPhoneNumber + + activateLinphoneSipAccount + CREATE A LINPHONE ACCOUNT + + + confirmAction + ACTIVATE + + + activationSteps + We have sent a SMS with a validation code to %1. To complete your phone number verification, please enter the 4-digits code below. + + App @@ -592,7 +607,7 @@ Server url not configured. quitWarning - Your account has been created but is not yet validated. If you quit this view, you should add manually your account and validate it within 24 hours. + Your account has been created but is not yet validated. Are you sure you want to quit this view? displayNameLabel diff --git a/linphone-desktop/assets/languages/fr.ts b/linphone-desktop/assets/languages/fr.ts index 9f29ad488..c1fca045d 100644 --- a/linphone-desktop/assets/languages/fr.ts +++ b/linphone-desktop/assets/languages/fr.ts @@ -23,6 +23,21 @@ Pour activer votre compte : Suivez les instructions que vous avez reçues à %1, puis cliquez sur le bouton plus bas. + + ActivateLinphoneSipAccountWithPhoneNumber + + activateLinphoneSipAccount + CRÉER UN COMPTE LINPHONE + + + confirmAction + ACTIVER + + + activationSteps + Nous vous avons envoyé un SMS avec un code de validation au %1. Pour compléter la vérification de votre tél., merci d'entrer le code à 4 chiffres ci-dessous. + + App @@ -592,7 +607,7 @@ Url du serveur non configurée. quitWarning - Votre compte a été crée mais il n'a pas été validé. Si vous quittez cette vue, vous devrez ajouter manuellement votre compte et le valider dans les 24 heures. + Votre compte a été crée mais il n'a pas été validé. Êtes-vous sûr de vouloir quitter cette vue ? displayNameLabel diff --git a/linphone-desktop/resources.qrc b/linphone-desktop/resources.qrc index eb981d6a8..e03ccd40d 100644 --- a/linphone-desktop/resources.qrc +++ b/linphone-desktop/resources.qrc @@ -377,6 +377,7 @@ ui/views/App/Calls/OutgoingCall.qml ui/views/App/Calls/ZrtpTokenAuthentication.qml ui/views/App/Main/Assistant/ActivateLinphoneSipAccountWithEmail.qml + ui/views/App/Main/Assistant/ActivateLinphoneSipAccountWithPhoneNumber.qml ui/views/App/Main/Assistant/AssistantAbstractView.qml ui/views/App/Main/Assistant/AssistantHome.qml ui/views/App/Main/Assistant/CreateLinphoneSipAccount.qml @@ -422,6 +423,7 @@ ui/views/App/Styles/Calls/Dialogs/CallTransferStyle.qml ui/views/App/Styles/Calls/Dialogs/ConferenceManagerStyle.qml ui/views/App/Styles/Main/Assistant/ActivateLinphoneSipAccountWithEmailStyle.qml + ui/views/App/Styles/Main/Assistant/ActivateLinphoneSipAccountWithPhoneNumberStyle.qml ui/views/App/Styles/Main/Assistant/AssistantAbstractViewStyle.qml ui/views/App/Styles/Main/Assistant/AssistantHomeStyle.qml ui/views/App/Styles/Main/Assistant/CreateLinphoneSipAccountStyle.qml diff --git a/linphone-desktop/src/components/assistant/AssistantModel.cpp b/linphone-desktop/src/components/assistant/AssistantModel.cpp index d7efb874a..fddbb3790 100644 --- a/linphone-desktop/src/components/assistant/AssistantModel.cpp +++ b/linphone-desktop/src/components/assistant/AssistantModel.cpp @@ -110,42 +110,6 @@ private: } } - // void onLinkAccount ( - // const shared_ptr &creator, - // linphone::AccountCreatorStatus status, - // const string &resp - // ) override {} - // - // void onActivateAlias ( - // const shared_ptr &creator, - // linphone::AccountCreatorStatus status, - // const string &resp - // ) override {} - // - // void onIsAliasUsed ( - // const shared_ptr &creator, - // linphone::AccountCreatorStatus status, - // const string &resp - // ) override {} - // - // void onIsAccountLinked ( - // const shared_ptr &creator, - // linphone::AccountCreatorStatus status, - // const string &resp - // ) override {} - // - // void onRecoverAccount ( - // const shared_ptr &creator, - // linphone::AccountCreatorStatus status, - // const string &resp - // ) override {} - // - // void onUpdateAccount ( - // const shared_ptr &creator, - // linphone::AccountCreatorStatus status, - // const string &resp - // ) override {} - private: AssistantModel *mAssistant; }; @@ -320,6 +284,17 @@ void AssistantModel::setDisplayName (const QString &displayName) { // ----------------------------------------------------------------------------- +QString AssistantModel::getActivationCode () const { + return ::Utils::coreStringToAppString(mAccountCreator->getActivationCode()); +} + +void AssistantModel::setActivationCode (const QString &activationCode) { + mAccountCreator->setActivationCode(::Utils::appStringToCoreString(activationCode)); + emit activationCodeChanged(activationCode); +} + +// ----------------------------------------------------------------------------- + QString AssistantModel::getConfigFilename () const { return mConfigFilename; } diff --git a/linphone-desktop/src/components/assistant/AssistantModel.hpp b/linphone-desktop/src/components/assistant/AssistantModel.hpp index 29f951a91..de70271ed 100644 --- a/linphone-desktop/src/components/assistant/AssistantModel.hpp +++ b/linphone-desktop/src/components/assistant/AssistantModel.hpp @@ -39,6 +39,7 @@ class AssistantModel : public QObject { Q_PROPERTY(QString phoneNumber READ getPhoneNumber WRITE setPhoneNumber NOTIFY phoneNumberChanged); Q_PROPERTY(QString username READ getUsername WRITE setUsername NOTIFY usernameChanged); Q_PROPERTY(QString displayName READ getDisplayName WRITE setDisplayName NOTIFY displayNameChanged); + Q_PROPERTY(QString activationCode READ getActivationCode WRITE setActivationCode NOTIFY activationCodeChanged); Q_PROPERTY(QString configFilename READ getConfigFilename WRITE setConfigFilename NOTIFY configFilenameChanged); public: @@ -57,6 +58,7 @@ signals: void phoneNumberChanged (const QString &phoneNumber, const QString &error); void usernameChanged (const QString &username, const QString &error); void displayNameChanged (const QString &displayName, const QString &error); + void activationCodeChanged (const QString &activationCode); void activateStatusChanged (const QString &error); void createStatusChanged (const QString &error); @@ -83,6 +85,9 @@ private: QString getDisplayName () const; void setDisplayName (const QString &displayName); + QString getActivationCode () const; + void setActivationCode (const QString &activationCode); + QString getConfigFilename () const; void setConfigFilename (const QString &configFilename); diff --git a/linphone-desktop/ui/views/App/Main/Assistant/ActivateLinphoneSipAccountWithPhoneNumber.qml b/linphone-desktop/ui/views/App/Main/Assistant/ActivateLinphoneSipAccountWithPhoneNumber.qml new file mode 100644 index 000000000..7dd189816 --- /dev/null +++ b/linphone-desktop/ui/views/App/Main/Assistant/ActivateLinphoneSipAccountWithPhoneNumber.qml @@ -0,0 +1,70 @@ +import QtQuick 2.7 + +import Common 1.0 +import Linphone 1.0 + +import App.Styles 1.0 + +// ============================================================================= + +AssistantAbstractView { + property var assistantModel + + backEnabled: false + + title: qsTr('activateLinphoneSipAccount') + + mainAction: requestBlock.execute + mainActionEnabled: activationCode.length === 4 && !requestBlock.loading + mainActionLabel: qsTr('confirmAction') + + Column { + anchors.centerIn: parent + spacing: ActivateLinphoneSipAccountWithPhoneNumberStyle.spacing + width: parent.width + + Text { + color: ActivateLinphoneSipAccountWithPhoneNumberStyle.activationSteps.color + font.pointSize: ActivateLinphoneSipAccountWithPhoneNumberStyle.activationSteps.fontSize + horizontalAlignment: Text.AlignHCenter + text: qsTr('activationSteps').replace('%1', assistantModel.phoneNumber) + width: parent.width + wrapMode: Text.WordWrap + } + + TextField { + id: activationCode + + anchors.horizontalCenter: parent.horizontalCenter + validator: IntValidator { + bottom: 0 + top: 9999 + } + + onTextChanged: assistantModel.activationCode = text + } + + RequestBlock { + id: requestBlock + + action: assistantModel.activate + width: parent.width + } + } + + // --------------------------------------------------------------------------- + // Assistant. + // --------------------------------------------------------------------------- + + Connections { + target: assistantModel + + onActivateStatusChanged: { + requestBlock.stop(error) + if (!error.length) { + window.unlockView() + window.setView('Home') + } + } + } +} diff --git a/linphone-desktop/ui/views/App/Styles/Main/Assistant/ActivateLinphoneSipAccountWithPhoneNumberStyle.qml b/linphone-desktop/ui/views/App/Styles/Main/Assistant/ActivateLinphoneSipAccountWithPhoneNumberStyle.qml new file mode 100644 index 000000000..3179749bd --- /dev/null +++ b/linphone-desktop/ui/views/App/Styles/Main/Assistant/ActivateLinphoneSipAccountWithPhoneNumberStyle.qml @@ -0,0 +1,15 @@ +pragma Singleton +import QtQuick 2.7 + +import Common 1.0 + +// ============================================================================= + +QtObject { + property int spacing: 20 + + property QtObject activationSteps: QtObject { + property color color: Colors.g + property int fontSize: 10 + } +} diff --git a/linphone-desktop/ui/views/App/Styles/qmldir b/linphone-desktop/ui/views/App/Styles/qmldir index d1eb4617b..7bd9c15f2 100644 --- a/linphone-desktop/ui/views/App/Styles/qmldir +++ b/linphone-desktop/ui/views/App/Styles/qmldir @@ -4,34 +4,35 @@ module App.Styles # Views styles ----------------------------------------------------------------- -singleton CallStyle 1.0 Calls/CallStyle.qml -singleton CallsWindowStyle 1.0 Calls/CallsWindowStyle.qml -singleton ConferenceStyle 1.0 Calls/ConferenceStyle.qml +singleton CallStyle 1.0 Calls/CallStyle.qml +singleton CallsWindowStyle 1.0 Calls/CallsWindowStyle.qml +singleton ConferenceStyle 1.0 Calls/ConferenceStyle.qml -singleton CallTransferStyle 1.0 Calls/Dialogs/CallTransferStyle.qml -singleton ConferenceManagerStyle 1.0 Calls/Dialogs/ConferenceManagerStyle.qml +singleton CallTransferStyle 1.0 Calls/Dialogs/CallTransferStyle.qml +singleton ConferenceManagerStyle 1.0 Calls/Dialogs/ConferenceManagerStyle.qml -singleton ActivateLinphoneSipAccountWithEmailStyle 1.0 Main/Assistant/ActivateLinphoneSipAccountWithEmailStyle.qml -singleton AssistantAbstractViewStyle 1.0 Main/Assistant/AssistantAbstractViewStyle.qml -singleton AssistantHomeStyle 1.0 Main/Assistant/AssistantHomeStyle.qml -singleton CreateLinphoneSipAccountStyle 1.0 Main/Assistant/CreateLinphoneSipAccountStyle.qml -singleton UseLinphoneSipAccountStyle 1.0 Main/Assistant/UseLinphoneSipAccountStyle.qml +singleton ActivateLinphoneSipAccountWithEmailStyle 1.0 Main/Assistant/ActivateLinphoneSipAccountWithEmailStyle.qml +singleton ActivateLinphoneSipAccountWithPhoneNumberStyle 1.0 Main/Assistant/ActivateLinphoneSipAccountWithPhoneNumberStyle.qml +singleton AssistantAbstractViewStyle 1.0 Main/Assistant/AssistantAbstractViewStyle.qml +singleton AssistantHomeStyle 1.0 Main/Assistant/AssistantHomeStyle.qml +singleton CreateLinphoneSipAccountStyle 1.0 Main/Assistant/CreateLinphoneSipAccountStyle.qml +singleton UseLinphoneSipAccountStyle 1.0 Main/Assistant/UseLinphoneSipAccountStyle.qml -singleton AssistantStyle 1.0 Main/AssistantStyle.qml -singleton ContactEditStyle 1.0 Main/ContactEditStyle.qml -singleton ContactsStyle 1.0 Main/ContactsStyle.qml -singleton ConversationStyle 1.0 Main/ConversationStyle.qml -singleton HomeStyle 1.0 Main/HomeStyle.qml -singleton InviteFriendsStyle 1.0 Main/InviteFriendsStyle.qml -singleton MainWindowStyle 1.0 Main/MainWindowStyle.qml +singleton AssistantStyle 1.0 Main/AssistantStyle.qml +singleton ContactEditStyle 1.0 Main/ContactEditStyle.qml +singleton ContactsStyle 1.0 Main/ContactsStyle.qml +singleton ConversationStyle 1.0 Main/ConversationStyle.qml +singleton HomeStyle 1.0 Main/HomeStyle.qml +singleton InviteFriendsStyle 1.0 Main/InviteFriendsStyle.qml +singleton MainWindowStyle 1.0 Main/MainWindowStyle.qml -singleton AboutStyle 1.0 Main/Dialogs/AboutStyle.qml -singleton AuthenticationRequestStyle 1.0 Main/Dialogs/AuthenticationRequestStyle.qml -singleton ManageAccountsStyle 1.0 Main/Dialogs/ManageAccountsStyle.qml +singleton AboutStyle 1.0 Main/Dialogs/AboutStyle.qml +singleton AuthenticationRequestStyle 1.0 Main/Dialogs/AuthenticationRequestStyle.qml +singleton ManageAccountsStyle 1.0 Main/Dialogs/ManageAccountsStyle.qml -singleton SettingsAudioStyle 1.0 Settings/SettingsAudioStyle.qml -singleton SettingsSipAccountsEditStyle 1.0 Settings/SettingsSipAccountsEditStyle.qml -singleton SettingsVideoPreviewStyle 1.0 Settings/SettingsVideoPreviewStyle.qml -singleton SettingsWindowStyle 1.0 Settings/SettingsWindowStyle.qml +singleton SettingsAudioStyle 1.0 Settings/SettingsAudioStyle.qml +singleton SettingsSipAccountsEditStyle 1.0 Settings/SettingsSipAccountsEditStyle.qml +singleton SettingsVideoPreviewStyle 1.0 Settings/SettingsVideoPreviewStyle.qml +singleton SettingsWindowStyle 1.0 Settings/SettingsWindowStyle.qml -singleton SplashScreenStyle 1.0 SplashScreen/SplashScreenStyle.qml +singleton SplashScreenStyle 1.0 SplashScreen/SplashScreenStyle.qml