Display an icon during a video call to show the signal strength

This commit is contained in:
Sylvain Berfini 2011-09-30 13:54:06 +02:00
parent 68a8c67add
commit bd71366e11
8 changed files with 73 additions and 1 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 587 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 597 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 595 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 594 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 532 B

9
res/layout-land/videocall.xml Normal file → Executable file
View file

@ -25,5 +25,14 @@ android:layout_alignParentRight="true"
android:layout_marginTop="15dip"
android:layout_marginRight="15dip" >
</ImageView>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/QoS"
android:src="@drawable/stat_sys_signal_0"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true">
</ImageView>
</RelativeLayout>

10
res/layout/videocall.xml Normal file → Executable file
View file

@ -26,5 +26,13 @@ android:layout_marginBottom="15dip"
android:layout_marginRight="15dip" >
</ImageView>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/QoS"
android:src="@drawable/stat_sys_signal_0"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true" >
</ImageView>
</RelativeLayout>

55
src/org/linphone/VideoCallActivity.java Normal file → Executable file
View file

@ -23,11 +23,15 @@ package org.linphone;
import org.linphone.core.LinphoneCall;
import org.linphone.core.Log;
import org.linphone.mediastream.video.AndroidVideoWindowImpl;
import org.linphone.mediastream.video.capture.AndroidVideoApi5JniWrapper;
import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration;
import android.content.Context;
import android.hardware.Camera;
import android.hardware.Camera.CameraInfo;
import android.opengl.GLSurfaceView;
import android.os.Bundle;
import android.os.Handler;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
import android.view.Menu;
@ -36,6 +40,8 @@ import android.view.MenuItem;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
/**
* For Android SDK >= 5
@ -47,6 +53,7 @@ public class VideoCallActivity extends SoftVolumeActivity {
private SurfaceView mVideoCaptureViewReady;
public static boolean launched = false;
private WakeLock mWakeLock;
private Handler refreshHandler = new Handler();
AndroidVideoWindowImpl androidVideoWindowImpl;
@ -111,6 +118,54 @@ public class VideoCallActivity extends SoftVolumeActivity {
PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
mWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK|PowerManager.ON_AFTER_RELEASE,Log.TAG);
mWakeLock.acquire();
Runnable runnable = new Runnable() {
public void run() {
while (launched && LinphoneManager.getLc().isIncall())
{
refreshHandler.post(new Runnable() {
public void run() {
int oldQuality = 0;
float newQuality = LinphoneManager.getLc().getCurrentCall().getCurrentQuality();
if ((int) newQuality != oldQuality)
updateQualityOfSignalIcon(newQuality);
}
});
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
};
new Thread(runnable).start();
}
void updateQualityOfSignalIcon(float quality)
{
ImageView qos = (ImageView) findViewById(R.id.QoS);
if (quality >= 4) // Good Quality
{
qos.setImageDrawable(getResources().getDrawable(R.drawable.stat_sys_signal_4));
}
else if (quality >= 3) // Average quality
{
qos.setImageDrawable(getResources().getDrawable(R.drawable.stat_sys_signal_3));
}
else if (quality >= 2) // Low quality
{
qos.setImageDrawable(getResources().getDrawable(R.drawable.stat_sys_signal_2));
}
else if (quality >= 1) // Very low quality
{
qos.setImageDrawable(getResources().getDrawable(R.drawable.stat_sys_signal_1));
}
else // Worst quality
{
qos.setImageDrawable(getResources().getDrawable(R.drawable.stat_sys_signal_0));
}
}
void updatePreview(boolean cameraCaptureEnabled) {