DO NOT MERGE: Downbranch don't need this adjustment

[Output Switcher] Adjust properties in dialog

1. only set padding for GroupDialog due to icon size
2. adjust properties in dialog layout to fix A11y suggestions

Test: verify on device
Bug: 208370984
Bug: 204846673
Bug: 204847219
Bug: 204844680
Change-Id: I93c440851b2bf1e1d8ed133ca48b2a9fd8fa38ea
This commit is contained in:
shaoweishen
2021-12-01 09:31:11 +00:00
committed by Shaowei Shen
parent 7834387feb
commit 19987ee056
4 changed files with 35 additions and 28 deletions

View File

@@ -13,9 +13,11 @@
~ 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.
--> -->
<shape xmlns:android="http://schemas.android.com/apk/res/android" <inset xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android" xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
android:shape="rectangle"> android:insetBottom="6dp"
android:insetTop="6dp">
<shape android:shape="rectangle">
<stroke <stroke
android:color="?androidprv:attr/colorAccentPrimaryVariant" android:color="?androidprv:attr/colorAccentPrimaryVariant"
android:width="1dp"/> android:width="1dp"/>
@@ -24,6 +26,7 @@
android:left="16dp" android:left="16dp"
android:right="16dp" android:right="16dp"
android:top="8dp" android:top="8dp"
android:bottom="8dp" /> android:bottom="8dp"/>
<solid android:color="@android:color/transparent" /> <solid android:color="@android:color/transparent"/>
</shape> </shape>
</inset>

View File

@@ -24,9 +24,9 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="96dp" android:layout_height="wrap_content"
android:gravity="start|center_vertical" android:gravity="start|center_vertical"
android:paddingStart="16dp" android:paddingStart="24dp"
android:orientation="horizontal"> android:orientation="horizontal">
<ImageView <ImageView
android:id="@+id/header_icon" android:id="@+id/header_icon"
@@ -36,7 +36,7 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:paddingStart="16dp" android:paddingStart="16dp"
android:paddingTop="20dp" android:paddingTop="20dp"
android:paddingBottom="24dp" android:paddingBottom="24dp"
@@ -59,7 +59,7 @@
android:gravity="center_vertical" android:gravity="center_vertical"
android:ellipsize="end" android:ellipsize="end"
android:maxLines="1" android:maxLines="1"
android:textColor="?android:attr/textColorTertiary" android:textColor="?android:attr/textColorSecondary"
android:fontFamily="roboto-regular" android:fontFamily="roboto-regular"
android:textSize="16sp"/> android:textSize="16sp"/>
</LinearLayout> </LinearLayout>
@@ -90,7 +90,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="16dp" android:layout_marginTop="16dp"
android:layout_marginStart="24dp" android:layout_marginStart="24dp"
android:layout_marginBottom="18dp" android:layout_marginBottom="24dp"
android:layout_marginEnd="24dp" android:layout_marginEnd="24dp"
android:orientation="horizontal"> android:orientation="horizontal">
@@ -98,7 +98,7 @@
android:id="@+id/stop" android:id="@+id/stop"
style="@style/MediaOutputRoundedOutlinedButton" style="@style/MediaOutputRoundedOutlinedButton"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="36dp" android:layout_height="wrap_content"
android:minWidth="0dp" android:minWidth="0dp"
android:text="@string/keyboard_key_media_stop" android:text="@string/keyboard_key_media_stop"
android:visibility="gone"/> android:visibility="gone"/>
@@ -112,7 +112,7 @@
android:id="@+id/done" android:id="@+id/done"
style="@style/MediaOutputRoundedOutlinedButton" style="@style/MediaOutputRoundedOutlinedButton"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="36dp" android:layout_height="wrap_content"
android:minWidth="0dp" android:minWidth="0dp"
android:text="@string/inline_done_button"/> android:text="@string/inline_done_button"/>
</LinearLayout> </LinearLayout>

View File

@@ -63,13 +63,14 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements
View mDialogView; View mDialogView;
private TextView mHeaderTitle; private TextView mHeaderTitle;
private TextView mHeaderSubtitle; private TextView mHeaderSubtitle;
private ImageView mHeaderIcon;
private RecyclerView mDevicesRecyclerView; private RecyclerView mDevicesRecyclerView;
private LinearLayout mDeviceListLayout; private LinearLayout mDeviceListLayout;
private Button mDoneButton; private Button mDoneButton;
private Button mStopButton; private Button mStopButton;
private int mListMaxHeight; private int mListMaxHeight;
protected ImageView mHeaderIcon;
MediaOutputBaseAdapter mAdapter; MediaOutputBaseAdapter mAdapter;
private final ViewTreeObserver.OnGlobalLayoutListener mDeviceListLayoutListener = () -> { private final ViewTreeObserver.OnGlobalLayoutListener mDeviceListLayoutListener = () -> {
@@ -140,7 +141,6 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements
mMediaOutputController.stop(); mMediaOutputController.stop();
} }
@VisibleForTesting
void refresh() { void refresh() {
// Update header icon // Update header icon
final int iconRes = getHeaderIconRes(); final int iconRes = getHeaderIconRes();
@@ -154,12 +154,6 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements
} else { } else {
mHeaderIcon.setVisibility(View.GONE); mHeaderIcon.setVisibility(View.GONE);
} }
if (mHeaderIcon.getVisibility() == View.VISIBLE) {
final int size = getHeaderIconSize();
final int padding = mContext.getResources().getDimensionPixelSize(
R.dimen.media_output_dialog_header_icon_padding);
mHeaderIcon.setLayoutParams(new LinearLayout.LayoutParams(size + padding, size));
}
// Update title and subtitle // Update title and subtitle
mHeaderTitle.setText(getHeaderText()); mHeaderTitle.setText(getHeaderText());
final CharSequence subTitle = getHeaderSubtitle(); final CharSequence subTitle = getHeaderSubtitle();

View File

@@ -20,6 +20,7 @@ import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import android.view.View; import android.view.View;
import android.view.WindowManager; import android.view.WindowManager;
import android.widget.LinearLayout;
import androidx.core.graphics.drawable.IconCompat; import androidx.core.graphics.drawable.IconCompat;
@@ -75,6 +76,15 @@ public class MediaOutputGroupDialog extends MediaOutputBaseDialog {
return mContext.getString(R.string.media_output_dialog_multiple_devices, size); return mContext.getString(R.string.media_output_dialog_multiple_devices, size);
} }
@Override
void refresh() {
super.refresh();
final int size = getHeaderIconSize();
final int padding = mContext.getResources().getDimensionPixelSize(
R.dimen.media_output_dialog_header_icon_padding);
mHeaderIcon.setLayoutParams(new LinearLayout.LayoutParams(size + padding, size));
}
@Override @Override
int getStopButtonVisibility() { int getStopButtonVisibility() {
return View.VISIBLE; return View.VISIBLE;