diff options
-rw-r--r-- | car-qc-lib/Android.bp | 2 | ||||
-rw-r--r-- | car-qc-lib/res/layout/qc_row_view.xml | 4 | ||||
-rw-r--r-- | car-qc-lib/res/layout/qc_tile_view.xml | 2 | ||||
-rw-r--r-- | car-qc-lib/res/values/overlayable.xml | 87 | ||||
-rw-r--r-- | car-qc-lib/src/com/android/car/qc/view/QCRowView.java | 3 | ||||
-rw-r--r-- | car-qc-lib/src/com/android/car/qc/view/QCTileView.java | 3 | ||||
-rw-r--r-- | car-qc-lib/src/com/android/car/qc/view/QCViewUtils.java | 59 |
7 files changed, 25 insertions, 135 deletions
diff --git a/car-qc-lib/Android.bp b/car-qc-lib/Android.bp index c12fd28..f0ccd8b 100644 --- a/car-qc-lib/Android.bp +++ b/car-qc-lib/Android.bp @@ -26,6 +26,6 @@ android_library { }, static_libs: [ "androidx.annotation_annotation", - "car-ui-lib" + "car-ui-lib-no-overlayable", ], } diff --git a/car-qc-lib/res/layout/qc_row_view.xml b/car-qc-lib/res/layout/qc_row_view.xml index a4af032..9976ac6 100644 --- a/car-qc-lib/res/layout/qc_row_view.xml +++ b/car-qc-lib/res/layout/qc_row_view.xml @@ -77,7 +77,7 @@ android:layout_height="wrap_content" android:layout_centerVertical="true" android:singleLine="true" - android:textAppearance="@style/TextAppearance.QC.Title" + style="@style/TextAppearance.QC.Title" app:layout_constraintStart_toEndOf="@+id/barrier1" app:layout_constraintTop_toTopOf="parent" app:layout_constraintBottom_toTopOf="@+id/qc_summary" @@ -89,7 +89,7 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:layout_centerVertical="true" - android:textAppearance="@style/TextAppearance.QC.Subtitle" + style="@style/TextAppearance.QC.Subtitle" app:layout_constraintStart_toEndOf="@+id/barrier1" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toBottomOf="@+id/qc_title" diff --git a/car-qc-lib/res/layout/qc_tile_view.xml b/car-qc-lib/res/layout/qc_tile_view.xml index 7fb0884..c7b7511 100644 --- a/car-qc-lib/res/layout/qc_tile_view.xml +++ b/car-qc-lib/res/layout/qc_tile_view.xml @@ -37,5 +37,5 @@ android:id="@android:id/summary" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:textAppearance="@style/TextAppearance.QC.Subtitle"/> + style="@style/TextAppearance.QC.Subtitle"/> </com.android.car.ui.uxr.DrawableStateLinearLayout>
\ No newline at end of file diff --git a/car-qc-lib/res/values/overlayable.xml b/car-qc-lib/res/values/overlayable.xml deleted file mode 100644 index d5b405a..0000000 --- a/car-qc-lib/res/values/overlayable.xml +++ /dev/null @@ -1,87 +0,0 @@ -<?xml version='1.0' encoding='UTF-8'?> -<!-- - ~ Copyright (C) 2022 The Android Open Source Project - ~ - ~ Licensed under the Apache License, Version 2.0 (the "License"); - ~ you may not use this file except in compliance with the License. - ~ You may obtain a copy of the License at - ~ - ~ http://www.apache.org/licenses/LICENSE-2.0 - ~ - ~ Unless required by applicable law or agreed to in writing, software - ~ distributed under the License is distributed on an "AS IS" BASIS, - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - ~ See the License for the specific language governing permissions and - ~ limitations under the License. - --> -<!-- -THIS FILE WAS AUTO GENERATED, DO NOT EDIT MANUALLY. -REGENERATE USING packages/apps/Car/tests/tools/rro/generate-overlayable.py ---> -<resources> - <overlayable name="car-qc-lib"> - <policy type="system|product|signature"> - <item type="attr" name="state_toggle_unavailable"/> - <item type="color" name="qc_start_icon_color"/> - <item type="color" name="qc_toggle_background_color"/> - <item type="color" name="qc_toggle_icon_fill_color"/> - <item type="color" name="qc_toggle_off_background_color"/> - <item type="color" name="qc_toggle_rotary_shadow_color"/> - <item type="color" name="qc_toggle_unavailable_background_color"/> - <item type="color" name="qc_toggle_unavailable_color"/> - <item type="dimen" name="qc_action_items_horizontal_margin"/> - <item type="dimen" name="qc_row_content_margin"/> - <item type="dimen" name="qc_row_horizontal_margin"/> - <item type="dimen" name="qc_row_icon_margin_end"/> - <item type="dimen" name="qc_row_icon_size"/> - <item type="dimen" name="qc_row_margin_vertical"/> - <item type="dimen" name="qc_row_min_height"/> - <item type="dimen" name="qc_row_padding_end"/> - <item type="dimen" name="qc_row_padding_start"/> - <item type="dimen" name="qc_seekbar_padding_top"/> - <item type="dimen" name="qc_toggle_background_padding"/> - <item type="dimen" name="qc_toggle_background_radius"/> - <item type="dimen" name="qc_toggle_foreground_icon_inset"/> - <item type="dimen" name="qc_toggle_margin"/> - <item type="dimen" name="qc_toggle_rotary_highlight_radius"/> - <item type="dimen" name="qc_toggle_rotary_highlight_size"/> - <item type="dimen" name="qc_toggle_rotary_shadow_padding"/> - <item type="dimen" name="qc_toggle_rotary_shadow_radius"/> - <item type="dimen" name="qc_toggle_rotary_shadow_size"/> - <item type="dimen" name="qc_toggle_rotary_shadow_width"/> - <item type="dimen" name="qc_toggle_background_size"/> - <item type="dimen" name="qc_toggle_size"/> - <item type="dimen" name="qc_toggle_unavailable_outline_width"/> - <item type="drawable" name="qc_row_action_divider"/> - <item type="drawable" name="qc_seekbar_wrapper_background"/> - <item type="drawable" name="qc_toggle_background"/> - <item type="drawable" name="qc_toggle_button_background"/> - <item type="drawable" name="qc_toggle_rotary_background"/> - <item type="drawable" name="qc_toggle_rotary_highlight"/> - <item type="drawable" name="qc_toggle_rotary_shadow"/> - <item type="drawable" name="qc_toggle_unavailable_background"/> - <item type="id" name="barrier1"/> - <item type="id" name="barrier2"/> - <item type="id" name="qc_icon"/> - <item type="id" name="qc_row_content"/> - <item type="id" name="qc_row_end_items"/> - <item type="id" name="qc_row_start_items"/> - <item type="id" name="qc_seekbar"/> - <item type="id" name="qc_seekbar_wrapper"/> - <item type="id" name="qc_summary"/> - <item type="id" name="qc_tile_toggle_button"/> - <item type="id" name="qc_tile_wrapper"/> - <item type="id" name="qc_title"/> - <item type="id" name="qc_toggle_button"/> - <item type="layout" name="qc_action_switch"/> - <item type="layout" name="qc_action_toggle"/> - <item type="layout" name="qc_row_view"/> - <item type="layout" name="qc_tile_view"/> - <item type="style" name="TextAppearance.QC"/> - <item type="style" name="TextAppearance.QC.Subtitle"/> - <item type="style" name="TextAppearance.QC.Title"/> - <item type="style" name="Widget.QC"/> - <item type="style" name="Widget.QC.SeekBar"/> - </policy> - </overlayable> -</resources>
\ No newline at end of file diff --git a/car-qc-lib/src/com/android/car/qc/view/QCRowView.java b/car-qc-lib/src/com/android/car/qc/view/QCRowView.java index 2b6b7a5..490615c 100644 --- a/car-qc-lib/src/com/android/car/qc/view/QCRowView.java +++ b/car-qc-lib/src/com/android/car/qc/view/QCRowView.java @@ -346,8 +346,7 @@ public class QCRowView extends FrameLayout { toggleButton.setTextOn(null); toggleButton.setTextOff(null); toggleButton.setOnCheckedChangeListener(null); - Drawable icon = QCViewUtils.getInstance(mContext).getToggleIcon( - action.getIcon(), action.isAvailable()); + Drawable icon = QCViewUtils.getToggleIcon(mContext, action.getIcon(), action.isAvailable()); toggleButton.setContentDescription(action.getContentDescription()); toggleButton.setButtonDrawable(icon); toggleButton.setChecked(action.isChecked()); diff --git a/car-qc-lib/src/com/android/car/qc/view/QCTileView.java b/car-qc-lib/src/com/android/car/qc/view/QCTileView.java index 33c0eff..4173e25 100644 --- a/car-qc-lib/src/com/android/car/qc/view/QCTileView.java +++ b/car-qc-lib/src/com/android/car/qc/view/QCTileView.java @@ -125,8 +125,7 @@ public class QCTileView extends FrameLayout implements Observer<QCItem> { } mToggleButton.toggle(); }); - Drawable icon = QCViewUtils.getInstance(mContext).getToggleIcon( - qcTile.getIcon(), qcTile.isAvailable()); + Drawable icon = QCViewUtils.getToggleIcon(mContext, qcTile.getIcon(), qcTile.isAvailable()); mToggleButton.setButtonDrawable(icon); mToggleButton.setOnCheckedChangeListener( (buttonView, isChecked) -> { diff --git a/car-qc-lib/src/com/android/car/qc/view/QCViewUtils.java b/car-qc-lib/src/com/android/car/qc/view/QCViewUtils.java index 366c724..ca0f877 100644 --- a/car-qc-lib/src/com/android/car/qc/view/QCViewUtils.java +++ b/car-qc-lib/src/com/android/car/qc/view/QCViewUtils.java @@ -16,7 +16,6 @@ package com.android.car.qc.view; -import android.annotation.ColorInt; import android.content.Context; import android.content.res.ColorStateList; import android.graphics.drawable.Drawable; @@ -32,64 +31,44 @@ import com.android.car.qc.R; * Utility class used by {@link QCTileView} and {@link QCRowView} */ public class QCViewUtils { - private static QCViewUtils sInstance; - - private final Context mContext; - private final Drawable mDefaultToggleBackground; - private final Drawable mUnavailableToggleBackground; - private final ColorStateList mDefaultToggleIconTint; - @ColorInt - private final int mUnavailableToggleIconTint; - private final int mToggleForegroundIconInset; - - private QCViewUtils(@NonNull Context context) { - mContext = context.getApplicationContext(); - mDefaultToggleBackground = mContext.getDrawable(R.drawable.qc_toggle_background); - mUnavailableToggleBackground = mContext.getDrawable( - R.drawable.qc_toggle_unavailable_background); - mDefaultToggleIconTint = mContext.getColorStateList(R.color.qc_toggle_icon_fill_color); - mUnavailableToggleIconTint = mContext.getColor(R.color.qc_toggle_unavailable_color); - mToggleForegroundIconInset = mContext.getResources() - .getDimensionPixelSize(R.dimen.qc_toggle_foreground_icon_inset); - } - - /** - * Get an instance of {@link QCViewUtils} - */ - public static QCViewUtils getInstance(@NonNull Context context) { - if (sInstance == null) { - sInstance = new QCViewUtils(context); - } - return sInstance; - } /** * Create a return a Quick Control toggle icon - used for tiles and action toggles. */ - public Drawable getToggleIcon(@Nullable Icon icon, boolean available) { + public static Drawable getToggleIcon(@NonNull Context context, @Nullable Icon icon, + boolean available) { + Drawable defaultToggleBackground = context.getDrawable(R.drawable.qc_toggle_background); + Drawable unavailableToggleBackground = context.getDrawable( + R.drawable.qc_toggle_unavailable_background); + int toggleForegroundIconInset = context.getResources() + .getDimensionPixelSize(R.dimen.qc_toggle_foreground_icon_inset); + Drawable background = available - ? mDefaultToggleBackground.getConstantState().newDrawable().mutate() - : mUnavailableToggleBackground.getConstantState().newDrawable().mutate(); + ? defaultToggleBackground.getConstantState().newDrawable().mutate() + : unavailableToggleBackground.getConstantState().newDrawable().mutate(); if (icon == null) { return background; } - Drawable iconDrawable = icon.loadDrawable(mContext); + Drawable iconDrawable = icon.loadDrawable(context); if (iconDrawable == null) { return background; } if (!available) { - iconDrawable.setTint(mUnavailableToggleIconTint); + int unavailableToggleIconTint = context.getColor(R.color.qc_toggle_unavailable_color); + iconDrawable.setTint(unavailableToggleIconTint); } else { - iconDrawable.setTintList(mDefaultToggleIconTint); + ColorStateList defaultToggleIconTint = context.getColorStateList( + R.color.qc_toggle_icon_fill_color); + iconDrawable.setTintList(defaultToggleIconTint); } Drawable[] layers = {background, iconDrawable}; LayerDrawable drawable = new LayerDrawable(layers); - drawable.setLayerInsetRelative(/* index= */ 1, mToggleForegroundIconInset, - mToggleForegroundIconInset, mToggleForegroundIconInset, - mToggleForegroundIconInset); + drawable.setLayerInsetRelative(/* index= */ 1, toggleForegroundIconInset, + toggleForegroundIconInset, toggleForegroundIconInset, + toggleForegroundIconInset); return drawable; } } |