Add a done button to vision setting pages in setup flow

Root cause: User feels confused because the particular screen doesn't have a back button but at that moment of the setup flow the regular UI gestures didn't even work.
Solution: Add a done button to the vision settings pages for clearer navigation.

Bug: 262995569
Test: make RunSettingsRoboTests ROBOTEST_FILTER=FragmentForSetupWizardTest
Change-Id: Id3a0d78389e0e6c11b5b5cf016b37673fde7f286
This commit is contained in:
menghanli
2023-02-13 17:18:40 +08:00
parent d3ff83eb4f
commit dd2ec775c8
11 changed files with 119 additions and 33 deletions

View File

@@ -19,8 +19,13 @@ import android.content.Context;
import android.graphics.drawable.Drawable;
import android.widget.LinearLayout;
import androidx.annotation.StringRes;
import com.android.settings.R;
import com.google.android.setupcompat.template.FooterBarMixin;
import com.google.android.setupcompat.template.FooterButton;
import com.google.android.setupcompat.template.Mixin;
import com.google.android.setupdesign.GlifPreferenceLayout;
import com.google.android.setupdesign.util.ThemeHelper;
@@ -30,7 +35,7 @@ class AccessibilitySetupWizardUtils {
private AccessibilitySetupWizardUtils(){}
/**
* Update the {@link GlifPreferenceLayout} attributes if they have previously been initialized.
* Updates the {@link GlifPreferenceLayout} attributes if they have previously been initialized.
* When the SetupWizard supports the extended partner configs, it means the material layout
* would be applied. It should set a different padding/margin in views to align Settings style
* for accessibility feature pages.
@@ -55,4 +60,46 @@ class AccessibilitySetupWizardUtils {
}
}
}
/**
* Sets primary button for footer of the {@link GlifPreferenceLayout}.
*
* <p> This will be the initial by given material theme style.
*
* @param context A {@link Context}
* @param mixin A {@link Mixin} for managing buttons.
* @param text The {@code text} by resource.
* @param runnable The {@link Runnable} to run.
*/
public static void setPrimaryButton(Context context, FooterBarMixin mixin, @StringRes int text,
Runnable runnable) {
mixin.setPrimaryButton(
new FooterButton.Builder(context)
.setText(text)
.setListener(l -> runnable.run())
.setButtonType(FooterButton.ButtonType.DONE)
.setTheme(R.style.SudGlifButton_Primary)
.build());
}
/**
* Sets secondary button for the footer of the {@link GlifPreferenceLayout}.
*
* <p> This will be the initial by given material theme style.
*
* @param context A {@link Context}
* @param mixin A {@link Mixin} for managing buttons.
* @param text The {@code text} by resource.
* @param runnable The {@link Runnable} to run.
*/
public static void setSecondaryButton(Context context, FooterBarMixin mixin,
@StringRes int text, Runnable runnable) {
mixin.setSecondaryButton(
new FooterButton.Builder(context)
.setText(text)
.setListener(l -> runnable.run())
.setButtonType(FooterButton.ButtonType.CLEAR)
.setTheme(R.style.SudGlifButton_Secondary)
.build());
}
}