Started remote provisioning view home view used with linphone-config links
This commit is contained in:
parent
8b465caeb8
commit
1e3ecb97c7
11 changed files with 236 additions and 0 deletions
|
@ -110,6 +110,21 @@
|
|||
<action android:name="android.intent.action.MAIN" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity android:name="org.linphone.setup.RemoteProvisioningActivity"
|
||||
android:theme="@style/NoTitle"
|
||||
android:screenOrientation="nosensor">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
</intent-filter>
|
||||
|
||||
<intent-filter>
|
||||
<data android:scheme="linphone-config" /> <!-- Change if needed -->
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<service android:name="org.linphone.LinphoneService"
|
||||
android:label="@string/service_name"
|
||||
|
|
25
res/layout/remote_provisioning.xml
Normal file
25
res/layout/remote_provisioning.xml
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/background"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<ImageView
|
||||
android:contentDescription="@string/content_description_welcome"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="centerCrop"
|
||||
android:layout_centerInParent="true"
|
||||
android:src="@drawable/logo"/>
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/spinner"
|
||||
android:visibility="gone"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerHorizontal="true" />
|
||||
|
||||
</RelativeLayout>
|
|
@ -400,4 +400,6 @@
|
|||
<string name="unread_messages">%i messages non lus</string>
|
||||
|
||||
<string name="retry">Renvoyer</string>
|
||||
|
||||
<string name="remote_provisioning_failure">Erreur durant le téléchargement ou l\'application de la configuration distante...</string>
|
||||
</resources>
|
||||
|
|
|
@ -451,4 +451,6 @@
|
|||
<string name="unread_messages">%i unread messages</string>
|
||||
|
||||
<string name="retry">Retry</string>
|
||||
|
||||
<string name="remote_provisioning_failure">Failed to download or apply remote provisioning profile...</string>
|
||||
</resources>
|
||||
|
|
|
@ -71,6 +71,11 @@
|
|||
<bool name="intercept_outgoing_gsm_calls">false</bool>
|
||||
<bool name="automatically_start_intercepted_outgoing_gsm_call">true</bool>
|
||||
|
||||
<!-- This settings handle the behavior of the view waiting for the remote provisioning configuration to be done -->
|
||||
<bool name="display_sms_remote_provisioning_activity">false</bool>
|
||||
<bool name="forbid_app_usage_until_remote_provisioning_completed">false</bool>
|
||||
<bool name="display_confirmation_popup_after_first_configuration">false</bool>
|
||||
|
||||
<bool name="hash_images_as_name_before_upload">true</bool>
|
||||
|
||||
<bool name="enable_log_collect">false</bool>
|
||||
|
|
|
@ -451,4 +451,6 @@
|
|||
<string name="unread_messages">%i unread messages</string>
|
||||
|
||||
<string name="retry">Retry</string>
|
||||
|
||||
<string name="remote_provisioning_failure">Failed to download or apply remote provisioning profile...</string>
|
||||
</resources>
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.linphone;
|
|||
import static android.content.Intent.ACTION_MAIN;
|
||||
|
||||
import org.linphone.mediastream.Log;
|
||||
import org.linphone.setup.RemoteProvisioningActivity;
|
||||
import org.linphone.tutorials.TutorialLauncherActivity;
|
||||
|
||||
import android.app.Activity;
|
||||
|
@ -72,6 +73,8 @@ public class LinphoneLauncherActivity extends Activity {
|
|||
final Class<? extends Activity> classToStart;
|
||||
if (getResources().getBoolean(R.bool.show_tutorials_instead_of_app)) {
|
||||
classToStart = TutorialLauncherActivity.class;
|
||||
} else if (getResources().getBoolean(R.bool.display_sms_remote_provisioning_activity) && LinphonePreferences.instance().isFirstRemoteProvisioning()) {
|
||||
classToStart = RemoteProvisioningActivity.class;
|
||||
} else {
|
||||
classToStart = LinphoneActivity.class;
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ import org.linphone.LinphoneSimpleListener.LinphoneOnAudioChangedListener.AudioS
|
|||
import org.linphone.LinphoneSimpleListener.LinphoneOnComposingReceivedListener;
|
||||
import org.linphone.LinphoneSimpleListener.LinphoneOnDTMFReceivedListener;
|
||||
import org.linphone.LinphoneSimpleListener.LinphoneOnMessageReceivedListener;
|
||||
import org.linphone.LinphoneSimpleListener.LinphoneOnRemoteProvisioningListener;
|
||||
import org.linphone.LinphoneSimpleListener.LinphoneServiceListener;
|
||||
import org.linphone.compatibility.Compatibility;
|
||||
import org.linphone.core.CallDirection;
|
||||
|
@ -74,6 +75,7 @@ import org.linphone.mediastream.Version;
|
|||
import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration;
|
||||
import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration.AndroidCamera;
|
||||
import org.linphone.mediastream.video.capture.hwconf.Hacks;
|
||||
import org.linphone.setup.RemoteProvisioningActivity;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
|
@ -1369,10 +1371,22 @@ public class LinphoneManager implements LinphoneCoreListener {
|
|||
if (composingReceivedListener != null)
|
||||
composingReceivedListener.onComposingReceived(cr);
|
||||
}
|
||||
|
||||
private LinphoneOnRemoteProvisioningListener remoteProvisioningListener;
|
||||
public void setOnRemoteProvisioningListener(LinphoneOnRemoteProvisioningListener listener) {
|
||||
remoteProvisioningListener = listener;
|
||||
}
|
||||
@Override
|
||||
public void configuringStatus(LinphoneCore lc,
|
||||
RemoteProvisioningState state, String message) {
|
||||
Log.d("Remote provisioning status = " + state.toString() + " (" + message + ")");
|
||||
if (RemoteProvisioningActivity.getInstance() != null) {
|
||||
RemoteProvisioningActivity.getInstance().onConfiguringStatus(state);
|
||||
}
|
||||
|
||||
if (remoteProvisioningListener != null) {
|
||||
remoteProvisioningListener.onConfiguringStatus(state);
|
||||
}
|
||||
|
||||
if (state == RemoteProvisioningState.ConfiguringSuccessful) {
|
||||
if (LinphonePreferences.instance().isProvisioningLoginViewEnabled()) {
|
||||
|
|
|
@ -988,4 +988,12 @@ public class LinphonePreferences {
|
|||
Log.w("Remote provisioning login view wasn't enabled, ignoring");
|
||||
}
|
||||
}
|
||||
|
||||
public void firstRemoteProvisioningSuccessful() {
|
||||
getConfig().setBool("app", "first_remote_provisioning", false);
|
||||
}
|
||||
|
||||
public boolean isFirstRemoteProvisioning() {
|
||||
return getConfig().getBool("app", "first_remote_provisioning", true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.linphone.core.LinphoneChatMessage;
|
|||
import org.linphone.core.LinphoneChatRoom;
|
||||
import org.linphone.core.LinphoneCore.GlobalState;
|
||||
import org.linphone.core.LinphoneCore.RegistrationState;
|
||||
import org.linphone.core.LinphoneCore.RemoteProvisioningState;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
|
@ -80,4 +81,7 @@ public interface LinphoneSimpleListener {
|
|||
public static interface LinphoneOnComposingReceivedListener extends LinphoneSimpleListener {
|
||||
void onComposingReceived(LinphoneChatRoom room);
|
||||
}
|
||||
public static interface LinphoneOnRemoteProvisioningListener extends LinphoneSimpleListener {
|
||||
void onConfiguringStatus(RemoteProvisioningState state);
|
||||
}
|
||||
}
|
||||
|
|
156
src/org/linphone/setup/RemoteProvisioningActivity.java
Normal file
156
src/org/linphone/setup/RemoteProvisioningActivity.java
Normal file
|
@ -0,0 +1,156 @@
|
|||
package org.linphone.setup;
|
||||
/*
|
||||
RemoteProvisioningActivity.java
|
||||
Copyright (C) 2014 Belledonne Communications, Grenoble, France
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
import static android.content.Intent.ACTION_MAIN;
|
||||
|
||||
import org.linphone.LinphoneActivity;
|
||||
import org.linphone.LinphoneLauncherActivity;
|
||||
import org.linphone.LinphonePreferences;
|
||||
import org.linphone.LinphoneService;
|
||||
import org.linphone.LinphoneSimpleListener.LinphoneOnRemoteProvisioningListener;
|
||||
import org.linphone.R;
|
||||
import org.linphone.core.LinphoneCore.RemoteProvisioningState;
|
||||
import org.linphone.mediastream.Log;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.View;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.Toast;
|
||||
|
||||
/**
|
||||
* @author Sylvain Berfini
|
||||
*/
|
||||
public class RemoteProvisioningActivity extends Activity implements LinphoneOnRemoteProvisioningListener {
|
||||
private static RemoteProvisioningActivity instance = null;
|
||||
|
||||
private Handler mHandler = new Handler();
|
||||
private String configUriParam = null;
|
||||
private ProgressBar spinner;
|
||||
|
||||
public static RemoteProvisioningActivity getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.remote_provisioning);
|
||||
spinner = (ProgressBar) findViewById(R.id.spinner);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
instance = this;
|
||||
|
||||
checkIntentForConfigUri(getIntent());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
instance = null;
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfiguringStatus(RemoteProvisioningState state) {
|
||||
if (spinner != null) spinner.setVisibility(View.GONE);
|
||||
if (state == RemoteProvisioningState.ConfiguringSuccessful) {
|
||||
goToLinphoneActivity();
|
||||
} else if (state == RemoteProvisioningState.ConfiguringFailed) {
|
||||
Toast.makeText(this, R.string.remote_provisioning_failure, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNewIntent(Intent intent) {
|
||||
super.onNewIntent(intent);
|
||||
checkIntentForConfigUri(intent);
|
||||
}
|
||||
|
||||
private void checkIntentForConfigUri(final Intent intent) {
|
||||
new Thread(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Uri openUri = intent.getData();
|
||||
if (openUri != null) {
|
||||
// We expect something like linphone-config://http://linphone.org/config.xml
|
||||
configUriParam = openUri.getEncodedSchemeSpecificPart().substring(2); // Removes the linphone-config://
|
||||
Log.d("Using config uri: " + configUriParam);
|
||||
}
|
||||
|
||||
if (configUriParam == null) {
|
||||
if (!LinphonePreferences.instance().isFirstRemoteProvisioning()) {
|
||||
mHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
goToLinphoneActivity();
|
||||
}
|
||||
});
|
||||
} else if (!getResources().getBoolean(R.bool.forbid_app_usage_until_remote_provisioning_completed)) {
|
||||
// Show this view for a few seconds then go to the dialer
|
||||
mHandler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
goToLinphoneActivity();
|
||||
}
|
||||
}, 1500);
|
||||
} // else we do nothing if there is no config uri parameter and if user not allowed to leave this screen
|
||||
} else {
|
||||
if (getResources().getBoolean(R.bool.display_confirmation_popup_after_first_configuration)
|
||||
&& !LinphonePreferences.instance().isFirstRemoteProvisioning()) {
|
||||
// TODO: show confirmation popup
|
||||
} else {
|
||||
setRemoteProvisioningAddressAndRestart(configUriParam);
|
||||
}
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
private void setRemoteProvisioningAddressAndRestart(String configUri) {
|
||||
if (spinner != null) spinner.setVisibility(View.VISIBLE);
|
||||
|
||||
LinphonePreferences.instance().setRemoteProvisioningUrl(configUri);
|
||||
LinphonePreferences.instance().firstRemoteProvisioningSuccessful();
|
||||
|
||||
mHandler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// Restart Linphone
|
||||
stopService(new Intent(ACTION_MAIN).setClass(RemoteProvisioningActivity.this, LinphoneService.class));
|
||||
Intent intent = new Intent();
|
||||
intent.setClass(RemoteProvisioningActivity.this, LinphoneLauncherActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
private void goToLinphoneActivity() {
|
||||
LinphoneService.instance().setActivityToLaunchOnIncomingReceived(LinphoneActivity.class);
|
||||
finish(); // To prevent the user to come back to this page using back button
|
||||
startActivity(new Intent().setClass(this, LinphoneActivity.class).setData(getIntent().getData()));
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue