Update layoutlib for jb mr1. do not merge.
Status bar displayed on all devices.
Update logic for displaying nav bar to whether or not
device has soft button.
Update navigation buttons to new look.
Remove battery and signal from navigation bar.
(cherry picked from commit 891b703f7b)
Change-Id: Id7cc9ad4255d2c4d2e6461a565dfe2cc17e12e75
BIN
tools/layoutlib/bridge/resources/bars/hdpi/ic_sysbar_back.png
Normal file
|
After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 1007 B |
BIN
tools/layoutlib/bridge/resources/bars/hdpi/ic_sysbar_home.png
Normal file
|
After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 852 B |
BIN
tools/layoutlib/bridge/resources/bars/hdpi/ic_sysbar_recent.png
Normal file
|
After Width: | Height: | Size: 711 B |
|
Before Width: | Height: | Size: 574 B |
BIN
tools/layoutlib/bridge/resources/bars/mdpi/ic_sysbar_back.png
Normal file
|
After Width: | Height: | Size: 774 B |
|
Before Width: | Height: | Size: 782 B |
BIN
tools/layoutlib/bridge/resources/bars/mdpi/ic_sysbar_home.png
Normal file
|
After Width: | Height: | Size: 836 B |
|
Before Width: | Height: | Size: 695 B |
BIN
tools/layoutlib/bridge/resources/bars/mdpi/ic_sysbar_recent.png
Normal file
|
After Width: | Height: | Size: 591 B |
|
Before Width: | Height: | Size: 534 B |
20
tools/layoutlib/bridge/resources/bars/navigation_bar.xml
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<merge xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"/>
|
||||||
|
<ImageView
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="wrap_content"/>
|
||||||
|
<ImageView
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="wrap_content"/>
|
||||||
|
<ImageView
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="wrap_content"/>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"/>
|
||||||
|
</merge>
|
||||||
BIN
tools/layoutlib/bridge/resources/bars/xhdpi/ic_sysbar_back.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.3 KiB |
BIN
tools/layoutlib/bridge/resources/bars/xhdpi/ic_sysbar_home.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.0 KiB |
BIN
tools/layoutlib/bridge/resources/bars/xhdpi/ic_sysbar_recent.png
Normal file
|
After Width: | Height: | Size: 749 B |
|
Before Width: | Height: | Size: 644 B |
@@ -210,7 +210,8 @@ public final class Bridge extends com.android.ide.common.rendering.api.Bridge {
|
|||||||
Capability.PLAY_ANIMATION,
|
Capability.PLAY_ANIMATION,
|
||||||
Capability.ANIMATED_VIEW_MANIPULATION,
|
Capability.ANIMATED_VIEW_MANIPULATION,
|
||||||
Capability.ADAPTER_BINDING,
|
Capability.ADAPTER_BINDING,
|
||||||
Capability.EXTENDED_VIEWINFO);
|
Capability.EXTENDED_VIEWINFO,
|
||||||
|
Capability.FIXED_SCALABLE_NINE_PATCH);
|
||||||
|
|
||||||
|
|
||||||
BridgeAssetManager.initSystem();
|
BridgeAssetManager.initSystem();
|
||||||
|
|||||||
@@ -56,15 +56,19 @@ import java.io.InputStream;
|
|||||||
*
|
*
|
||||||
* It also provides a few utility methods to configure the content of the layout.
|
* It also provides a few utility methods to configure the content of the layout.
|
||||||
*/
|
*/
|
||||||
abstract class CustomBar extends LinearLayout {
|
public abstract class CustomBar extends LinearLayout {
|
||||||
|
|
||||||
protected abstract TextView getStyleableTextView();
|
protected abstract TextView getStyleableTextView();
|
||||||
|
|
||||||
protected CustomBar(Context context, Density density, String layoutPath, String name)
|
protected CustomBar(Context context, Density density, int orientation, String layoutPath,
|
||||||
throws XmlPullParserException {
|
String name) throws XmlPullParserException {
|
||||||
super(context);
|
super(context);
|
||||||
setOrientation(LinearLayout.HORIZONTAL);
|
setOrientation(orientation);
|
||||||
|
if (orientation == LinearLayout.HORIZONTAL) {
|
||||||
setGravity(Gravity.CENTER_VERTICAL);
|
setGravity(Gravity.CENTER_VERTICAL);
|
||||||
|
} else {
|
||||||
|
setGravity(Gravity.CENTER_HORIZONTAL);
|
||||||
|
}
|
||||||
|
|
||||||
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(
|
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(
|
||||||
Context.LAYOUT_INFLATER_SERVICE);
|
Context.LAYOUT_INFLATER_SERVICE);
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import com.android.resources.Density;
|
|||||||
import org.xmlpull.v1.XmlPullParserException;
|
import org.xmlpull.v1.XmlPullParserException;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
public class FakeActionBar extends CustomBar {
|
public class FakeActionBar extends CustomBar {
|
||||||
@@ -29,7 +30,7 @@ public class FakeActionBar extends CustomBar {
|
|||||||
|
|
||||||
public FakeActionBar(Context context, Density density, String label, String icon)
|
public FakeActionBar(Context context, Density density, String label, String icon)
|
||||||
throws XmlPullParserException {
|
throws XmlPullParserException {
|
||||||
super(context, density, "/bars/action_bar.xml", "action_bar.xml");
|
super(context, density, LinearLayout.HORIZONTAL, "/bars/action_bar.xml", "action_bar.xml");
|
||||||
|
|
||||||
// Cannot access the inside items through id because no R.id values have been
|
// Cannot access the inside items through id because no R.id values have been
|
||||||
// created for them.
|
// created for them.
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2011 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.layoutlib.bridge.bars;
|
||||||
|
|
||||||
|
import com.android.resources.Density;
|
||||||
|
|
||||||
|
import org.xmlpull.v1.XmlPullParserException;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
public class NavigationBar extends CustomBar {
|
||||||
|
|
||||||
|
public NavigationBar(Context context, Density density, int orientation) throws XmlPullParserException {
|
||||||
|
super(context, density, orientation, "/bars/navigation_bar.xml", "navigation_bar.xml");
|
||||||
|
|
||||||
|
setBackgroundColor(0xFF000000);
|
||||||
|
|
||||||
|
// Cannot access the inside items through id because no R.id values have been
|
||||||
|
// created for them.
|
||||||
|
// We do know the order though.
|
||||||
|
// 0 is a spacer.
|
||||||
|
int back = 1;
|
||||||
|
int recent = 3;
|
||||||
|
if (orientation == LinearLayout.VERTICAL) {
|
||||||
|
back = 3;
|
||||||
|
recent = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
loadIcon(back, "ic_sysbar_back.png", density);
|
||||||
|
loadIcon(2, "ic_sysbar_home.png", density);
|
||||||
|
loadIcon(recent, "ic_sysbar_recent.png", density);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected TextView getStyleableTextView() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -25,12 +25,13 @@ import android.content.Context;
|
|||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.graphics.drawable.LevelListDrawable;
|
import android.graphics.drawable.LevelListDrawable;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
public class PhoneSystemBar extends CustomBar {
|
public class StatusBar extends CustomBar {
|
||||||
|
|
||||||
public PhoneSystemBar(Context context, Density density) throws XmlPullParserException {
|
public StatusBar(Context context, Density density) throws XmlPullParserException {
|
||||||
super(context, density, "/bars/phone_system_bar.xml", "phone_system_bar.xml");
|
super(context, density, LinearLayout.HORIZONTAL, "/bars/status_bar.xml", "status_bar.xml");
|
||||||
|
|
||||||
// FIXME: use FILL_H?
|
// FIXME: use FILL_H?
|
||||||
setGravity(Gravity.START | Gravity.TOP | Gravity.RIGHT);
|
setGravity(Gravity.START | Gravity.TOP | Gravity.RIGHT);
|
||||||
@@ -24,21 +24,23 @@ import org.xmlpull.v1.XmlPullParserException;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.graphics.drawable.LevelListDrawable;
|
import android.graphics.drawable.LevelListDrawable;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
public class TabletSystemBar extends CustomBar {
|
public class TabletSystemBar extends CustomBar {
|
||||||
|
|
||||||
public TabletSystemBar(Context context, Density density) throws XmlPullParserException {
|
public TabletSystemBar(Context context, Density density) throws XmlPullParserException {
|
||||||
super(context, density, "/bars/tablet_system_bar.xml", "tablet_system_bar.xml");
|
super(context, density, LinearLayout.HORIZONTAL,
|
||||||
|
"/bars/tablet_system_bar.xml", "tablet_system_bar.xml");
|
||||||
|
|
||||||
setBackgroundColor(0xFF000000);
|
setBackgroundColor(0xFF000000);
|
||||||
|
|
||||||
// Cannot access the inside items through id because no R.id values have been
|
// Cannot access the inside items through id because no R.id values have been
|
||||||
// created for them.
|
// created for them.
|
||||||
// We do know the order though.
|
// We do know the order though.
|
||||||
loadIcon(0, "ic_sysbar_back_default.png", density);
|
loadIcon(0, "ic_sysbar_back.png", density);
|
||||||
loadIcon(1, "ic_sysbar_home_default.png", density);
|
loadIcon(1, "ic_sysbar_home.png", density);
|
||||||
loadIcon(2, "ic_sysbar_recent_default.png", density);
|
loadIcon(2, "ic_sysbar_recent.png", density);
|
||||||
// 3 is the spacer
|
// 3 is the spacer
|
||||||
loadIcon(4, "stat_sys_wifi_signal_4_fully.png", density);
|
loadIcon(4, "stat_sys_wifi_signal_4_fully.png", density);
|
||||||
Drawable drawable = loadIcon(5, ResourceType.DRAWABLE, "stat_sys_battery_charge");
|
Drawable drawable = loadIcon(5, ResourceType.DRAWABLE, "stat_sys_battery_charge");
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import com.android.resources.Density;
|
|||||||
import org.xmlpull.v1.XmlPullParserException;
|
import org.xmlpull.v1.XmlPullParserException;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
public class TitleBar extends CustomBar {
|
public class TitleBar extends CustomBar {
|
||||||
@@ -29,7 +30,7 @@ public class TitleBar extends CustomBar {
|
|||||||
|
|
||||||
public TitleBar(Context context, Density density, String label)
|
public TitleBar(Context context, Density density, String label)
|
||||||
throws XmlPullParserException {
|
throws XmlPullParserException {
|
||||||
super(context, density, "/bars/title_bar.xml", "title_bar.xml");
|
super(context, density, LinearLayout.HORIZONTAL, "/bars/title_bar.xml", "title_bar.xml");
|
||||||
|
|
||||||
// Cannot access the inside items through id because no R.id values have been
|
// Cannot access the inside items through id because no R.id values have been
|
||||||
// created for them.
|
// created for them.
|
||||||
|
|||||||
@@ -20,11 +20,12 @@ import static com.android.ide.common.rendering.api.Result.Status.ERROR_LOCK_INTE
|
|||||||
import static com.android.ide.common.rendering.api.Result.Status.ERROR_TIMEOUT;
|
import static com.android.ide.common.rendering.api.Result.Status.ERROR_TIMEOUT;
|
||||||
import static com.android.ide.common.rendering.api.Result.Status.SUCCESS;
|
import static com.android.ide.common.rendering.api.Result.Status.SUCCESS;
|
||||||
|
|
||||||
|
import com.android.ide.common.rendering.api.HardwareConfig;
|
||||||
import com.android.ide.common.rendering.api.LayoutLog;
|
import com.android.ide.common.rendering.api.LayoutLog;
|
||||||
import com.android.ide.common.rendering.api.RenderParams;
|
import com.android.ide.common.rendering.api.RenderParams;
|
||||||
import com.android.ide.common.rendering.api.RenderResources;
|
import com.android.ide.common.rendering.api.RenderResources;
|
||||||
import com.android.ide.common.rendering.api.Result;
|
|
||||||
import com.android.ide.common.rendering.api.RenderResources.FrameworkResourceIdProvider;
|
import com.android.ide.common.rendering.api.RenderResources.FrameworkResourceIdProvider;
|
||||||
|
import com.android.ide.common.rendering.api.Result;
|
||||||
import com.android.layoutlib.bridge.Bridge;
|
import com.android.layoutlib.bridge.Bridge;
|
||||||
import com.android.layoutlib.bridge.android.BridgeContext;
|
import com.android.layoutlib.bridge.android.BridgeContext;
|
||||||
import com.android.resources.Density;
|
import com.android.resources.Density;
|
||||||
@@ -98,19 +99,21 @@ public abstract class RenderAction<T extends RenderParams> extends FrameworkReso
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HardwareConfig hardwareConfig = mParams.getHardwareConfig();
|
||||||
|
|
||||||
// setup the display Metrics.
|
// setup the display Metrics.
|
||||||
DisplayMetrics metrics = new DisplayMetrics();
|
DisplayMetrics metrics = new DisplayMetrics();
|
||||||
metrics.densityDpi = mParams.getDensity().getDpiValue();
|
metrics.densityDpi = hardwareConfig.getDensity().getDpiValue();
|
||||||
|
|
||||||
metrics.density = metrics.noncompatDensity =
|
metrics.density = metrics.noncompatDensity =
|
||||||
metrics.densityDpi / (float) DisplayMetrics.DENSITY_DEFAULT;
|
metrics.densityDpi / (float) DisplayMetrics.DENSITY_DEFAULT;
|
||||||
|
|
||||||
metrics.scaledDensity = metrics.noncompatScaledDensity = metrics.density;
|
metrics.scaledDensity = metrics.noncompatScaledDensity = metrics.density;
|
||||||
|
|
||||||
metrics.widthPixels = metrics.noncompatWidthPixels = mParams.getScreenWidth();
|
metrics.widthPixels = metrics.noncompatWidthPixels = hardwareConfig.getScreenWidth();
|
||||||
metrics.heightPixels = metrics.noncompatHeightPixels = mParams.getScreenHeight();
|
metrics.heightPixels = metrics.noncompatHeightPixels = hardwareConfig.getScreenHeight();
|
||||||
metrics.xdpi = metrics.noncompatXdpi = mParams.getXdpi();
|
metrics.xdpi = metrics.noncompatXdpi = hardwareConfig.getXdpi();
|
||||||
metrics.ydpi = metrics.noncompatYdpi = mParams.getYdpi();
|
metrics.ydpi = metrics.noncompatYdpi = hardwareConfig.getYdpi();
|
||||||
|
|
||||||
RenderResources resources = mParams.getResources();
|
RenderResources resources = mParams.getResources();
|
||||||
|
|
||||||
@@ -305,7 +308,9 @@ public abstract class RenderAction<T extends RenderParams> extends FrameworkReso
|
|||||||
private Configuration getConfiguration() {
|
private Configuration getConfiguration() {
|
||||||
Configuration config = new Configuration();
|
Configuration config = new Configuration();
|
||||||
|
|
||||||
ScreenSize screenSize = mParams.getConfigScreenSize();
|
HardwareConfig hardwareConfig = mParams.getHardwareConfig();
|
||||||
|
|
||||||
|
ScreenSize screenSize = hardwareConfig.getScreenSize();
|
||||||
if (screenSize != null) {
|
if (screenSize != null) {
|
||||||
switch (screenSize) {
|
switch (screenSize) {
|
||||||
case SMALL:
|
case SMALL:
|
||||||
@@ -323,13 +328,13 @@ public abstract class RenderAction<T extends RenderParams> extends FrameworkReso
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Density density = mParams.getDensity();
|
Density density = hardwareConfig.getDensity();
|
||||||
if (density == null) {
|
if (density == null) {
|
||||||
density = Density.MEDIUM;
|
density = Density.MEDIUM;
|
||||||
}
|
}
|
||||||
|
|
||||||
config.screenWidthDp = mParams.getScreenWidth() / density.getDpiValue();
|
config.screenWidthDp = hardwareConfig.getScreenWidth() / density.getDpiValue();
|
||||||
config.screenHeightDp = mParams.getScreenHeight() / density.getDpiValue();
|
config.screenHeightDp = hardwareConfig.getScreenHeight() / density.getDpiValue();
|
||||||
if (config.screenHeightDp < config.screenWidthDp) {
|
if (config.screenHeightDp < config.screenWidthDp) {
|
||||||
config.smallestScreenWidthDp = config.screenHeightDp;
|
config.smallestScreenWidthDp = config.screenHeightDp;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package com.android.layoutlib.bridge.impl;
|
|||||||
import static com.android.ide.common.rendering.api.Result.Status.ERROR_UNKNOWN;
|
import static com.android.ide.common.rendering.api.Result.Status.ERROR_UNKNOWN;
|
||||||
|
|
||||||
import com.android.ide.common.rendering.api.DrawableParams;
|
import com.android.ide.common.rendering.api.DrawableParams;
|
||||||
|
import com.android.ide.common.rendering.api.HardwareConfig;
|
||||||
import com.android.ide.common.rendering.api.ResourceValue;
|
import com.android.ide.common.rendering.api.ResourceValue;
|
||||||
import com.android.ide.common.rendering.api.Result;
|
import com.android.ide.common.rendering.api.Result;
|
||||||
import com.android.ide.common.rendering.api.Result.Status;
|
import com.android.ide.common.rendering.api.Result.Status;
|
||||||
@@ -59,6 +60,7 @@ public class RenderDrawable extends RenderAction<DrawableParams> {
|
|||||||
try {
|
try {
|
||||||
// get the drawable resource value
|
// get the drawable resource value
|
||||||
DrawableParams params = getParams();
|
DrawableParams params = getParams();
|
||||||
|
HardwareConfig hardwareConfig = params.getHardwareConfig();
|
||||||
ResourceValue drawableResource = params.getDrawable();
|
ResourceValue drawableResource = params.getDrawable();
|
||||||
|
|
||||||
// resolve it
|
// resolve it
|
||||||
@@ -75,15 +77,15 @@ public class RenderDrawable extends RenderAction<DrawableParams> {
|
|||||||
|
|
||||||
// get the actual Drawable object to draw
|
// get the actual Drawable object to draw
|
||||||
Drawable d = ResourceHelper.getDrawable(drawableResource, context);
|
Drawable d = ResourceHelper.getDrawable(drawableResource, context);
|
||||||
content.setBackgroundDrawable(d);
|
content.setBackground(d);
|
||||||
|
|
||||||
// set the AttachInfo on the root view.
|
// set the AttachInfo on the root view.
|
||||||
AttachInfo_Accessor.setAttachInfo(content);
|
AttachInfo_Accessor.setAttachInfo(content);
|
||||||
|
|
||||||
|
|
||||||
// measure
|
// measure
|
||||||
int w = params.getScreenWidth();
|
int w = hardwareConfig.getScreenWidth();
|
||||||
int h = params.getScreenHeight();
|
int h = hardwareConfig.getScreenHeight();
|
||||||
int w_spec = MeasureSpec.makeMeasureSpec(w, MeasureSpec.EXACTLY);
|
int w_spec = MeasureSpec.makeMeasureSpec(w, MeasureSpec.EXACTLY);
|
||||||
int h_spec = MeasureSpec.makeMeasureSpec(h, MeasureSpec.EXACTLY);
|
int h_spec = MeasureSpec.makeMeasureSpec(h, MeasureSpec.EXACTLY);
|
||||||
content.measure(w_spec, h_spec);
|
content.measure(w_spec, h_spec);
|
||||||
@@ -99,11 +101,11 @@ public class RenderDrawable extends RenderAction<DrawableParams> {
|
|||||||
|
|
||||||
// create an Android bitmap around the BufferedImage
|
// create an Android bitmap around the BufferedImage
|
||||||
Bitmap bitmap = Bitmap_Delegate.createBitmap(image,
|
Bitmap bitmap = Bitmap_Delegate.createBitmap(image,
|
||||||
true /*isMutable*/, params.getDensity());
|
true /*isMutable*/, hardwareConfig.getDensity());
|
||||||
|
|
||||||
// create a Canvas around the Android bitmap
|
// create a Canvas around the Android bitmap
|
||||||
Canvas canvas = new Canvas(bitmap);
|
Canvas canvas = new Canvas(bitmap);
|
||||||
canvas.setDensity(params.getDensity().getDpiValue());
|
canvas.setDensity(hardwareConfig.getDensity().getDpiValue());
|
||||||
|
|
||||||
// and draw
|
// and draw
|
||||||
content.draw(canvas);
|
content.draw(canvas);
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import static com.android.ide.common.rendering.api.Result.Status.ERROR_VIEWGROUP
|
|||||||
import static com.android.ide.common.rendering.api.Result.Status.SUCCESS;
|
import static com.android.ide.common.rendering.api.Result.Status.SUCCESS;
|
||||||
|
|
||||||
import com.android.ide.common.rendering.api.AdapterBinding;
|
import com.android.ide.common.rendering.api.AdapterBinding;
|
||||||
|
import com.android.ide.common.rendering.api.HardwareConfig;
|
||||||
import com.android.ide.common.rendering.api.IAnimationListener;
|
import com.android.ide.common.rendering.api.IAnimationListener;
|
||||||
import com.android.ide.common.rendering.api.ILayoutPullParser;
|
import com.android.ide.common.rendering.api.ILayoutPullParser;
|
||||||
import com.android.ide.common.rendering.api.IProjectCallback;
|
import com.android.ide.common.rendering.api.IProjectCallback;
|
||||||
@@ -42,13 +43,16 @@ import com.android.layoutlib.bridge.Bridge;
|
|||||||
import com.android.layoutlib.bridge.android.BridgeContext;
|
import com.android.layoutlib.bridge.android.BridgeContext;
|
||||||
import com.android.layoutlib.bridge.android.BridgeLayoutParamsMapAttributes;
|
import com.android.layoutlib.bridge.android.BridgeLayoutParamsMapAttributes;
|
||||||
import com.android.layoutlib.bridge.android.BridgeXmlBlockParser;
|
import com.android.layoutlib.bridge.android.BridgeXmlBlockParser;
|
||||||
|
import com.android.layoutlib.bridge.bars.CustomBar;
|
||||||
import com.android.layoutlib.bridge.bars.FakeActionBar;
|
import com.android.layoutlib.bridge.bars.FakeActionBar;
|
||||||
import com.android.layoutlib.bridge.bars.PhoneSystemBar;
|
import com.android.layoutlib.bridge.bars.NavigationBar;
|
||||||
|
import com.android.layoutlib.bridge.bars.StatusBar;
|
||||||
import com.android.layoutlib.bridge.bars.TabletSystemBar;
|
import com.android.layoutlib.bridge.bars.TabletSystemBar;
|
||||||
import com.android.layoutlib.bridge.bars.TitleBar;
|
import com.android.layoutlib.bridge.bars.TitleBar;
|
||||||
import com.android.layoutlib.bridge.impl.binding.FakeAdapter;
|
import com.android.layoutlib.bridge.impl.binding.FakeAdapter;
|
||||||
import com.android.layoutlib.bridge.impl.binding.FakeExpandableAdapter;
|
import com.android.layoutlib.bridge.impl.binding.FakeExpandableAdapter;
|
||||||
import com.android.resources.ResourceType;
|
import com.android.resources.ResourceType;
|
||||||
|
import com.android.resources.ScreenOrientation;
|
||||||
import com.android.resources.ScreenSize;
|
import com.android.resources.ScreenSize;
|
||||||
import com.android.util.Pair;
|
import com.android.util.Pair;
|
||||||
|
|
||||||
@@ -120,7 +124,8 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
|
|||||||
private boolean mWindowIsFloating;
|
private boolean mWindowIsFloating;
|
||||||
|
|
||||||
private int mStatusBarSize;
|
private int mStatusBarSize;
|
||||||
private int mSystemBarSize;
|
private int mNavigationBarSize;
|
||||||
|
private int mNavigationBarOrientation = LinearLayout.HORIZONTAL;
|
||||||
private int mTitleBarSize;
|
private int mTitleBarSize;
|
||||||
private int mActionBarSize;
|
private int mActionBarSize;
|
||||||
|
|
||||||
@@ -183,7 +188,7 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
|
|||||||
findBackground(resources);
|
findBackground(resources);
|
||||||
findStatusBar(resources, metrics);
|
findStatusBar(resources, metrics);
|
||||||
findActionBar(resources, metrics);
|
findActionBar(resources, metrics);
|
||||||
findSystemBar(resources, metrics);
|
findNavigationBar(resources, metrics);
|
||||||
|
|
||||||
// build the inflater and parser.
|
// build the inflater and parser.
|
||||||
mInflater = new BridgeInflater(context, params.getProjectCallback());
|
mInflater = new BridgeInflater(context, params.getProjectCallback());
|
||||||
@@ -209,19 +214,57 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
SessionParams params = getParams();
|
SessionParams params = getParams();
|
||||||
|
HardwareConfig hardwareConfig = params.getHardwareConfig();
|
||||||
BridgeContext context = getContext();
|
BridgeContext context = getContext();
|
||||||
|
|
||||||
|
|
||||||
// the view group that receives the window background.
|
// the view group that receives the window background.
|
||||||
ViewGroup backgroundView = null;
|
ViewGroup backgroundView = null;
|
||||||
|
|
||||||
if (mWindowIsFloating || params.isForceNoDecor()) {
|
if (mWindowIsFloating || params.isForceNoDecor()) {
|
||||||
backgroundView = mViewRoot = mContentRoot = new FrameLayout(context);
|
backgroundView = mViewRoot = mContentRoot = new FrameLayout(context);
|
||||||
} else {
|
} else {
|
||||||
|
if (hasSoftwareButtons() && mNavigationBarOrientation == LinearLayout.VERTICAL) {
|
||||||
|
/*
|
||||||
|
* This is a special case where the navigation bar is on the right.
|
||||||
|
+-------------------------------------------------+---+
|
||||||
|
| Status bar (always) | |
|
||||||
|
+-------------------------------------------------+ |
|
||||||
|
| (Layout with background drawable) | |
|
||||||
|
| +---------------------------------------------+ | |
|
||||||
|
| | Title/Action bar (optional) | | |
|
||||||
|
| +---------------------------------------------+ | |
|
||||||
|
| | Content, vertical extending | | |
|
||||||
|
| | | | |
|
||||||
|
| +---------------------------------------------+ | |
|
||||||
|
+-------------------------------------------------+---+
|
||||||
|
|
||||||
|
So we create a horizontal layout, with the nav bar on the right,
|
||||||
|
and the left part is the normal layout below without the nav bar at
|
||||||
|
the bottom
|
||||||
|
*/
|
||||||
|
LinearLayout topLayout = new LinearLayout(context);
|
||||||
|
mViewRoot = topLayout;
|
||||||
|
topLayout.setOrientation(LinearLayout.HORIZONTAL);
|
||||||
|
|
||||||
|
try {
|
||||||
|
NavigationBar navigationBar = new NavigationBar(context,
|
||||||
|
hardwareConfig.getDensity(), LinearLayout.VERTICAL);
|
||||||
|
navigationBar.setLayoutParams(
|
||||||
|
new LinearLayout.LayoutParams(
|
||||||
|
mNavigationBarSize,
|
||||||
|
LayoutParams.MATCH_PARENT));
|
||||||
|
topLayout.addView(navigationBar);
|
||||||
|
} catch (XmlPullParserException e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* we're creating the following layout
|
* we're creating the following layout
|
||||||
*
|
*
|
||||||
+-------------------------------------------------+
|
+-------------------------------------------------+
|
||||||
| System bar (only in phone UI) |
|
| Status bar (except for xlarge tablets) |
|
||||||
+-------------------------------------------------+
|
+-------------------------------------------------+
|
||||||
| (Layout with background drawable) |
|
| (Layout with background drawable) |
|
||||||
| +---------------------------------------------+ |
|
| +---------------------------------------------+ |
|
||||||
@@ -231,20 +274,31 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
|
|||||||
| | | |
|
| | | |
|
||||||
| +---------------------------------------------+ |
|
| +---------------------------------------------+ |
|
||||||
+-------------------------------------------------+
|
+-------------------------------------------------+
|
||||||
| System bar (only in tablet UI) |
|
| Navigation bar for soft buttons, maybe see above|
|
||||||
+-------------------------------------------------+
|
+-------------------------------------------------+
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
LinearLayout topLayout = new LinearLayout(context);
|
LinearLayout topLayout = new LinearLayout(context);
|
||||||
mViewRoot = topLayout;
|
|
||||||
topLayout.setOrientation(LinearLayout.VERTICAL);
|
topLayout.setOrientation(LinearLayout.VERTICAL);
|
||||||
|
// if we don't already have a view root this is it
|
||||||
|
if (mViewRoot == null) {
|
||||||
|
mViewRoot = topLayout;
|
||||||
|
} else {
|
||||||
|
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
|
||||||
|
LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
|
||||||
|
layoutParams.weight = 1;
|
||||||
|
topLayout.setLayoutParams(layoutParams);
|
||||||
|
|
||||||
|
// this is the case of soft buttons + vertical bar.
|
||||||
|
// this top layout is the first layout in the horizontal layout. see above)
|
||||||
|
mViewRoot.addView(topLayout, 0);
|
||||||
|
}
|
||||||
|
|
||||||
if (mStatusBarSize > 0) {
|
if (mStatusBarSize > 0) {
|
||||||
// system bar
|
// system bar
|
||||||
try {
|
try {
|
||||||
PhoneSystemBar systemBar = new PhoneSystemBar(context,
|
StatusBar systemBar = new StatusBar(context, hardwareConfig.getDensity());
|
||||||
params.getDensity());
|
|
||||||
systemBar.setLayoutParams(
|
systemBar.setLayoutParams(
|
||||||
new LinearLayout.LayoutParams(
|
new LinearLayout.LayoutParams(
|
||||||
LayoutParams.MATCH_PARENT, mStatusBarSize));
|
LayoutParams.MATCH_PARENT, mStatusBarSize));
|
||||||
@@ -268,7 +322,7 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
|
|||||||
if (mActionBarSize > 0) {
|
if (mActionBarSize > 0) {
|
||||||
try {
|
try {
|
||||||
FakeActionBar actionBar = new FakeActionBar(context,
|
FakeActionBar actionBar = new FakeActionBar(context,
|
||||||
params.getDensity(),
|
hardwareConfig.getDensity(),
|
||||||
params.getAppLabel(), params.getAppIcon());
|
params.getAppLabel(), params.getAppIcon());
|
||||||
actionBar.setLayoutParams(
|
actionBar.setLayoutParams(
|
||||||
new LinearLayout.LayoutParams(
|
new LinearLayout.LayoutParams(
|
||||||
@@ -280,7 +334,7 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
|
|||||||
} else if (mTitleBarSize > 0) {
|
} else if (mTitleBarSize > 0) {
|
||||||
try {
|
try {
|
||||||
TitleBar titleBar = new TitleBar(context,
|
TitleBar titleBar = new TitleBar(context,
|
||||||
params.getDensity(), params.getAppLabel());
|
hardwareConfig.getDensity(), params.getAppLabel());
|
||||||
titleBar.setLayoutParams(
|
titleBar.setLayoutParams(
|
||||||
new LinearLayout.LayoutParams(
|
new LinearLayout.LayoutParams(
|
||||||
LayoutParams.MATCH_PARENT, mTitleBarSize));
|
LayoutParams.MATCH_PARENT, mTitleBarSize));
|
||||||
@@ -298,15 +352,23 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
|
|||||||
mContentRoot.setLayoutParams(layoutParams);
|
mContentRoot.setLayoutParams(layoutParams);
|
||||||
backgroundLayout.addView(mContentRoot);
|
backgroundLayout.addView(mContentRoot);
|
||||||
|
|
||||||
if (mSystemBarSize > 0) {
|
if (mNavigationBarOrientation == LinearLayout.HORIZONTAL &&
|
||||||
|
mNavigationBarSize > 0) {
|
||||||
// system bar
|
// system bar
|
||||||
try {
|
try {
|
||||||
TabletSystemBar systemBar = new TabletSystemBar(context,
|
CustomBar navigationBar;
|
||||||
params.getDensity());
|
if (hardwareConfig.getScreenSize() == ScreenSize.XLARGE) {
|
||||||
systemBar.setLayoutParams(
|
navigationBar = new TabletSystemBar(context,
|
||||||
|
hardwareConfig.getDensity());
|
||||||
|
} else {
|
||||||
|
navigationBar = new NavigationBar(context,
|
||||||
|
hardwareConfig.getDensity(), LinearLayout.HORIZONTAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
navigationBar.setLayoutParams(
|
||||||
new LinearLayout.LayoutParams(
|
new LinearLayout.LayoutParams(
|
||||||
LayoutParams.MATCH_PARENT, mSystemBarSize));
|
LayoutParams.MATCH_PARENT, mNavigationBarSize));
|
||||||
topLayout.addView(systemBar);
|
topLayout.addView(navigationBar);
|
||||||
} catch (XmlPullParserException e) {
|
} catch (XmlPullParserException e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -334,7 +396,7 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
|
|||||||
// get the background drawable
|
// get the background drawable
|
||||||
if (mWindowBackground != null && backgroundView != null) {
|
if (mWindowBackground != null && backgroundView != null) {
|
||||||
Drawable d = ResourceHelper.getDrawable(mWindowBackground, context);
|
Drawable d = ResourceHelper.getDrawable(mWindowBackground, context);
|
||||||
backgroundView.setBackgroundDrawable(d);
|
backgroundView.setBackground(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
return SUCCESS.createResult();
|
return SUCCESS.createResult();
|
||||||
@@ -377,13 +439,14 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
RenderingMode renderingMode = params.getRenderingMode();
|
RenderingMode renderingMode = params.getRenderingMode();
|
||||||
|
HardwareConfig hardwareConfig = params.getHardwareConfig();
|
||||||
|
|
||||||
// only do the screen measure when needed.
|
// only do the screen measure when needed.
|
||||||
boolean newRenderSize = false;
|
boolean newRenderSize = false;
|
||||||
if (mMeasuredScreenWidth == -1) {
|
if (mMeasuredScreenWidth == -1) {
|
||||||
newRenderSize = true;
|
newRenderSize = true;
|
||||||
mMeasuredScreenWidth = params.getScreenWidth();
|
mMeasuredScreenWidth = hardwareConfig.getScreenWidth();
|
||||||
mMeasuredScreenHeight = params.getScreenHeight();
|
mMeasuredScreenHeight = hardwareConfig.getScreenHeight();
|
||||||
|
|
||||||
if (renderingMode != RenderingMode.NORMAL) {
|
if (renderingMode != RenderingMode.NORMAL) {
|
||||||
int widthMeasureSpecMode = renderingMode.isHorizExpand() ?
|
int widthMeasureSpecMode = renderingMode.isHorizExpand() ?
|
||||||
@@ -483,11 +546,11 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
|
|||||||
|
|
||||||
// create an Android bitmap around the BufferedImage
|
// create an Android bitmap around the BufferedImage
|
||||||
Bitmap bitmap = Bitmap_Delegate.createBitmap(mImage,
|
Bitmap bitmap = Bitmap_Delegate.createBitmap(mImage,
|
||||||
true /*isMutable*/, params.getDensity());
|
true /*isMutable*/, hardwareConfig.getDensity());
|
||||||
|
|
||||||
// create a Canvas around the Android bitmap
|
// create a Canvas around the Android bitmap
|
||||||
mCanvas = new Canvas(bitmap);
|
mCanvas = new Canvas(bitmap);
|
||||||
mCanvas.setDensity(params.getDensity().getDpiValue());
|
mCanvas.setDensity(hardwareConfig.getDensity().getDpiValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (freshRender && newImage == false) {
|
if (freshRender && newImage == false) {
|
||||||
@@ -960,12 +1023,14 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isTabletUi() {
|
private boolean hasSoftwareButtons() {
|
||||||
return getParams().getConfigScreenSize() == ScreenSize.XLARGE;
|
return getParams().getHardwareConfig().hasSoftwareButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void findStatusBar(RenderResources resources, DisplayMetrics metrics) {
|
private void findStatusBar(RenderResources resources, DisplayMetrics metrics) {
|
||||||
if (isTabletUi() == false) {
|
// status bar is on for all but x-large device
|
||||||
|
HardwareConfig hardwareConfig = getParams().getHardwareConfig();
|
||||||
|
if (hardwareConfig.getScreenSize() != ScreenSize.XLARGE) {
|
||||||
boolean windowFullscreen = getBooleanThemeValue(resources,
|
boolean windowFullscreen = getBooleanThemeValue(resources,
|
||||||
"windowFullscreen", false /*defaultValue*/);
|
"windowFullscreen", false /*defaultValue*/);
|
||||||
|
|
||||||
@@ -1050,22 +1115,48 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void findSystemBar(RenderResources resources, DisplayMetrics metrics) {
|
private void findNavigationBar(RenderResources resources, DisplayMetrics metrics) {
|
||||||
if (isTabletUi() && mWindowIsFloating == false) {
|
if (hasSoftwareButtons() && mWindowIsFloating == false) {
|
||||||
|
|
||||||
// default value
|
// default value
|
||||||
mSystemBarSize = 48; // ??
|
mNavigationBarSize = 48; // ??
|
||||||
|
|
||||||
|
HardwareConfig hardwareConfig = getParams().getHardwareConfig();
|
||||||
|
|
||||||
|
boolean barOnBottom = true;
|
||||||
|
|
||||||
|
if (hardwareConfig.getOrientation() == ScreenOrientation.LANDSCAPE) {
|
||||||
|
// compute the dp of the screen.
|
||||||
|
int shortSize = hardwareConfig.getScreenHeight();
|
||||||
|
|
||||||
|
// compute in dp
|
||||||
|
int shortSizeDp = shortSize * DisplayMetrics.DENSITY_DEFAULT / hardwareConfig.getDensity().getDpiValue();
|
||||||
|
|
||||||
|
if (shortSizeDp < 600) {
|
||||||
|
// 0-599dp: "phone" UI with bar on the side
|
||||||
|
barOnBottom = false;
|
||||||
|
} else {
|
||||||
|
// 600+dp: "tablet" UI with bar on the bottom
|
||||||
|
barOnBottom = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (barOnBottom) {
|
||||||
|
mNavigationBarOrientation = LinearLayout.HORIZONTAL;
|
||||||
|
} else {
|
||||||
|
mNavigationBarOrientation = LinearLayout.VERTICAL;
|
||||||
|
}
|
||||||
|
|
||||||
// get the real value
|
// get the real value
|
||||||
ResourceValue value = resources.getFrameworkResource(ResourceType.DIMEN,
|
ResourceValue value = resources.getFrameworkResource(ResourceType.DIMEN,
|
||||||
"status_bar_height");
|
barOnBottom ? "navigation_bar_height" : "navigation_bar_width");
|
||||||
|
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
TypedValue typedValue = ResourceHelper.getValue("status_bar_height",
|
TypedValue typedValue = ResourceHelper.getValue("navigation_bar_height",
|
||||||
value.getValue(), true /*requireUnit*/);
|
value.getValue(), true /*requireUnit*/);
|
||||||
if (typedValue != null) {
|
if (typedValue != null) {
|
||||||
// compute the pixel value based on the display metrics
|
// compute the pixel value based on the display metrics
|
||||||
mSystemBarSize = (int)typedValue.getDimension(metrics);
|
mNavigationBarSize = (int)typedValue.getDimension(metrics);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||