1 /* 2 * Copyright (C) 2020 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.systemui.car.userswitcher; 18 19 import android.content.Context; 20 import android.graphics.Color; 21 import android.graphics.Rect; 22 import android.util.AttributeSet; 23 import android.view.View; 24 import android.widget.LinearLayout; 25 26 import androidx.annotation.IdRes; 27 28 import com.android.settingslib.Utils; 29 import com.android.systemui.R; 30 import com.android.systemui.plugins.DarkIconDispatcher; 31 32 import java.util.ArrayList; 33 34 /** 35 * A view that forms the header of the notification panel. This view will ensure that any 36 * status icons that are displayed are tinted accordingly to the current theme. 37 */ 38 public class CarStatusBarHeader extends LinearLayout { CarStatusBarHeader(Context context, AttributeSet attrs)39 public CarStatusBarHeader(Context context, AttributeSet attrs) { 40 super(context, attrs); 41 } 42 43 @Override onFinishInflate()44 protected void onFinishInflate() { 45 super.onFinishInflate(); 46 47 // Set the light/dark theming on the header status UI to match the current theme. 48 int colorForeground = Utils.getColorAttrDefaultColor(getContext(), 49 android.R.attr.colorForeground); 50 float intensity = colorForeground == Color.WHITE ? 0f : 1f; 51 52 applyDarkness(R.id.clock, new ArrayList<>(), intensity, colorForeground); 53 } 54 applyDarkness(@dRes int id, ArrayList<Rect> tintAreas, float intensity, int color)55 private void applyDarkness(@IdRes int id, ArrayList<Rect> tintAreas, float intensity, 56 int color) { 57 View v = findViewById(id); 58 if (v instanceof DarkIconDispatcher.DarkReceiver) { 59 ((DarkIconDispatcher.DarkReceiver) v).onDarkChanged(tintAreas, intensity, color); 60 } 61 } 62 } 63