SUW: improve navigation on D-pad devices

* Set the initial focus on a usable view instead of a whole layout.
* Set the next focus of the locale selector to next-button.

Change-Id: I4a16127c24e87b52e38892882e44b3a8d24b779b
This commit is contained in:
Timi Rautamäki
2022-01-15 09:25:02 +00:00
parent b416c33ab6
commit daef80ecaf
4 changed files with 20 additions and 2 deletions

View File

@@ -1,6 +1,6 @@
/* /*
* Copyright (C) 2016 The CyanogenMod Project * Copyright (C) 2016 The CyanogenMod Project
* Copyright (C) 2017-2021 The LineageOS Project * 2017-2022 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -247,6 +247,10 @@ public abstract class BaseSetupWizardActivity extends Activity implements Naviga
} }
} }
public Button getNextButton() {
return mNavigationBar.getNextButton();
}
protected void setSkipText(int resId) { protected void setSkipText(int resId) {
if (mNavigationBar != null) { if (mNavigationBar != null) {
mNavigationBar.getSkipButton().setText(resId); mNavigationBar.getSkipButton().setText(resId);

View File

@@ -82,6 +82,7 @@ public class LineageSettingsActivity extends BaseSetupWizardActivity {
View metricsRow = findViewById(R.id.metrics); View metricsRow = findViewById(R.id.metrics);
metricsRow.setOnClickListener(mMetricsClickListener); metricsRow.setOnClickListener(mMetricsClickListener);
metricsRow.requestFocus();
String metricsHelpImproveLineage = String metricsHelpImproveLineage =
getString(R.string.services_help_improve_cm, os_name); getString(R.string.services_help_improve_cm, os_name);
String metricsSummary = getString(R.string.services_metrics_label, String metricsSummary = getString(R.string.services_metrics_label,

View File

@@ -1,6 +1,6 @@
/* /*
* Copyright (C) 2016 The CyanogenMod Project * Copyright (C) 2016 The CyanogenMod Project
* Copyright (C) 2017-2021 The LineageOS Project * 2017-2022 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -81,6 +81,8 @@ public class LocaleActivity extends BaseSetupWizardActivity {
SystemBarHelper.setBackButtonVisible(getWindow(), true); SystemBarHelper.setBackButtonVisible(getWindow(), true);
setNextText(R.string.next); setNextText(R.string.next);
mLanguagePicker = (LocalePicker) findViewById(R.id.locale_list); mLanguagePicker = (LocalePicker) findViewById(R.id.locale_list);
mLanguagePicker.setNextRight(getNextButton().getId());
mLanguagePicker.requestFocus();
loadLanguages(); loadLanguages();
} }

View File

@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2008 The Android Open Source Project * Copyright (C) 2008 The Android Open Source Project
* 2022 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -56,6 +57,8 @@ import android.widget.LinearLayout;
import android.widget.Scroller; import android.widget.Scroller;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.IdRes;
import org.lineageos.setupwizard.R; import org.lineageos.setupwizard.R;
import java.util.ArrayList; import java.util.ArrayList;
@@ -1175,6 +1178,14 @@ public class LocalePicker extends LinearLayout {
setValueInternal(value, false); setValueInternal(value, false);
} }
/**
* Sets the next focused item for a remote D-pad key right.
* @param id The ID of the next view.
*/
public void setNextRight(@IdRes int id) {
setNextFocusRightId(id);
}
/** /**
* Shows the soft input for its input text. * Shows the soft input for its input text.
*/ */