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

Commit e87032cd authored by Anthony Chen's avatar Anthony Chen
Browse files

Scale phone state icons.

The status bar icons can all be optionally scaled by the scale factor in
dimens. The phone stat icons had not been updated to include this
scaling logic.

Also allow the spacing between the icons in the mobile signal group to
be adjusted.

Change-Id: I12b35d462599f8a0747477fb280a974ffa77d01c
parent 91eff22b
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -528,6 +528,13 @@

    <dimen name="battery_margin_bottom">0dp</dimen>

    <!-- Padding at the end of the view that displays the mobile signal icons. If the view is
         empty, then this padding will not be added to that view. -->
    <dimen name="mobile_signal_group_end_padding">0dp</dimen>

    <!-- Padding between the mobile data type and the strength indicator. -->
    <dimen name="mobile_data_icon_start_padding">0dp</dimen>

    <!-- Extra padding between the mobile data type icon and the strength indicator when the data
         type icon is wide. -->
    <dimen name="wide_type_icon_start_padding">2dp</dimen>
+29 −3
Original line number Diff line number Diff line
@@ -90,6 +90,8 @@ public class SignalClusterView
    View mWifiSignalSpacer;
    LinearLayout mMobileSignalGroup;

    private final int mMobileSignalGroupEndPadding;
    private final int mMobileDataIconStartPadding;
    private final int mWideTypeIconStartPadding;
    private final int mSecondaryTelephonyPadding;
    private final int mEndPadding;
@@ -113,6 +115,10 @@ public class SignalClusterView
        super(context, attrs, defStyle);

        Resources res = getResources();
        mMobileSignalGroupEndPadding =
                res.getDimensionPixelSize(R.dimen.mobile_signal_group_end_padding);
        mMobileDataIconStartPadding =
                res.getDimensionPixelSize(R.dimen.mobile_data_icon_start_padding);
        mWideTypeIconStartPadding = res.getDimensionPixelSize(R.dimen.wide_type_icon_start_padding);
        mSecondaryTelephonyPadding = res.getDimensionPixelSize(R.dimen.secondary_telephony_padding);
        mEndPadding = res.getDimensionPixelSize(R.dimen.signal_cluster_battery_padding);
@@ -206,6 +212,10 @@ public class SignalClusterView
        for (PhoneState state : mPhoneStates) {
            mMobileSignalGroup.addView(state.mMobileGroup);
        }

        int endPadding = mMobileSignalGroup.getChildCount() > 0 ? mMobileSignalGroupEndPadding : 0;
        mMobileSignalGroup.setPaddingRelative(0, 0, endPadding, 0);

        TunerService.get(mContext).addTunable(this, StatusBarIconController.ICON_BLACKLIST);

        apply();
@@ -577,9 +587,11 @@ public class SignalClusterView
            // When this isn't next to wifi, give it some extra padding between the signals.
            mMobileGroup.setPaddingRelative(isSecondaryIcon ? mSecondaryTelephonyPadding : 0,
                    0, 0, 0);
            mMobile.setPaddingRelative(mIsMobileTypeIconWide ? mWideTypeIconStartPadding : 0,
            mMobile.setPaddingRelative(
                    mIsMobileTypeIconWide ? mWideTypeIconStartPadding : mMobileDataIconStartPadding,
                    0, 0, 0);
            mMobileDark.setPaddingRelative(mIsMobileTypeIconWide ? mWideTypeIconStartPadding : 0,
            mMobileDark.setPaddingRelative(
                    mIsMobileTypeIconWide ? mWideTypeIconStartPadding : mMobileDataIconStartPadding,
                    0, 0, 0);

            if (DEBUG) Log.d(TAG, String.format("mobile: %s sig=%d typ=%d",
@@ -592,12 +604,19 @@ public class SignalClusterView

        private void updateAnimatableIcon(ImageView view, int resId) {
            maybeStopAnimatableDrawable(view);
            view.setImageResource(resId);
            setIconForView(view, resId);
            maybeStartAnimatableDrawable(view);
        }

        private void maybeStopAnimatableDrawable(ImageView view) {
            Drawable drawable = view.getDrawable();

            // Check if the icon has been scaled. If it has retrieve the actual drawable out of the
            // wrapper.
            if (drawable instanceof ScalingDrawableWrapper) {
                drawable = ((ScalingDrawableWrapper) drawable).getDrawable();
            }

            if (drawable instanceof Animatable) {
                Animatable ad = (Animatable) drawable;
                if (ad.isRunning()) {
@@ -608,6 +627,13 @@ public class SignalClusterView

        private void maybeStartAnimatableDrawable(ImageView view) {
            Drawable drawable = view.getDrawable();

            // Check if the icon has been scaled. If it has retrieve the actual drawable out of the
            // wrapper.
            if (drawable instanceof ScalingDrawableWrapper) {
                drawable = ((ScalingDrawableWrapper) drawable).getDrawable();
            }

            if (drawable instanceof Animatable) {
                Animatable ad = (Animatable) drawable;
                if (!ad.isRunning()) {