From fb0c74a8833444c5065dcd104c402cdf4c208a5e Mon Sep 17 00:00:00 2001 From: beanstown106 Date: Thu, 20 Oct 2016 15:46:47 +0200 Subject: [PATCH] Custom Carrier Label & Carrier Label Placement [1/2] Squash commits: Keyguard/Statusbar Carrier label options [1/2] * Stock behavior(only on keyguard), only on statusbar,both disabled or both enabled * code originally writted by @Altaf-Mahdi i just squased into one commit PureNexusProject-Legacy/android_frameworks_base@688d56f Show carrier label / custom & change color [1/2] *code originally written by @martincz *includes various fixs by the du team PureNexusProject-Legacy/android_frameworks_base@16a247a Carrier label - fix capitilization bug PureNexusProject-Legacy/android_frameworks_base@4b9e22b remove carrier label color and make carrier label play nice with dark statusbar PureNexusProject-Legacy/android_frameworks_base@3f32102 Fix Carrier Label font size not changing on system font size change DirtyUnicorns/android_frameworks_base@8da9dcf include carrier label in icon merger width calculation PureNexusProject-Legacy/android_frameworks_base@9df3a0c Credit/Thanks to @Altaf-Mahdi @beanstown106 @dwitherell and @martincz PureNexus Edits: - Adapt statusbar hook for N AICPfy: - Adapt for AICP (CM14) source - add missing @hide AICP brought up to O by AliB: - Adapt to O statusbar - Adapt to DarkController - parts of the code adapted from http://gerrit.aicp-rom.com/#/c/53587/ Change-Id: Ic1ecdbc606248dce5b2a2277374a8fa04c23b164 Signed-off-by: PMS22 --- core/java/android/content/Intent.java | 15 ++ core/java/android/provider/Settings.java | 22 ++- .../res/layout/keyguard_status_bar.xml | 5 +- .../res/layout/notification_icon_area.xml | 2 +- packages/SystemUI/res/layout/status_bar.xml | 9 ++ packages/SystemUI/res/values/fh_colors.xml | 3 + packages/SystemUI/res/values/fh_dimens.xml | 7 + packages/SystemUI/res/values/fh_styles.xml | 7 + .../fh/carrierlabel/CarrierLabel.java | 151 ++++++++++++++++++ .../systemui/fh/carrierlabel/SpnOverride.java | 95 +++++++++++ .../systemui/qs/tiles/WeatherTile.java | 2 +- .../phone/CollapsedStatusBarFragment.java | 75 ++++++++- .../phone/KeyguardStatusBarView.java | 30 ++++ .../systemui/statusbar/phone/StatusBar.java | 1 - 14 files changed, 406 insertions(+), 18 deletions(-) create mode 100644 packages/SystemUI/src/com/android/systemui/fh/carrierlabel/CarrierLabel.java create mode 100644 packages/SystemUI/src/com/android/systemui/fh/carrierlabel/SpnOverride.java diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java index 08acfb651b1..63b5077d80d 100644 --- a/core/java/android/content/Intent.java +++ b/core/java/android/content/Intent.java @@ -2775,6 +2775,21 @@ public static Intent createChooser(Intent target, CharSequence title, IntentSend @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE"; + /** + *

Broadcast Action: The user has changed carrier label:

+ * + * + *

This is a protected intent that can only be sent + * by the system. + * + * @hide + */ + //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String ACTION_CUSTOM_CARRIER_LABEL_CHANGED + = "android.intent.action.CUSTOM_CARRIER_LABEL"; + /** * Broadcast Action: Some content providers have parts of their namespace * where they publish new events or items that the user may be especially diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 5c96eb3cc24..8175875a1f9 100755 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -4072,11 +4072,6 @@ public boolean validate(String value) { */ public static final String QS_TILE_TITLE_VISIBILITY = "qs_tile_title_visibility"; - /** - * @hide - */ - public static final String OMNIJAWS_WEATHER_ICON_PACK = "omnijaws_weather_icon_pack"; - /** * Change volume up and down handlign based on rotation * @hide @@ -4588,6 +4583,23 @@ public boolean validate(String value) { */ public static final String STATUS_BAR_FILE_HEADER_IMAGE = "status_bar_file_header_image"; + /** + * Status bar carrier label + * 0: Hide + * 1: Display on keyguard status bar + * 2: Display on Normal status bar + * 3: Enabled for both + * @hide + */ + public static final String STATUS_BAR_SHOW_CARRIER = "status_bar_show_carrier"; + + /** + * custom carrier label. The value is + * String. + * @hide + */ + public static final String CUSTOM_CARRIER_LABEL = "custom_carrier_label"; + /** * Settings to backup. This is here so that it's in the same place as the settings * keys and easy to update. diff --git a/packages/SystemUI/res/layout/keyguard_status_bar.xml b/packages/SystemUI/res/layout/keyguard_status_bar.xml index cd1c84bf7bd..ea927e79024 100644 --- a/packages/SystemUI/res/layout/keyguard_status_bar.xml +++ b/packages/SystemUI/res/layout/keyguard_status_bar.xml @@ -54,7 +54,7 @@ - diff --git a/packages/SystemUI/res/layout/notification_icon_area.xml b/packages/SystemUI/res/layout/notification_icon_area.xml index 6732e6c62e8..9a578c2247d 100644 --- a/packages/SystemUI/res/layout/notification_icon_area.xml +++ b/packages/SystemUI/res/layout/notification_icon_area.xml @@ -26,4 +26,4 @@ android:layout_alignParentStart="true" android:gravity="center_vertical" android:orientation="horizontal"/> - \ No newline at end of file + diff --git a/packages/SystemUI/res/layout/status_bar.xml b/packages/SystemUI/res/layout/status_bar.xml index 7fb804f01f1..8747464188b 100644 --- a/packages/SystemUI/res/layout/status_bar.xml +++ b/packages/SystemUI/res/layout/status_bar.xml @@ -60,6 +60,15 @@ android:gravity="center_vertical|start" /> + + @*android:color/accent_device_default_light @android:color/white + + #FFFFFFFF + diff --git a/packages/SystemUI/res/values/fh_dimens.xml b/packages/SystemUI/res/values/fh_dimens.xml index a964a71f268..7f1371c8b1a 100644 --- a/packages/SystemUI/res/values/fh_dimens.xml +++ b/packages/SystemUI/res/values/fh_dimens.xml @@ -44,5 +44,12 @@ 8dp + 40dp + + + 14dp + 40dp + 25dp + 85dp diff --git a/packages/SystemUI/res/values/fh_styles.xml b/packages/SystemUI/res/values/fh_styles.xml index fbcbe974afb..2adfd74b8f5 100644 --- a/packages/SystemUI/res/values/fh_styles.xml +++ b/packages/SystemUI/res/values/fh_styles.xml @@ -41,4 +41,11 @@ ?android:attr/textColorPrimary + + + diff --git a/packages/SystemUI/src/com/android/systemui/fh/carrierlabel/CarrierLabel.java b/packages/SystemUI/src/com/android/systemui/fh/carrierlabel/CarrierLabel.java new file mode 100644 index 00000000000..1e2fb3955bd --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/fh/carrierlabel/CarrierLabel.java @@ -0,0 +1,151 @@ +/* + * Copyright (C) 2014-2015 The MoKee OpenSource 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.systemui.fh.carrierlabel; + +import android.content.BroadcastReceiver; +import android.content.ContentResolver; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.database.ContentObserver; +import android.graphics.Rect; +import android.os.Handler; +import com.android.internal.util.fh.FhUtils; +import android.os.UserHandle; +import android.provider.Settings; +import android.telephony.TelephonyManager; +import android.text.TextUtils; +import android.util.AttributeSet; +import android.util.Log; +import android.view.View; +import android.widget.TextView; + +import com.android.internal.telephony.TelephonyIntents; +import com.android.systemui.Dependency; +import com.android.systemui.fh.carrierlabel.SpnOverride; +import com.android.systemui.statusbar.policy.DarkIconDispatcher; +import com.android.systemui.statusbar.policy.DarkIconDispatcher.DarkReceiver; + +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.TimeZone; + +import com.android.systemui.R; + +public class CarrierLabel extends TextView implements DarkReceiver { + + private Context mContext; + private boolean mAttached; + private static boolean isCN; + + public CarrierLabel(Context context) { + this(context, null); + } + + public CarrierLabel(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + public CarrierLabel(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + mContext = context; + updateNetworkName(true, null, false, null); + } + + @Override + protected void onAttachedToWindow() { + super.onAttachedToWindow(); + Dependency.get(DarkIconDispatcher.class).addDarkReceiver(this); + if (!mAttached) { + mAttached = true; + IntentFilter filter = new IntentFilter(); + filter.addAction(TelephonyIntents.SPN_STRINGS_UPDATED_ACTION); + filter.addAction(Intent.ACTION_CUSTOM_CARRIER_LABEL_CHANGED); + mContext.registerReceiver(mIntentReceiver, filter, null, getHandler()); + } + } + + @Override + protected void onDetachedFromWindow() { + super.onDetachedFromWindow(); + Dependency.get(DarkIconDispatcher.class).removeDarkReceiver(this); + if (mAttached) { + mContext.unregisterReceiver(mIntentReceiver); + mAttached = false; + } + } + + @Override + public void onDarkChanged(Rect area, float darkIntensity, int tint) { + setTextColor(DarkIconDispatcher.getTint(area, this, tint)); + } + + private final BroadcastReceiver mIntentReceiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + String action = intent.getAction(); + if (TelephonyIntents.SPN_STRINGS_UPDATED_ACTION.equals(action) + || Intent.ACTION_CUSTOM_CARRIER_LABEL_CHANGED.equals(action)) { + updateNetworkName(intent.getBooleanExtra(TelephonyIntents.EXTRA_SHOW_SPN, true), + intent.getStringExtra(TelephonyIntents.EXTRA_SPN), + intent.getBooleanExtra(TelephonyIntents.EXTRA_SHOW_PLMN, false), + intent.getStringExtra(TelephonyIntents.EXTRA_PLMN)); + isCN = FhUtils.isChineseLanguage(); + } + } + }; + + void updateNetworkName(boolean showSpn, String spn, boolean showPlmn, String plmn) { + final String str; + final boolean plmnValid = showPlmn && !TextUtils.isEmpty(plmn); + final boolean spnValid = showSpn && !TextUtils.isEmpty(spn); + if (spnValid) { + str = spn; + } else if (plmnValid) { + str = plmn; + } else { + str = ""; + } + String customCarrierLabel = Settings.System.getStringForUser(mContext.getContentResolver(), + Settings.System.CUSTOM_CARRIER_LABEL, UserHandle.USER_CURRENT); + if (!TextUtils.isEmpty(customCarrierLabel)) { + setText(customCarrierLabel); + } else { + setText(TextUtils.isEmpty(str) ? getOperatorName() : str); + } + } + + private String getOperatorName() { + String operatorName = getContext().getString(R.string.quick_settings_wifi_no_network); + TelephonyManager telephonyManager = (TelephonyManager) getContext().getSystemService( + Context.TELEPHONY_SERVICE); + if (isCN) { + String operator = telephonyManager.getNetworkOperator(); + if (TextUtils.isEmpty(operator)) { + operator = telephonyManager.getSimOperator(); + } + SpnOverride mSpnOverride = new SpnOverride(); + operatorName = mSpnOverride.getSpn(operator); + } else { + operatorName = telephonyManager.getNetworkOperatorName(); + } + if (TextUtils.isEmpty(operatorName)) { + operatorName = telephonyManager.getSimOperatorName(); + } + return operatorName; + } +} diff --git a/packages/SystemUI/src/com/android/systemui/fh/carrierlabel/SpnOverride.java b/packages/SystemUI/src/com/android/systemui/fh/carrierlabel/SpnOverride.java new file mode 100644 index 00000000000..5c86bbbed26 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/fh/carrierlabel/SpnOverride.java @@ -0,0 +1,95 @@ +/* + * Copyright (C) 2014 The MoKee OpenSource 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.systemui.fh.carrierlabel; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.util.HashMap; + +import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; + +import android.os.Environment; +import android.telephony.Rlog; +import android.util.Xml; + +import com.android.internal.util.XmlUtils; + +public class SpnOverride { + private HashMap mCarrierSpnMap; + + + static final String LOG_TAG = "SpnOverride"; + static final String PARTNER_SPN_OVERRIDE_PATH ="etc/spn-conf.xml"; + + public SpnOverride () { + mCarrierSpnMap = new HashMap(); + loadSpnOverrides(); + } + + public boolean containsCarrier(String carrier) { + return mCarrierSpnMap.containsKey(carrier); + } + + public String getSpn(String carrier) { + return mCarrierSpnMap.get(carrier); + } + + private void loadSpnOverrides() { + FileReader spnReader; + + final File spnFile = new File(Environment.getRootDirectory(), + PARTNER_SPN_OVERRIDE_PATH); + + try { + spnReader = new FileReader(spnFile); + } catch (FileNotFoundException e) { + Rlog.w(LOG_TAG, "Can not open " + + Environment.getRootDirectory() + "/" + PARTNER_SPN_OVERRIDE_PATH); + return; + } + + try { + XmlPullParser parser = Xml.newPullParser(); + parser.setInput(spnReader); + + XmlUtils.beginDocument(parser, "spnOverrides"); + + while (true) { + XmlUtils.nextElement(parser); + + String name = parser.getName(); + if (!"spnOverride".equals(name)) { + break; + } + + String numeric = parser.getAttributeValue(null, "numeric"); + String data = parser.getAttributeValue(null, "spn"); + + mCarrierSpnMap.put(numeric, data); + } + spnReader.close(); + } catch (XmlPullParserException e) { + Rlog.w(LOG_TAG, "Exception in spn-conf parser " + e); + } catch (IOException e) { + Rlog.w(LOG_TAG, "Exception in spn-conf parser " + e); + } + } + +} diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/WeatherTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/WeatherTile.java index c994134abd3..35542752de3 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/WeatherTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/WeatherTile.java @@ -182,7 +182,7 @@ protected void handleClick() { @Override public Intent getLongClickIntent() { if (DEBUG) Log.d(TAG, "getLongClickIntent"); - if (Utils.isPackageInstalled(mContext, "com.google.android.googlequicksearchbox")) { + if (FhUtils.isPackageInstalled(mContext, "com.google.android.googlequicksearchbox")) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("dynact://velour/weather/ProxyActivity")); intent.setComponent(new ComponentName("com.google.android.googlequicksearchbox", diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CollapsedStatusBarFragment.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CollapsedStatusBarFragment.java index 87be6abf158..944256ea3b9 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CollapsedStatusBarFragment.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CollapsedStatusBarFragment.java @@ -22,7 +22,11 @@ import android.annotation.Nullable; import android.app.Fragment; import android.app.StatusBarManager; +import android.content.ContentResolver; +import android.database.ContentObserver; import android.os.Bundle; +import android.os.Handler; +import android.os.UserHandle; import android.provider.Settings; import android.view.LayoutInflater; import android.view.View; @@ -71,9 +75,33 @@ public class CollapsedStatusBarFragment extends Fragment implements CommandQueue private View mTickerViewFromStub; private LinearLayout mCenterClockLayout; + private View mCustomCarrierLabel; + private int mShowCarrierLabel; + private final Handler mHandler = new Handler(); + private static final String STATUS_BAR_SHOW_TICKER = "system:" + Settings.System.STATUS_BAR_SHOW_TICKER; + private class FhSettingsObserver extends ContentObserver { + FhSettingsObserver(Handler handler) { + super(handler); + } + + void observe() { + getContext().getContentResolver().registerContentObserver(Settings.System.getUriFor( + Settings.System.STATUS_BAR_SHOW_CARRIER), + false, this, UserHandle.USER_ALL); + } + + @Override + public void onChange(boolean selfChange) { + updateSettings(true); + } + } + private FhSettingsObserver mFhSettingsObserver = new FhSettingsObserver(mHandler); + + private ContentResolver mContentResolver; + private SignalCallback mSignalCallback = new SignalCallback() { @Override public void setIsAirplaneMode(NetworkController.IconState icon) { @@ -84,9 +112,11 @@ public void setIsAirplaneMode(NetworkController.IconState icon) { @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); + mContentResolver = getContext().getContentResolver(); mKeyguardMonitor = Dependency.get(KeyguardMonitor.class); mNetworkController = Dependency.get(NetworkController.class); mStatusBarComponent = SysUiServiceProvider.getComponent(getContext(), StatusBar.class); + mFhSettingsObserver.observe(); } @Override @@ -122,6 +152,8 @@ public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { mCenterClockLayout = (LinearLayout) mStatusBar.findViewById(R.id.center_clock_layout); mSignalClusterView = mStatusBar.findViewById(R.id.signal_cluster); Dependency.get(DarkIconDispatcher.class).addDarkReceiver(mSignalClusterView); + mCustomCarrierLabel = mStatusBar.findViewById(R.id.statusbar_carrier_text); + updateSettings(false); // Default to showing until we know otherwise. showSystemIconArea(false); initEmergencyCryptkeeperText(); @@ -189,8 +221,10 @@ public void disable(int state1, int state2, boolean animate) { if ((diff1 & DISABLE_NOTIFICATION_ICONS) != 0) { if ((state1 & DISABLE_NOTIFICATION_ICONS) != 0) { hideNotificationIconArea(animate); + hideCarrierName(animate); } else { showNotificationIconArea(animate); + showCarrierName(animate); } } } @@ -224,9 +258,9 @@ private boolean shouldHideNotificationIcons() { } public void hideSystemIconArea(boolean animate) { - animateHide(mCenterClockLayout, animate); - animateHide(mBatteryBar, animate); - animateHide(mSystemIconArea, animate); + animateHide(mSystemIconArea, animate, true); + animateHide(mCenterClockLayout, animate, true); + animateHide(mBatteryBar, animate, true); } public void showSystemIconArea(boolean animate) { @@ -236,21 +270,33 @@ public void showSystemIconArea(boolean animate) { } public void hideNotificationIconArea(boolean animate) { - animateHide(mNotificationIconAreaInner, animate); + animateHide(mNotificationIconAreaInner, animate, true); } public void showNotificationIconArea(boolean animate) { animateShow(mNotificationIconAreaInner, animate); } + public void hideCarrierName(boolean animate) { + if (mCustomCarrierLabel != null) { + animateHide(mCustomCarrierLabel, animate, false); + } + } + + public void showCarrierName(boolean animate) { + if (mCustomCarrierLabel != null) { + setCarrierLabel(animate); + } + } + /** * Hides a view. */ - private void animateHide(final View v, boolean animate) { + private void animateHide(final View v, boolean animate, final boolean invisible) { v.animate().cancel(); if (!animate) { v.setAlpha(0f); - v.setVisibility(View.INVISIBLE); + v.setVisibility(invisible ? View.INVISIBLE : View.GONE); return; } v.animate() @@ -258,7 +304,7 @@ private void animateHide(final View v, boolean animate) { .setDuration(160) .setStartDelay(0) .setInterpolator(Interpolators.ALPHA_OUT) - .withEndAction(() -> v.setVisibility(View.INVISIBLE)); + .withEndAction(() -> v.setVisibility(invisible ? View.INVISIBLE : View.GONE)); } /** @@ -305,6 +351,13 @@ private void initEmergencyCryptkeeperText() { } } + public void updateSettings(boolean animate) { + mShowCarrierLabel = Settings.System.getIntForUser( + mContentResolver, Settings.System.STATUS_BAR_SHOW_CARRIER, 1, + UserHandle.USER_CURRENT); + setCarrierLabel(animate); + } + private void initTickerView() { if (mTickerEnabled != 0) { View tickerStub = mStatusBar.findViewById(R.id.ticker_stub); @@ -319,4 +372,12 @@ private void initTickerView() { mStatusBarComponent.disableTicker(); } } + + private void setCarrierLabel(boolean animate) { + if (mShowCarrierLabel == 2 || mShowCarrierLabel == 3) { + animateShow(mCustomCarrierLabel, animate); + } else { + animateHide(mCustomCarrierLabel, animate, false); + } + } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java index 0aa7901e1a5..d6a70ed420f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java @@ -23,7 +23,12 @@ import android.content.res.TypedArray; import android.graphics.Color; import android.graphics.Rect; +import android.database.ContentObserver; import android.graphics.drawable.Drawable; +import android.net.Uri; +import android.os.Handler; +import android.os.UserHandle; +import android.provider.Settings; import android.util.AttributeSet; import android.util.TypedValue; import android.view.View; @@ -63,6 +68,8 @@ public class KeyguardStatusBarView extends RelativeLayout private boolean mKeyguardUserSwitcherShowing; private boolean mBatteryListening; + private int mShowCarrierLabel; + private TextView mCarrierLabel; private View mSystemIconsSuperContainer; private MultiUserSwitch mMultiUserSwitch; @@ -78,8 +85,21 @@ public class KeyguardStatusBarView extends RelativeLayout private View mSystemIconsContainer; private TintedIconManager mIconManager; + private ContentObserver mObserver = new ContentObserver(new Handler()) { + public void onChange(boolean selfChange, Uri uri) { + showStatusBarCarrier(); + updateVisibilities(); + } + }; + public KeyguardStatusBarView(Context context, AttributeSet attrs) { super(context, attrs); + showStatusBarCarrier(); + } + + private void showStatusBarCarrier() { + mShowCarrierLabel = Settings.System.getIntForUser(getContext().getContentResolver(), + Settings.System.STATUS_BAR_SHOW_CARRIER, 1, UserHandle.USER_CURRENT); } @Override @@ -179,6 +199,13 @@ private void updateVisibilities() { } } mBatteryView.setForceShowPercent(mBatteryCharging); + if (mCarrierLabel != null) { + if (mShowCarrierLabel == 1 || mShowCarrierLabel == 3) { + mCarrierLabel.setVisibility(View.VISIBLE); + } else { + mCarrierLabel.setVisibility(View.GONE); + } + } } private void updateSystemIconsLayoutParams() { @@ -228,6 +255,9 @@ protected void onAttachedToWindow() { mIconManager = new TintedIconManager(findViewById(R.id.statusIcons)); Dependency.get(StatusBarIconController.class).addIconGroup(mIconManager); onOverlayChanged(); + + getContext().getContentResolver().registerContentObserver(Settings.System.getUriFor( + Settings.System.STATUS_BAR_SHOW_CARRIER), false, mObserver); } @Override diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java index 874b2b74def..6c40351d067 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java @@ -504,7 +504,6 @@ public class StatusBar extends SystemUI implements DemoMode, // settings private QSPanel mQSPanel; - private QuickStatusBarHeader mQuickStatusBarHeader; // top bar protected KeyguardStatusBarView mKeyguardStatusBar;