From 3801f2c7958eab4d0df3f2487b59adabc463c6cc Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Fri, 18 Oct 2013 09:36:53 +0200 Subject: [PATCH] Added remote provisioning menu to wizard + fix db crash when restart app after fresh install --- res/layout-small/setup_menu.xml | 31 +++++++- res/layout/setup_menu.xml | 24 ++++++ res/layout/setup_remote_provisioning.xml | 75 +++++++++++++++++++ res/values-FR/strings.xml | 4 + res/values-RU/strings.xml | 4 + res/values/non_localizable_custom.xml | 1 + res/values/strings.xml | 4 + src/org/linphone/ChatStorage.java | 2 +- src/org/linphone/LinphoneManager.java | 2 - src/org/linphone/setup/MenuFragment.java | 11 ++- .../setup/RemoteProvisioningFragment.java | 49 ++++++++++++ src/org/linphone/setup/SetupActivity.java | 11 ++- .../linphone/setup/SetupFragmentsEnum.java | 1 + 13 files changed, 212 insertions(+), 7 deletions(-) create mode 100644 res/layout/setup_remote_provisioning.xml create mode 100644 src/org/linphone/setup/RemoteProvisioningFragment.java diff --git a/res/layout-small/setup_menu.xml b/res/layout-small/setup_menu.xml index d7b0bcd53..e7b0517f6 100644 --- a/res/layout-small/setup_menu.xml +++ b/res/layout-small/setup_menu.xml @@ -5,7 +5,7 @@ android:orientation="vertical"> @@ -13,7 +13,7 @@ @@ -97,6 +97,33 @@ + + + + + + + + \ No newline at end of file diff --git a/res/layout/setup_menu.xml b/res/layout/setup_menu.xml index e778a62f0..54b608de0 100644 --- a/res/layout/setup_menu.xml +++ b/res/layout/setup_menu.xml @@ -88,6 +88,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/res/values-FR/strings.xml b/res/values-FR/strings.xml index 7c435881e..782a275b1 100644 --- a/res/values-FR/strings.xml +++ b/res/values-FR/strings.xml @@ -381,6 +381,10 @@ Mise à jour de la base des messages Compte par défaut + Télécharger ma configuration + Cet assistant va télécharger une configuration existante. + addresse où télécharger la configuration + Accepter Refuser Vous ne devriez accepter que si vous avez le même code (ci-dessus) que votre contact diff --git a/res/values-RU/strings.xml b/res/values-RU/strings.xml index 0528f0415..23f635e57 100755 --- a/res/values-RU/strings.xml +++ b/res/values-RU/strings.xml @@ -436,6 +436,10 @@ Updating messages database Default account + Download provisioning + This assistant will download an existing configuration. + provisioning url + Accept Deny You should only accept if you have the same code (see above) as your correspondent diff --git a/res/values/non_localizable_custom.xml b/res/values/non_localizable_custom.xml index 3ad73fff7..71aebf4c6 100644 --- a/res/values/non_localizable_custom.xml +++ b/res/values/non_localizable_custom.xml @@ -28,6 +28,7 @@ false false false + false false true true diff --git a/res/values/strings.xml b/res/values/strings.xml index dd48a5876..138b4ad83 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -436,6 +436,10 @@ Updating messages database Default account + Download provisioning + This assistant will download an existing configuration. + provisioning url + Accept Deny You should only accept if you have the same code (see above) as your correspondent diff --git a/src/org/linphone/ChatStorage.java b/src/org/linphone/ChatStorage.java index 3da666517..7cab57e53 100644 --- a/src/org/linphone/ChatStorage.java +++ b/src/org/linphone/ChatStorage.java @@ -68,7 +68,7 @@ public class ChatStorage { context = c; boolean useLinphoneStorage = c.getResources().getBoolean(R.bool.use_linphone_chat_storage); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(LinphoneService.instance()); - boolean updateNeeded = prefs.getBoolean(c.getString(R.string.pref_first_time_linphone_chat_storage), true); + boolean updateNeeded = prefs.getBoolean(c.getString(R.string.pref_first_time_linphone_chat_storage), !LinphonePreferences.instance().isFirstLaunch()); useNativeAPI = useLinphoneStorage && !updateNeeded; Log.d("Using native API: " + useNativeAPI); diff --git a/src/org/linphone/LinphoneManager.java b/src/org/linphone/LinphoneManager.java index d381ed732..c1e9363c3 100644 --- a/src/org/linphone/LinphoneManager.java +++ b/src/org/linphone/LinphoneManager.java @@ -85,7 +85,6 @@ import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; -import android.content.SharedPreferences; import android.content.pm.PackageManager.NameNotFoundException; import android.content.res.Resources; import android.hardware.Sensor; @@ -100,7 +99,6 @@ import android.os.Build; import android.os.PowerManager; import android.os.PowerManager.WakeLock; import android.os.Vibrator; -import android.preference.PreferenceManager; import android.provider.Settings; import android.provider.Settings.SettingNotFoundException; import android.telephony.TelephonyManager; diff --git a/src/org/linphone/setup/MenuFragment.java b/src/org/linphone/setup/MenuFragment.java index c5242ee3b..5eebba12c 100644 --- a/src/org/linphone/setup/MenuFragment.java +++ b/src/org/linphone/setup/MenuFragment.java @@ -30,7 +30,7 @@ import android.widget.ImageView; * @author Sylvain Berfini */ public class MenuFragment extends Fragment implements OnClickListener { - private ImageView createAccount, logLinphoneAccount, logGenericAccount; + private ImageView createAccount, logLinphoneAccount, logGenericAccount, remoteProvisioning; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, @@ -54,6 +54,13 @@ public class MenuFragment extends Fragment implements OnClickListener { logGenericAccount.setOnClickListener(this); } + remoteProvisioning = (ImageView) view.findViewById(R.id.setup_remote_provisioning); + if (getResources().getBoolean(R.bool.hide_remote_provisioning_in_wizard)) { + view.findViewById(R.id.setup_remote_provisioning_layout).setVisibility(View.GONE); + } else { + remoteProvisioning.setOnClickListener(this); + } + return view; } @@ -67,6 +74,8 @@ public class MenuFragment extends Fragment implements OnClickListener { SetupActivity.instance().displayLoginLinphone(); } else if (id == R.id.setup_create_account) { SetupActivity.instance().displayWizard(); + } else if (id == R.id.setup_remote_provisioning) { + SetupActivity.instance().displayRemoteProvisioning(); } } } diff --git a/src/org/linphone/setup/RemoteProvisioningFragment.java b/src/org/linphone/setup/RemoteProvisioningFragment.java new file mode 100644 index 000000000..b70e08850 --- /dev/null +++ b/src/org/linphone/setup/RemoteProvisioningFragment.java @@ -0,0 +1,49 @@ +package org.linphone.setup; + +import org.linphone.LinphoneActivity; +import org.linphone.LinphoneLauncherActivity; +import org.linphone.LinphonePreferences; +import org.linphone.R; + +import android.content.Intent; +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.view.LayoutInflater; +import android.view.View; +import android.view.View.OnClickListener; +import android.view.ViewGroup; +import android.widget.EditText; +import android.widget.ImageView; + +public class RemoteProvisioningFragment extends Fragment implements OnClickListener { + private EditText remoteProvisioningUrl; + private ImageView apply; + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.setup_remote_provisioning, container, false); + + remoteProvisioningUrl = (EditText) view.findViewById(R.id.setup_remote_provisioning_url); + apply = (ImageView) view.findViewById(R.id.setup_apply); + apply.setOnClickListener(this); + + return view; + } + + @Override + public void onClick(View v) { + int id = v.getId(); + + if (id == R.id.setup_apply) { + String url = remoteProvisioningUrl.getText().toString(); + LinphonePreferences.instance().setRemoteProvisioningUrl(url); + + // Restart Linphone + Intent intent = new Intent(); + intent.setClass(getActivity(), LinphoneLauncherActivity.class); + LinphoneActivity.instance().exit(); + startActivity(intent); + } + } +} diff --git a/src/org/linphone/setup/SetupActivity.java b/src/org/linphone/setup/SetupActivity.java index 0da73db4a..92649780a 100644 --- a/src/org/linphone/setup/SetupActivity.java +++ b/src/org/linphone/setup/SetupActivity.java @@ -153,7 +153,10 @@ public class SetupActivity extends FragmentActivity implements OnClickListener { next.setVisibility(View.VISIBLE); back.setVisibility(View.GONE); - } else if (currentFragment == SetupFragmentsEnum.GENERIC_LOGIN || currentFragment == SetupFragmentsEnum.LINPHONE_LOGIN || currentFragment == SetupFragmentsEnum.WIZARD) { + } else if (currentFragment == SetupFragmentsEnum.GENERIC_LOGIN + || currentFragment == SetupFragmentsEnum.LINPHONE_LOGIN + || currentFragment == SetupFragmentsEnum.WIZARD + || currentFragment == SetupFragmentsEnum.REMOTE_PROVISIONING) { MenuFragment fragment = new MenuFragment(); changeFragment(fragment); currentFragment = SetupFragmentsEnum.MENU; @@ -268,6 +271,12 @@ public class SetupActivity extends FragmentActivity implements OnClickListener { changeFragment(fragment); currentFragment = SetupFragmentsEnum.WIZARD; } + + public void displayRemoteProvisioning() { + fragment = new RemoteProvisioningFragment(); + changeFragment(fragment); + currentFragment = SetupFragmentsEnum.REMOTE_PROVISIONING; + } public void saveCreatedAccount(String username, String password, String domain) { if (accountCreated) diff --git a/src/org/linphone/setup/SetupFragmentsEnum.java b/src/org/linphone/setup/SetupFragmentsEnum.java index 91b8c2feb..9ef733bac 100644 --- a/src/org/linphone/setup/SetupFragmentsEnum.java +++ b/src/org/linphone/setup/SetupFragmentsEnum.java @@ -27,5 +27,6 @@ public enum SetupFragmentsEnum { WIZARD_CONFIRM, LINPHONE_LOGIN, GENERIC_LOGIN, + REMOTE_PROVISIONING, ECHO_CANCELLER_CALIBRATION; }