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

Commit 178e2b98 authored by Adrian Roos's avatar Adrian Roos Committed by Android (Google) Code Review
Browse files

Merge "Add Emergency Calls Only and Charging State to Status Bar Header"

parents 2ad173d8 59a61275
Loading
Loading
Loading
Loading
+56 −25
Original line number Diff line number Diff line
@@ -35,12 +35,65 @@
        android:background="@drawable/notification_header_bg"
        android:clickable="true"
        />

    <View android:id="@+id/header_spacer"
        android:layout_height="8dp"
        android:layout_width="0dp" />

    <TextView
        android:id="@+id/header_emergency_calls_only"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:layout_below="@id/header_spacer"
        android:paddingTop="12dp"
        android:paddingStart="16dp"
        android:paddingEnd="16dp"
        android:visibility="gone"
        android:textAppearance="@style/TextAppearance.StatusBar.Expanded.EmergencyCallsOnly"
        android:text="@*android:string/emergency_calls_only" />

    <com.android.systemui.statusbar.phone.MultiUserSwitch android:id="@+id/multi_user_switch"
        android:layout_width="40dp"
        android:layout_height="@dimen/status_bar_header_height"
        android:layout_alignParentEnd="true"
        android:background="@null"
        android:scaleType="centerInside"
        android:padding="8dp" />

    <ImageButton android:id="@+id/settings_button"
        style="@android:style/Widget.Material.Button.Borderless"
        android:layout_toStartOf="@id/multi_user_switch"
        android:layout_width="56dp"
        android:layout_height="@dimen/status_bar_header_height"
        android:src="@drawable/ic_settings_24dp"
        android:contentDescription="@string/accessibility_desc_quick_settings"/>

    <FrameLayout android:id="@+id/system_icons_container"
        android:layout_width="wrap_content"
        android:layout_height="@dimen/status_bar_header_height"
        android:layout_toStartOf="@id/multi_user_switch"
        android:layout_marginEnd="4dp"
        android:layout_marginStart="16dp"
        />

    <TextView
        android:id="@+id/header_charging_info"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toEndOf="@id/system_icons_container"
        android:layout_below="@id/header_spacer"
        android:paddingTop="12dp"
        android:paddingEnd="16dp"
        android:paddingStart="4dp"
        style="@style/TextAppearance.StatusBar.Expanded.ChargingInfo"/>

    <RelativeLayout
        android:id="@+id/datetime"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="start"
        android:paddingTop="16dp"
        android:layout_below="@id/header_emergency_calls_only"
        android:paddingTop="8dp"
        android:paddingBottom="16dp"
        android:paddingStart="16dp"
        android:paddingEnd="16dp"
@@ -65,30 +118,6 @@
            />
    </RelativeLayout>

    <com.android.systemui.statusbar.phone.MultiUserSwitch android:id="@+id/multi_user_switch"
        android:layout_width="40dp"
        android:layout_height="@dimen/status_bar_header_height"
        android:layout_alignParentEnd="true"
        android:background="@null"
        android:scaleType="centerInside"
        android:padding="8dp"
        />

    <ImageButton android:id="@+id/settings_button"
        style="@android:style/Widget.Material.Button.Borderless"
        android:layout_toStartOf="@id/multi_user_switch"
        android:layout_width="56dp"
        android:layout_height="@dimen/status_bar_header_height"
        android:src="@drawable/ic_settings_24dp"
        android:contentDescription="@string/accessibility_desc_quick_settings"/>

    <FrameLayout android:id="@+id/system_icons_container"
        android:layout_width="wrap_content"
        android:layout_height="@dimen/status_bar_header_height"
        android:layout_toStartOf="@id/multi_user_switch"
        android:layout_marginEnd="4dp"
        />

    <com.android.keyguard.CarrierText
        android:id="@+id/keyguard_carrier_text"
        android:layout_width="match_parent"
@@ -105,6 +134,8 @@
        layout="@layout/quick_settings_brightness_dialog"
        android:id="@+id/brightness_container"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        />

    <TextView
+12 −0
Original line number Diff line number Diff line
@@ -531,6 +531,18 @@
    <string name="recents_search_bar_label">search</string>


    <!-- Expanded Status Bar Header: Battery Charged [CHAR LIMIT=40] -->
    <string name="expanded_header_battery_charged">Charged</string>

    <!-- Expanded Status Bar Header: Charging, no known time [CHAR LIMIT=40] -->
    <string name="expanded_header_battery_charging">Charging</string>

    <!-- Expanded Status Bar Header: Charging, showing time left until charged [CHAR LIMIT=40] -->
    <string name="expanded_header_battery_charging_with_time"><xliff:g id="charging_time" example="2 hrs 25 min">%s</xliff:g> until full</string>

    <!-- Expanded Status Bar Header: Not charging [CHAR LIMIT=40] -->
    <string name="expanded_header_battery_not_charging">Not charging</string>

    <!-- Glyph to be overlaid atop the battery when the level is extremely low. Do not translate. -->
    <string name="battery_meter_very_low_overlay_symbol">!</string>

+14 −2
Original line number Diff line number Diff line
@@ -70,17 +70,29 @@
    <style name="TextAppearance.StatusBar.Expanded" parent="@*android:style/TextAppearance.StatusBar" />

    <style name="TextAppearance.StatusBar.Expanded.Clock">
        <item name="android:textSize">18dp</item>
        <item name="android:textSize">16dp</item>
        <item name="android:textStyle">normal</item>
        <item name="android:textColor">#ffffff</item>
    </style>

    <style name="TextAppearance.StatusBar.Expanded.Date">
        <item name="android:textSize">14dp</item>
        <item name="android:textStyle">normal</item>
        <item name="android:textColor">#99ffffff</item>
    </style>

    <style name="TextAppearance.StatusBar.Expanded.AboveDateTime">
        <item name="android:textSize">12dp</item>
        <item name="android:textStyle">normal</item>
        <item name="android:textColor">#afb3b6</item>
        <item name="android:textColor">#99ffffff</item>
    </style>

    <style name="TextAppearance.StatusBar.Expanded.EmergencyCallsOnly"
           parent="TextAppearance.StatusBar.Expanded.AboveDateTime" />

    <style name="TextAppearance.StatusBar.Expanded.ChargingInfo"
            parent="TextAppearance.StatusBar.Expanded.AboveDateTime" />

    <style name="TextAppearance.StatusBar.Expanded.Network" parent="@style/TextAppearance.StatusBar.Expanded.Date">
        <item name="android:textColor">#999999</item>
	</style>
+5 −17
Original line number Diff line number Diff line
@@ -266,7 +266,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
    private TextView mCarrierLabel;
    private boolean mCarrierLabelVisible = false;
    private int mCarrierLabelHeight;
    private TextView mEmergencyCallLabel;
    private int mStatusBarHeaderHeight;

    private boolean mShowCarrierInPanel = false;
@@ -720,23 +719,9 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,

        mNetworkController.addSignalCluster(signalCluster);
        signalCluster.setNetworkController(mNetworkController);

        final boolean isAPhone = mNetworkController.hasVoiceCallingFeature();
        if (isAPhone) {
            mEmergencyCallLabel =
                    (TextView) mStatusBarWindow.findViewById(R.id.emergency_calls_only);
            // TODO: Uncomment when correctly positioned
//            if (mEmergencyCallLabel != null) {
//                mNetworkController.addEmergencyLabelView(mEmergencyCallLabel);
//                mEmergencyCallLabel.setOnClickListener(new View.OnClickListener() {
//                    public void onClick(View v) { }});
//                mEmergencyCallLabel.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
//                    @Override
//                    public void onLayoutChange(View v, int left, int top, int right, int bottom,
//                            int oldLeft, int oldTop, int oldRight, int oldBottom) {
//                        updateCarrierLabelVisibility(false);
//                    }});
//            }
            mNetworkController.addEmergencyLabelView(mHeader);
        }

        mCarrierLabel = (TextView)mStatusBarWindow.findViewById(R.id.carrier_label);
@@ -762,6 +747,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
//                    updateCarrierLabelVisibility(false);
        }

        mBatteryController.setStatusBarHeaderView(mHeader);

        // Set up the quick settings tile panel
        mQSPanel = (QSPanel) mStatusBarWindow.findViewById(R.id.quick_settings_panel);
        if (mQSPanel != null) {
@@ -1351,7 +1338,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
                    mCarrierLabelHeight));
        }

        final boolean emergencyCallsShownElsewhere = mEmergencyCallLabel != null;
        // Emergency calls only is shown in the expanded header now.
        final boolean emergencyCallsShownElsewhere = true;
        final boolean makeVisible =
            !(emergencyCallsShownElsewhere && mNetworkController.isEmergencyOnly())
            && mStackScroller.getHeight() < (mNotificationPanel.getHeight()
+50 −3
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.android.systemui.R;
import com.android.systemui.qs.QSPanel;
@@ -57,6 +58,11 @@ public class StatusBarHeaderView extends RelativeLayout implements View.OnClickL
    private View mSignalCluster;
    private View mSettingsButton;
    private View mBrightnessContainer;
    private View mEmergencyCallsOnly;
    private TextView mChargingInfo;

    private boolean mShowEmergencyCallsOnly;
    private boolean mShowChargingInfo;

    private int mCollapsedHeight;
    private int mExpandedHeight;
@@ -91,6 +97,8 @@ public class StatusBarHeaderView extends RelativeLayout implements View.OnClickL
        mBrightnessController = new BrightnessController(getContext(),
                (ImageView) findViewById(R.id.brightness_icon),
                (ToggleSlider) findViewById(R.id.brightness_slider));
        mEmergencyCallsOnly = findViewById(R.id.header_emergency_calls_only);
        mChargingInfo = (TextView) findViewById(R.id.header_charging_info);
        loadDimens();
        updateVisibilities();
        addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
@@ -195,13 +203,32 @@ public class StatusBarHeaderView extends RelativeLayout implements View.OnClickL
        if (mSignalCluster != null) {
            mSignalCluster.setVisibility(!mExpanded || mOverscrolled ? View.VISIBLE : View.GONE);
        }
        mEmergencyCallsOnly.setVisibility(mExpanded && !mOverscrolled && mShowEmergencyCallsOnly
                ? VISIBLE : GONE);
        mChargingInfo.setVisibility(mExpanded && !mOverscrolled && mShowChargingInfo
                && !mShowEmergencyCallsOnly ? VISIBLE : GONE);
    }

    private void updateSystemIconsLayoutParams() {
        RelativeLayout.LayoutParams lp = (LayoutParams) mSystemIconsContainer.getLayoutParams();
        boolean systemIconsAboveClock = mExpanded && !mOverscrolled
                && mShowChargingInfo && !mShowEmergencyCallsOnly;
        if (systemIconsAboveClock) {
            lp.addRule(ALIGN_PARENT_START);
            lp.removeRule(START_OF);
        } else {
            lp.addRule(RelativeLayout.START_OF, mExpanded
                    ? mSettingsButton.getId()
                    : mMultiUserSwitch.getId());
            lp.removeRule(ALIGN_PARENT_START);
        }

        RelativeLayout.LayoutParams clockLp = (LayoutParams) mDateTime.getLayoutParams();
        if (systemIconsAboveClock) {
            clockLp.addRule(BELOW, mChargingInfo.getId());
        } else {
            clockLp.addRule(BELOW, mEmergencyCallsOnly.getId());
        }
    }

    private void updateBrightnessControllerState() {
@@ -307,4 +334,24 @@ public class StatusBarHeaderView extends RelativeLayout implements View.OnClickL
            mBrightnessContainer.animate().alpha(showingDetail ? 0 : 1).withLayer().start();
        }
    };

    public void setShowEmergencyCallsOnly(boolean show) {
        mShowEmergencyCallsOnly = show;
        if (mExpanded) {
            updateVisibilities();
            updateSystemIconsLayoutParams();
        }
    }

    public void setShowChargingInfo(boolean showChargingInfo) {
        mShowChargingInfo = showChargingInfo;
        if (mExpanded) {
            updateVisibilities();
            updateSystemIconsLayoutParams();
        }
    }

    public void setChargingInfo(CharSequence chargingInfo) {
        mChargingInfo.setText(chargingInfo);
    }
}
Loading