add proxymity sensor
This commit is contained in:
parent
ec30570366
commit
0c1705227d
6 changed files with 63 additions and 27 deletions
|
@ -4,6 +4,9 @@
|
|||
android:versionCode="1"
|
||||
android:versionName="1.0">
|
||||
<application android:icon="@drawable/linphone2" android:label="@string/app_name" android:debuggable = "true">
|
||||
|
||||
<uses-sdk android:minSdkVersion="3" />
|
||||
|
||||
<activity android:name=".LinphoneActivity"
|
||||
android:label="@string/app_name"
|
||||
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.READ_CONTACTS"/>
|
||||
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||
|
||||
</manifest>
|
|
@ -1,3 +1,4 @@
|
|||
APP_PROJECT_PATH := $(call my-dir)/
|
||||
APP_MODULES :=libspeex libgsm libortp libosip2 libeXosip2 libmediastreamer2 libmsandroidsnd liblinphone
|
||||
APP_BUILD_SCRIPT:=$(call my-dir)/../linphone-builder/android/Android.mk
|
||||
APP_PLATFORM := android-3
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
# "build.properties", and override values to adapt the script to your
|
||||
# project structure.
|
||||
|
||||
# Project target.
|
||||
target=android-4
|
||||
# Indicates whether an apk should be generated for each density.
|
||||
split.density=false
|
||||
# Project target.
|
||||
target=android-7
|
||||
|
|
|
@ -1,21 +1,19 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@android:id/tabhost"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
><!-- android:padding="5dp"-->
|
||||
<TabWidget
|
||||
android:id="@android:id/tabs"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
<FrameLayout
|
||||
android:id="@android:id/tabcontent"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"/>
|
||||
<!-- android:padding="5dp" /-->
|
||||
</LinearLayout>
|
||||
</TabHost>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/main_frame" android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
<TabHost android:id="@android:id/tabhost" android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
<LinearLayout android:orientation="vertical"
|
||||
android:layout_width="fill_parent" android:layout_height="fill_parent">
|
||||
<!--
|
||||
android:padding="5dp"
|
||||
-->
|
||||
<TabWidget android:id="@android:id/tabs"
|
||||
android:layout_width="fill_parent" android:layout_height="wrap_content" />
|
||||
<FrameLayout android:id="@android:id/tabcontent"
|
||||
android:layout_width="fill_parent" android:layout_height="fill_parent" />
|
||||
</LinearLayout>
|
||||
|
||||
</TabHost>
|
||||
</FrameLayout>
|
|
@ -230,6 +230,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
|
|||
} else {
|
||||
mAudioManager.setSpeakerphoneOn(false);
|
||||
}
|
||||
setVolumeControlStream(AudioManager.STREAM_VOICE_CALL);
|
||||
break;
|
||||
}
|
||||
case GSTATE_CALL_ERROR: {
|
||||
|
@ -256,7 +257,8 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
|
|||
|
||||
private void exitCallMode() {
|
||||
mCall.setEnabled(true);
|
||||
mHangup.setEnabled(false);
|
||||
mHangup.setEnabled(false);
|
||||
setVolumeControlStream(AudioManager.USE_DEFAULT_STREAM_TYPE);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,11 +19,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
package org.linphone;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.TabActivity;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
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.os.Build;
|
||||
import android.os.Bundle;
|
||||
|
@ -31,13 +37,17 @@ import android.util.Log;
|
|||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.TabHost;
|
||||
|
||||
public class LinphoneActivity extends TabActivity {
|
||||
public class LinphoneActivity extends TabActivity implements SensorEventListener {
|
||||
public static String DIALER_TAB = "dialer";
|
||||
private AudioManager mAudioManager;
|
||||
private static LinphoneActivity theLinphoneActivity;
|
||||
|
||||
private SensorManager mSensorManager;
|
||||
private FrameLayout mMainFrame;
|
||||
protected static LinphoneActivity instance()
|
||||
{
|
||||
if (theLinphoneActivity == null) {
|
||||
|
@ -51,11 +61,16 @@ public class LinphoneActivity extends TabActivity {
|
|||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.main);
|
||||
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));
|
||||
|
||||
TabHost lTabHost = getTabHost(); // The activity TabHost
|
||||
TabHost lTabHost = getTabHost(); // The activity TabHost
|
||||
TabHost.TabSpec spec; // Reusable TabSpec for each tab
|
||||
|
||||
|
||||
|
@ -165,5 +180,21 @@ public class LinphoneActivity extends TabActivity {
|
|||
});
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue