App 2.16.4: drop-downs that keep full screen
Back to drop-downs for upload frequency, tyre pressure unit and accent colour, as Material exposed dropdown menus instead of Spinners. A Spinner's list is a focusable window of its own without the full-screen flags, so the car showed its bars while it was open; an exposed dropdown's list leaves the focus with the activity, so the app stays full screen. Styled like the other input fields, with full-height rows. Replaces the buttons of 2.16.3. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QLJfZQZeAKAwSqViTmLzki
This commit is contained in:
@@ -126,7 +126,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
/** Upload page: live telemetry switch and cadence. */
|
||||
private SwitchMaterial liveTelemetrySwitch, boostSwitch, voiceKeySwitch, fullScreenSwitch;
|
||||
private TextView steeringKeysText;
|
||||
private com.google.android.material.chip.ChipGroup intervalChoices;
|
||||
private com.google.android.material.textfield.MaterialAutoCompleteTextView intervalChoices;
|
||||
private TextInputLayout lowSocLayout;
|
||||
private TextInputEditText lowSocInput;
|
||||
|
||||
@@ -1126,28 +1126,18 @@ public class MainActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
/**
|
||||
* A single choice as buttons on the page (choice_chip.xml), in place of a drop-down: a
|
||||
* drop-down opens a window of its own that is not full screen, and the car's bars came back
|
||||
* while it was open. Rebinding replaces the buttons, so it may be called again.
|
||||
* A single choice as a drop-down (Widget.EV.Dropdown). An exposed dropdown menu rather than
|
||||
* a Spinner: a Spinner's list is a focusable window of its own without the full-screen
|
||||
* flags, and the car showed its bars while it was open; this list leaves the focus with
|
||||
* the activity. setSimpleItems keeps every option listed (a plain adapter would filter the
|
||||
* list down to the current text). Rebinding is safe.
|
||||
*/
|
||||
private void bindChoices(com.google.android.material.chip.ChipGroup group, String[] labels, int selected,
|
||||
java.util.function.IntConsumer onPick) {
|
||||
group.setOnCheckedStateChangeListener(null);
|
||||
group.removeAllViews();
|
||||
for (int i = 0; i < labels.length; i++) {
|
||||
com.google.android.material.chip.Chip chip = (com.google.android.material.chip.Chip)
|
||||
getLayoutInflater().inflate(R.layout.choice_chip, group, false);
|
||||
chip.setId(View.generateViewId());
|
||||
chip.setText(labels[i]);
|
||||
chip.setTag(i);
|
||||
group.addView(chip);
|
||||
if (i == selected) chip.setChecked(true);
|
||||
}
|
||||
group.setOnCheckedStateChangeListener((g, checkedIds) -> {
|
||||
if (checkedIds.isEmpty()) return;
|
||||
View chosen = g.findViewById(checkedIds.get(0));
|
||||
if (chosen != null) onPick.accept((Integer) chosen.getTag());
|
||||
});
|
||||
private void bindChoices(com.google.android.material.textfield.MaterialAutoCompleteTextView view,
|
||||
String[] labels, int selected, java.util.function.IntConsumer onPick) {
|
||||
view.setOnItemClickListener(null);
|
||||
view.setSimpleItems(labels);
|
||||
view.setText(labels[selected], false);
|
||||
view.setOnItemClickListener((parent, item, position, id) -> onPick.accept(position));
|
||||
}
|
||||
|
||||
/** The accent colour; a change recreates the activity so every view takes it. */
|
||||
|
||||
Reference in New Issue
Block a user