Merge "[PhysicalKeyboard] Update Setting Feature Provider for follow up usage" into main
This commit is contained in:
@@ -35,20 +35,21 @@ public interface KeyboardSettingsFeatureProvider {
|
||||
boolean supportsFirmwareUpdate();
|
||||
|
||||
/**
|
||||
* Add firmware update preference category .
|
||||
* Register firmware information preferences update on preference screen.
|
||||
*
|
||||
* @param context The context to initialize the application with.
|
||||
* @param screen The {@link PreferenceScreen} to add the firmware update preference category.
|
||||
*
|
||||
* @return true if the category is added successfully.
|
||||
* @param screen The {@link PreferenceScreen} to add the firmware information preferences.
|
||||
*/
|
||||
boolean addFirmwareUpdateCategory(Context context, PreferenceScreen screen);
|
||||
void registerKeyboardInformationCategory(@Nullable PreferenceScreen screen);
|
||||
|
||||
/**
|
||||
* Unregister firmware information preferences update on preference screen.
|
||||
*/
|
||||
void unregisterKeyboardInformationCategory();
|
||||
|
||||
/**
|
||||
* Get custom action key icon.
|
||||
*
|
||||
* @param context Context for accessing resources.
|
||||
*
|
||||
* @return Returns the image of the icon, or null if there is no any custom icon.
|
||||
*/
|
||||
@Nullable
|
||||
|
@@ -19,6 +19,7 @@ package com.android.settings.inputmethod;
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
/**
|
||||
@@ -32,12 +33,13 @@ public class KeyboardSettingsFeatureProviderImpl implements KeyboardSettingsFeat
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addFirmwareUpdateCategory(Context context, PreferenceScreen screen) {
|
||||
return false;
|
||||
}
|
||||
public void registerKeyboardInformationCategory(@Nullable PreferenceScreen screen) {}
|
||||
|
||||
@Override
|
||||
public void unregisterKeyboardInformationCategory() {}
|
||||
|
||||
@Override
|
||||
public Drawable getActionKeyIcon(Context context) {
|
||||
return null;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -164,7 +164,7 @@ public final class PhysicalKeyboardFragment extends DashboardFragment
|
||||
mFeatureProvider = featureFactory.getKeyboardSettingsFeatureProvider();
|
||||
mSupportsFirmwareUpdate = mFeatureProvider.supportsFirmwareUpdate();
|
||||
if (mSupportsFirmwareUpdate) {
|
||||
mFeatureProvider.addFirmwareUpdateCategory(getContext(), getPreferenceScreen());
|
||||
mFeatureProvider.registerKeyboardInformationCategory(getPreferenceScreen());
|
||||
}
|
||||
boolean isModifierKeySettingsEnabled = FeatureFlagUtils
|
||||
.isEnabled(getContext(), FeatureFlagUtils.SETTINGS_NEW_KEYBOARD_MODIFIER_KEY);
|
||||
@@ -344,7 +344,7 @@ public final class PhysicalKeyboardFragment extends DashboardFragment
|
||||
mKeyboardAssistanceCategory.setOrder(1);
|
||||
preferenceScreen.addPreference(mKeyboardAssistanceCategory);
|
||||
if (mSupportsFirmwareUpdate) {
|
||||
mFeatureProvider.addFirmwareUpdateCategory(getPrefContext(), preferenceScreen);
|
||||
mFeatureProvider.registerKeyboardInformationCategory(preferenceScreen);
|
||||
}
|
||||
|
||||
if (InputSettings.isAccessibilityBounceKeysFeatureEnabled()
|
||||
@@ -423,6 +423,9 @@ public final class PhysicalKeyboardFragment extends DashboardFragment
|
||||
|
||||
private void unregisterSettingsObserver() {
|
||||
getActivity().getContentResolver().unregisterContentObserver(mContentObserver);
|
||||
if (mSupportsFirmwareUpdate) {
|
||||
mFeatureProvider.unregisterKeyboardInformationCategory();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateAccessibilityBounceKeysSwitch(@NonNull Context context) {
|
||||
|
@@ -19,10 +19,7 @@ package com.android.settings.inputmethod;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Looper;
|
||||
|
||||
import androidx.preference.PreferenceManager;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
|
||||
@@ -47,17 +44,6 @@ public class KeyboardSettingsFeatureProviderImplTest {
|
||||
assertThat(mFeatureProvider.supportsFirmwareUpdate()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addFirmwareUpdateCategory_defaultValue_returnsFalse() {
|
||||
if (Looper.myLooper() == null) {
|
||||
Looper.prepare();
|
||||
}
|
||||
PreferenceManager preferenceManager = new PreferenceManager(mContext);
|
||||
PreferenceScreen screen = preferenceManager.createPreferenceScreen(mContext);
|
||||
|
||||
assertThat(mFeatureProvider.addFirmwareUpdateCategory(mContext, screen)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getActionKeyIcon_defaultValue_returnsNull() {
|
||||
assertThat(mFeatureProvider.getActionKeyIcon(mContext)).isNull();
|
||||
|
Reference in New Issue
Block a user