[Catalyst] Support main switch bar

MainSwitchBar is a view widget in activity layout stick to the top of
screen UI. There is no corresponding Preference in the preference
screen. For Catalyst support, introduce an invisible Preference object
to manipulate with MainSwitchBar, so that the binding mechanism is
still working on top of this abstraction.

Bug: 332201912
Flag: EXEMPT new class
Test: manual
Change-Id: If50932a443c1ed3ac04d3ea2e3273724d750297d
This commit is contained in:
Jacky Wang
2024-11-12 14:05:00 +08:00
parent ab5dd02bd9
commit 6a52eeabbc
3 changed files with 120 additions and 6 deletions

View File

@@ -311,6 +311,11 @@ public class SettingsActivity extends SettingsBaseActivity
}
setContentView(R.layout.settings_main_prefs);
mMainSwitch = findViewById(R.id.switch_bar);
if (mMainSwitch != null) {
mMainSwitch.setMetricsCategory(lookupMetricsCategory());
mMainSwitch.setTranslationZ(findViewById(R.id.main_content).getTranslationZ() + 1);
}
getSupportFragmentManager().addOnBackStackChangedListener(this);
@@ -330,12 +335,6 @@ public class SettingsActivity extends SettingsBaseActivity
launchSettingFragment(initialFragmentName, intent);
}
mMainSwitch = findViewById(R.id.switch_bar);
if (mMainSwitch != null) {
mMainSwitch.setMetricsCategory(lookupMetricsCategory());
mMainSwitch.setTranslationZ(findViewById(R.id.main_content).getTranslationZ() + 1);
}
// see if we should show Back/Next buttons
if (intent.getBooleanExtra(EXTRA_PREFS_SHOW_BUTTON_BAR, false)) {