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

Commit 5a347637 authored by Ying Xu's avatar Ying Xu Committed by Android (Google) Code Review
Browse files

Merge "Use different slots for no_calling and call_strength icons" into sc-dev

parents 5590c983 00db3e0c
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@
        <item><xliff:g id="id">@string/status_bar_mobile</xliff:g></item>
        <item><xliff:g id="id">@string/status_bar_airplane</xliff:g></item>
        <item><xliff:g id="id">@string/status_bar_no_calling</xliff:g></item>
        <item><xliff:g id="id">@string/status_bar_call_strength</xliff:g></item>
        <item><xliff:g id="id">@string/status_bar_battery</xliff:g></item>
        <item><xliff:g id="id">@string/status_bar_sensors_off</xliff:g></item>
    </string-array>
@@ -96,6 +97,7 @@
    <string translatable="false" name="status_bar_camera">camera</string>
    <string translatable="false" name="status_bar_airplane">airplane</string>
    <string translatable="false" name="status_bar_no_calling">no_calling</string>
    <string translatable="false" name="status_bar_call_strength">call_strength</string>
    <string translatable="false" name="status_bar_sensors_off">sensors_off</string>
    <string translatable="false" name="status_bar_screen_record">screen_record</string>

+1 −0
Original line number Diff line number Diff line
@@ -2977,6 +2977,7 @@
  <java-symbol type="string" name="status_bar_clock" />
  <java-symbol type="string" name="status_bar_airplane" />
  <java-symbol type="string" name="status_bar_no_calling" />
  <java-symbol type="string" name="status_bar_call_strength" />
  <java-symbol type="string" name="status_bar_mobile" />
  <java-symbol type="string" name="status_bar_ethernet" />
  <java-symbol type="string" name="status_bar_vpn" />
+5 −1
Original line number Diff line number Diff line
@@ -66,7 +66,11 @@ public interface StatusBarIconController {
    /**
     * Display the no calling & SMS icons.
     */
    void setCallIndicatorIcons(String slot, List<CallIndicatorIconState> states);
    void setCallStrengthIcons(String slot, List<CallIndicatorIconState> states);
    /**
     * Display the no calling & SMS icons.
     */
    void setNoCallingIcons(String slot, List<CallIndicatorIconState> states);
    public void setIconVisibility(String slot, boolean b);

    /**
+51 −16
Original line number Diff line number Diff line
@@ -219,27 +219,56 @@ public class StatusBarIconControllerImpl extends StatusBarIconList implements Tu
    }

    /**
     * Accept a list of CallIndicatorIconStates, and show them in the same slot
     * @param slot StatusBar slot
     * Accept a list of CallIndicatorIconStates, and show the call strength icons.
     * @param slot StatusBar slot for the call strength icons
     * @param states All of the no Calling & SMS icon states
     */
    @Override
    public void setCallIndicatorIcons(String slot, List<CallIndicatorIconState> states) {
    public void setCallStrengthIcons(String slot, List<CallIndicatorIconState> states) {
        Slot callStrengthSlot = getSlot(slot);
        int callStrengthSlotIndex = getSlotIndex(slot);
        Collections.reverse(states);
        for (CallIndicatorIconState state : states) {
            if (!state.isNoCalling) {
                StatusBarIconHolder holder = callStrengthSlot.getHolderForTag(state.subId);
                if (holder == null) {
                    holder = StatusBarIconHolder.fromCallIndicatorState(mContext, state);
                    setIcon(callStrengthSlotIndex, holder);
                } else {
                    holder.setIcon(new StatusBarIcon(UserHandle.SYSTEM, mContext.getPackageName(),
                            Icon.createWithResource(mContext, state.callStrengthResId), 0, 0,
                            state.callStrengthDescription));
                    setIcon(callStrengthSlotIndex, holder);
                }
            }
            setIconVisibility(slot, !state.isNoCalling, state.subId);
        }
    }

    /**
     * Accept a list of CallIndicatorIconStates, and show the no calling icons.
     * @param slot StatusBar slot for the no calling icons
     * @param states All of the no Calling & SMS icon states
     */
    @Override
    public void setNoCallingIcons(String slot, List<CallIndicatorIconState> states) {
        Slot noCallingSlot = getSlot(slot);
        int slotIndex = getSlotIndex(slot);
        int noCallingSlotIndex = getSlotIndex(slot);
        Collections.reverse(states);
        for (CallIndicatorIconState state : states) {
            if (state.isNoCalling) {
                StatusBarIconHolder holder = noCallingSlot.getHolderForTag(state.subId);
                if (holder == null) {
                    holder = StatusBarIconHolder.fromCallIndicatorState(mContext, state);
                setIcon(slotIndex, holder);
                    setIcon(noCallingSlotIndex, holder);
                } else {
                int resId = state.isNoCalling ? state.noCallingResId : state.callStrengthResId;
                String contentDescription = state.isNoCalling
                        ? state.noCallingDescription : state.callStrengthDescription;
                    holder.setIcon(new StatusBarIcon(UserHandle.SYSTEM, mContext.getPackageName(),
                        Icon.createWithResource(mContext, resId), 0, 0, contentDescription));
                setIcon(slotIndex, holder);
                            Icon.createWithResource(mContext, state.noCallingResId), 0, 0,
                            state.noCallingDescription));
                    setIcon(noCallingSlotIndex, holder);
                }
            }
            setIconVisibility(slot, state.isNoCalling, state.subId);
        }
    }

@@ -282,9 +311,15 @@ public class StatusBarIconControllerImpl extends StatusBarIconList implements Tu
        }
    }

    /** */
    public void setIconVisibility(String slot, boolean visibility) {
        setIconVisibility(slot, visibility, 0);
    }

    /** */
    public void setIconVisibility(String slot, boolean visibility, int tag) {
        int index = getSlotIndex(slot);
        StatusBarIconHolder holder = getIcon(index, 0);
        StatusBarIconHolder holder = getIcon(index, tag);
        if (holder == null || holder.isVisible() == visibility) {
            return;
        }
+0 −1
Original line number Diff line number Diff line
@@ -83,7 +83,6 @@ public class StatusBarIconHolder {
        holder.mIcon = new StatusBarIcon(UserHandle.SYSTEM, context.getPackageName(),
                Icon.createWithResource(context, resId), 0, 0, contentDescription);
        holder.mTag = state.subId;
        holder.setVisible(true);
        return holder;
    }

Loading