Skip to content

Commit

Permalink
KeyboardSettings: Add a RemotePreference for device-specific panel
Browse files Browse the repository at this point in the history
Allow devices to provide advanced keyboard settings.

Unfortunatelly this can't be done with existing IA settings,
so use the RemotePreference API to allow the external app
to update the view. The action for this is:

     "org.lineageos.settings.device.ADVANCED_KEYBOARD_SETTINGS"

Change-Id: I1c46d3568c4d5bfc78e1cbae033071c7641fdf29
  • Loading branch information
bgcngm authored and mikeNG committed Oct 25, 2024
1 parent 2b4208b commit 8b03dbd
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
4 changes: 4 additions & 0 deletions res/values/cm_strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
limitations under the License.
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- Advanced keyboard settings -->
<string name="keyboard_extras_title">Extras</string>
<string name="advanced_keyboard_settings_title">Advanced settings</string>

<!-- Android debugging as root -->
<string name="adb_enable_root">Rooted debugging</string>
<string name="adb_enable_summary_root">Allow running Android debugging as root</string>
Expand Down
17 changes: 17 additions & 0 deletions res/xml/physical_keyboard_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
-->
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:title="@string/physical_keyboard_title">
<!-- Additional preference screens are inserted here programmatically
with low order values to set the key map of each attached keyboard. -->
Expand Down Expand Up @@ -60,4 +61,20 @@
android:defaultValue="false" />

</PreferenceCategory>

<!-- Device-specific keyboard settings. -->
<PreferenceCategory
android:key="keyboard_extras_category"
android:title="@string/keyboard_extras_title" >

<lineageos.preference.RemotePreference
android:key="advanced_keyboard_settings"
android:title="@string/advanced_keyboard_settings_title"
settings:requiresAction="org.lineageos.settings.device.ADVANCED_KEYBOARD_SETTINGS">
<intent
android:action="org.lineageos.settings.device.ADVANCED_KEYBOARD_SETTINGS" />
</lineageos.preference.RemotePreference>

</PreferenceCategory>

</PreferenceScreen>
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public final class PhysicalKeyboardFragment extends SettingsPreferenceFragment

private static final String KEYBOARD_OPTIONS_CATEGORY = "keyboard_options_category";
private static final String KEYBOARD_A11Y_CATEGORY = "keyboard_a11y_category";
private static final String KEYBOARD_EXTRAS_CATEGORY = "keyboard_extras_category";
private static final String SHOW_VIRTUAL_KEYBOARD_SWITCH = "show_virtual_keyboard_switch";
private static final String ACCESSIBILITY_BOUNCE_KEYS = "accessibility_bounce_keys";
private static final String ACCESSIBILITY_SLOW_KEYS = "accessibility_slow_keys";
Expand Down Expand Up @@ -99,6 +100,8 @@ public final class PhysicalKeyboardFragment extends SettingsPreferenceFragment
private PreferenceCategory mKeyboardAssistanceCategory;
@Nullable
private PreferenceCategory mKeyboardA11yCategory = null;
@NonNull
private PreferenceCategory mKeyboardExtrasCategory = null;
@Nullable
private TwoStatePreference mShowVirtualKeyboardSwitch = null;
@Nullable
Expand Down Expand Up @@ -129,6 +132,8 @@ public void onCreatePreferences(Bundle bundle, String s) {
mImm = Preconditions.checkNotNull(activity.getSystemService(InputMethodManager.class));
mKeyboardAssistanceCategory = Preconditions.checkNotNull(
findPreference(KEYBOARD_OPTIONS_CATEGORY));
mKeyboardExtrasCategory = Preconditions.checkNotNull(
findPreference(KEYBOARD_EXTRAS_CATEGORY));
mShowVirtualKeyboardSwitch = Objects.requireNonNull(
mKeyboardAssistanceCategory.findPreference(SHOW_VIRTUAL_KEYBOARD_SWITCH));

Expand Down Expand Up @@ -311,6 +316,8 @@ private void updateHardKeyboards(@NonNull List<HardKeyboardDeviceInfo> newHardKe
}
mKeyboardAssistanceCategory.setOrder(1);
preferenceScreen.addPreference(mKeyboardAssistanceCategory);
mKeyboardExtrasCategory.setOrder(99);
preferenceScreen.addPreference(mKeyboardExtrasCategory);
if (mSupportsFirmwareUpdate) {
mFeatureProvider.addFirmwareUpdateCategory(getPrefContext(), preferenceScreen);
}
Expand Down

0 comments on commit 8b03dbd

Please sign in to comment.