add proxymity sensor

This commit is contained in:
Jehan Monnier 2010-03-10 10:11:45 +01:00
parent ec30570366
commit 0c1705227d
6 changed files with 63 additions and 27 deletions

View file

@ -4,6 +4,9 @@
android:versionCode="1" android:versionCode="1"
android:versionName="1.0"> android:versionName="1.0">
<application android:icon="@drawable/linphone2" android:label="@string/app_name" android:debuggable = "true"> <application android:icon="@drawable/linphone2" android:label="@string/app_name" android:debuggable = "true">
<uses-sdk android:minSdkVersion="3" />
<activity android:name=".LinphoneActivity" <activity android:name=".LinphoneActivity"
android:label="@string/app_name" android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar" android:theme="@android:style/Theme.NoTitleBar"
@ -49,5 +52,6 @@
<uses-permission android:name="android.permission.RECORD_AUDIO"></uses-permission> <uses-permission android:name="android.permission.RECORD_AUDIO"></uses-permission>
<uses-permission android:name="android.permission.READ_CONTACTS"/> <uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/> <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
</manifest> </manifest>

View file

@ -1,3 +1,4 @@
APP_PROJECT_PATH := $(call my-dir)/ APP_PROJECT_PATH := $(call my-dir)/
APP_MODULES :=libspeex libgsm libortp libosip2 libeXosip2 libmediastreamer2 libmsandroidsnd liblinphone APP_MODULES :=libspeex libgsm libortp libosip2 libeXosip2 libmediastreamer2 libmsandroidsnd liblinphone
APP_BUILD_SCRIPT:=$(call my-dir)/../linphone-builder/android/Android.mk APP_BUILD_SCRIPT:=$(call my-dir)/../linphone-builder/android/Android.mk
APP_PLATFORM := android-3

View file

@ -7,7 +7,7 @@
# "build.properties", and override values to adapt the script to your # "build.properties", and override values to adapt the script to your
# project structure. # project structure.
# Project target.
target=android-4
# Indicates whether an apk should be generated for each density. # Indicates whether an apk should be generated for each density.
split.density=false split.density=false
# Project target.
target=android-7

View file

@ -1,21 +1,19 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost" android:id="@+id/main_frame" android:layout_width="fill_parent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"> android:layout_height="fill_parent">
<LinearLayout <TabHost android:id="@android:id/tabhost" android:layout_width="fill_parent"
android:orientation="vertical" android:layout_height="fill_parent">
android:layout_width="fill_parent" <LinearLayout android:orientation="vertical"
android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_height="fill_parent">
><!-- android:padding="5dp"--> <!--
<TabWidget android:padding="5dp"
android:id="@android:id/tabs" -->
android:layout_width="fill_parent" <TabWidget android:id="@android:id/tabs"
android:layout_height="wrap_content" /> android:layout_width="fill_parent" android:layout_height="wrap_content" />
<FrameLayout <FrameLayout android:id="@android:id/tabcontent"
android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="fill_parent" />
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
<!-- android:padding="5dp" /-->
</LinearLayout> </LinearLayout>
</TabHost>
</TabHost>
</FrameLayout>

View file

@ -230,6 +230,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
} else { } else {
mAudioManager.setSpeakerphoneOn(false); mAudioManager.setSpeakerphoneOn(false);
} }
setVolumeControlStream(AudioManager.STREAM_VOICE_CALL);
break; break;
} }
case GSTATE_CALL_ERROR: { case GSTATE_CALL_ERROR: {
@ -257,6 +258,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
private void exitCallMode() { private void exitCallMode() {
mCall.setEnabled(true); mCall.setEnabled(true);
mHangup.setEnabled(false); mHangup.setEnabled(false);
setVolumeControlStream(AudioManager.USE_DEFAULT_STREAM_TYPE);
} }
} }

View file

@ -19,11 +19,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
package org.linphone; package org.linphone;
import java.util.List;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.TabActivity; import android.app.TabActivity;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.media.AudioManager; import android.media.AudioManager;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
@ -31,13 +37,17 @@ import android.util.Log;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.TabHost; import android.widget.TabHost;
public class LinphoneActivity extends TabActivity { public class LinphoneActivity extends TabActivity implements SensorEventListener {
public static String DIALER_TAB = "dialer"; public static String DIALER_TAB = "dialer";
private AudioManager mAudioManager; private AudioManager mAudioManager;
private static LinphoneActivity theLinphoneActivity; private static LinphoneActivity theLinphoneActivity;
private SensorManager mSensorManager;
private FrameLayout mMainFrame;
protected static LinphoneActivity instance() protected static LinphoneActivity instance()
{ {
if (theLinphoneActivity == null) { if (theLinphoneActivity == null) {
@ -51,8 +61,13 @@ public class LinphoneActivity extends TabActivity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.main); setContentView(R.layout.main);
theLinphoneActivity = this; theLinphoneActivity = this;
mMainFrame = (FrameLayout) findViewById(R.id.main_frame);
mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
List<Sensor> lSensorList = mSensorManager.getSensorList(Sensor.TYPE_PROXIMITY);
if (lSensorList.size() >0) {
mSensorManager.registerListener(this,lSensorList.get(0),SensorManager.SENSOR_DELAY_UI);
}
mAudioManager = ((AudioManager)getSystemService(Context.AUDIO_SERVICE)); mAudioManager = ((AudioManager)getSystemService(Context.AUDIO_SERVICE));
TabHost lTabHost = getTabHost(); // The activity TabHost TabHost lTabHost = getTabHost(); // The activity TabHost
@ -166,4 +181,20 @@ public class LinphoneActivity extends TabActivity {
builder.create().show(); builder.create().show();
} }
public void onAccuracyChanged(Sensor sensor, int accuracy) {
//nop
}
public void onSensorChanged(SensorEvent event) {
WindowManager.LayoutParams lAttrs =getWindow().getAttributes();
if (event.values[0] == 0) {
lAttrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
mMainFrame.setVisibility(View.INVISIBLE);
} else if (event.values[0] == 1) {
lAttrs.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
mMainFrame.setVisibility(View.VISIBLE);
}
getWindow().setAttributes(lAttrs);
}
} }