summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDiego Perez <diegoperez@google.com>2015-04-15 18:58:52 +0100
committerDiego Perez <diegoperez@google.com>2015-04-21 17:50:28 +0100
commit9b39c49bfcf9caf434799976304e492ef4599b86 (patch)
treebc22ec9ad68b53c0954ef42d6fb15018bd73fd85
parent220f360e02ae833fcadc342756932f76f6780626 (diff)
downloadframeworks_base-9b39c49bfcf9caf434799976304e492ef4599b86.zip
frameworks_base-9b39c49bfcf9caf434799976304e492ef4599b86.tar.gz
frameworks_base-9b39c49bfcf9caf434799976304e492ef4599b86.tar.bz2
Make status and navigation bars widgets and usable from layouts
This will allow the theme editor to render these components separately. Change-Id: I8b2e0e78039b44623152e34f68ffcdfab5aa9885
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/Config.java4
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/NavigationBar.java19
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/StatusBar.java15
3 files changed, 36 insertions, 2 deletions
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/Config.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/Config.java
index 9f9b968..dc89d0c 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/Config.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/Config.java
@@ -74,7 +74,7 @@ public class Config {
}
public static String getTime(int platformVersion) {
- if (platformVersion == 0) {
+ if (isGreaterOrEqual(platformVersion, LOLLIPOP_MR1)) {
return "5:10";
}
if (platformVersion < GINGERBREAD) {
@@ -117,7 +117,7 @@ public class Config {
}
public static String getWifiIconType(int platformVersion) {
- return platformVersion == 0 ? "xml" : "png";
+ return isGreaterOrEqual(platformVersion, LOLLIPOP) ? "xml" : "png";
}
/**
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/NavigationBar.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/NavigationBar.java
index 9450b6c..04aadff 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/NavigationBar.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/NavigationBar.java
@@ -21,6 +21,10 @@ import com.android.resources.Density;
import org.xmlpull.v1.XmlPullParserException;
+import android.content.Context;
+import android.content.pm.ApplicationInfo;
+import android.util.AttributeSet;
+import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
@@ -29,6 +33,21 @@ public class NavigationBar extends CustomBar {
/** Navigation bar background color attribute name. */
private static final String ATTR_COLOR = "navigationBarColor";
+ /**
+ * Constructor to be used when creating the {@link NavigationBar} as a regular control.
+ * This is currently used by the theme editor.
+ */
+ public NavigationBar(Context context, AttributeSet attrs)
+ throws XmlPullParserException {
+ this((BridgeContext) context,
+ Density.getEnum(((BridgeContext) context).getMetrics().densityDpi),
+ LinearLayout.HORIZONTAL, // In this mode, it doesn't need to be render vertically
+ ((BridgeContext) context).getConfiguration().getLayoutDirection() ==
+ View.LAYOUT_DIRECTION_RTL,
+ (context.getApplicationInfo().flags & ApplicationInfo.FLAG_SUPPORTS_RTL) != 0,
+ context.getApplicationInfo().targetSdkVersion);
+ }
+
public NavigationBar(BridgeContext context, Density density, int orientation, boolean isRtl,
boolean rtlEnabled, int simulatedPlatformVersion) throws XmlPullParserException {
super(context, orientation, "/bars/navigation_bar.xml", "navigation_bar.xml",
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/StatusBar.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/StatusBar.java
index e5f1f68..7de6668 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/StatusBar.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/StatusBar.java
@@ -25,7 +25,9 @@ import com.android.resources.Density;
import org.xmlpull.v1.XmlPullParserException;
+import android.content.Context;
import android.graphics.drawable.Drawable;
+import android.util.AttributeSet;
import android.view.Gravity;
import android.view.View;
import android.widget.ImageView;
@@ -41,6 +43,19 @@ public class StatusBar extends CustomBar {
/** Status bar background color attribute name. */
private static final String ATTR_COLOR = "colorPrimaryDark";
+ /**
+ * Constructor to be used when creating the {@link StatusBar} as a regular control. This
+ * is currently used by the theme editor.
+ */
+ public StatusBar(Context context, AttributeSet attrs) throws XmlPullParserException {
+ this((BridgeContext) context,
+ Density.getEnum(((BridgeContext) context).getMetrics().densityDpi),
+ LinearLayout.HORIZONTAL, // In this mode, it doesn't need to be render vertically
+ ((BridgeContext) context).getConfiguration().getLayoutDirection() ==
+ View.LAYOUT_DIRECTION_RTL,
+ context.getApplicationInfo().targetSdkVersion);
+ }
+
public StatusBar(BridgeContext context, Density density, int direction, boolean RtlEnabled,
int simulatedPlatformVersion) throws XmlPullParserException {
// FIXME: if direction is RTL but it's not enabled in application manifest, mirror this bar.