From 9deca05ed17c8f4282723ff65b922080a9947e65 Mon Sep 17 00:00:00 2001 From: Erwan Croze Date: Mon, 10 Oct 2016 17:22:45 +0200 Subject: [PATCH] Some fix for Assistant --- ...stant_account_creation_code_activation.xml | 1 + res/values/strings.xml | 4 +-- .../linphone/assistant/AssistantActivity.java | 36 +++++++++---------- .../assistant/CreateAccountFragment.java | 6 ++-- .../assistant/LinphoneLoginFragment.java | 15 ++++++-- 5 files changed, 37 insertions(+), 25 deletions(-) diff --git a/res/layout/assistant_account_creation_code_activation.xml b/res/layout/assistant_account_creation_code_activation.xml index 8d70717f1..d9b84b292 100644 --- a/res/layout/assistant_account_creation_code_activation.xml +++ b/res/layout/assistant_account_creation_code_activation.xml @@ -22,6 +22,7 @@ android:text="@string/assistant_create_account_part_2" style="@style/font11" android:paddingTop="10dp" + android:gravity="center_horizontal" android:layout_width="wrap_content" android:layout_height="wrap_content"/> diff --git a/res/values/strings.xml b/res/values/strings.xml index d21724911..30beb834e 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -117,7 +117,7 @@ What will my phone number be used for? \nThanks to your phone number, your friends will find you more easily.\n\n You will see in your address book who is using Linphone and your friends will know that they can rach you on Linphone as well.\n \nYour friends will find you more easily if you link your account to your phone number\n\nYou will see in your address book who is using Linphone and your friends will know that they can reach you on Linphone as well.\n - You can only use your phone number with one linphone account.\n\nIf you had already linked your number to an other account but you prefer to use this one simply link it now and your number will automatically be moved to this account. + You can only use your phone number with one Linphone account.\n\nIf you had already linked your number to an other account but you prefer to use this one, simply link it now and your number will automatically be moved to this account. Invalid email @@ -337,7 +337,7 @@ Send in-band DTMFs(RFC2833) Send out-band DTMFs(SIP INFO) Voice mail URI - + Chat Sharing server diff --git a/src/org/linphone/assistant/AssistantActivity.java b/src/org/linphone/assistant/AssistantActivity.java index a88456779..0f4e291e5 100644 --- a/src/org/linphone/assistant/AssistantActivity.java +++ b/src/org/linphone/assistant/AssistantActivity.java @@ -99,7 +99,7 @@ private static AssistantActivity instance; public String phone_number; public String email; public String activation_code; - + protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -136,7 +136,7 @@ private static AssistantActivity instance; accountCreator.setListener(this); countryListAdapter = new CountryListAdapter(R.raw.countries, getApplicationContext()); - + mListener = new LinphoneCoreListenerBase() { @Override public void registrationState(LinphoneCore lc, LinphoneProxyConfig cfg, RegistrationState state, String smessage) { @@ -178,7 +178,7 @@ private static AssistantActivity instance; lc.addListener(mListener); } } - + @Override protected void onPause() { LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull(); @@ -188,14 +188,14 @@ private static AssistantActivity instance; super.onPause(); } - + @Override protected void onSaveInstanceState(Bundle outState) { outState.putSerializable("CurrentFragment", currentFragment); outState.putBoolean("echoCanceller", echoCancellerAlreadyDone); super.onSaveInstanceState(outState); } - + public static AssistantActivity instance() { return instance; } @@ -210,7 +210,7 @@ private static AssistantActivity instance; cancel = (ImageView) findViewById(R.id.assistant_cancel); cancel.setOnClickListener(this); } - + private void changeFragment(Fragment newFragment) { hideKeyboard(); FragmentTransaction transaction = getFragmentManager().beginTransaction(); @@ -221,7 +221,7 @@ private static AssistantActivity instance; @Override public void onClick(View v) { int id = v.getId(); - + if (id == R.id.assistant_cancel) { hideKeyboard(); LinphonePreferences.instance().firstLaunchSuccessful(); @@ -310,7 +310,7 @@ private static AssistantActivity instance; private void launchEchoCancellerCalibration(boolean sendEcCalibrationResult) { int recordAudio = getPackageManager().checkPermission(Manifest.permission.RECORD_AUDIO, getPackageName()); Log.i("[Permission] Record audio permission is " + (recordAudio == PackageManager.PERMISSION_GRANTED ? "granted" : "denied")); - + if (recordAudio == PackageManager.PERMISSION_GRANTED) { EchoCancellerCalibrationFragment fragment = new EchoCancellerCalibrationFragment(); fragment.enableEcCalibrationResultSending(sendEcCalibrationResult); @@ -378,7 +378,7 @@ private static AssistantActivity instance; currentFragment = AssistantFragmentsEnum.LOGIN; back.setVisibility(View.VISIBLE); } - + public void displayLoginLinphone() { fragment = new LinphoneLoginFragment(); changeFragment(fragment); @@ -466,7 +466,7 @@ private static AssistantActivity instance; if(prefix != null){ builder.setPrefix(prefix); } - + if (isMainAccountLinphoneDotOrg) { if (getResources().getBoolean(R.bool.disable_all_security_features_for_markets)) { builder.setProxy(domain) @@ -487,7 +487,7 @@ private static AssistantActivity instance; .setNoDefault(false); mPrefs.enabledFriendlistSubscription(getResources().getBoolean(R.bool.use_friendlist_subscription)); - + mPrefs.setStunServer(getString(R.string.default_stun)); mPrefs.setIceEnabled(true); @@ -506,7 +506,7 @@ private static AssistantActivity instance; builder.setTransport(transport); } } - + if (getResources().getBoolean(R.bool.enable_push_id)) { String regId = mPrefs.getPushNotificationRegistrationID(); String appId = getString(R.string.push_sender_id); @@ -541,7 +541,7 @@ private static AssistantActivity instance; public void displayRemoteProvisioningInProgressDialog() { remoteProvisioningInProgress = true; - + progress = ProgressDialog.show(this, null, null); Drawable d = new ColorDrawable(ContextCompat.getColor(this, R.color.colorE)); d.setAlpha(200); @@ -559,7 +559,7 @@ private static AssistantActivity instance; extras.putString("Password", password); fragment.setArguments(extras); changeFragment(fragment); - + currentFragment = AssistantFragmentsEnum.CREATE_ACCOUNT_ACTIVATION; back.setVisibility(View.INVISIBLE); } @@ -579,7 +579,7 @@ private static AssistantActivity instance; currentFragment = AssistantFragmentsEnum.CREATE_ACCOUNT_CODE_ACTIVATION; back.setVisibility(View.INVISIBLE); } - + public void isAccountVerified(String username) { Toast.makeText(this, getString(R.string.assistant_account_validated), Toast.LENGTH_LONG).show(); launchEchoCancellerCalibration(true); @@ -611,7 +611,7 @@ private static AssistantActivity instance; }); return builder.show(); } - + public void success() { boolean needsEchoCalibration = LinphoneManager.getLc().needsEchoCalibration(); if (needsEchoCalibration && mPrefs.isFirstLaunch()) { @@ -620,7 +620,7 @@ private static AssistantActivity instance; launchDownloadCodec(); } } - + private void goToLinphoneActivity() { mPrefs.firstLaunchSuccessful(); startActivity(new Intent().setClass(this, LinphoneActivity.class).putExtra("isNewProxyConfig", true)); @@ -738,7 +738,7 @@ private static AssistantActivity instance; public Country getCountryFromCountryCode(String countryCode) { countryCode = (countryCode.startsWith("+")) ? countryCode : "+" + countryCode; for (Country c : allCountries) { - if (c.dial_code.compareTo("+"+countryCode) == 0) + if (c.dial_code.compareTo(countryCode) == 0) return c; } return null; diff --git a/src/org/linphone/assistant/CreateAccountFragment.java b/src/org/linphone/assistant/CreateAccountFragment.java index 09db57b33..45a63c57e 100644 --- a/src/org/linphone/assistant/CreateAccountFragment.java +++ b/src/org/linphone/assistant/CreateAccountFragment.java @@ -62,7 +62,7 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On private EditText phoneNumberEdit, usernameEdit, passwordEdit, passwordConfirmEdit, emailEdit, dialCode; private TextView phoneNumberError, usernameError, passwordError, passwordConfirmError, emailError, assisstantTitle, sipUri, skip; private ImageView phoneNumberInfo; - + private boolean phoneNumberOk = false; private boolean usernameOk = false; private boolean passwordOk = false; @@ -413,7 +413,9 @@ public class CreateAccountFragment extends Fragment implements CompoundButton.On AssistantActivity.Country c = AssistantActivity.instance().getCountryListAdapter().getCountryFromCountryCode(dialCode.getText().toString()); if (c != null) { AssistantActivity.instance().country = c; - LinphoneUtils.setCountry(AssistantActivity.instance().country, dialCode, selectCountry, countryCode); + selectCountry.setText(c.name); + } else { + selectCountry.setText(R.string.select_your_country); } } } diff --git a/src/org/linphone/assistant/LinphoneLoginFragment.java b/src/org/linphone/assistant/LinphoneLoginFragment.java index 80a1a62e2..796904cdd 100644 --- a/src/org/linphone/assistant/LinphoneLoginFragment.java +++ b/src/org/linphone/assistant/LinphoneLoginFragment.java @@ -68,7 +68,7 @@ public class LinphoneLoginFragment extends Fragment implements CompoundButton.On accountCreator.setListener(this); String url = "http://linphone.org/free-sip-service.html&action=recover"; - + login = (EditText) view.findViewById(R.id.assistant_username); login.addTextChangedListener(this); @@ -171,6 +171,15 @@ public class LinphoneLoginFragment extends Fragment implements CompoundButton.On private void addPhoneNumberHandler(final EditText field, final ImageView icon) { field.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) { + if (field.equals(dialCode)) { + AssistantActivity.Country c = AssistantActivity.instance().getCountryListAdapter().getCountryFromCountryCode(dialCode.getText().toString()); + if (c != null) { + AssistantActivity.instance().country = c; + selectCountry.setText(c.name); + } else { + selectCountry.setText(R.string.select_your_country); + } + } } public void beforeTextChanged(CharSequence s, int start, int count, int after) { @@ -194,7 +203,7 @@ public class LinphoneLoginFragment extends Fragment implements CompoundButton.On @Override public void onClick(View v) { int id = v.getId(); - + switch(id) { case R.id.assistant_apply: { if (recoverAccount) { @@ -207,7 +216,7 @@ public class LinphoneLoginFragment extends Fragment implements CompoundButton.On case R.id.info_phone_number: { new AlertDialog.Builder(getActivity()) .setTitle(getString(R.string.phone_number_info_title)) - .setMessage(getString(R.string.phone_number_link_info_content) + "\n" + getString(R.string.phone_number_link_info_content_already_account)) + .setMessage(getString(R.string.phone_number_link_info_content)) .show(); break; }