This commit is contained in:
Guillaume Beraudo 2011-02-17 16:26:17 +01:00
parent ef93c28b72
commit de64a0918f

View file

@ -46,12 +46,9 @@ import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.media.AudioManager; import android.media.AudioManager;
import android.media.MediaPlayer;
import android.os.Bundle; import android.os.Bundle;
import android.os.PowerManager; import android.os.PowerManager;
import android.os.Vibrator;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.provider.Settings;
import android.text.Html; import android.text.Html;
import android.util.Log; import android.util.Log;
import android.view.View; import android.view.View;
@ -90,12 +87,10 @@ public class DialerActivity extends Activity implements LinphoneCoreListener, Al
private static String CURRENT_DISPLAYNAME = "org.linphone.current-displayname"; private static String CURRENT_DISPLAYNAME = "org.linphone.current-displayname";
static int VIDEO_VIEW_ACTIVITY = 100; static int VIDEO_VIEW_ACTIVITY = 100;
Settings.System mSystemSettings = new Settings.System();
MediaPlayer mRingerPlayer;
Vibrator mVibrator;
private static boolean accountCheckingDone; private static boolean accountCheckingDone;
/** /**
* @return null if not ready yet * @return null if not ready yet
*/ */
@ -111,7 +106,6 @@ public class DialerActivity extends Activity implements LinphoneCoreListener, Al
AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE); AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
LinphoneManager.getInstance().setUsefullStuff(am, mPref, getWindowManager(), getResources()); LinphoneManager.getInstance().setUsefullStuff(am, mPref, getWindowManager(), getResources());
PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE); PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
mVibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
mWakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK|PowerManager.ON_AFTER_RELEASE,"Linphone"); mWakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK|PowerManager.ON_AFTER_RELEASE,"Linphone");
@ -292,6 +286,9 @@ public class DialerActivity extends Activity implements LinphoneCoreListener, Al
mAddVideo.setVisibility(View.GONE); mAddVideo.setVisibility(View.GONE);
} }
} }
@Override @Override
public void onSaveInstanceState(Bundle savedInstanceState) { public void onSaveInstanceState(Bundle savedInstanceState) {
super.onSaveInstanceState(savedInstanceState); super.onSaveInstanceState(savedInstanceState);
@ -309,6 +306,8 @@ public class DialerActivity extends Activity implements LinphoneCoreListener, Al
} }
mAddress.setDisplayedName(savedInstanceState.getString(CURRENT_DISPLAYNAME)); mAddress.setDisplayedName(savedInstanceState.getString(CURRENT_DISPLAYNAME));
} }
@Override @Override
protected void onDestroy() { protected void onDestroy() {
super.onDestroy(); super.onDestroy();
@ -321,6 +320,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener, Al
super.onResume(); super.onResume();
} }
public void authInfoRequested(LinphoneCore lc, String realm, String username) /*nop*/{} public void authInfoRequested(LinphoneCore lc, String realm, String username) /*nop*/{}
public void byeReceived(LinphoneCore lc, String from) {/*nop*/} public void byeReceived(LinphoneCore lc, String from) {/*nop*/}
public void displayMessage(LinphoneCore lc, String message) {/*nop*/} public void displayMessage(LinphoneCore lc, String message) {/*nop*/}
@ -355,8 +355,9 @@ public class DialerActivity extends Activity implements LinphoneCoreListener, Al
} }
public void registrationState(final LinphoneCore lc, final LinphoneProxyConfig cfg,final LinphoneCore.RegistrationState state,final String smessage) {/*nop*/}; public void registrationState(final LinphoneCore lc, final LinphoneProxyConfig cfg,final LinphoneCore.RegistrationState state,final String smessage) {/*nop*/};
public void callState(final LinphoneCore lc,final LinphoneCall call, final State state, final String message) {
public void callState(final LinphoneCore lc,final LinphoneCall call, final State state, final String message) {
if (state == LinphoneCall.State.OutgoingInit) { if (state == LinphoneCall.State.OutgoingInit) {
enterIncallMode(lc); enterIncallMode(lc);
LinphoneManager.getInstance().routeAudioToReceiver(); LinphoneManager.getInstance().routeAudioToReceiver();
@ -416,6 +417,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener, Al
if (!mWakeLock.isHeld()) mWakeLock.acquire(); if (!mWakeLock.isHeld()) mWakeLock.acquire();
} }
private void loadMicAndSpeakerUiStateFromLibrary() { private void loadMicAndSpeakerUiStateFromLibrary() {
mMute.setChecked(LinphoneService.getLc().isMicMuted()); mMute.setChecked(LinphoneService.getLc().isMicMuted());
mSpeaker.setSpeakerOn(LinphoneManager.getInstance().isSpeakerOn()); mSpeaker.setSpeakerOn(LinphoneManager.getInstance().isSpeakerOn());
@ -432,7 +434,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener, Al
mHangup.setEnabled(false); mHangup.setEnabled(false);
setVolumeControlStream(AudioManager.USE_DEFAULT_STREAM_TYPE); setVolumeControlStream(AudioManager.USE_DEFAULT_STREAM_TYPE);
mDecline.setEnabled(false); mDecline.setEnabled(false);
if (LinphoneService.instance().getLinphoneCore().isVideoEnabled()) { if (LinphoneService.getLc().isVideoEnabled()) {
finishActivity(VIDEO_VIEW_ACTIVITY); finishActivity(VIDEO_VIEW_ACTIVITY);
} }
if (mWakeLock.isHeld())mWakeLock.release(); if (mWakeLock.isHeld())mWakeLock.release();
@ -453,6 +455,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener, Al
AndroidCameraRecordManager.getInstance().setMuted(!(prefVideoEnable && prefAutomaticallyShareMyCamera)); AndroidCameraRecordManager.getInstance().setMuted(!(prefVideoEnable && prefAutomaticallyShareMyCamera));
call.enableCamera(prefAutomaticallyShareMyCamera); call.enableCamera(prefAutomaticallyShareMyCamera);
} }
public void newOutgoingCall(String aTo) { public void newOutgoingCall(String aTo) {
mAddress.setText(aTo); mAddress.setText(aTo);
mAddress.clearDisplayedName(); mAddress.clearDisplayedName();
@ -491,7 +494,8 @@ public class DialerActivity extends Activity implements LinphoneCoreListener, Al
public void onAlreadyInCall() { public void onAlreadyInCall() {
Toast toast = Toast.makeText(DialerActivity.this, getString(R.string.warning_already_incall), Toast.LENGTH_LONG); Toast toast = Toast.makeText(DialerActivity.this,
getString(R.string.warning_already_incall), Toast.LENGTH_LONG);
toast.show(); toast.show();
} }
@ -501,8 +505,5 @@ public class DialerActivity extends Activity implements LinphoneCoreListener, Al
,String.format(getString(R.string.error_cannot_get_call_parameters),mAddress.getText().toString()) ,String.format(getString(R.string.error_cannot_get_call_parameters),mAddress.getText().toString())
,Toast.LENGTH_LONG); ,Toast.LENGTH_LONG);
toast.show(); toast.show();
} }
} }