am b1ad4a15: LayoutLib: Fix true transparency in status bar. [DO NOT MERGE]
* commit 'b1ad4a155957160de9c4ad5c5beb39ce00ef6799': LayoutLib: Fix true transparency in status bar. [DO NOT MERGE]
This commit is contained in:
@@ -33,6 +33,7 @@ import org.xmlpull.v1.XmlPullParser;
|
|||||||
import org.xmlpull.v1.XmlPullParserException;
|
import org.xmlpull.v1.XmlPullParserException;
|
||||||
|
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
|
import android.annotation.Nullable;
|
||||||
import android.content.res.ColorStateList;
|
import android.content.res.ColorStateList;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.Bitmap_Delegate;
|
import android.graphics.Bitmap_Delegate;
|
||||||
@@ -227,16 +228,18 @@ abstract class CustomBar extends LinearLayout {
|
|||||||
* Find the background color for this bar from the theme attributes. Only relevant to StatusBar
|
* Find the background color for this bar from the theme attributes. Only relevant to StatusBar
|
||||||
* and NavigationBar.
|
* and NavigationBar.
|
||||||
* <p/>
|
* <p/>
|
||||||
* Returns 0 if not found.
|
* Returns null if not found.
|
||||||
*
|
*
|
||||||
* @param colorAttrName the attribute name for the background color
|
* @param colorAttrName the attribute name for the background color
|
||||||
* @param translucentAttrName the attribute name for the translucency property of the bar.
|
* @param translucentAttrName the attribute name for the translucency property of the bar.
|
||||||
*
|
*
|
||||||
* @throws NumberFormatException if color resolved to an invalid string.
|
* @throws NumberFormatException if color resolved to an invalid string.
|
||||||
*/
|
*/
|
||||||
protected int getBarColor(@NonNull String colorAttrName, @NonNull String translucentAttrName) {
|
@Nullable
|
||||||
|
protected Integer getBarColor(@NonNull String colorAttrName,
|
||||||
|
@NonNull String translucentAttrName) {
|
||||||
if (!Config.isGreaterOrEqual(mSimulatedPlatformVersion, LOLLIPOP)) {
|
if (!Config.isGreaterOrEqual(mSimulatedPlatformVersion, LOLLIPOP)) {
|
||||||
return 0;
|
return null;
|
||||||
}
|
}
|
||||||
RenderResources renderResources = getContext().getRenderResources();
|
RenderResources renderResources = getContext().getRenderResources();
|
||||||
// First check if the bar is translucent.
|
// First check if the bar is translucent.
|
||||||
@@ -251,10 +254,11 @@ abstract class CustomBar extends LinearLayout {
|
|||||||
if (transparent) {
|
if (transparent) {
|
||||||
return getColor(renderResources, colorAttrName);
|
return getColor(renderResources, colorAttrName);
|
||||||
}
|
}
|
||||||
return 0;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getColor(RenderResources renderResources, String attr) {
|
@Nullable
|
||||||
|
private static Integer getColor(RenderResources renderResources, String attr) {
|
||||||
// From ?attr/foo to @color/bar. This is most likely an ItemResourceValue.
|
// From ?attr/foo to @color/bar. This is most likely an ItemResourceValue.
|
||||||
ResourceValue resource = renderResources.findItemInTheme(attr, true);
|
ResourceValue resource = renderResources.findItemInTheme(attr, true);
|
||||||
// Form @color/bar to the #AARRGGBB
|
// Form @color/bar to the #AARRGGBB
|
||||||
@@ -275,7 +279,7 @@ abstract class CustomBar extends LinearLayout {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ResourceValue getResourceValue(String reference) {
|
private ResourceValue getResourceValue(String reference) {
|
||||||
|
|||||||
@@ -62,8 +62,8 @@ public class NavigationBar extends CustomBar {
|
|||||||
super(context, orientation, "/bars/navigation_bar.xml", "navigation_bar.xml",
|
super(context, orientation, "/bars/navigation_bar.xml", "navigation_bar.xml",
|
||||||
simulatedPlatformVersion);
|
simulatedPlatformVersion);
|
||||||
|
|
||||||
int color = getBarColor(ATTR_COLOR, ATTR_TRANSLUCENT);
|
Integer color = getBarColor(ATTR_COLOR, ATTR_TRANSLUCENT);
|
||||||
setBackgroundColor(color == 0 ? 0xFF000000 : color);
|
setBackgroundColor(color == null ? 0xFF000000 : color);
|
||||||
|
|
||||||
// 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.
|
||||||
|
|||||||
@@ -71,8 +71,9 @@ public class StatusBar extends CustomBar {
|
|||||||
// FIXME: use FILL_H?
|
// FIXME: use FILL_H?
|
||||||
setGravity(Gravity.START | Gravity.TOP | Gravity.RIGHT);
|
setGravity(Gravity.START | Gravity.TOP | Gravity.RIGHT);
|
||||||
|
|
||||||
int color = getBarColor(ATTR_COLOR, ATTR_TRANSLUCENT);
|
Integer color = getBarColor(ATTR_COLOR, ATTR_TRANSLUCENT);
|
||||||
setBackgroundColor(color == 0 ? Config.getStatusBarColor(simulatedPlatformVersion) : color);
|
setBackgroundColor(
|
||||||
|
color == null ? Config.getStatusBarColor(simulatedPlatformVersion) : color);
|
||||||
|
|
||||||
// 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.
|
||||||
|
|||||||
@@ -421,8 +421,7 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
|
|||||||
gc.setComposite(AlphaComposite.Src);
|
gc.setComposite(AlphaComposite.Src);
|
||||||
|
|
||||||
gc.setColor(new Color(0x00000000, true));
|
gc.setColor(new Color(0x00000000, true));
|
||||||
gc.fillRect(0, 0,
|
gc.fillRect(0, 0, mMeasuredScreenWidth, mMeasuredScreenHeight);
|
||||||
mMeasuredScreenWidth, mMeasuredScreenHeight);
|
|
||||||
|
|
||||||
// done
|
// done
|
||||||
gc.dispose();
|
gc.dispose();
|
||||||
|
|||||||
Reference in New Issue
Block a user