Interace improved

This commit is contained in:
Sylvain Berfini 2012-08-06 13:09:51 +02:00
parent 43005d088f
commit 5ecf57aa9e
15 changed files with 223 additions and 69 deletions

View file

@ -28,7 +28,7 @@
<activity android:name="org.linphone.LinphoneLauncherActivity"
android:label="@string/app_name"
android:windowSoftInputMode="adjustPan"
android:theme="@android:style/Theme.NoTitleBar">
android:theme="@style/NoTitle">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
@ -51,7 +51,7 @@
</activity>
<activity android:name="org.linphone.LinphoneActivity"
android:theme="@android:style/Theme.NoTitleBar"
android:theme="@style/NoTitle"
android:screenOrientation="nosensor"
android:launchMode="singleTask">
<intent-filter>
@ -61,7 +61,7 @@
</activity>
<activity android:name="org.linphone.IncomingCallActivity"
android:theme="@android:style/Theme.NoTitleBar"
android:theme="@style/NoTitle"
android:noHistory="true"
android:launchMode="singleTop"
android:screenOrientation="nosensor">
@ -71,7 +71,7 @@
</activity>
<activity android:name="org.linphone.InCallActivity"
android:theme="@android:style/Theme.NoTitleBar"
android:theme="@style/FullScreen"
android:noHistory="true"
android:launchMode="singleInstance">
<intent-filter>
@ -80,18 +80,18 @@
</activity>
<activity android:name=".AccountPreferencesActivity"
android:theme="@android:style/Theme.NoTitleBar">
android:theme="@style/NoTitle">
</activity>
<activity android:name=".PreferencesActivity"
android:theme="@android:style/Theme.NoTitleBar">
android:theme="@style/NoTitle">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
<activity android:name=".setup.SetupActivity"
android:theme="@android:style/Theme.NoTitleBar"
android:theme="@style/NoTitle"
android:screenOrientation="nosensor">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

View file

@ -5,35 +5,28 @@
android:layout_width="match_parent"
android:layout_height="match_parent" >
<FrameLayout
<LinearLayout
android:id="@+id/fragmentContainer"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="@+id/fragmentContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:paddingTop="20dp" />
<fragment
android:id="@+id/status"
android:name="org.linphone.StatusFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:layout="@layout/status" />
</FrameLayout>
android:layout_height="match_parent"
android:orientation="horizontal" />
<ImageView
android:id="@+id/switchCamera"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:contentDescription="@string/content_description_switch_camera"
android:paddingTop="20dp"
android:layout_marginTop="20dp"
android:src="@drawable/switch_camera"
android:visibility="gone" />
android:visibility="invisible" />
<fragment
android:id="@+id/status"
android:name="org.linphone.StatusFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:layout="@layout/status" />
<!-- TODO Add numpad -->
@ -42,6 +35,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:visibility="gone"
android:orientation="vertical" >
<LinearLayout

View file

@ -4,37 +4,30 @@
android:id="@+id/topLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
<LinearLayout
android:id="@+id/fragmentContainer"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="@+id/fragmentContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:paddingTop="20dp" />
<fragment
android:id="@+id/status"
android:name="org.linphone.StatusFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:layout="@layout/status" />
</FrameLayout>
android:layout_height="match_parent"
android:orientation="horizontal" />
<ImageView
android:id="@+id/switchCamera"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:contentDescription="@string/content_description_switch_camera"
android:paddingTop="20dp"
android:src="@drawable/switch_camera"
android:visibility="invisible" />
android:layout_marginTop="20dp"
android:visibility="invisible"
android:src="@drawable/switch_camera" />
<fragment
android:id="@+id/status"
android:name="org.linphone.StatusFragment"
android:layout_alignParentTop="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:layout="@layout/status" />
<org.linphone.ui.Numpad
android:id="@+id/numpad"
@ -50,6 +43,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:visibility="gone"
android:orientation="vertical" >
<LinearLayout

View file

@ -29,6 +29,7 @@
android:paddingBottom="10dp">
<ImageView
android:id="@+id/background"
android:layout_width="match_parent"
android:layout_height="20dp"
android:scaleType="fitXY"
@ -37,6 +38,7 @@
<TextView
android:id="@+id/statusText"
android:text="@string/status_not_connected"
android:textColor="@android:color/white"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
@ -78,6 +80,7 @@
<TextView
android:id="@+id/exit"
android:text="EXIT"
android:textColor="@android:color/white"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"

8
res/values/styles.xml Normal file
View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Default" parent="android:Theme" />
<style name="NoTitle" parent="android:Theme.NoTitleBar" />
<style name="FullScreen" parent="android:Theme.NoTitleBar.Fullscreen" />
</resources>

View file

@ -22,6 +22,7 @@ import java.util.List;
import org.linphone.LinphoneSimpleListener.LinphoneOnCallEncryptionChangedListener;
import org.linphone.LinphoneSimpleListener.LinphoneOnCallStateChangedListener;
import org.linphone.compatibility.Compatibility;
import org.linphone.core.LinphoneCall;
import org.linphone.core.LinphoneCall.State;
import org.linphone.core.LinphoneCallParams;
@ -82,6 +83,7 @@ public class InCallActivity extends FragmentActivity implements
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
instance = this;
Compatibility.setFullScreen(getWindow());
setContentView(R.layout.incall);
isVideoEnabled = getIntent().getExtras() != null && getIntent().getExtras().getBoolean("VideoEnabled");
@ -151,8 +153,8 @@ public class InCallActivity extends FragmentActivity implements
dialer.setEnabled(false);
numpad = (Numpad) findViewById(R.id.numpad);
switchCamera = (ImageView) findViewById(R.id.switchCamera);
switchCamera.setOnClickListener(this);
switchCamera = (ImageView) findViewById(R.id.switchCamera);
switchCamera.setOnClickListener(this);
mControlsLayout = (LinearLayout) findViewById(R.id.menu);
@ -300,6 +302,10 @@ public class InCallActivity extends FragmentActivity implements
}
private void replaceFragmentAudioByVideo() {
//Hiding controls to let displayVideoCallControlsIfHidden add them plus the callback
mControlsLayout.setVisibility(View.GONE);
switchCamera.setVisibility(View.INVISIBLE);
videoCallFragment = new VideoCallFragment();
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
@ -308,10 +314,6 @@ public class InCallActivity extends FragmentActivity implements
transaction.commitAllowingStateLoss();
} catch (Exception e) {
}
if (AndroidCameraConfiguration.retrieveCameras().length > 1) {
switchCamera.setVisibility(View.VISIBLE);
}
}
private void toogleMicro() {
@ -394,7 +396,9 @@ public class InCallActivity extends FragmentActivity implements
}
});
mControlsLayout.startAnimation(animation);
switchCamera.startAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_in_top_to_bottom));
if (AndroidCameraConfiguration.retrieveCameras().length > 1) {
switchCamera.startAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_in_top_to_bottom));
}
}
resetControlsHidingCallBack();
@ -442,7 +446,9 @@ public class InCallActivity extends FragmentActivity implements
}
});
mControlsLayout.startAnimation(animation);
switchCamera.startAnimation(AnimationUtils.loadAnimation(instance, R.anim.slide_out_bottom_to_top));
if (AndroidCameraConfiguration.retrieveCameras().length > 1) {
switchCamera.startAnimation(AnimationUtils.loadAnimation(instance, R.anim.slide_out_bottom_to_top));
}
}
}
}, SECONDS_BEFORE_HIDING_CONTROLS);

View file

@ -50,7 +50,7 @@ public class IncomingCallActivity extends Activity implements LinphoneOnCallStat
private AvatarWithShadow mPictureView;
private LinphoneCall mCall;
private LinphoneSliders mIncomingCallWidget;
@Override
protected void onCreate(Bundle savedInstanceState) {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
@ -61,8 +61,7 @@ public class IncomingCallActivity extends Activity implements LinphoneOnCallStat
mPictureView = (AvatarWithShadow) findViewById(R.id.incoming_picture);
// set this flag so this activity will stay in front of the keyguard
int flags = WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED;
flags |= WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD;
int flags = WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON;
getWindow().addFlags(flags);
@ -70,7 +69,6 @@ public class IncomingCallActivity extends Activity implements LinphoneOnCallStat
mIncomingCallWidget = (LinphoneSliders) findViewById(R.id.sliding_widget);
mIncomingCallWidget.setOnTriggerListener(this);
super.onCreate(savedInstanceState);
}

View file

@ -1402,6 +1402,5 @@ public final class LinphoneManager implements LinphoneCoreListener {
@Override
public void notifyReceived(LinphoneCore lc, LinphoneCall call,
LinphoneAddress from, byte[] event) {
}
}

View file

@ -51,7 +51,7 @@ public class StatusFragment extends Fragment {
private Handler mHandler = new Handler();
private Handler refreshHandler = new Handler();
private TextView statusText, exit;
private ImageView statusLed, callQuality, encryption;
private ImageView statusLed, callQuality, encryption, background;
private ListView sliderContent;
private SlidingDrawer drawer;
// private LinearLayout allAccountsLed;
@ -67,6 +67,7 @@ public class StatusFragment extends Fragment {
statusLed = (ImageView) view.findViewById(R.id.statusLed);
callQuality = (ImageView) view.findViewById(R.id.callQuality);
encryption = (ImageView) view.findViewById(R.id.encryption);
background = (ImageView) view.findViewById(R.id.background);
// allAccountsLed = (LinearLayout) view.findViewById(R.id.moreStatusLed);
drawer = (SlidingDrawer) view.findViewById(R.id.statusBar);
@ -299,6 +300,7 @@ public class StatusFragment extends Fragment {
MediaEncryption mediaEncryption = call.getCurrentParamsCopy().getMediaEncryption();
exit.setVisibility(View.GONE);
background.setVisibility(View.GONE);
encryption.setVisibility(View.VISIBLE);
if (mediaEncryption == MediaEncryption.SRTP || (mediaEncryption == MediaEncryption.ZRTP && call.isAuthenticationTokenVerified())) {
@ -310,6 +312,7 @@ public class StatusFragment extends Fragment {
}
} else {
exit.setVisibility(View.VISIBLE);
background.setVisibility(View.VISIBLE);
}
}

View file

@ -7,6 +7,9 @@ import android.app.Notification;
import android.app.PendingIntent;
import android.content.Context;
import android.graphics.Bitmap;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
/*
ApiElevenPlus.java
@ -80,4 +83,13 @@ public class ApiElevenPlus {
Context context, String title, String content, PendingIntent intent) {
notif.setLatestEventInfo(context, title, content, intent);
}
@SuppressWarnings("deprecation")
public static void setFullScreen(Window window) {
window.getDecorView().setSystemUiVisibility(View.STATUS_BAR_HIDDEN);
WindowManager.LayoutParams lAttrs = window.getAttributes();
lAttrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
window.setAttributes(lAttrs);
}
}

View file

@ -32,6 +32,8 @@ import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.Data;
import android.provider.ContactsContract.Intents.Insert;
import android.view.Display;
import android.view.Window;
import android.view.WindowManager;
/*
ApiFivePlus.java
@ -321,4 +323,10 @@ public class ApiFivePlus {
public static void setNotificationLatestEventInfo(Notification notif, Context context, String title, String content, PendingIntent intent) {
notif.setLatestEventInfo(context, title, content, intent);
}
public static void setFullScreen(Window window) {
WindowManager.LayoutParams lAttrs = window.getAttributes();
lAttrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
window.setAttributes(lAttrs);
}
}

View file

@ -0,0 +1,38 @@
package org.linphone.compatibility;
import android.annotation.TargetApi;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
/*
ApiFourteenPlus.java
Copyright (C) 2012 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.
*/
/**
* @author Sylvain Berfini
*/
@TargetApi(14)
public class ApiFourteenPlus {
public static void setFullScreen(Window window) {
window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
WindowManager.LayoutParams lAttrs = window.getAttributes();
lAttrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
window.setAttributes(lAttrs);
}
}

View file

@ -7,6 +7,9 @@ import android.app.Notification;
import android.app.PendingIntent;
import android.content.Context;
import android.graphics.Bitmap;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
/*
ApiSixteenPlus.java
Copyright (C) 2012 Belledonne Communications, Grenoble, France
@ -76,4 +79,12 @@ public class ApiSixteenPlus {
return notif;
}
public static void setFullScreen(Window window) {
window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LOW_PROFILE);
WindowManager.LayoutParams lAttrs = window.getAttributes();
lAttrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
window.setAttributes(lAttrs);
}
}

View file

@ -34,6 +34,7 @@ import android.database.Cursor;
import android.graphics.Bitmap;
import android.net.Uri;
import android.view.Display;
import android.view.Window;
/**
* @author Sylvain Berfini
*/
@ -170,4 +171,16 @@ public class Compatibility {
}
return null;
}
public static void setFullScreen(Window window) {
if (Version.sdkAboveOrEqual(16)) {
ApiSixteenPlus.setFullScreen(window);
} else if (Version.sdkAboveOrEqual(14)) {
ApiFourteenPlus.setFullScreen(window);
} else if (Version.sdkAboveOrEqual(11)) {
ApiElevenPlus.setFullScreen(window);
} else {
ApiFivePlus.setFullScreen(window);
}
}
}

View file

@ -15,36 +15,47 @@ 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.ui;
import org.linphone.LinphoneManager.AddressType;
import android.content.Context;
import android.graphics.Paint;
import android.net.Uri;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.widget.EditText;
/**
* @author Guillaume Beraudo
*
*
*/
public class AddressText extends EditText implements AddressType {
private String displayedName;
private Uri pictureUri;
public void setPictureUri(Uri uri) {pictureUri = uri;}
public Uri getPictureUri() {return pictureUri;}
private Paint mTestPaint;
public void setPictureUri(Uri uri) {
pictureUri = uri;
}
public Uri getPictureUri() {
return pictureUri;
}
public AddressText(Context context, AttributeSet attrs) {
super(context, attrs);
mTestPaint = new Paint();
mTestPaint.set(this.getPaint());
}
public void clearDisplayedName() {
displayedName = "";
}
public String getDisplayedName() {
return displayedName;
}
@ -63,7 +74,63 @@ public class AddressText extends EditText implements AddressType {
int after) {
clearDisplayedName();
pictureUri = null;
String resizedText = getText().toString();
if (resizedText.equals("") && getHint() != null) {
resizedText = getHint().toString();
}
refitText(resizedText, getWidth());
super.onTextChanged(text, start, before, after);
}
@Override
protected void onSizeChanged(int width, int height, int oldWidth, int oldHeight) {
if (width != oldWidth) {
String resizedText = getText().toString();
if (resizedText.equals("") && getHint() != null) {
resizedText = getHint().toString();
}
refitText(resizedText, getWidth());
}
}
private void refitText(String text, int textWidth) {
if (textWidth <= 0) {
return;
}
int targetWidth = textWidth - getPaddingLeft() - getPaddingRight();
float hi = 90;
float lo = 2;
final float threshold = 0.5f;
mTestPaint.set(getPaint());
while ((hi - lo) > threshold) {
float size = (hi + lo) / 2;
mTestPaint.setTextSize(size);
if (mTestPaint.measureText(text) >= targetWidth) {
hi = size;
}
else {
lo = size;
}
}
setTextSize(TypedValue.COMPLEX_UNIT_PX, lo);
}
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
int parentWidth = MeasureSpec.getSize(widthMeasureSpec);
int height = getMeasuredHeight();
String resizedText = getText().toString();
if (resizedText.equals("") && getHint() != null) {
resizedText = getHint().toString();
}
refitText(resizedText, parentWidth);
setMeasuredDimension(parentWidth, height);
}
}