FileDocCategorySizeDatePackage
SignalClusterView.javaAPI DocAndroid 5.1 API13103Thu Mar 12 22:22:42 GMT 2015com.android.systemui.statusbar

SignalClusterView

public class SignalClusterView extends android.widget.LinearLayout implements SecurityController.SecurityControllerCallback, NetworkControllerImpl.SignalCluster

Fields Summary
static final String
TAG
static final boolean
DEBUG
com.android.systemui.statusbar.policy.NetworkControllerImpl
mNC
com.android.systemui.statusbar.policy.SecurityController
mSC
private boolean
mNoSimsVisible
private boolean
mVpnVisible
private boolean
mWifiVisible
private int
mWifiStrengthId
private boolean
mIsAirplaneMode
private int
mAirplaneIconId
private int
mAirplaneContentDescription
private String
mWifiDescription
private ArrayList
mPhoneStates
android.view.ViewGroup
mWifiGroup
android.widget.ImageView
mVpn
android.widget.ImageView
mWifi
android.widget.ImageView
mAirplane
android.widget.ImageView
mNoSims
android.view.View
mWifiAirplaneSpacer
android.view.View
mWifiSignalSpacer
android.widget.LinearLayout
mMobileSignalGroup
private int
mWideTypeIconStartPadding
private int
mSecondaryTelephonyPadding
private int
mEndPadding
private int
mEndPaddingNothingVisible
Constructors Summary
public SignalClusterView(android.content.Context context)


       
        this(context, null);
    
public SignalClusterView(android.content.Context context, android.util.AttributeSet attrs)

        this(context, attrs, 0);
    
public SignalClusterView(android.content.Context context, android.util.AttributeSet attrs, int defStyle)

        super(context, attrs, defStyle);
    
Methods Summary
private voidapply()

        if (mWifiGroup == null) return;

        mVpn.setVisibility(mVpnVisible ? View.VISIBLE : View.GONE);
        if (DEBUG) Log.d(TAG, String.format("vpn: %s", mVpnVisible ? "VISIBLE" : "GONE"));
        if (mWifiVisible) {
            mWifi.setImageResource(mWifiStrengthId);
            mWifiGroup.setContentDescription(mWifiDescription);
            mWifiGroup.setVisibility(View.VISIBLE);
        } else {
            mWifiGroup.setVisibility(View.GONE);
        }

        if (DEBUG) Log.d(TAG,
                String.format("wifi: %s sig=%d",
                    (mWifiVisible ? "VISIBLE" : "GONE"),
                    mWifiStrengthId));

        boolean anyMobileVisible = false;
        int firstMobileTypeId = 0;
        for (PhoneState state : mPhoneStates) {
            if (state.apply(anyMobileVisible)) {
                if (!anyMobileVisible) {
                    firstMobileTypeId = state.mMobileTypeId;
                    anyMobileVisible = true;
                }
            }
        }

        if (mIsAirplaneMode) {
            mAirplane.setImageResource(mAirplaneIconId);
            mAirplane.setContentDescription(mAirplaneContentDescription != 0 ?
                    mContext.getString(mAirplaneContentDescription) : null);
            mAirplane.setVisibility(View.VISIBLE);
        } else {
            mAirplane.setVisibility(View.GONE);
        }

        if (mIsAirplaneMode && mWifiVisible) {
            mWifiAirplaneSpacer.setVisibility(View.VISIBLE);
        } else {
            mWifiAirplaneSpacer.setVisibility(View.GONE);
        }

        if (((anyMobileVisible && firstMobileTypeId != 0) || mNoSimsVisible) && mWifiVisible) {
            mWifiSignalSpacer.setVisibility(View.VISIBLE);
        } else {
            mWifiSignalSpacer.setVisibility(View.GONE);
        }

        mNoSims.setVisibility(mNoSimsVisible ? View.VISIBLE : View.GONE);

        boolean anythingVisible = mNoSimsVisible || mWifiVisible || mIsAirplaneMode
                || anyMobileVisible || mVpnVisible;
        setPaddingRelative(0, 0, anythingVisible ? mEndPadding : mEndPaddingNothingVisible, 0);
    
public booleandispatchPopulateAccessibilityEvent(android.view.accessibility.AccessibilityEvent event)

        // Standard group layout onPopulateAccessibilityEvent() implementations
        // ignore content description, so populate manually
        if (mWifiVisible && mWifiGroup != null && mWifiGroup.getContentDescription() != null)
            event.getText().add(mWifiGroup.getContentDescription());
        for (PhoneState state : mPhoneStates) {
            state.populateAccessibilityEvent(event);
        }
        return super.dispatchPopulateAccessibilityEvent(event);
    
private com.android.systemui.statusbar.SignalClusterView$PhoneStategetOrInflateState(int subId)

        for (PhoneState state : mPhoneStates) {
            if (state.mSubId == subId) {
                return state;
            }
        }
        return inflatePhoneState(subId);
    
public booleanhasOverlappingRendering()

        return false;
    
private com.android.systemui.statusbar.SignalClusterView$PhoneStateinflatePhoneState(int subId)

        PhoneState state = new PhoneState(subId, mContext);
        if (mMobileSignalGroup != null) {
            mMobileSignalGroup.addView(state.mMobileGroup);
        }
        mPhoneStates.add(state);
        return state;
    
protected voidonAttachedToWindow()

        super.onAttachedToWindow();

        mVpn            = (ImageView) findViewById(R.id.vpn);
        mWifiGroup      = (ViewGroup) findViewById(R.id.wifi_combo);
        mWifi           = (ImageView) findViewById(R.id.wifi_signal);
        mAirplane       = (ImageView) findViewById(R.id.airplane);
        mNoSims         = (ImageView) findViewById(R.id.no_sims);
        mWifiAirplaneSpacer =         findViewById(R.id.wifi_airplane_spacer);
        mWifiSignalSpacer =           findViewById(R.id.wifi_signal_spacer);
        mMobileSignalGroup = (LinearLayout) findViewById(R.id.mobile_signal_group);
        for (PhoneState state : mPhoneStates) {
            mMobileSignalGroup.addView(state.mMobileGroup);
        }

        apply();
    
protected voidonDetachedFromWindow()

        mVpn            = null;
        mWifiGroup      = null;
        mWifi           = null;
        mAirplane       = null;
        mMobileSignalGroup.removeAllViews();
        mMobileSignalGroup = null;

        super.onDetachedFromWindow();
    
protected voidonFinishInflate()

        super.onFinishInflate();
        mWideTypeIconStartPadding = getContext().getResources().getDimensionPixelSize(
                R.dimen.wide_type_icon_start_padding);
        mSecondaryTelephonyPadding = getContext().getResources().getDimensionPixelSize(
                R.dimen.secondary_telephony_padding);
        mEndPadding = getContext().getResources().getDimensionPixelSize(
                R.dimen.signal_cluster_battery_padding);
        mEndPaddingNothingVisible = getContext().getResources().getDimensionPixelSize(
                R.dimen.no_signal_cluster_battery_padding);
    
public voidonRtlPropertiesChanged(int layoutDirection)

        super.onRtlPropertiesChanged(layoutDirection);

        if (mWifi != null) {
            mWifi.setImageDrawable(null);
        }

        for (PhoneState state : mPhoneStates) {
            if (state.mMobile != null) {
                state.mMobile.setImageDrawable(null);
            }
            if (state.mMobileType != null) {
                state.mMobileType.setImageDrawable(null);
            }
        }

        if(mAirplane != null) {
            mAirplane.setImageDrawable(null);
        }

        apply();
    
public voidonStateChanged()

        post(new Runnable() {
            @Override
            public void run() {
                mVpnVisible = mSC.isVpnEnabled();
                apply();
            }
        });
    
public voidsetIsAirplaneMode(boolean is, int airplaneIconId, int contentDescription)

        mIsAirplaneMode = is;
        mAirplaneIconId = airplaneIconId;
        mAirplaneContentDescription = contentDescription;

        apply();
    
public voidsetMobileDataIndicators(boolean visible, int strengthIcon, int typeIcon, java.lang.String contentDescription, java.lang.String typeContentDescription, boolean isTypeIconWide, int subId)

        PhoneState state = getOrInflateState(subId);
        state.mMobileVisible = visible;
        state.mMobileStrengthId = strengthIcon;
        state.mMobileTypeId = typeIcon;
        state.mMobileDescription = contentDescription;
        state.mMobileTypeDescription = typeContentDescription;
        state.mIsMobileTypeIconWide = isTypeIconWide;

        apply();
    
public voidsetNetworkController(com.android.systemui.statusbar.policy.NetworkControllerImpl nc)

        if (DEBUG) Log.d(TAG, "NetworkController=" + nc);
        mNC = nc;
    
public voidsetNoSims(boolean show)

        mNoSimsVisible = show;
    
public voidsetSecurityController(com.android.systemui.statusbar.policy.SecurityController sc)

        if (DEBUG) Log.d(TAG, "SecurityController=" + sc);
        mSC = sc;
        mSC.addCallback(this);
        mVpnVisible = mSC.isVpnEnabled();
    
public voidsetSubs(java.util.List subs)

        // Clear out all old subIds.
        mPhoneStates.clear();
        if (mMobileSignalGroup != null) {
            mMobileSignalGroup.removeAllViews();
        }
        final int n = subs.size();
        for (int i = 0; i < n; i++) {
            inflatePhoneState(subs.get(i).getSubscriptionId());
        }
    
public voidsetWifiIndicators(boolean visible, int strengthIcon, java.lang.String contentDescription)

        mWifiVisible = visible;
        mWifiStrengthId = strengthIcon;
        mWifiDescription = contentDescription;

        apply();