Add first start activity

Move non translatable strings to dedicated file
Move Activity constant integers to LinphoneActivity to avoid duplicates
Finish Incall activity if called number triggers an error
Simplify PreferenceActivity
This commit is contained in:
Guillaume Beraudo 2011-02-28 16:19:52 +01:00
parent 030cb18926
commit 833668d180
11 changed files with 278 additions and 70 deletions

View file

@ -27,6 +27,11 @@
</activity>
<activity android:name=".FirstLoginActivity" android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
<activity android:name=".IncallActivity" android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
<intent-filter>

View file

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:a="http://schemas.android.com/apk/res/android"
a:layout_width="fill_parent" a:layout_height="fill_parent" a:orientation="vertical">
<TextView a:text="@string/first_login_explanation" a:layout_width="fill_parent" a:layout_height="wrap_content" a:layout_marginBottom="20px"/>
<LinearLayout a:layout_width="fill_parent" a:layout_height="wrap_content">
<TextView a:text="@string/first_login_username" a:layout_width="wrap_content" a:layout_height="wrap_content" />
<EditText a:id="@+id/login" a:layout_width="fill_parent" a:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout a:layout_width="fill_parent" a:layout_height="wrap_content">
<TextView a:text="@string/first_login_password" a:layout_width="wrap_content" a:layout_height="wrap_content"/>
<EditText a:id="@+id/password" a:password="true" a:layout_width="fill_parent" a:layout_height="wrap_content" />
</LinearLayout>
<Button a:id="@+id/connect" a:text="@string/first_login_connect" a:layout_width="fill_parent" a:layout_height="wrap_content" a:layout_marginTop="20px"/>
// Some moving widget
</LinearLayout>

View file

@ -40,7 +40,6 @@ el_transmit_thres=1.7
ng_floorgain=0.01
[video]
size=qvga-portrait

View file

@ -6,5 +6,28 @@
<string name="pref_passwd_key">pref_passwd_key</string>
<string name="pref_username_key">pref_username_key</string>
<string name="pref_debug_key">pref_debug_key</string>
<string name="first_launch_suceeded_once_key">first_launch_suceeded_once_key</string>
<string name="pref_video_use_front_camera_key">pref_video_use_front_camera_key</string>
<string name="pref_video_codec_h263_key">pref_video_codec_h263_key</string>
<string name="pref_video_codec_mpeg4_key">pref_video_codec_mpeg4_key</string>
<string name="pref_video_codec_h264_key">pref_video_codec_h264_key</string>
<string name="pref_video_automatically_share_my_video_key">pref_video_automatically_share_my_video_key</string>
<string name="pref_video_initiate_call_with_video_key">pref_video_initiate_call_with_video_key</string>
<string name="pref_video_enable_key">pref_video_enable_key</string>
<string name="pref_escape_plus_key">pref_escape_plus_key</string>
<string name="pref_echo_cancellation_key">pref_echo_cancellation_key</string>
<string name="pref_autostart_key">pref_autostart_key</string>
<string name="pref_enable_outbound_proxy_key">Outbound proxy</string>
<string name="pref_codec_pcma_key">pref_codec_pcma_key</string>
<string name="pref_codec_pcmu_key">pref_codec_pcmu_key</string>
<string name="pref_codec_gsm_key">pref_codec_gsm_key</string>
<string name="pref_codec_ilbc_key">pref_codec_ilbc_key</string>
<string name="pref_codec_speex8_key">pref_codec_speex8_key</string>
<string name="pref_codec_speex16_key">pref_codec_speex16_key</string>
<string name="pref_codec_speex32_key">pref_codec_speex32_key</string>
<string name="pref_codecs_key">pref_codecs_key</string>
<string name="pref_stun_server_key">pref_stun_server_key</string>
<string name="default_domain">test.linphone.org</string>
</resources>

View file

@ -3,15 +3,11 @@
<string name="pref_echo_canceller_calibration_key">pref_echo_canceller_calibration_key</string>
<string name="pref_echo_canceller_calibration">Echo calibration</string>
<string name="pref_video_use_front_camera_title">Use front camera</string>
<string name="pref_video_use_front_camera_key">pref_video_use_front_camera_key</string>
<string name="pref_video">Video</string>
<string name="pref_preferences">Preferences</string>
<string name="pref_video_codec_h263_title">H263</string>
<string name="pref_video_codec_h263_key">pref_video_codec_h263_key</string>
<string name="pref_video_codec_mpeg4_title">MPEG4</string>
<string name="pref_video_codec_mpeg4_key">pref_video_codec_mpeg4_key</string>
<string name="pref_video_codec_h264_title">H264</string>
<string name="pref_video_codec_h264_key">pref_video_codec_h264_key</string>
<string name="pref_video_codecs_title">Codecs</string>
<string name="pref_video_codecs_key">pref_video_codecs_key</string>
<string name="menu_videocall_back_to_dialer_title">Display dialer</string>
@ -24,40 +20,25 @@
<string name="menu_videocall_toggle_camera_enable">Enable camera</string>
<string name="menu_videocall_terminate_call_title">Terminate call</string>
<string name="pref_video_settings_title">Video settings</string>
<string name="pref_video_automatically_share_my_video_key">pref_video_automatically_share_my_video_key</string>
<string name="pref_video_automatically_share_my_video_title">Share my camera</string>
<string name="pref_video_automatically_share_my_video">Automatically send my camera on incoming calls</string>
<string name="pref_video_initiate_call_with_video_key">pref_video_initiate_call_with_video_key</string>
<string name="pref_video_initiate_call_with_video_title">Initiate video calls</string>
<string name="pref_video_initiate_call_with_video">Always send my camera on outgoing calls</string>
<string name="pref_video_enable_key">pref_video_enable_key</string>
<string name="pref_video_enable_title">Enable Video</string>
<string name="pref_escape_plus">Replace + by 00</string>
<string name="pref_escape_plus_key">pref_escape_plus_key</string>
<string name="pref_ilbc_summary">iLBC might be unavailable depending on ARM processor and Android OS version.</string>
<string name="pref_echo_cancellation">Echo cancellation</string>
<string name="pref_echo_cancellation_key">pref_echo_cancellation_key</string>
<string name="pref_autostart">Start at boot time</string>
<string name="pref_autostart_key">pref_autostart_key</string>
<string name="outcall_chooser_cellular">Cellular</string>
<string name="outcall_chooser_text">Choose application to call %s</string>
<string name="pref_enable_outbound_proxy">Outbound proxy</string>
<string name="pref_enable_outbound_proxy_key">Outbound proxy</string>
<string name="pref_codec_pcma">pcma</string>
<string name="pref_codec_pcma_key">pref_codec_pcma_key</string>
<string name="pref_codec_pcmu">pcmu</string>
<string name="pref_codec_pcmu_key">pref_codec_pcmu_key</string>
<string name="pref_codec_gsm">gsm</string>
<string name="pref_codec_gsm_key">pref_codec_gsm_key</string>
<string name="pref_codec_ilbc">ilbc</string>
<string name="pref_codec_ilbc_key">pref_codec_ilbc_key</string>
<string name="pref_codec_speex8">speex 8 Khz</string>
<string name="pref_codec_speex8_key">pref_codec_speex8_key</string>
<string name="pref_codec_speex16">speex 16 Khz</string>
<string name="pref_codec_speex16_key">pref_codec_speex16_key</string>
<string name="pref_codec_speex32_key">pref_codec_speex32_key</string>
<string name="pref_codecs">Codecs</string>
<string name="pref_codecs_key">pref_codecs_key</string>
<string name="place_call_chooser">Place a call</string>
<string name="pref_debug">Debug</string>
<string name="about_text">Linphone %s SIP (rfc 3261) compatible phone under GNU Public License V2\n http://www.linphone.org\n\nInstructions\nhttp://www.linphone.org/m/help\n\n© 2011 Belledonne Communications</string>
@ -102,8 +83,13 @@
<string name="notification_started">started</string>
<string name="pref_echo_cancellation_summary">Removes the echo heard by other end</string>
<string name="pref_stun_server">Stun server</string>
<string name="pref_stun_server_key">pref_stun_server_key</string>
<string name="ec_calibrating">Calibrating...</string>
<string name="ec_calibrated">Calibrated [%s ms]</string>
<string name="failed">failed</string>
<string name="first_login_explanation">Enter your username and password to connect to the service.</string>
<string name="first_login_username">Username</string>
<string name="first_login_password">Password</string>
<string name="first_login_connect">Connect</string>
<string name="first_launch_no_login_password">Please enter your login and password</string>
<string name="first_launch_bad_login_password">Couldn\'t connect; check your login and password and start again</string>
</resources>

View file

@ -88,9 +88,8 @@ public class DialerActivity extends Activity implements LinphoneGuiListener, Alr
private static final String PREF_CHECK_CONFIG = "pref_check_config";
public static final String PREF_FIRST_LAUNCH = "pref_first_launch";
private static String CURRENT_ADDRESS = "org.linphone.current-address";
private static String CURRENT_DISPLAYNAME = "org.linphone.current-displayname";
static int VIDEO_VIEW_ACTIVITY = 100;
private static final String CURRENT_ADDRESS = "org.linphone.current-address";
private static final String CURRENT_DISPLAYNAME = "org.linphone.current-displayname";
private static boolean checkAccount = true;
@ -115,8 +114,6 @@ public class DialerActivity extends Activity implements LinphoneGuiListener, Alr
mWakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK|PowerManager.ON_AFTER_RELEASE,"Linphone");
mAddress = (AddressText) findViewById(R.id.SipUri);
mDisplayNameView = (TextView) findViewById(R.id.DisplayNameView);
((EraseButton) findViewById(R.id.Erase)).setAddressView(mAddress);
@ -317,8 +314,6 @@ public class DialerActivity extends Activity implements LinphoneGuiListener, Alr
private void startVideoView(int requestCode) {
@ -346,10 +341,11 @@ public class DialerActivity extends Activity implements LinphoneGuiListener, Alr
}
private void openIncallActivity(CharSequence callerName) {
startActivity(new Intent()
private void startIncallActivity(CharSequence callerName) {
startActivityForResult(new Intent()
.setClass(this, IncallActivity.class)
.putExtra(IncallActivity.CONTACT_KEY, callerName));
.putExtra(IncallActivity.CONTACT_KEY, callerName),
LinphoneActivity.INCALL_ACTIVITY);
}
@ -381,7 +377,7 @@ public class DialerActivity extends Activity implements LinphoneGuiListener, Alr
setVolumeControlStream(AudioManager.USE_DEFAULT_STREAM_TYPE);
mDecline.setEnabled(false);
if (LinphoneManager.getLc().isVideoEnabled()) {
finishActivity(VIDEO_VIEW_ACTIVITY);
finishActivity(LinphoneActivity.VIDEO_VIEW_ACTIVITY);
}
if (mWakeLock.isHeld())mWakeLock.release();
mSpeaker.setSpeakerOn(false);
@ -430,7 +426,7 @@ public class DialerActivity extends Activity implements LinphoneGuiListener, Alr
}
public void onAlreadyInVideoCall() {
startVideoView(VIDEO_VIEW_ACTIVITY);
startVideoView(LinphoneActivity.VIDEO_VIEW_ACTIVITY);
}
public void onAlreadyInCall() {
@ -460,17 +456,18 @@ public class DialerActivity extends Activity implements LinphoneGuiListener, Alr
LinphoneCore lc = LinphoneManager.getLc();
if (state == LinphoneCall.State.OutgoingInit) {
enterIncallMode(lc);
openIncallActivity(mDisplayNameView.getText());
startIncallActivity(mDisplayNameView.getText());
} else if (state == LinphoneCall.State.IncomingReceived) {
LinphoneManager.getInstance().resetCameraFromPreferences();
callPending(call);
} else if (state == LinphoneCall.State.Connected) {
if (call.getDirection() == CallDirection.Incoming) {
enterIncallMode(lc);
openIncallActivity(mDisplayNameView.getText());
startIncallActivity(mDisplayNameView.getText());
}
} else if (state == LinphoneCall.State.Error) {
if (mWakeLock.isHeld()) mWakeLock.release();
finishActivity(LinphoneActivity.INCALL_ACTIVITY);
Toast toast = Toast.makeText(this
,String.format(getString(R.string.call_error),message)
, Toast.LENGTH_LONG);
@ -480,12 +477,13 @@ public class DialerActivity extends Activity implements LinphoneGuiListener, Alr
exitCallMode();
} else if (state == LinphoneCall.State.StreamsRunning) {
if (LinphoneManager.getLc().getCurrentCall().getCurrentParamsCopy().getVideoEnabled()) {
startVideoView(VIDEO_VIEW_ACTIVITY);
startVideoView(LinphoneActivity.VIDEO_VIEW_ACTIVITY);
}
}
}
public void onGlobalStateChangedToOn(String message) {
mCall.setEnabled(!LinphoneManager.getLc().isIncall());
mHangup.setEnabled(!mCall.isEnabled());
@ -503,4 +501,6 @@ public class DialerActivity extends Activity implements LinphoneGuiListener, Alr
outgoingCallIntentReceived();
}
}
}

View file

@ -0,0 +1,114 @@
/*
IncallActivity.java
Copyright (C) 2011 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.
*/
package org.linphone;
import org.linphone.core.LinphoneCore.RegistrationState;
import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;
import android.widget.Toast;
public class FirstLoginActivity extends Activity implements OnClickListener {
private TextView login;
private TextView password;
private SharedPreferences mPref;
static FirstLoginActivity instance;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.first_login_view);
mPref = PreferenceManager.getDefaultSharedPreferences(this);
setDefaultDomain(getString(R.string.default_domain));
login = (TextView) findViewById(R.id.login);
login.setText(mPref.getString(getString(R.string.pref_username_key), ""));
password = (TextView) findViewById(R.id.password);
findViewById(R.id.connect).setOnClickListener(this);
instance = this;
}
private void setDefaultDomain(String string) {
String domain = mPref.getString(getString(R.string.pref_domain_key), "");
if (domain.length() != 0) return;
writePreference(R.string.pref_domain_key, getString(R.string.default_domain));
}
public void onClick(View v) {
if (login.getText() == null || login.length() == 0
|| password.getText() == null || password.length() == 0) {
toast(R.string.first_launch_no_login_password);
return;
}
writePreference(R.string.pref_username_key, login.getText().toString());
writePreference(R.string.pref_passwd_key, password.getText().toString());
try {
LinphoneManager.getInstance().initFromConf(getApplicationContext());
} catch (Throwable e) {
Log.e(LinphoneManager.TAG, "Error while initializing from config in first login activity", e);
}
}
private void writePreference(int key, String value) {
mPref.edit().putString(getString(key), value).commit();
}
@Override
protected void onDestroy() {
instance = null;
super.onDestroy();
}
public void onRegistrationStateChanged(RegistrationState state) {
if (RegistrationState.RegistrationOk == state) {
mPref.edit().putBoolean(getString(R.string.first_launch_suceeded_once_key), true).commit();
finish();
} else if (RegistrationState.RegistrationFailed == state) {
toast(R.string.first_launch_bad_login_password);
}
}
private void toast(int key) {
Toast.makeText(instance, instance.getString(key), Toast.LENGTH_LONG).show();
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
// Forbid user to press back button
return true;
}
return super.onKeyDown(keyCode, event);
}
}

View file

@ -23,7 +23,6 @@ import java.util.TimerTask;
import org.linphone.ui.AddVideoButton;
import org.linphone.ui.HangCallButton;
import org.linphone.ui.AddVideoButton.AlreadyInVideoCallListener;
import android.app.Activity;
import android.content.Intent;

View file

@ -24,12 +24,14 @@ import static android.media.AudioManager.*;
import java.util.List;
import org.linphone.core.Version;
import org.linphone.core.LinphoneCore.RegistrationState;
import android.app.AlertDialog;
import android.app.TabActivity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.drawable.Drawable;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
@ -37,6 +39,7 @@ import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.media.AudioManager;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
@ -56,8 +59,13 @@ public class LinphoneActivity extends TabActivity {
private static SensorEventListener mSensorEventListener;
private static final String SCREEN_IS_HIDDEN ="screen_is_hidden";
static final int VIDEO_VIEW_ACTIVITY = 100;
static final int FIRST_LOGIN_ACTIVITY = 101;
static final int INCALL_ACTIVITY = 102;
protected static LinphoneActivity instance() {
static final LinphoneActivity instance() {
if (instance != null) return instance;
throw new RuntimeException("LinphoneActivity not instantiated yet");
@ -81,8 +89,34 @@ public class LinphoneActivity extends TabActivity {
mMainFrame = (FrameLayout) findViewById(R.id.main_frame);
mAudioManager = ((AudioManager)getSystemService(Context.AUDIO_SERVICE));
mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
if (pref.getBoolean(getString(R.string.first_launch_suceeded_once_key), false)) {
fillTabHost();
} else {
startActivityForResult(new Intent().setClass(this, FirstLoginActivity.class), FIRST_LOGIN_ACTIVITY);
}
if (savedInstanceState !=null && savedInstanceState.getBoolean(SCREEN_IS_HIDDEN,false)) {
hideScreen(true);
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == FIRST_LOGIN_ACTIVITY) {
fillTabHost();
}
super.onActivityResult(requestCode, resultCode, data);
}
private void fillTabHost() {
TabHost lTabHost = getTabHost(); // The activity TabHost
TabHost.TabSpec spec; // Reusable TabSpec for each tab
Drawable tabDrawable; // Drawable for a tab
@ -119,15 +153,9 @@ public class LinphoneActivity extends TabActivity {
lTabHost.addTab(spec);
lTabHost.setCurrentTabByTag("dialer");
if (savedInstanceState !=null && savedInstanceState.getBoolean(SCREEN_IS_HIDDEN,false)) {
hideScreen(true);
}
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
@ -256,6 +284,15 @@ public class LinphoneActivity extends TabActivity {
});
builder.create().show();
}
}
public void onRegistrationStateChanged(RegistrationState state,
String message) {
if (FirstLoginActivity.instance != null) {
FirstLoginActivity.instance.onRegistrationStateChanged(state);
}
}
}

View file

@ -20,8 +20,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
package org.linphone;
import static android.media.AudioManager.STREAM_VOICE_CALL;
import static org.linphone.R.string.cont;
import static org.linphone.R.string.ec_calibrating;
import static org.linphone.R.string.ec_calibration_launch_message;
import static org.linphone.R.string.pref_codec_ilbc_key;
import static org.linphone.R.string.pref_codec_speex16_key;
import static org.linphone.R.string.pref_codec_speex32_key;
import static org.linphone.R.string.pref_echo_cancellation_key;
import static org.linphone.R.string.pref_echo_canceller_calibration_key;
import static org.linphone.R.string.pref_video_enable_key;
import org.linphone.core.LinphoneCoreException;
import org.linphone.core.Version;
@ -51,13 +59,13 @@ public class LinphonePreferencesActivity extends PreferenceActivity {
// if not ilbc, we are on low end cpu.
enableIlbc = LinphoneManager.getLc().findPayloadType("iLBC", 8000)!=null?true:false;
mIsLowEndCpu=!enableIlbc;
if (!mIsLowEndCpu && !getPreferenceManager().getSharedPreferences().contains(getString(R.string.pref_echo_cancellation_key))) {
getPreferenceManager().getSharedPreferences().edit().putBoolean(getString(R.string.pref_echo_cancellation_key), true).commit();
if (!mIsLowEndCpu && !getPreferenceManager().getSharedPreferences().contains(getString(pref_echo_cancellation_key))) {
writeBoolean(pref_echo_cancellation_key, true);
}
if (mIsLowEndCpu) {
getPreferenceManager().getSharedPreferences().edit().putBoolean(getString(R.string.pref_codec_ilbc_key), false).commit();
getPreferenceManager().getSharedPreferences().edit().putBoolean(getString(R.string.pref_codec_speex16_key), false).commit();
getPreferenceManager().getSharedPreferences().edit().putBoolean(getString(R.string.pref_codec_speex32_key), false).commit();
writeBoolean(pref_codec_ilbc_key, false);
writeBoolean(pref_codec_speex16_key, false);
writeBoolean(pref_codec_speex32_key, false);
}
}
@ -65,11 +73,11 @@ public class LinphonePreferencesActivity extends PreferenceActivity {
// Load the preferences from an XML resource
addPreferencesFromResource(R.xml.preferences);
if (!mIsLowEndCpu) {
getPreferenceScreen().findPreference(getString(R.string.pref_codec_ilbc_key)).setEnabled(enableIlbc);
getPreferenceScreen().findPreference(getString(R.string.pref_codec_speex16_key)).setEnabled(enableIlbc);
//getPreferenceScreen().findPreference(getString(R.string.pref_codec_speex32_key)).setEnabled(enableIlbc);
findPreference(pref_codec_ilbc_key).setEnabled(enableIlbc);
findPreference(pref_codec_speex16_key).setEnabled(enableIlbc);
//findPreference(pref_codec_speex32_key)).setEnabled(enableIlbc);
}
getPreferenceScreen().findPreference(getString(R.string.pref_echo_canceller_calibration_key))
findPreference(pref_echo_canceller_calibration_key)
.setOnPreferenceClickListener(new OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference preference) {
startEcCalibration(preference);
@ -79,14 +87,14 @@ public class LinphonePreferencesActivity extends PreferenceActivity {
// Force disable video
if (Version.sdkStrictlyBelow(5) || !enableIlbc || !LinphoneManager.getInstance().hasCamera()) {
disableCheckbox(R.string.pref_video_enable_key);
disableCheckbox(pref_video_enable_key);
}
if (getPreferenceManager().getSharedPreferences().getBoolean(DialerActivity.PREF_FIRST_LAUNCH,true)) {
if (!mIsLowEndCpu ) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.ec_calibration_launch_message).setCancelable(false).setPositiveButton(getString(R.string.cont), new OnClickListener() {
builder.setTitle(ec_calibration_launch_message).setCancelable(false).setPositiveButton(getString(cont), new OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
startEcCalibration(getPreferenceScreen().findPreference(getString(R.string.pref_echo_canceller_calibration_key)));
startEcCalibration(findPreference(pref_echo_canceller_calibration_key));
}
}).create().show();
@ -105,20 +113,27 @@ public class LinphonePreferencesActivity extends PreferenceActivity {
mAudioManager.setStreamVolume(STREAM_VOICE_CALL, oldVolume, 0);
preference.setSummary(R.string.ec_calibrating);
preference.getEditor().putBoolean(getString(R.string.pref_echo_canceller_calibration_key), false).commit();
preference.setSummary(ec_calibrating);
preference.getEditor().putBoolean(getString(pref_echo_canceller_calibration_key), false).commit();
} catch (LinphoneCoreException e) {
Log.w(LinphoneManager.TAG, "Cannot calibrate EC",e);
}
}
private void disableCheckbox(int key) {
getPreferenceManager().getSharedPreferences().edit().putBoolean(getString(key), false).commit();
CheckBoxPreference box = (CheckBoxPreference) getPreferenceScreen().findPreference(getString(key));
writeBoolean(key, false);
CheckBoxPreference box = (CheckBoxPreference) findPreference(key);
box.setEnabled(false);
box.setChecked(false);
}
private Preference findPreference(int key) {
return getPreferenceScreen().findPreference(getString(key));
}
private void writeBoolean(int key, boolean value) {
getPreferenceManager().getSharedPreferences().edit().putBoolean(getString(key), value).commit();
}
@Override
protected void onPause() {

View file

@ -87,8 +87,8 @@ public final class LinphoneService extends Service implements LinphoneServiceLis
private static final int IC_LEVEL_ORANGE=0;
private static final int IC_LEVEL_GREEN=1;
private static final int IC_LEVEL_RED=2;
/*private static final int IC_LEVEL_GREEN=1;
private static final int IC_LEVEL_RED=2;*/
private static final int IC_LEVEL_OFFLINE=3;
@ -189,14 +189,23 @@ public final class LinphoneService extends Service implements LinphoneServiceLis
}
public void onRegistrationStateChanged(RegistrationState state,
String message) {
if (state == LinphoneCore.RegistrationState.RegistrationOk && LinphoneManager.getLc().getDefaultProxyConfig().isRegistered()) {
public void onRegistrationStateChanged(final RegistrationState state,
final String message) {
if (state == RegistrationState.RegistrationOk && LinphoneManager.getLc().getDefaultProxyConfig().isRegistered()) {
sendNotificationWithId(IC_LEVEL_ORANGE, R.string.notification_registered);
}
if (state == LinphoneCore.RegistrationState.RegistrationFailed ) {
if (state == RegistrationState.RegistrationFailed) {
sendNotificationWithId(IC_LEVEL_OFFLINE, R.string.notification_register_failure);
}
if (state == RegistrationState.RegistrationOk || state == RegistrationState.RegistrationFailed) {
mHandler.post(new Runnable() {
public void run() {
LinphoneActivity.instance().onRegistrationStateChanged(state, message);
}
});
}
}