diff --git a/packages/SystemUI/res/layout/global_screenshot_action_chip.xml b/packages/SystemUI/res/layout/global_screenshot_action_chip.xml index 7198e5c1f6211..aeae722c4ed4f 100644 --- a/packages/SystemUI/res/layout/global_screenshot_action_chip.xml +++ b/packages/SystemUI/res/layout/global_screenshot_action_chip.xml @@ -34,14 +34,11 @@ android:id="@+id/screenshot_action_chip_icon" android:tint="?android:attr/textColorPrimary" android:layout_width="@dimen/screenshot_action_chip_icon_size" - android:layout_height="@dimen/screenshot_action_chip_icon_size" - android:layout_marginStart="@dimen/screenshot_action_chip_padding_start" - android:layout_marginEnd="@dimen/screenshot_action_chip_padding_middle"/> + android:layout_height="@dimen/screenshot_action_chip_icon_size"/> diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml index d624793ee44b2..40ca87dd1f16a 100644 --- a/packages/SystemUI/res/values/dimens.xml +++ b/packages/SystemUI/res/values/dimens.xml @@ -342,14 +342,18 @@ 8dp 8dp + 8dp + 4dp 11dp 18dp - 8dp - - 8dp - 16dp + + 14dp + + 12dp + + 8dp 14sp 80dp 3dp diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotActionChip.java b/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotActionChip.java index 3370946ec2747..4a1aa169b207c 100644 --- a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotActionChip.java +++ b/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotActionChip.java @@ -21,8 +21,10 @@ import android.content.Context; import android.graphics.drawable.Icon; import android.util.AttributeSet; import android.util.Log; +import android.view.View; import android.widget.FrameLayout; import android.widget.ImageView; +import android.widget.LinearLayout; import android.widget.TextView; import com.android.systemui.R; @@ -59,6 +61,7 @@ public class ScreenshotActionChip extends FrameLayout { protected void onFinishInflate() { mIconView = findViewById(R.id.screenshot_action_chip_icon); mTextView = findViewById(R.id.screenshot_action_chip_text); + updatePadding(mTextView.getText().length() > 0); } @Override @@ -76,6 +79,7 @@ public class ScreenshotActionChip extends FrameLayout { void setText(CharSequence text) { mTextView.setText(text); + updatePadding(text.length() > 0); } void setPendingIntent(PendingIntent intent, Runnable finisher) { @@ -93,4 +97,28 @@ public class ScreenshotActionChip extends FrameLayout { mIsPending = isPending; setPressed(mIsPending); } + + private void updatePadding(boolean hasText) { + LinearLayout.LayoutParams iconParams = + (LinearLayout.LayoutParams) mIconView.getLayoutParams(); + LinearLayout.LayoutParams textParams = + (LinearLayout.LayoutParams) mTextView.getLayoutParams(); + if (hasText) { + int paddingHorizontal = mContext.getResources().getDimensionPixelSize( + R.dimen.screenshot_action_chip_padding_horizontal); + int spacing = mContext.getResources().getDimensionPixelSize( + R.dimen.screenshot_action_chip_spacing); + iconParams.setMarginStart(paddingHorizontal); + iconParams.setMarginEnd(spacing); + textParams.setMarginEnd(paddingHorizontal); + } else { + int paddingHorizontal = mContext.getResources().getDimensionPixelSize( + R.dimen.screenshot_action_chip_icon_only_padding_horizontal); + iconParams.setMarginStart(paddingHorizontal); + iconParams.setMarginEnd(paddingHorizontal); + } + mTextView.setVisibility(hasText ? View.VISIBLE : View.GONE); + mIconView.setLayoutParams(iconParams); + mTextView.setLayoutParams(textParams); + } } diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotView.java b/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotView.java index 426f6ebe98efd..af4836d997fa1 100644 --- a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotView.java +++ b/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotView.java @@ -519,7 +519,7 @@ public class ScreenshotView extends FrameLayout implements ArrayList chips = new ArrayList<>(); - mShareChip.setText(mContext.getString(com.android.internal.R.string.share)); + mShareChip.setContentDescription(mContext.getString(com.android.internal.R.string.share)); mShareChip.setIcon(Icon.createWithResource(mContext, R.drawable.ic_screenshot_share), true); mShareChip.setOnClickListener(v -> { mShareChip.setIsPending(true); @@ -531,7 +531,7 @@ public class ScreenshotView extends FrameLayout implements }); chips.add(mShareChip); - mEditChip.setText(mContext.getString(R.string.screenshot_edit_label)); + mEditChip.setContentDescription(mContext.getString(R.string.screenshot_edit_label)); mEditChip.setIcon(Icon.createWithResource(mContext, R.drawable.ic_screenshot_edit), true); mEditChip.setOnClickListener(v -> { mEditChip.setIsPending(true);