summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorSandeep Siddhartha <sansid@google.com>2014-05-16 17:21:15 -0700
committerSandeep Siddhartha <sansid@google.com>2014-05-16 17:48:16 -0700
commit2efc7d928a3df57838f8abd8ed6fdb9eeb21b481 (patch)
tree1b6d7854d641b580d800046a28d8684eb79aeeb6 /src/com
parentdbc46f5e05d035524eff7fb1ea3ac8681b6b673a (diff)
downloadandroid_packages_apps_Trebuchet-2efc7d928a3df57838f8abd8ed6fdb9eeb21b481.tar.gz
android_packages_apps_Trebuchet-2efc7d928a3df57838f8abd8ed6fdb9eeb21b481.tar.bz2
android_packages_apps_Trebuchet-2efc7d928a3df57838f8abd8ed6fdb9eeb21b481.zip
Use transparent system bars on L
Change-Id: I1e8921fa0e8a5bdf34495f9d88ba9f3b1f1e9c89
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/launcher3/Launcher.java50
-rw-r--r--src/com/android/launcher3/Utilities.java9
2 files changed, 59 insertions, 0 deletions
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 3636107c2..72cad5138 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -50,6 +50,7 @@ import android.content.res.Resources;
import android.database.ContentObserver;
import android.graphics.Bitmap;
import android.graphics.Canvas;
+import android.graphics.Color;
import android.graphics.Point;
import android.graphics.PorterDuff;
import android.graphics.Rect;
@@ -79,6 +80,7 @@ import android.view.Menu;
import android.view.MotionEvent;
import android.view.Surface;
import android.view.View;
+import android.view.Window;
import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;
import android.view.ViewGroup;
@@ -110,6 +112,9 @@ import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Collection;
@@ -1591,10 +1596,55 @@ public class Launcher extends Activity
}
registerReceiver(mReceiver, filter);
FirstFrameAnimatorHelper.initializeDrawListener(getWindow().getDecorView());
+ setupTransparentSystemBarsForLmp();
mAttached = true;
mVisible = true;
}
+ /**
+ * Sets up transparent navigation and status bars in LMP.
+ * This method is a no-op for other platform versions.
+ */
+ private void setupTransparentSystemBarsForLmp() {
+ // TODO(sansid): use the APIs directly when compiling against L sdk.
+ // Currently we use reflection to access the flags and the API to set the transparency
+ // on the System bars.
+ if (Utilities.isLmp()) {
+ try {
+ getWindow().getAttributes().systemUiVisibility |=
+ (View.SYSTEM_UI_FLAG_LAYOUT_STABLE
+ | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
+ | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
+ Field translucentStatusField =
+ WindowManager.LayoutParams.class.getField("FLAG_TRANSLUCENT_STATUS");
+ Field translucentNavigationField =
+ WindowManager.LayoutParams.class.getField("FLAG_TRANSLUCENT_NAVIGATION");
+ getWindow().clearFlags(translucentStatusField.getInt(null)
+ | translucentNavigationField.getInt(null));
+ Field drawsSysBackgroundsField = WindowManager.LayoutParams.class.getField(
+ "FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS");
+ getWindow().addFlags(drawsSysBackgroundsField.getInt(null));
+
+ Method setStatusBarColorMethod =
+ Window.class.getDeclaredMethod("setStatusBarColor", int.class);
+ Method setNavigationBarColorMethod =
+ Window.class.getDeclaredMethod("setNavigationBarColor", int.class);
+ setStatusBarColorMethod.invoke(getWindow(), Color.TRANSPARENT);
+ setNavigationBarColorMethod.invoke(getWindow(), Color.TRANSPARENT);
+ } catch (NoSuchFieldException e) {
+ Log.w(TAG, "NoSuchFieldException while setting up transparent bars");
+ } catch (NoSuchMethodException ex) {
+ Log.w(TAG, "NoSuchMethodException while setting up transparent bars");
+ } catch (IllegalAccessException e) {
+ Log.w(TAG, "IllegalAccessException while setting up transparent bars");
+ } catch (IllegalArgumentException e) {
+ Log.w(TAG, "IllegalArgumentException while setting up transparent bars");
+ } catch (InvocationTargetException e) {
+ Log.w(TAG, "InvocationTargetException while setting up transparent bars");
+ } finally {}
+ }
+ }
+
@Override
public void onDetachedFromWindow() {
super.onDetachedFromWindow();
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java
index 8deadf1d9..74b6e47f1 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -33,6 +33,7 @@ import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.PaintDrawable;
+import android.os.Build;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.View;
@@ -99,6 +100,14 @@ public final class Utilities {
}
/**
+ * Indicates if the device is running LMP or not.
+ * TODO(sansid): Change the check to a VERSION_CODES code check once we have a version for L.
+ */
+ public static boolean isLmp() {
+ return "L".equals(Build.VERSION.CODENAME);
+ }
+
+ /**
* Returns a bitmap suitable for the all apps view. Used to convert pre-ICS
* icon bitmaps that are stored in the database (which were 74x74 pixels at hdpi size)
* to the proper size (48dp)