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

Commit d86824ef authored by Nihanth Subramanya's avatar Nihanth Subramanya
Browse files

Make compact carrier not require reboot

This flashed to me all of a sudden yesterday.
No idea why I didn't do it this way from the start.

Change-Id: I390ba8e9f675667060280644a61dbcbbe5db4426
parent 4c7381ad
Loading
Loading
Loading
Loading
+28 −1
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@
            android:layout_height="wrap_content"
            />

        <LinearLayout
        <LinearLayout android:id="@+id/carrier_label_layout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
@@ -127,9 +127,36 @@
                    android:layout_height="wrap_content"
                    android:orientation="vertical"
                    />
                <TextView android:id="@+id/compact_clear_all_button"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="right|center_vertical"
                    android:layout_marginTop="4dp"
                    android:layout_marginBottom="1dp"
                    android:text="@string/status_bar_clear_all_button"
                    style="@style/StatusBar.ClearButton"
                    android:paddingLeft="15dp"
                    android:paddingRight="15dp"
                    />
            </com.android.systemui.statusbar.NotificationLinearLayout>
        </ScrollView>

        <LinearLayout android:id="@+id/compact_carrier_layout"
            android:orientation="horizontal"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            >
            <com.android.systemui.statusbar.CarrierLabel
                 android:gravity="bottom|right|center"
                 android:textAppearance="@style/TextAppearance.StatusBar.Title"
                 android:background="@android:color/transparent"
                 android:layout_marginRight="6.0dip"
                 android:layout_width="fill_parent"
                 android:layout_height="wrap_content"
                 android:layout_alignParentRight="true"
                 />
        </LinearLayout>

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
+0 −135
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
/* apps/common/assets/default/default/skins/StatusBar.xml
**
** Copyright 2006, 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.
*/
-->

<com.android.systemui.statusbar.ExpandedView xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:focusable="true"
    android:descendantFocusability="afterDescendants"
    >

    <LinearLayout android:id="@+id/power_and_carrier"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:paddingTop="3dp"
        android:paddingBottom="5dp"
        android:paddingRight="3dp"
        android:background="@drawable/title_bar_portrait"
        >
        <com.android.systemui.statusbar.powerwidget.PowerWidget android:id="@+id/exp_power_stat"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            />
    </LinearLayout>

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        >
        <ScrollView
            android:id="@+id/scroll"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fadingEdge="none"
            android:overScrollMode="ifContentScrolls"
            >
            <com.android.systemui.statusbar.NotificationLinearLayout
                android:id="@+id/notificationLinearLayout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                >

                <TextView android:id="@+id/noNotificationsTitle"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@drawable/shade_header_background"
                    android:paddingLeft="5dp"
                    android:textAppearance="@style/TextAppearance.StatusBar.Title"
                    android:text="@string/status_bar_no_notifications_title"
                    />

                <TextView android:id="@+id/ongoingTitle"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@drawable/shade_header_background"
                    android:paddingLeft="5dp"
                    android:textAppearance="@style/TextAppearance.StatusBar.Title"
                    android:text="@string/status_bar_ongoing_events_title"
                    />
                <LinearLayout android:id="@+id/ongoingItems"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical"
                    />

                <TextView android:id="@+id/latestTitle"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@drawable/shade_header_background"
                    android:paddingLeft="5dp"
                    android:textAppearance="@style/TextAppearance.StatusBar.Title"
                    android:text="@string/status_bar_latest_events_title"
                    />
                <LinearLayout android:id="@+id/latestItems"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical"
                    />
                <TextView android:id="@+id/clear_all_button"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="right|center_vertical"
                    android:layout_marginTop="4dp"
                    android:layout_marginBottom="1dp"
                    android:text="@string/status_bar_clear_all_button"
                    style="@style/StatusBar.ClearButton"
                    android:paddingLeft="15dp"
                    android:paddingRight="15dp"
                />
            </com.android.systemui.statusbar.NotificationLinearLayout>
        </ScrollView>

        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            >
            <com.android.systemui.statusbar.CarrierLabel
                 android:gravity="bottom|right|center"
                 android:textAppearance="@style/TextAppearance.StatusBar.Title"
                 android:background="@android:color/transparent"
                 android:layout_marginRight="6.0dip"
                 android:layout_width="fill_parent"
                 android:layout_height="wrap_content"
                 android:layout_alignParentRight="true"
                 />
        </LinearLayout>

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:src="@drawable/title_bar_shadow"
            android:scaleType="fitXY"
        />

    </FrameLayout>
</com.android.systemui.statusbar.ExpandedView>
+48 −19
Original line number Diff line number Diff line
@@ -136,6 +136,7 @@ public class StatusBarService extends Service implements CommandQueue.Callbacks
    // top bar
    TextView mNoNotificationsTitle;
    TextView mClearButton;
    TextView mCompactClearButton;
    ViewGroup mClearButtonParent;
    CmBatteryMiniIcon mCmBatteryMiniIcon;
    // drag bar
@@ -165,6 +166,11 @@ public class StatusBarService extends Service implements CommandQueue.Callbacks
    // the power widget
    PowerWidget mPowerWidget;

    //Carrier label stuff
    LinearLayout mCarrierLabelLayout;
    LinearLayout mCompactCarrierLayout;
    LinearLayout mPowerAndCarrier;

    // ticker
    private Ticker mTicker;
    private View mTickerView;
@@ -213,6 +219,10 @@ public class StatusBarService extends Service implements CommandQueue.Callbacks
                    Settings.System.getUriFor(Settings.System.SOFT_BUTTONS_LEFT), false, this);
            resolver.registerContentObserver(
                    Settings.System.getUriFor(Settings.System.STATUS_BAR_DEAD_ZONE), false, this);
            resolver.registerContentObserver(
                    Settings.System.getUriFor(Settings.System.STATUS_BAR_COMPACT_CARRIER), false, this);
            resolver.registerContentObserver(
                    Settings.System.getUriFor(Settings.System.EXPANDED_VIEW_WIDGET), false, this);
            onChange(true);
        }

@@ -230,7 +240,10 @@ public class StatusBarService extends Service implements CommandQueue.Callbacks
            defValue=(CmSystem.getDefaultBool(mContext, CmSystem.CM_DEFAULT_USE_DEAD_ZONE) ? 1 : 0);
            mDeadZone = (Settings.System.getInt(resolver,
                    Settings.System.STATUS_BAR_DEAD_ZONE, defValue) == 1);
            mCompactCarrier = (Settings.System.getInt(resolver,
                    Settings.System.STATUS_BAR_COMPACT_CARRIER, 0) == 1);
            updateLayout();
            updateCarrierLabel();
        }
    }

@@ -342,7 +355,7 @@ public class StatusBarService extends Service implements CommandQueue.Callbacks
        return null;
    }

    private boolean compactCarrier = false;
    private boolean mCompactCarrier = false;

    // ================================================================================
    // Constructing the view
@@ -353,11 +366,9 @@ public class StatusBarService extends Service implements CommandQueue.Callbacks
        mIconSize = res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_icon_size);

        //Check for compact carrier layout and apply if enabled
        compactCarrier = Settings.System.getInt(getContentResolver(),
        mCompactCarrier = Settings.System.getInt(getContentResolver(),
                                                Settings.System.STATUS_BAR_COMPACT_CARRIER, 0) == 1;
        ExpandedView expanded = compactCarrier ? (ExpandedView)View.inflate(context,
                                                R.layout.status_bar_expanded_compact_carrier, null) :
                                                (ExpandedView)View.inflate(context,
        ExpandedView expanded = (ExpandedView)View.inflate(context,
                                                R.layout.status_bar_expanded, null);
        expanded.mService = this;

@@ -389,7 +400,9 @@ public class StatusBarService extends Service implements CommandQueue.Callbacks
        mNoNotificationsTitle = (TextView)expanded.findViewById(R.id.noNotificationsTitle);
        mClearButton = (TextView)expanded.findViewById(R.id.clear_all_button);
        mClearButton.setOnClickListener(mClearButtonListener);
        mClearButtonParent = (ViewGroup)mClearButton.getParent();
        mCompactClearButton = (TextView)expanded.findViewById(R.id.compact_clear_all_button);
        mCompactClearButton.setOnClickListener(mClearButtonListener);
        mPowerAndCarrier = (LinearLayout)expanded.findViewById(R.id.power_and_carrier);
        mScrollView = (ScrollView)expanded.findViewById(R.id.scroll);
        mNotificationLinearLayout = expanded.findViewById(R.id.notificationLinearLayout);

@@ -414,6 +427,9 @@ public class StatusBarService extends Service implements CommandQueue.Callbacks
                   }
               });

        mCarrierLabelLayout = (LinearLayout)expanded.findViewById(R.id.carrier_label_layout);
        mCompactCarrierLayout = (LinearLayout)expanded.findViewById(R.id.compact_carrier_layout);

        mTicker = new MyTicker(context, sb);

        TickerView tickerView = (TickerView)sb.findViewById(R.id.tickerText);
@@ -424,8 +440,9 @@ public class StatusBarService extends Service implements CommandQueue.Callbacks
        mCloseView = (CloseDragHandle)mTrackingView.findViewById(R.id.close);
        mCloseView.mService = this;

        updateLayout();
        mContext=context;
        updateLayout();
        updateCarrierLabel();

        mEdgeBorder = res.getDimensionPixelSize(R.dimen.status_bar_edge_ignore);

@@ -434,6 +451,20 @@ public class StatusBarService extends Service implements CommandQueue.Callbacks
        mDateView.setVisibility(View.INVISIBLE);
    }

    private void updateCarrierLabel() {
        if (mCompactCarrier) {
            mCarrierLabelLayout.setVisibility(View.GONE);
            mCompactCarrierLayout.setVisibility(View.VISIBLE);
            if (mLatest.hasClearableItems())
                mCompactClearButton.setVisibility(View.VISIBLE);
        } else {
            mCarrierLabelLayout.setVisibility(View.VISIBLE);
            mCompactCarrierLayout.setVisibility(View.GONE);
            mCompactClearButton.setVisibility(View.GONE);
        }

    }

    private void updateLayout() {
        if(mTrackingView==null || mCloseView==null || mExpandedView==null)
            return;
@@ -453,7 +484,13 @@ public class StatusBarService extends Service implements CommandQueue.Callbacks

        // readd in right order
        mExpandedView.addView(powerAndCarrier, mBottomBar ? 1 : 0);
        powerAndCarrier.addView(power, mBottomBar && !compactCarrier ? 1 : 0);
        powerAndCarrier.addView(power, mBottomBar && !mCompactCarrier ? 1 : 0);

        //remove small ugly grey area if compactcarrier is enabled and power widget disabled
        boolean hideArea = mCompactCarrier &&
                           Settings.System.getInt(mContext.getContentResolver(),
                                   Settings.System.EXPANDED_VIEW_WIDGET, 1) == 0;
        mPowerAndCarrier.setVisibility(hideArea ? View.GONE : View.VISIBLE);
    }

    protected void addStatusBarView() {
@@ -741,25 +778,17 @@ public class StatusBarService extends Service implements CommandQueue.Callbacks
        return entry.notification;
    }

    private boolean isClearButtonAdded = false;

    private void setAreThereNotifications() {
        boolean ongoing = mOngoing.hasVisibleItems();
        boolean latest = mLatest.hasVisibleItems();

        // (no ongoing notifications are clearable)
        if (mLatest.hasClearableItems()) {
            if (mCompactCarrier) mCompactClearButton.setVisibility(View.VISIBLE);
            mClearButton.setVisibility(View.VISIBLE);
            if (compactCarrier && !isClearButtonAdded) {
                mClearButtonParent.addView(mClearButton);
                isClearButtonAdded = true;
            }
        } else {
            mCompactClearButton.setVisibility(View.GONE);
            mClearButton.setVisibility(View.INVISIBLE);
            if (compactCarrier) {
                mClearButtonParent.removeView(mClearButton);
                isClearButtonAdded = false;
            }
        }

        mOngoingTitle.setVisibility(ongoing ? View.VISIBLE : View.GONE);