add status bar
|
@ -1,7 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="submodules/linphone/java"/>
|
||||
<classpathentry kind="src" path="submodules/linphone/java/j2se"/>
|
||||
<classpathentry kind="src" path="submodules/linphone/java/common"/>
|
||||
<classpathentry kind="src" path="gen"/>
|
||||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
|
|
BIN
res/drawable/clavier_bg.9.png
Normal file
After Width: | Height: | Size: 488 B |
BIN
res/drawable/clavier_bg_ori.png
Normal file
After Width: | Height: | Size: 356 B |
BIN
res/drawable/contact_orange.png
Normal file
After Width: | Height: | Size: 734 B |
BIN
res/drawable/dialer_orange.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 3.9 KiB |
BIN
res/drawable/history_orange.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 5.4 KiB |
Before Width: | Height: | Size: 33 KiB |
BIN
res/drawable/linphone_banner.png
Normal file
After Width: | Height: | Size: 9 KiB |
Before Width: | Height: | Size: 4 KiB |
BIN
res/drawable/startcall_green.png
Normal file
After Width: | Height: | Size: 3 KiB |
BIN
res/drawable/status_green.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
7
res/drawable/status_level.xml
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<level-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:maxLevel="0" android:drawable="@drawable/status_orange" />
|
||||
<item android:maxLevel="1" android:drawable="@drawable/status_green" />
|
||||
<item android:maxLevel="2" android:drawable="@drawable/status_red" />
|
||||
<item android:maxLevel="3" android:drawable="@drawable/status_offline" />
|
||||
</level-list>
|
BIN
res/drawable/status_offline.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
res/drawable/status_orange.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
res/drawable/status_red.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
res/drawable/stopcall_red.png
Normal file
After Width: | Height: | Size: 2.9 KiB |
|
@ -11,8 +11,7 @@
|
|||
android:hint="sip:" android:layout_width="fill_parent"
|
||||
android:lines="1" android:layout_weight="0.2"></EditText>
|
||||
<Button android:layout_height="wrap_content" android:id="@+id/Erase"
|
||||
android:layout_width="fill_parent" android:text="<-"
|
||||
android:layout_weight="0.8"></Button>
|
||||
android:layout_width="fill_parent" android:layout_weight="0.8" android:text="<"></Button>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
|
@ -28,20 +27,20 @@
|
|||
<TableLayout android:layout_width="fill_parent" android:id="@+id/Dialer"
|
||||
android:layout_height="fill_parent" android:layout_weight="1">
|
||||
<TableRow android:layout_height="fill_parent" android:layout_width="fill_parent" android:id="@+id/IncallControlRow">
|
||||
<ToggleButton android:id="@+id/mic_mute_button" android:textOn="" android:textOff="" android:layout_height="fill_parent" android:layout_width="fill_parent" android:drawableTop="@drawable/mic_active" android:checked="true" android:layout_weight="1"></ToggleButton>
|
||||
<ImageButton android:src="@drawable/red" android:layout_height="fill_parent" android:layout_width="fill_parent" android:id="@+id/HangUp" android:layout_weight="1"></ImageButton>
|
||||
<ToggleButton android:id="@+id/speaker_button" android:textOn="" android:textOff="" android:layout_height="fill_parent" android:layout_width="fill_parent" android:drawableTop="@drawable/speaker_32_on" android:layout_weight="1"></ToggleButton>
|
||||
<ToggleButton android:id="@+id/mic_mute_button" android:textOn="" android:textOff="" android:layout_height="fill_parent" android:layout_width="fill_parent" android:drawableTop="@drawable/mic_active" android:checked="true" android:layout_weight="1" android:background="@drawable/clavier_bg_ori"></ToggleButton>
|
||||
<ImageButton android:src="@drawable/red" android:layout_height="fill_parent" android:layout_width="fill_parent" android:id="@+id/HangUp" android:layout_weight="1" android:background="@drawable/clavier_bg_ori"></ImageButton>
|
||||
<ToggleButton android:id="@+id/speaker_button" android:textOn="" android:textOff="" android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="1" android:background="@drawable/clavier_bg_ori" android:drawableTop="@drawable/speaker_32_off"></ToggleButton>
|
||||
</TableRow>
|
||||
</TableLayout>
|
||||
<LinearLayout android:layout_height="fill_parent"
|
||||
android:layout_width="fill_parent" android:id="@+id/CallControlRow" android:layout_weight="1">
|
||||
<ImageButton android:id="@+id/Call"
|
||||
android:layout_height="fill_parent" android:src="@drawable/green"
|
||||
android:layout_width="fill_parent" android:layout_weight="0.25">
|
||||
android:layout_width="fill_parent" android:layout_weight="0.25" android:background="@drawable/clavier_bg_ori">
|
||||
</ImageButton>
|
||||
<ImageButton android:src="@drawable/red"
|
||||
android:layout_height="fill_parent" android:layout_width="fill_parent"
|
||||
android:layout_weight="0.25" android:id="@+id/Decline"></ImageButton>
|
||||
android:layout_weight="0.25" android:id="@+id/Decline" android:background="@drawable/clavier_bg_ori"></ImageButton>
|
||||
</LinearLayout>
|
||||
<EditText android:layout_width="fill_parent" android:id="@+id/status_label"
|
||||
android:clickable="false" android:focusable="false"
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent" android:orientation="vertical" android:gravity="center" android:layout_height="fill_parent">
|
||||
<ImageView android:id="@+id/ImageView01" android:layout_height="wrap_content" android:layout_width="wrap_content" android:src="@drawable/linphone_3_250x130"></ImageView>
|
||||
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/about_text" android:autoLink="web" android:gravity="center" android:paddingTop="50sp" android:textStyle="bold" android:id="@+id/AboutText"></TextView>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent" android:orientation="vertical"
|
||||
android:gravity="center" android:layout_height="fill_parent">
|
||||
<ImageView android:id="@+id/ImageView01"
|
||||
android:layout_height="wrap_content" android:layout_width="wrap_content"
|
||||
android:src="@drawable/linphone_banner"></ImageView>
|
||||
<TextView android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" android:text="@string/about_text"
|
||||
android:autoLink="web" android:gravity="center" android:paddingTop="50sp"
|
||||
android:textStyle="bold" android:id="@+id/AboutText"></TextView>
|
||||
</LinearLayout>
|
||||
|
|
|
@ -11,9 +11,8 @@
|
|||
android:hint="sip:" android:layout_width="fill_parent"
|
||||
android:lines="1" android:layout_weight="0.2"></EditText>
|
||||
<Button android:layout_height="wrap_content" android:id="@+id/Erase"
|
||||
android:layout_width="fill_parent" android:text="<-"
|
||||
android:layout_weight="0.8" android:textSize="20sp"
|
||||
android:textStyle="bold"></Button>
|
||||
android:layout_width="fill_parent" android:layout_weight="0.8" android:textSize="20sp"
|
||||
android:textStyle="bold" android:text="<"></Button>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
|
@ -35,15 +34,15 @@
|
|||
<Button android:id="@+id/Button01" android:text="1"
|
||||
android:layout_width="fill_parent" android:layout_height="fill_parent"
|
||||
android:textStyle="bold" android:textSize="20sp"
|
||||
android:layout_weight="1"></Button>
|
||||
android:layout_weight="1" android:background="@drawable/clavier_bg_ori"></Button>
|
||||
<Button android:id="@+id/Button02" android:text="2"
|
||||
android:layout_width="fill_parent" android:layout_height="fill_parent"
|
||||
android:textStyle="bold" android:textSize="20sp"
|
||||
android:layout_weight="1"></Button>
|
||||
android:layout_weight="1" android:background="@drawable/clavier_bg_ori"></Button>
|
||||
<Button android:id="@+id/Button03" android:text="3"
|
||||
android:layout_width="fill_parent" android:layout_height="fill_parent"
|
||||
android:textStyle="bold" android:textSize="20sp"
|
||||
android:layout_weight="1"></Button>
|
||||
android:layout_weight="1" android:background="@drawable/clavier_bg_ori"></Button>
|
||||
</TableRow>
|
||||
<TableRow android:layout_height="fill_parent"
|
||||
android:layout_weight="1" android:id="@+id/DialerRow02"
|
||||
|
@ -51,45 +50,45 @@
|
|||
<Button android:id="@+id/Button04" android:text="4"
|
||||
android:layout_width="fill_parent" android:layout_height="fill_parent"
|
||||
android:textStyle="bold" android:textSize="20sp"
|
||||
android:layout_weight="1"></Button>
|
||||
android:layout_weight="1" android:background="@drawable/clavier_bg_ori"></Button>
|
||||
<Button android:text="5" android:id="@+id/Button05"
|
||||
android:layout_width="fill_parent" android:layout_height="fill_parent"
|
||||
android:textStyle="bold" android:textSize="20sp"
|
||||
android:layout_weight="1"></Button>
|
||||
android:layout_weight="1" android:background="@drawable/clavier_bg_ori"></Button>
|
||||
<Button android:id="@+id/Button06" android:text="6"
|
||||
android:layout_width="fill_parent" android:layout_height="fill_parent"
|
||||
android:textStyle="bold" android:textSize="20sp"
|
||||
android:layout_weight="1"></Button>
|
||||
android:layout_weight="1" android:background="@drawable/clavier_bg_ori"></Button>
|
||||
</TableRow>
|
||||
<TableRow android:layout_weight="1" android:layout_height="fill_parent"
|
||||
android:id="@+id/DialerRow03" android:layout_width="fill_parent">
|
||||
<Button android:text="7" android:id="@+id/Button07"
|
||||
android:layout_width="fill_parent" android:layout_height="fill_parent"
|
||||
android:textStyle="bold" android:textSize="20sp"
|
||||
android:layout_weight="1"></Button>
|
||||
android:layout_weight="1" android:background="@drawable/clavier_bg_ori"></Button>
|
||||
<Button android:id="@+id/Button08" android:text="8"
|
||||
android:layout_width="fill_parent" android:layout_height="fill_parent"
|
||||
android:textStyle="bold" android:textSize="20sp"
|
||||
android:layout_weight="1"></Button>
|
||||
android:layout_weight="1" android:background="@drawable/clavier_bg_ori"></Button>
|
||||
<Button android:text="9" android:id="@+id/Button09"
|
||||
android:layout_width="fill_parent" android:layout_height="fill_parent"
|
||||
android:textStyle="bold" android:textSize="20sp"
|
||||
android:layout_weight="1"></Button>
|
||||
android:layout_weight="1" android:background="@drawable/clavier_bg_ori"></Button>
|
||||
</TableRow>
|
||||
<TableRow android:layout_weight="1" android:layout_height="fill_parent"
|
||||
android:id="@+id/DialerRow04" android:layout_width="fill_parent">
|
||||
<Button android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent" android:text="*" android:id="@+id/ButtonStar"
|
||||
android:textStyle="bold" android:textSize="20sp"
|
||||
android:layout_weight="1"></Button>
|
||||
android:layout_weight="1" android:background="@drawable/clavier_bg_ori"></Button>
|
||||
<Button android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent" android:text="0+" android:id="@+id/Button00"
|
||||
android:textStyle="bold" android:textSize="20sp"
|
||||
android:layout_weight="1"></Button>
|
||||
android:layout_weight="1" android:background="@drawable/clavier_bg_ori"></Button>
|
||||
<Button android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent" android:id="@+id/ButtonHash"
|
||||
android:text="#" android:textStyle="bold" android:textSize="20sp"
|
||||
android:layout_weight="1"></Button>
|
||||
android:layout_weight="1" android:background="@drawable/clavier_bg_ori"></Button>
|
||||
</TableRow>
|
||||
|
||||
|
||||
|
@ -97,17 +96,17 @@
|
|||
|
||||
|
||||
<TableRow android:layout_height="fill_parent" android:layout_width="fill_parent" android:id="@+id/IncallControlRow">
|
||||
<ToggleButton android:id="@+id/mic_mute_button" android:textOn="" android:textOff="" android:layout_height="fill_parent" android:layout_width="fill_parent" android:drawableTop="@drawable/mic_active" android:checked="true" android:layout_weight="1"></ToggleButton>
|
||||
<ImageButton android:src="@drawable/red" android:layout_height="fill_parent" android:layout_width="fill_parent" android:id="@+id/HangUp" android:layout_weight="1"></ImageButton>
|
||||
<ToggleButton android:id="@+id/speaker_button" android:textOn="" android:textOff="" android:layout_height="fill_parent" android:layout_width="fill_parent" android:drawableTop="@drawable/speaker_32_on" android:layout_weight="1"></ToggleButton>
|
||||
<ToggleButton android:id="@+id/mic_mute_button" android:textOn="" android:textOff="" android:layout_height="fill_parent" android:layout_width="fill_parent" android:drawableTop="@drawable/mic_active" android:checked="true" android:layout_weight="1" android:background="@drawable/clavier_bg_ori"></ToggleButton>
|
||||
<ImageButton android:layout_height="fill_parent" android:layout_width="fill_parent" android:id="@+id/HangUp" android:layout_weight="1" android:src="@drawable/stopcall_red" android:background="@drawable/clavier_bg_ori"></ImageButton>
|
||||
<ToggleButton android:id="@+id/speaker_button" android:textOn="" android:textOff="" android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="1" android:background="@drawable/clavier_bg_ori" android:drawableTop="@drawable/speaker_32_off"></ToggleButton>
|
||||
</TableRow>
|
||||
</TableLayout>
|
||||
<LinearLayout android:id="@+id/LinearLayout01" android:layout_height="wrap_content" android:orientation="vertical" android:layout_width="fill_parent">
|
||||
|
||||
<LinearLayout android:layout_height="fill_parent" android:layout_width="fill_parent" android:id="@+id/CallControlRow">
|
||||
<ImageButton android:id="@+id/Call" android:layout_height="fill_parent" android:src="@drawable/green" android:layout_width="fill_parent" android:layout_weight="0.25">
|
||||
<ImageButton android:id="@+id/Call" android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="0.25" android:src="@drawable/startcall_green" android:background="@drawable/clavier_bg_ori">
|
||||
</ImageButton>
|
||||
<ImageButton android:src="@drawable/red" android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="0.25" android:id="@+id/Decline"></ImageButton>
|
||||
<ImageButton android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="0.25" android:id="@+id/Decline" android:src="@drawable/stopcall_red" android:background="@drawable/clavier_bg_ori"></ImageButton>
|
||||
</LinearLayout><EditText android:layout_width="fill_parent" android:id="@+id/status_label" android:clickable="false" android:focusable="false" android:cursorVisible="false" android:textSize="12sp" android:height="15sp" android:layout_height="wrap_content" android:background="@android:color/transparent" android:textColor="@android:color/white"></EditText>
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -31,5 +31,8 @@
|
|||
<string name="tab_history">History</string>
|
||||
<string name="warning_wrong_destination_address">Cannot build destination address from [%s]</string>
|
||||
<string name="menu_clear_history">Clear</string>
|
||||
|
||||
<string name="error_cannot_invite_address">Cannot invite destination address [%s]</string>
|
||||
<string name="notification_registered">registered to %s </string>
|
||||
<string name="notification_register_failure">fails to register to %s</string>
|
||||
<string name="notification_started">started</string>
|
||||
</resources>
|
||||
|
|
|
@ -166,7 +166,15 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
|
|||
return;
|
||||
}
|
||||
lAddress.setDisplayName(mDisplayName);
|
||||
lLinphoneCore.invite(lAddress);
|
||||
try {
|
||||
lLinphoneCore.invite(lAddress);
|
||||
} catch (LinphoneCoreException e) {
|
||||
Toast toast = Toast.makeText(DialerActivity.this
|
||||
,String.format(getString(R.string.error_cannot_invite_address),mAddress.getText().toString())
|
||||
, Toast.LENGTH_LONG);
|
||||
toast.show();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -221,30 +229,35 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
|
|||
if (LinphoneService.isready()) {
|
||||
LinphoneCore lLinphoenCore = LinphoneService.instance().getLinphoneCore();
|
||||
if (lLinphoenCore.isIncall()) {
|
||||
mCall.setEnabled(false);
|
||||
mHangup.setEnabled(!mCall.isEnabled());
|
||||
mCallControlRow.setVisibility(View.GONE);
|
||||
mInCallControlRow.setVisibility(View.VISIBLE);
|
||||
mAddressLayout.setVisibility(View.GONE);
|
||||
mInCallAddressLayout.setVisibility(View.VISIBLE);
|
||||
mMute.setChecked(!lLinphoenCore.isMicMuted());
|
||||
mMute.setCompoundDrawablesWithIntrinsicBounds(0
|
||||
, mMute.isChecked()?R.drawable.mic_active:R.drawable.mic_muted
|
||||
, 0
|
||||
, 0);
|
||||
String DisplayName = lLinphoenCore.getRemoteAddress().getDisplayName();
|
||||
if (DisplayName!=null) {
|
||||
mDisplayNameView.setText(DisplayName);
|
||||
if(lLinphoenCore.isInComingInvitePending()) {
|
||||
callPending();
|
||||
} else {
|
||||
mDisplayNameView.setText(lLinphoenCore.getRemoteAddress().getUserName());
|
||||
}
|
||||
if ((Integer.parseInt(Build.VERSION.SDK) <=4 && mAudioManager.getMode() == AudioManager.MODE_NORMAL)
|
||||
|| Integer.parseInt(Build.VERSION.SDK) >4 &&mAudioManager.isSpeakerphoneOn()) {
|
||||
mSpeaker.setChecked(true);
|
||||
}
|
||||
mWakeLock.acquire();
|
||||
mCall.setEnabled(false);
|
||||
mHangup.setEnabled(!mCall.isEnabled());
|
||||
mCallControlRow.setVisibility(View.GONE);
|
||||
mInCallControlRow.setVisibility(View.VISIBLE);
|
||||
mAddressLayout.setVisibility(View.GONE);
|
||||
mInCallAddressLayout.setVisibility(View.VISIBLE);
|
||||
mMute.setChecked(!lLinphoenCore.isMicMuted());
|
||||
mMute.setCompoundDrawablesWithIntrinsicBounds(0
|
||||
, mMute.isChecked()?R.drawable.mic_active:R.drawable.mic_muted
|
||||
, 0
|
||||
, 0);
|
||||
|
||||
String DisplayName = lLinphoenCore.getRemoteAddress().getDisplayName();
|
||||
if (DisplayName!=null) {
|
||||
mDisplayNameView.setText(DisplayName);
|
||||
} else {
|
||||
mDisplayNameView.setText(lLinphoenCore.getRemoteAddress().getUserName());
|
||||
}
|
||||
if ((Integer.parseInt(Build.VERSION.SDK) <=4 && mAudioManager.getMode() == AudioManager.MODE_NORMAL)
|
||||
|| Integer.parseInt(Build.VERSION.SDK) >4 &&mAudioManager.isSpeakerphoneOn()) {
|
||||
mSpeaker.setChecked(true);
|
||||
}
|
||||
mWakeLock.acquire();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -270,8 +283,10 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
|
|||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
if (isChecked) {
|
||||
routeAudioToSpeaker();
|
||||
mSpeaker.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.speaker_32_on, 0, 0);
|
||||
} else {
|
||||
routeAudioToReceiver();
|
||||
mSpeaker.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.speaker_32_off, 0, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -359,70 +374,57 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
|
|||
|
||||
}
|
||||
public void generalState(LinphoneCore lc, GeneralState state) {
|
||||
switch(state) {
|
||||
|
||||
case GSTATE_POWER_ON:
|
||||
if (state == GeneralState.GSTATE_POWER_ON) {
|
||||
mCall.setEnabled(!lc.isIncall());
|
||||
mHangup.setEnabled(!mCall.isEnabled());
|
||||
try{
|
||||
LinphoneService.instance().initFromConf();
|
||||
LinphoneService.instance().initFromConf();
|
||||
} catch (LinphoneConfigException ec) {
|
||||
Log.w(LinphoneService.TAG,"no valid settings found",ec);
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setMessage(getString(R.string.initial_config_error))
|
||||
.setCancelable(false)
|
||||
.setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
LinphoneActivity.instance().startprefActivity();
|
||||
}
|
||||
}).setNeutralButton(getString(R.string.no), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
dialog.cancel();
|
||||
|
||||
}
|
||||
}).setNegativeButton(getString(R.string.never_remind), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
mPref.edit().putBoolean(PREF_CHECK_CONFIG, true).commit();
|
||||
dialog.cancel();
|
||||
}
|
||||
});
|
||||
.setCancelable(false)
|
||||
.setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
LinphoneActivity.instance().startprefActivity();
|
||||
}
|
||||
}).setNeutralButton(getString(R.string.no), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
dialog.cancel();
|
||||
|
||||
}
|
||||
}).setNegativeButton(getString(R.string.never_remind), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
mPref.edit().putBoolean(PREF_CHECK_CONFIG, true).commit();
|
||||
dialog.cancel();
|
||||
}
|
||||
});
|
||||
if (mPref.getBoolean(PREF_CHECK_CONFIG, false) == false) {
|
||||
builder.create().show();
|
||||
}
|
||||
} catch (Exception e ) {
|
||||
Log.e(LinphoneService.TAG,"Cannot get initial config", e);
|
||||
}
|
||||
break;
|
||||
case GSTATE_REG_OK: {
|
||||
break;
|
||||
}
|
||||
case GSTATE_CALL_OUT_INVITE: {
|
||||
} else if (state == GeneralState.GSTATE_REG_OK) {
|
||||
//nop
|
||||
} else if (state == GeneralState.GSTATE_CALL_OUT_INVITE) {
|
||||
mWakeLock.acquire();
|
||||
enterIncalMode(lc);
|
||||
routeAudioToReceiver();
|
||||
break;
|
||||
}
|
||||
case GSTATE_CALL_IN_INVITE: {
|
||||
mDecline.setEnabled(true);
|
||||
routeAudioToSpeaker();
|
||||
break;
|
||||
}
|
||||
case GSTATE_CALL_IN_CONNECTED:
|
||||
case GSTATE_CALL_OUT_CONNECTED: {
|
||||
} else if (state == GeneralState.GSTATE_CALL_IN_INVITE) {
|
||||
callPending();
|
||||
} else if (state == GeneralState.GSTATE_CALL_IN_CONNECTED
|
||||
|| state == GeneralState.GSTATE_CALL_OUT_CONNECTED) {
|
||||
enterIncalMode(lc);
|
||||
break;
|
||||
}
|
||||
case GSTATE_CALL_ERROR: {
|
||||
} else if (state == GeneralState.GSTATE_CALL_ERROR) {
|
||||
if (mWakeLock.isHeld()) mWakeLock.release();
|
||||
Toast toast = Toast.makeText(this
|
||||
,String.format(getString(R.string.call_error),lc.getRemoteAddress())
|
||||
, Toast.LENGTH_LONG);
|
||||
toast.show();
|
||||
}
|
||||
case GSTATE_CALL_END: {
|
||||
} else if (state == GeneralState.GSTATE_CALL_END) {
|
||||
exitCallMode();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void inviteReceived(LinphoneCore lc, String from) {
|
||||
|
@ -487,5 +489,9 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
|
|||
mAudioManager.setSpeakerphoneOn(false);
|
||||
}
|
||||
}
|
||||
private void callPending() {
|
||||
mDecline.setEnabled(true);
|
||||
routeAudioToSpeaker();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ import org.linphone.core.LinphoneAddress;
|
|||
import org.linphone.core.LinphoneCallLog;
|
||||
import org.linphone.core.LinphoneCore;
|
||||
import org.linphone.core.LinphoneProxyConfig;
|
||||
import org.linphone.core.LinphoneCallLog.CallDirection;
|
||||
import org.linphone.core.CallDirection;
|
||||
|
||||
import android.app.ListActivity;
|
||||
import android.content.Context;
|
||||
|
@ -132,7 +132,7 @@ public class HistoryActivity extends ListActivity {
|
|||
ImageView lDirectionImageIn = (ImageView) lView.findViewById(R.id.history_cell_icon_in);
|
||||
ImageView lDirectionImageOut = (ImageView) lView.findViewById(R.id.history_cell_icon_out);
|
||||
|
||||
if (lLog.getDirection() == CallDirection.Callincoming) {
|
||||
if (lLog.getDirection() == CallDirection.Incoming) {
|
||||
lAddress = lLog.getFrom();
|
||||
lDirectionImageIn.setVisibility(View.VISIBLE);
|
||||
lDirectionImageOut.setVisibility(View.GONE);
|
||||
|
@ -150,7 +150,7 @@ public class HistoryActivity extends ListActivity {
|
|||
if (lProxyConfig != null && lProxyConfig.getDomain().equals(lAddress.getDomain())) {
|
||||
lDetailedName = lAddress.getUserName();
|
||||
} else {
|
||||
lDetailedName = lAddress.toUri();
|
||||
lDetailedName = lAddress.asStringUriOnly();
|
||||
}
|
||||
if (lDisplayName == null) {
|
||||
lFirstLineView.setText(lDetailedName);
|
||||
|
|
|
@ -94,7 +94,7 @@ public class LinphoneActivity extends TabActivity implements SensorEventListener
|
|||
Intent lHistoryItent = new Intent().setClass(this, HistoryActivity.class);
|
||||
|
||||
spec = lTabHost.newTabSpec("history").setIndicator(getString(R.string.tab_history),
|
||||
null)
|
||||
getResources().getDrawable(R.drawable.history_orange))
|
||||
.setContent(lHistoryItent);
|
||||
lTabHost.addTab(spec);
|
||||
|
||||
|
@ -103,7 +103,7 @@ public class LinphoneActivity extends TabActivity implements SensorEventListener
|
|||
|
||||
// Initialize a TabSpec for each tab and add it to the TabHost
|
||||
spec = lTabHost.newTabSpec("dialer").setIndicator(getString(R.string.tab_dialer),
|
||||
getResources().getDrawable(android.R.drawable.ic_menu_call))
|
||||
getResources().getDrawable(R.drawable.dialer_orange))
|
||||
.setContent(lDialerIntent);
|
||||
lTabHost.addTab(spec);
|
||||
|
||||
|
@ -111,7 +111,7 @@ public class LinphoneActivity extends TabActivity implements SensorEventListener
|
|||
Intent lContactItent = new Intent().setClass(this, ContactPickerActivity.class);
|
||||
|
||||
spec = lTabHost.newTabSpec("contact").setIndicator(getString(R.string.tab_contact),
|
||||
null)
|
||||
getResources().getDrawable(R.drawable.history_orange))
|
||||
.setContent(lContactItent);
|
||||
lTabHost.addTab(spec);
|
||||
|
||||
|
@ -135,9 +135,7 @@ public class LinphoneActivity extends TabActivity implements SensorEventListener
|
|||
} else {
|
||||
mAudioManager.setSpeakerphoneOn(false);
|
||||
}
|
||||
Intent intent = new Intent(Intent.ACTION_MAIN);
|
||||
intent.setClass(this, LinphoneService.class);
|
||||
stopService(intent);
|
||||
|
||||
theLinphoneActivity = null;
|
||||
}
|
||||
|
||||
|
@ -173,6 +171,9 @@ public class LinphoneActivity extends TabActivity implements SensorEventListener
|
|||
return true;
|
||||
case R.id.menu_exit:
|
||||
finish();
|
||||
Intent exitIntent = new Intent(Intent.ACTION_MAIN);
|
||||
exitIntent.setClass(this, LinphoneService.class);
|
||||
stopService(exitIntent);
|
||||
break;
|
||||
case R.id.menu_about:
|
||||
Intent intent = new Intent(Intent.ACTION_MAIN);
|
||||
|
|
|
@ -35,6 +35,9 @@ import org.linphone.core.LinphoneProxyConfig;
|
|||
import org.linphone.core.LinphoneCore.GeneralState;
|
||||
|
||||
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.Service;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
@ -58,7 +61,18 @@ public class LinphoneService extends Service implements LinphoneCoreListener {
|
|||
private LinphoneCore mLinphoneCore;
|
||||
private SharedPreferences mPref;
|
||||
Timer mTimer = new Timer("Linphone scheduler");
|
||||
|
||||
|
||||
NotificationManager mNotificationManager;
|
||||
Notification mNotification;
|
||||
PendingIntent mNofificationContentIntent;
|
||||
final static int NOTIFICATION_ID=1;
|
||||
final String NOTIFICATION_TITLE = "Linphone";
|
||||
|
||||
final int IC_LEVEL_OFFLINE=3;
|
||||
final int IC_LEVEL_ORANGE=0;
|
||||
final int IC_LEVEL_GREEN=1;
|
||||
final int IC_LEVEL_RED=2;
|
||||
|
||||
private Handler mHandler = new Handler() ;
|
||||
static boolean isready() {
|
||||
return (theLinphone!=null);
|
||||
|
@ -75,14 +89,24 @@ public class LinphoneService extends Service implements LinphoneCoreListener {
|
|||
public void onCreate() {
|
||||
super.onCreate();
|
||||
theLinphone = this;
|
||||
|
||||
|
||||
mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
mNotification = new Notification(R.drawable.status_level
|
||||
, ""
|
||||
, System.currentTimeMillis());
|
||||
mNotification.iconLevel=IC_LEVEL_ORANGE;
|
||||
mNotification.flags |= Notification.FLAG_ONGOING_EVENT;
|
||||
Intent notificationIntent = new Intent(this, LinphoneActivity.class);
|
||||
mNofificationContentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
|
||||
mNotification.setLatestEventInfo(this, NOTIFICATION_TITLE,"", mNofificationContentIntent);
|
||||
mNotificationManager.notify(NOTIFICATION_ID, mNotification);
|
||||
mPref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||
try {
|
||||
copyAssetsFromPackage();
|
||||
|
||||
mLinphoneCore = LinphoneCoreFactory.instance().createLinphoneCore( this
|
||||
, new File(LINPHONE_RC)
|
||||
, new File(LINPHONE_FACTORY_RC)
|
||||
, LINPHONE_RC
|
||||
, LINPHONE_FACTORY_RC
|
||||
, null);
|
||||
|
||||
mLinphoneCore.setSoftPlayLevel(3);
|
||||
|
@ -101,6 +125,8 @@ public class LinphoneService extends Service implements LinphoneCoreListener {
|
|||
};
|
||||
|
||||
mTimer.scheduleAtFixedRate(lTask, 0, 100);
|
||||
|
||||
|
||||
}
|
||||
catch (Exception e) {
|
||||
Log.e(TAG,"Cannot start linphone",e);
|
||||
|
@ -166,20 +192,52 @@ public class LinphoneService extends Service implements LinphoneCoreListener {
|
|||
}
|
||||
public void generalState(final LinphoneCore lc, final LinphoneCore.GeneralState state) {
|
||||
Log.i(TAG, "new state ["+state+"]");
|
||||
if (state == GeneralState.GSTATE_POWER_OFF) {
|
||||
//just exist
|
||||
//System.exit(0);
|
||||
if (state == GeneralState.GSTATE_POWER_ON) {
|
||||
mNotification.iconLevel=IC_LEVEL_OFFLINE;
|
||||
mNotification.when=System.currentTimeMillis();
|
||||
mNotification.setLatestEventInfo(this
|
||||
, NOTIFICATION_TITLE
|
||||
,getString(R.string.notification_started)
|
||||
, mNofificationContentIntent);
|
||||
mNotificationManager.notify(NOTIFICATION_ID, mNotification);
|
||||
|
||||
}
|
||||
if (state == GeneralState.GSTATE_REG_OK && lc.getDefaultProxyConfig().isRegistered()) {
|
||||
mNotification.iconLevel=IC_LEVEL_ORANGE;
|
||||
mNotification.when=System.currentTimeMillis();
|
||||
mNotification.setLatestEventInfo(this
|
||||
, NOTIFICATION_TITLE
|
||||
,String.format(getString(R.string.notification_registered),lc.getDefaultProxyConfig().getIdentity())
|
||||
, mNofificationContentIntent);
|
||||
mNotificationManager.notify(NOTIFICATION_ID, mNotification);
|
||||
}
|
||||
if (state == GeneralState.GSTATE_REG_FAILED ) {
|
||||
mNotification.iconLevel=IC_LEVEL_OFFLINE;
|
||||
mNotification.when=System.currentTimeMillis();
|
||||
mNotification.setLatestEventInfo(this
|
||||
, NOTIFICATION_TITLE
|
||||
,String.format(getString(R.string.notification_register_failure),lc.getDefaultProxyConfig().getIdentity())
|
||||
, mNofificationContentIntent);
|
||||
mNotificationManager.notify(NOTIFICATION_ID, mNotification);
|
||||
}
|
||||
|
||||
if (DialerActivity.getDialer()!=null) {
|
||||
mHandler.post(new Runnable() {
|
||||
public void run() {
|
||||
DialerActivity.getDialer().generalState(lc,state);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (state == GeneralState.GSTATE_CALL_IN_INVITE) {
|
||||
//wakeup linphone
|
||||
Intent lIntent = new Intent();
|
||||
lIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
lIntent.setClass(this, LinphoneActivity.class);
|
||||
startActivity(lIntent);
|
||||
}
|
||||
}
|
||||
public void inviteReceived(LinphoneCore lc, String from) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
}
|
||||
public void show(LinphoneCore lc) {
|
||||
|
@ -213,7 +271,7 @@ public class LinphoneService extends Service implements LinphoneCoreListener {
|
|||
|
||||
//auth
|
||||
mLinphoneCore.clearAuthInfos();
|
||||
LinphoneAuthInfo lAuthInfo = LinphoneCoreFactory.instance().createAuthInfo(lUserName, lPasswd);
|
||||
LinphoneAuthInfo lAuthInfo = LinphoneCoreFactory.instance().createAuthInfo(lUserName, lPasswd,null);
|
||||
mLinphoneCore.addAuthInfo(lAuthInfo);
|
||||
|
||||
|
||||
|
@ -276,6 +334,7 @@ public class LinphoneService extends Service implements LinphoneCoreListener {
|
|||
mTimer.cancel();
|
||||
mLinphoneCore.destroy();
|
||||
theLinphone=null;
|
||||
mNotificationManager.cancel(NOTIFICATION_ID);
|
||||
}
|
||||
|
||||
}
|
|
@ -66,5 +66,32 @@ public class LinphoneAddressImpl implements LinphoneAddress {
|
|||
public void setDisplayName(String name) {
|
||||
setDisplayName(nativePtr,name);
|
||||
}
|
||||
public String asString() {
|
||||
return toString();
|
||||
}
|
||||
public String asStringUriOnly() {
|
||||
return toUri(nativePtr);
|
||||
}
|
||||
public void clean() {
|
||||
throw new RuntimeException("Not implemented");
|
||||
}
|
||||
public String getPort() {
|
||||
return String.valueOf(getPortInt());
|
||||
}
|
||||
public int getPortInt() {
|
||||
return getPortInt();
|
||||
}
|
||||
public void setDomain(String domain) {
|
||||
throw new RuntimeException("Not implemented");
|
||||
}
|
||||
public void setPort(String port) {
|
||||
throw new RuntimeException("Not implemented");
|
||||
}
|
||||
public void setPortInt(int port) {
|
||||
throw new RuntimeException("Not implemented");
|
||||
}
|
||||
public void setUserName(String username) {
|
||||
throw new RuntimeException("Not implemented");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,8 +22,8 @@ class LinphoneAuthInfoImpl implements LinphoneAuthInfo {
|
|||
protected final long nativePtr;
|
||||
private native long newLinphoneAuthInfo(String username, String userid, String passwd, String ha1,String realm);
|
||||
private native void delete(long ptr);
|
||||
protected LinphoneAuthInfoImpl(String username,String password) {
|
||||
nativePtr = newLinphoneAuthInfo(username,null,password,null,null);
|
||||
protected LinphoneAuthInfoImpl(String username,String password, String realm) {
|
||||
nativePtr = newLinphoneAuthInfo(username,null,password,null,realm);
|
||||
}
|
||||
protected void finalize() throws Throwable {
|
||||
delete(nativePtr);
|
||||
|
|
|
@ -32,7 +32,7 @@ class LinphoneCallLogImpl implements LinphoneCallLog {
|
|||
|
||||
|
||||
public CallDirection getDirection() {
|
||||
return isIncoming(nativePtr)?CallDirection.Callincoming:CallDirection.CallOutgoing;
|
||||
return isIncoming(nativePtr)?CallDirection.Incoming:CallDirection.Outgoing;
|
||||
}
|
||||
|
||||
public LinphoneAddress getFrom() {
|
||||
|
|
65
src/org/linphone/core/LinphoneCoreFactoryImpl.java
Normal file
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
LinphoneCoreFactoryImpl.java
|
||||
Copyright (C) 2010 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.core;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory {
|
||||
|
||||
static {
|
||||
System.loadLibrary("linphone");
|
||||
}
|
||||
@Override
|
||||
public LinphoneAuthInfo createAuthInfo(String username, String password,
|
||||
String realm) {
|
||||
return new LinphoneAuthInfoImpl(username,password,realm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LinphoneAddress createLinphoneAddress(String username,
|
||||
String domain, String displayName) {
|
||||
return new LinphoneAddressImpl(username,domain,displayName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LinphoneAddress createLinphoneAddress(String address) {
|
||||
throw new RuntimeException("Not implemeneted yet");
|
||||
}
|
||||
|
||||
@Override
|
||||
public LinphoneCore createLinphoneCore(LinphoneCoreListener listener,
|
||||
String userConfig, String factoryConfig, Object userdata)
|
||||
throws LinphoneCoreException {
|
||||
try {
|
||||
return new LinphoneCoreImpl(listener,new File(userConfig),new File(factoryConfig),userdata);
|
||||
} catch (IOException e) {
|
||||
throw new LinphoneCoreException("Cannot create LinphoneCore",e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public LinphoneProxyConfig createProxyConfig(String identity, String proxy,
|
||||
String route, boolean enableRegister) throws LinphoneCoreException {
|
||||
return new LinphoneProxyConfigImpl(identity,proxy,route,enableRegister);
|
||||
}
|
||||
|
||||
@Override
|
||||
public native void setDebugMode(boolean enable);
|
||||
}
|
|
@ -20,8 +20,7 @@ package org.linphone.core;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
|
||||
class LinphoneCoreImpl implements LinphoneCore {
|
||||
|
@ -139,9 +138,9 @@ class LinphoneCoreImpl implements LinphoneCore {
|
|||
acceptCall(nativePtr);
|
||||
|
||||
}
|
||||
public synchronized List<LinphoneCallLog> getCallLogs() {
|
||||
public synchronized Vector<LinphoneCallLog> getCallLogs() {
|
||||
isValid();
|
||||
List<LinphoneCallLog> logs = new ArrayList<LinphoneCallLog>();
|
||||
Vector<LinphoneCallLog> logs = new Vector<LinphoneCallLog>();
|
||||
for (int i=0;i < getNumberOfCallLogs(nativePtr);i++) {
|
||||
logs.add(new LinphoneCallLogImpl(getCallLog(nativePtr, i)));
|
||||
}
|
||||
|
|
|
@ -52,10 +52,15 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig {
|
|||
private native void done(long ptr);
|
||||
|
||||
private native void setIdentity(long ptr,String identity);
|
||||
private native String getIdentity(long ptr);
|
||||
private native int setProxy(long ptr,String proxy);
|
||||
private native String getProxy(long ptr);
|
||||
|
||||
|
||||
private native void enableRegister(long ptr,boolean value);
|
||||
private native boolean isRegisterEnabled(long ptr);
|
||||
|
||||
private native boolean isRegistered(long ptr);
|
||||
private native void setDialPrefix(long ptr, String prefix);
|
||||
|
||||
private native String normalizePhoneNumber(long ptr,String number);
|
||||
|
@ -98,18 +103,15 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig {
|
|||
setDialEscapePlus(nativePtr,value);
|
||||
}
|
||||
public String getIdentity() {
|
||||
throw new RuntimeException("not implemeneted yet");
|
||||
return getIdentity(nativePtr);
|
||||
}
|
||||
public String getProxy() {
|
||||
// TODO Auto-generated method stub
|
||||
throw new RuntimeException("not implemeneted yet");
|
||||
return getProxy(nativePtr);
|
||||
}
|
||||
public boolean isRegistered() {
|
||||
// TODO Auto-generated method stub
|
||||
throw new RuntimeException("not implemeneted yet");
|
||||
return isRegistered(nativePtr);
|
||||
}
|
||||
public boolean registerEnabled() {
|
||||
// TODO Auto-generated method stub
|
||||
throw new RuntimeException("not implemeneted yet");
|
||||
return isRegisterEnabled(nativePtr);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 572b696529119810350e083cec72e59b2d3e75d5
|
||||
Subproject commit ec20c545196905108f76a78190b8273f1d3e698e
|