Added remote provisioning menu to wizard + fix db crash when restart app after fresh install

This commit is contained in:
Sylvain Berfini 2013-10-18 09:36:53 +02:00
parent 35ba0ec662
commit 3801f2c795
13 changed files with 212 additions and 7 deletions

View file

@ -5,7 +5,7 @@
android:orientation="vertical">
<ImageView
android:paddingTop="40dp"
android:paddingTop="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/setup_title_assistant"/>
@ -13,7 +13,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="40dp"
android:paddingTop="10dp"
android:gravity="center"
android:orientation="vertical">
@ -97,6 +97,33 @@
</RelativeLayout>
<RelativeLayout
android:id="@+id/setup_remote_provisioning_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.7"
android:layout_marginBottom="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp">
<ImageView
android:id="@+id/setup_remote_provisioning"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:src="@drawable/button"
android:layout_centerInParent="true" />
<TextView
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/setup_remote_provisioning"
android:textColor="@android:color/black"/>
</RelativeLayout>
</LinearLayout>
</LinearLayout>

View file

@ -88,6 +88,30 @@
</RelativeLayout>
<RelativeLayout
android:id="@+id/setup_remote_provisioning_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.7"
android:paddingLeft="10dp"
android:paddingRight="10dp">
<ImageView
android:id="@+id/setup_remote_provisioning"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/button"
android:layout_centerInParent="true" />
<TextView
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/setup_remote_provisioning"
android:textColor="@android:color/black"/>
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="match_parent"

View file

@ -0,0 +1,75 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:contentDescription="@string/content_description_welcome"
android:paddingTop="40dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/setup_title_assistant"/>
<TextView
android:paddingTop="10dp"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/setup_remote_provisioning_hint"
android:textColor="@android:color/black"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="40dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:gravity="center"
android:orientation="vertical">
<EditText
android:textCursorDrawable="@null"
android:id="@+id/setup_remote_provisioning_url"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/setup_remote_provisioning_url_hint"
android:inputType="textUri"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:singleLine="true"
android:textColor="@android:color/black"
android:background="@drawable/setup_field_background" />
<RelativeLayout
android:id="@+id/setup_apply_button"
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:contentDescription="@string/content_description_validate"
android:id="@+id/setup_apply"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/button"
android:layout_centerInParent="true" />
<TextView
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/setup_apply"
android:textColor="@android:color/black"/>
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="10dp"
android:paddingRight="10dp" />
</LinearLayout>
</LinearLayout>

View file

@ -381,6 +381,10 @@
<string name="importing_messages">Mise à jour de la base des messages</string>
<string name="default_account_flag">Compte par défaut</string>
<string name="setup_remote_provisioning">Télécharger ma configuration</string>
<string name="setup_remote_provisioning_hint">Cet assistant va télécharger une configuration existante.</string>
<string name="setup_remote_provisioning_url_hint">addresse où télécharger la configuration</string>
<string name="zrtp_accept">Accepter</string>
<string name="zrtp_deny">Refuser</string>
<string name="zrtp_help">Vous ne devriez accepter que si vous avez le même code (ci-dessus) que votre contact</string>

View file

@ -436,6 +436,10 @@
<string name="importing_messages">Updating messages database</string>
<string name="default_account_flag">Default account</string>
<string name="setup_remote_provisioning">Download provisioning</string>
<string name="setup_remote_provisioning_hint">This assistant will download an existing configuration.</string>
<string name="setup_remote_provisioning_url_hint">provisioning url</string>
<string name="zrtp_accept">Accept</string>
<string name="zrtp_deny">Deny</string>
<string name="zrtp_help">You should only accept if you have the same code (see above) as your correspondent</string>

View file

@ -28,6 +28,7 @@
<bool name="setup_account_validation_mandatory">false</bool>
<bool name="hide_linphone_accounts_wizard">false</bool>
<bool name="hide_generic_accounts_wizard">false</bool>
<bool name="hide_remote_provisioning_in_wizard">false</bool>
<bool name="hide_accounts">false</bool>
<bool name="display_account_wizard_at_first_start">true</bool>
<bool name="use_linphone_server_ports">true</bool>

View file

@ -436,6 +436,10 @@
<string name="importing_messages">Updating messages database</string>
<string name="default_account_flag">Default account</string>
<string name="setup_remote_provisioning">Download provisioning</string>
<string name="setup_remote_provisioning_hint">This assistant will download an existing configuration.</string>
<string name="setup_remote_provisioning_url_hint">provisioning url</string>
<string name="zrtp_accept">Accept</string>
<string name="zrtp_deny">Deny</string>
<string name="zrtp_help">You should only accept if you have the same code (see above) as your correspondent</string>

View file

@ -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);

View file

@ -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;

View file

@ -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();
}
}
}

View file

@ -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);
}
}
}

View file

@ -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)

View file

@ -27,5 +27,6 @@ public enum SetupFragmentsEnum {
WIZARD_CONFIRM,
LINPHONE_LOGIN,
GENERIC_LOGIN,
REMOTE_PROVISIONING,
ECHO_CANCELLER_CALIBRATION;
}