Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9b39c49b authored by Diego Perez's avatar Diego Perez
Browse files

Make status and navigation bars widgets and usable from layouts

This will allow the theme editor to render these components
separately.

Change-Id: I8b2e0e78039b44623152e34f68ffcdfab5aa9885
parent 220f360e
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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";
    }

    /**
+19 −0
Original line number Diff line number Diff line
@@ -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",
+15 −0
Original line number Diff line number Diff line
@@ -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.