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

Commit 9589695f authored by Evan Laird's avatar Evan Laird
Browse files

Add status bar icons to QQS

Also add a alpha animation to QuickStatusBarHeader so status icon can do
the opposite fade that the footer does.

Test: visual
Bug: 70799006
Change-Id: I863517a43084285f022edf9133cf6ea326816977
parent 4e3ead32
Loading
Loading
Loading
Loading
+15 −3
Original line number Original line Diff line number Diff line
@@ -13,13 +13,25 @@
     See the License for the specific language governing permissions and
     See the License for the specific language governing permissions and
     limitations under the License.
     limitations under the License.
-->
-->
<View
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/quick_qs_status_icons"
    android:id="@+id/quick_qs_status_icons"
    android:layout_width="match_parent"
    android:layout_width="match_parent"
    android:layout_height="20dp"
    android:layout_height="20dp"
    android:layout_marginBottom="22dp"
    android:layout_marginTop="8dp"
    android:layout_marginBottom="14dp"
    android:layout_below="@id/quick_status_bar_system_icons"
    android:layout_below="@id/quick_status_bar_system_icons"
    >
    >


</View>
    <com.android.systemui.statusbar.phone.StatusIconContainer
        android:id="@+id/statusIcons"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1" />

    <include layout="@layout/signal_cluster_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_marginStart="@dimen/signal_cluster_margin_start" />

</LinearLayout>
+44 −11
Original line number Original line Diff line number Diff line
@@ -39,7 +39,8 @@ import com.android.systemui.SysUiServiceProvider;
import com.android.systemui.plugins.ActivityStarter;
import com.android.systemui.plugins.ActivityStarter;
import com.android.systemui.qs.QSDetail.Callback;
import com.android.systemui.qs.QSDetail.Callback;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.SignalClusterView;
import com.android.systemui.statusbar.phone.StatusBarIconController;
import com.android.systemui.statusbar.phone.StatusBarIconController.TintedIconManager;
import com.android.systemui.statusbar.policy.DarkIconDispatcher;
import com.android.systemui.statusbar.policy.DarkIconDispatcher;
import com.android.systemui.statusbar.policy.DarkIconDispatcher.DarkReceiver;
import com.android.systemui.statusbar.policy.DarkIconDispatcher.DarkReceiver;


@@ -56,6 +57,10 @@ public class QuickStatusBarHeader extends RelativeLayout


    protected QuickQSPanel mHeaderQsPanel;
    protected QuickQSPanel mHeaderQsPanel;
    protected QSTileHost mHost;
    protected QSTileHost mHost;
    private TintedIconManager mIconManager;
    private TouchAnimator mAlphaAnimator;

    private View mQuickQsStatusIcons;


    private View mDate;
    private View mDate;


@@ -71,16 +76,25 @@ public class QuickStatusBarHeader extends RelativeLayout
        mHeaderQsPanel = findViewById(R.id.quick_qs_panel);
        mHeaderQsPanel = findViewById(R.id.quick_qs_panel);
        mDate = findViewById(R.id.date);
        mDate = findViewById(R.id.date);
        mDate.setOnClickListener(this);
        mDate.setOnClickListener(this);
        mQuickQsStatusIcons = findViewById(R.id.quick_qs_status_icons);
        mIconManager = new TintedIconManager(findViewById(R.id.statusIcons));


        // RenderThread is doing more harm than good when touching the header (to expand quick
        // RenderThread is doing more harm than good when touching the header (to expand quick
        // settings), so disable it for this view
        // settings), so disable it for this view


        updateResources();
        updateResources();


        // Set light text on the header icons because they will always be on a black background
        int colorForeground = Utils.getColorAttr(getContext(), android.R.attr.colorForeground);
        Rect tintArea = new Rect(0, 0, 0, 0);
        Rect tintArea = new Rect(0, 0, 0, 0);
        int colorForeground = Utils.getColorAttr(getContext(), android.R.attr.colorForeground);
        float intensity = colorForeground == Color.WHITE ? 0 : 1;
        int fillColor = fillColorForIntensity(intensity, getContext());

        // Set light text on the header icons because they will always be on a black background
        applyDarkness(R.id.clock, tintArea, 0, DarkIconDispatcher.DEFAULT_ICON_TINT);
        applyDarkness(R.id.clock, tintArea, 0, DarkIconDispatcher.DEFAULT_ICON_TINT);
        applyDarkness(id.signal_cluster, tintArea, intensity, colorForeground);

        // Set the correct tint for the status icons so they contrast
        mIconManager.setTint(fillColor);


        BatteryMeterView battery = findViewById(R.id.battery);
        BatteryMeterView battery = findViewById(R.id.battery);
        battery.setFillColor(Color.WHITE);
        battery.setFillColor(Color.WHITE);
@@ -96,6 +110,13 @@ public class QuickStatusBarHeader extends RelativeLayout
        }
        }
    }
    }


    private int fillColorForIntensity(float intensity, Context context) {
        if (intensity == 0) {
            return context.getColor(R.color.light_mode_icon_color_dual_tone_fill);
        }
        return context.getColor(R.color.dark_mode_icon_color_dual_tone_fill);
    }

    @Override
    @Override
    protected void onConfigurationChanged(Configuration newConfig) {
    protected void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        super.onConfigurationChanged(newConfig);
@@ -109,6 +130,13 @@ public class QuickStatusBarHeader extends RelativeLayout
    }
    }


    private void updateResources() {
    private void updateResources() {
        updateAlphaAnimator();
    }

    private void updateAlphaAnimator() {
        mAlphaAnimator = new TouchAnimator.Builder()
                .addFloat(mQuickQsStatusIcons, "alpha", 1, 0)
                .build();
    }
    }


    public int getCollapsedHeight() {
    public int getCollapsedHeight() {
@@ -127,6 +155,9 @@ public class QuickStatusBarHeader extends RelativeLayout
    }
    }


    public void setExpansion(float headerExpansionFraction) {
    public void setExpansion(float headerExpansionFraction) {
        if (mAlphaAnimator != null ) {
            mAlphaAnimator.setPosition(headerExpansionFraction);
        }
    }
    }


    @Override
    @Override
@@ -142,6 +173,7 @@ public class QuickStatusBarHeader extends RelativeLayout
    @Override
    @Override
    public void onAttachedToWindow() {
    public void onAttachedToWindow() {
        SysUiServiceProvider.getComponent(getContext(), CommandQueue.class).addCallbacks(this);
        SysUiServiceProvider.getComponent(getContext(), CommandQueue.class).addCallbacks(this);
        Dependency.get(StatusBarIconController.class).addIconGroup(mIconManager);
    }
    }


    @Override
    @Override
@@ -149,17 +181,10 @@ public class QuickStatusBarHeader extends RelativeLayout
    public void onDetachedFromWindow() {
    public void onDetachedFromWindow() {
        setListening(false);
        setListening(false);
        SysUiServiceProvider.getComponent(getContext(), CommandQueue.class).removeCallbacks(this);
        SysUiServiceProvider.getComponent(getContext(), CommandQueue.class).removeCallbacks(this);
        Dependency.get(StatusBarIconController.class).removeIconGroup(mIconManager);
        super.onDetachedFromWindow();
        super.onDetachedFromWindow();
    }
    }


    @Override
    public void onClick(View v) {
        if (v == mDate) {
            Dependency.get(ActivityStarter.class).postStartActivityDismissingKeyguard(new Intent(
                    AlarmClock.ACTION_SHOW_ALARMS), 0);
        }
    }

    public void setListening(boolean listening) {
    public void setListening(boolean listening) {
        if (listening == mListening) {
        if (listening == mListening) {
            return;
            return;
@@ -168,6 +193,14 @@ public class QuickStatusBarHeader extends RelativeLayout
        mListening = listening;
        mListening = listening;
    }
    }


    @Override
    public void onClick(View v) {
        if(v == mDate){
            Dependency.get(ActivityStarter.class).postStartActivityDismissingKeyguard(new Intent(
                    AlarmClock.ACTION_SHOW_ALARMS),0);
        }
    }

    public void updateEverything() {
    public void updateEverything() {
        post(() -> setClickable(false));
        post(() -> setClickable(false));
    }
    }