Full screen while in call + better proximity sensor effect

This commit is contained in:
Sylvain Berfini 2012-08-08 16:15:44 +02:00
parent c3991cd339
commit d9cbf18ad8
10 changed files with 20 additions and 94 deletions

View file

@ -3,7 +3,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/topLayout"
android:layout_width="match_parent"
android:layout_height="match_parent" xmlns:app="http://schemas.android.com/apk/res/org.linphone">
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/fragmentContainer"

View file

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

View file

@ -22,7 +22,6 @@ 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;
@ -41,9 +40,9 @@ import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;
import android.view.KeyEvent;
import android.view.View;
import android.view.WindowManager;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
@ -87,7 +86,6 @@ public class InCallActivity extends FragmentActivity implements
super.onCreate(savedInstanceState);
instance = this;
Compatibility.setFullScreen(getWindow());
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
setContentView(R.layout.incall);
@ -417,9 +415,8 @@ public class InCallActivity extends FragmentActivity implements
switchCamera.startAnimation(slideInTopToBottom);
}
}
resetControlsHidingCallBack();
}
resetControlsHidingCallBack();
}
}

View file

@ -1230,16 +1230,16 @@ public final class LinphoneManager implements LinphoneCoreListener {
private static void simulateProximitySensorNearby(Activity activity, boolean nearby) {
final Window window = activity.getWindow();
WindowManager.LayoutParams lAttrs = activity.getWindow().getAttributes();
WindowManager.LayoutParams params = window.getAttributes();
View view = ((ViewGroup) window.getDecorView().findViewById(android.R.id.content)).getChildAt(0);
if (nearby) {
lAttrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
view.setVisibility(View.INVISIBLE);
params.screenBrightness = 0.1f;
view.setVisibility(View.INVISIBLE);
} else {
lAttrs.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
view.setVisibility(View.VISIBLE);
params.screenBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE;
view.setVisibility(View.VISIBLE);
}
window.setAttributes(lAttrs);
window.setAttributes(params);
}
private static void proximityNearbyChanged() {

View file

@ -300,6 +300,7 @@ public class StatusFragment extends Fragment {
MediaEncryption mediaEncryption = call.getCurrentParamsCopy().getMediaEncryption();
exit.setVisibility(View.GONE);
statusText.setVisibility(View.GONE);
background.setVisibility(View.GONE);
encryption.setVisibility(View.VISIBLE);
@ -312,7 +313,9 @@ public class StatusFragment extends Fragment {
}
} else {
exit.setVisibility(View.VISIBLE);
statusText.setVisibility(View.VISIBLE);
background.setVisibility(View.VISIBLE);
encryption.setVisibility(View.GONE);
}
}

View file

@ -7,9 +7,6 @@ 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
@ -83,13 +80,4 @@ 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,8 +32,6 @@ 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
@ -345,10 +343,4 @@ 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

@ -1,38 +0,0 @@
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,9 +7,6 @@ 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
@ -79,12 +76,4 @@ 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

@ -35,7 +35,6 @@ import android.graphics.Bitmap;
import android.media.AudioManager;
import android.net.Uri;
import android.view.Display;
import android.view.Window;
/**
* @author Sylvain Berfini
*/
@ -179,18 +178,6 @@ 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);
}
}
public static boolean enableBluetoothHeadset(AudioManager mAudioManager) {
if (Version.sdkAboveOrEqual(8)) {