[Wi-Fi DPP] Refine Wi-Fi DPP UI layouts with SUW library
1. Use GlifLayout in all fragments 2. Fragments use 32dp icon instead of 48 dp 3. Replace ScrollView & ProgressBar & Header & Footer of original layout with GlifLayout design 4. Remove ActionBar (no more back button on screen top) Bug: 129021867 Test: manual Change-Id: I2fda48cb7f7819b2c8dd85c10d39e1f187463bd8
This commit is contained in:
@@ -16,14 +16,22 @@
|
||||
|
||||
package com.android.settings.wifi.dpp;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.DrawableRes;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.InstrumentedFragment;
|
||||
|
||||
import com.google.android.setupcompat.template.FooterBarMixin;
|
||||
import com.google.android.setupcompat.template.FooterButton;
|
||||
import com.google.android.setupdesign.GlifLayout;
|
||||
|
||||
/**
|
||||
* There are below 4 fragments for Wi-Fi DPP UI flow, to reduce redundant code of UI components,
|
||||
* this parent fragment instantiates common UI components
|
||||
@@ -34,37 +42,63 @@ import com.android.settings.core.InstrumentedFragment;
|
||||
* {@code WifiDppAddDeviceFragment}
|
||||
*/
|
||||
public abstract class WifiDppQrCodeBaseFragment extends InstrumentedFragment {
|
||||
private GlifLayout mGlifLayout;
|
||||
private ImageView mHeaderIcon;
|
||||
private ImageView mDevicesCheckCircleGreenHeaderIcon;
|
||||
protected TextView mTitle;
|
||||
protected TextView mSummary;
|
||||
protected View mTitleSummaryContainer;
|
||||
protected FooterButton mLeftButton;
|
||||
protected FooterButton mRightButton;
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
mGlifLayout = (GlifLayout) view;
|
||||
|
||||
mHeaderIcon = view.findViewById(android.R.id.icon);
|
||||
mDevicesCheckCircleGreenHeaderIcon =
|
||||
view.findViewById(R.id.devices_check_circle_green_icon);
|
||||
mTitle = view.findViewById(android.R.id.title);
|
||||
mSummary = view.findViewById(android.R.id.summary);
|
||||
|
||||
// This is the LinearLayout which groups mTitle and mSummary for Talkback to announce the
|
||||
// content in a way that reflects its natural groupings.
|
||||
mTitleSummaryContainer = view.findViewById(R.id.title_summary_container);
|
||||
}
|
||||
if (isFooterAvailable()) {
|
||||
FooterBarMixin FooterBarMixin = ((GlifLayout) view).getMixin(FooterBarMixin.class);
|
||||
|
||||
protected void setHeaderIconImageResource(int resId) {
|
||||
// ic_devices_check_circle_green is a LayerDrawable,
|
||||
// it has different size from other VectorDrawable icons
|
||||
if (resId == R.drawable.ic_devices_check_circle_green) {
|
||||
mHeaderIcon.setVisibility(View.GONE);
|
||||
mDevicesCheckCircleGreenHeaderIcon.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
mDevicesCheckCircleGreenHeaderIcon.setVisibility(View.GONE);
|
||||
mHeaderIcon.setImageResource(resId);
|
||||
mHeaderIcon.setVisibility(View.VISIBLE);
|
||||
mLeftButton = new FooterButton.Builder(getContext())
|
||||
.setButtonType(FooterButton.ButtonType.CANCEL)
|
||||
.setTheme(R.style.SudGlifButton_Secondary)
|
||||
.build();
|
||||
mGlifLayout.getMixin(FooterBarMixin.class).setSecondaryButton(mLeftButton);
|
||||
|
||||
mRightButton = new FooterButton.Builder(getContext())
|
||||
.setButtonType(FooterButton.ButtonType.NEXT)
|
||||
.setTheme(R.style.SudGlifButton_Primary)
|
||||
.build();
|
||||
mGlifLayout.getMixin(FooterBarMixin.class).setPrimaryButton(mRightButton);
|
||||
}
|
||||
}
|
||||
|
||||
protected void setHeaderIconImageResource(@DrawableRes int iconResId) {
|
||||
mGlifLayout.setIcon(getDrawable(iconResId));
|
||||
}
|
||||
|
||||
private Drawable getDrawable(@DrawableRes int iconResId) {
|
||||
Drawable buttonIcon = null;
|
||||
|
||||
try {
|
||||
buttonIcon = getContext().getDrawable(iconResId);
|
||||
} catch (Resources.NotFoundException exception) {
|
||||
}
|
||||
return buttonIcon;
|
||||
}
|
||||
|
||||
protected void setHeaderTitle(String title) {
|
||||
mGlifLayout.setHeaderText(title);
|
||||
}
|
||||
|
||||
protected void setHeaderTitle(int resId, Object... formatArgs) {
|
||||
mGlifLayout.setHeaderText(getString(resId, formatArgs));
|
||||
}
|
||||
|
||||
protected void setProgressBarShown(boolean shown) {
|
||||
mGlifLayout.setProgressBarShown(shown);
|
||||
}
|
||||
|
||||
protected abstract boolean isFooterAvailable();
|
||||
}
|
||||
|
Reference in New Issue
Block a user