diff options
author | Kunhung Li <kunhungli@google.com> | 2021-06-23 16:28:05 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-06-23 16:28:05 +0000 |
commit | ac0e95d17124521a50bef3c8083361318b0fc45b (patch) | |
tree | 9e3c76e3783d358a8b33f2ef5a8b32c61651e1ae | |
parent | ab314a7eb6f0d5eb0d0d28f373ccc223b665bf2e (diff) | |
parent | 75780a44441d8107778d815ad9f71f2ccca72c9f (diff) | |
download | platform_packages_apps_WallpaperPicker2-ac0e95d17124521a50bef3c8083361318b0fc45b.tar.gz platform_packages_apps_WallpaperPicker2-ac0e95d17124521a50bef3c8083361318b0fc45b.tar.bz2 platform_packages_apps_WallpaperPicker2-ac0e95d17124521a50bef3c8083361318b0fc45b.zip |
Merge "Expose bottom action bar methods" into sc-dev am: 75780a4444
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/WallpaperPicker2/+/15022167
Change-Id: Ice20a8d43d202293dc0bcc2c2dbd90b296759be3
-rw-r--r-- | res/layout/bottom_actions_layout.xml | 5 | ||||
-rwxr-xr-x | res/values/styles.xml | 9 | ||||
-rw-r--r-- | src/com/android/wallpaper/widget/BottomActionBar.java | 25 |
3 files changed, 27 insertions, 12 deletions
diff --git a/res/layout/bottom_actions_layout.xml b/res/layout/bottom_actions_layout.xml index 91e8f1d..9102086 100644 --- a/res/layout/bottom_actions_layout.xml +++ b/res/layout/bottom_actions_layout.xml @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. --> +<!-- Updates layout's color and background in {@code BottomActionBar} --> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" @@ -31,7 +32,6 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginHorizontal="@dimen/bottom_sheet_margin" - android:background="@drawable/bottom_sheet_background" android:theme="@style/WallpaperPicker.BottomPaneStyle" android:clickable="true" app:behavior_peekHeight="0dp" @@ -45,7 +45,6 @@ android:layout_height="@dimen/bottom_actions_height" android:paddingTop="@dimen/bottom_actions_top_padding" android:paddingBottom="@dimen/bottom_actions_bottom_padding" - android:background="?android:colorBackground" android:theme="@style/BottomActionItemStyle" android:layout_alignParentBottom="true" android:layoutDirection="locale"> @@ -162,8 +161,6 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" - android:background="@drawable/btn_transparent_background" - android:textColor="?android:attr/colorAccent" android:text="@string/bottom_action_bar_apply" android:visibility="gone" app:layout_constraintTop_toTopOf="parent" diff --git a/res/values/styles.xml b/res/values/styles.xml index 63a1f44..051ca4b 100755 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -121,12 +121,7 @@ </style> <!-- Preview attribution pane styles --> - <style name="WallpaperPicker.BottomPaneStyle" parent="@android:style/Theme.DeviceDefault.Settings"> - <item name="tabTextAppearance">@style/WallpaperPicker.Preview.TextAppearance.NoAllCaps</item> - <item name="tabIndicatorColor">?android:attr/textColorPrimary</item> - <item name="tabGravity">fill</item> - <item name="tabMaxWidth">0dp</item> - </style> + <style name="WallpaperPicker.BottomPaneStyle" parent="@android:style/Theme.DeviceDefault.Settings"/> <!-- Preview customization pane styles --> <style name="WallpaperPicker.CustomizationPaneStyle" parent="@android:style/Theme.DeviceDefault.Settings"> @@ -182,8 +177,6 @@ <!-- Bottom action item --> <style name="BottomActionItemStyle"> - <item name="android:tint">@color/bottom_action_button_color_tint</item> - <item name="android:background">@drawable/bottom_action_button_background</item> <item name="android:paddingHorizontal">@dimen/bottom_action_button_padding_horizontal</item> </style> diff --git a/src/com/android/wallpaper/widget/BottomActionBar.java b/src/com/android/wallpaper/widget/BottomActionBar.java index fda4c8b..8c0169b 100644 --- a/src/com/android/wallpaper/widget/BottomActionBar.java +++ b/src/com/android/wallpaper/widget/BottomActionBar.java @@ -24,12 +24,16 @@ import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.Button; import android.widget.FrameLayout; +import android.widget.ImageView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.core.widget.ImageViewCompat; import com.android.wallpaper.R; +import com.android.wallpaper.util.ResourceUtils; import com.android.wallpaper.util.SizeCalculator; import com.google.android.material.bottomsheet.BottomSheetBehavior; @@ -127,6 +131,7 @@ public class BottomActionBar extends FrameLayout { mBottomSheetView = findViewById(R.id.action_bottom_sheet); SizeCalculator.adjustBackgroundCornerRadius(mBottomSheetView); + setColor(context); mBottomSheetBehavior = (QueueStateBottomSheetBehavior<ViewGroup>) BottomSheetBehavior.from( mBottomSheetView); @@ -460,6 +465,26 @@ public class BottomActionBar extends FrameLayout { mSelectedAction = null; } + /** Dynamic update color with {@code Context}. */ + public void setColor(Context context) { + mBottomSheetView.setBackground(context.getDrawable(R.drawable.bottom_sheet_background)); + + ViewGroup actionTabs = findViewById(R.id.action_tabs); + actionTabs.setBackgroundColor( + ResourceUtils.getColorAttr(context, android.R.attr.colorBackground)); + for (int i = 0; i < actionTabs.getChildCount(); i++) { + View v = actionTabs.getChildAt(i); + if (v instanceof ImageView) { + v.setBackground(context.getDrawable(R.drawable.bottom_action_button_background)); + ImageViewCompat.setImageTintList((ImageView) v, + context.getColorStateList(R.color.bottom_action_button_color_tint)); + } + } + Button applyButton = findViewById(R.id.action_apply_text_button); + applyButton.setBackground(context.getDrawable(R.drawable.btn_transparent_background)); + applyButton.setTextColor(ResourceUtils.getColorAttr(context, android.R.attr.colorAccent)); + } + private void updateSelectedState(BottomAction bottomAction, boolean selected) { View bottomActionView = mActionMap.get(bottomAction); if (bottomActionView.isSelected() == selected) { |