Add Input & Gesture/Language & Region pages under System.
- Removed LanguageAndInputDashboardAlias because now the contents are moved to new pages. Bug: 32637613 Bug: 32643833 Test: RunSettingsRoboTests Change-Id: Ia66a942a449a07b9cbba53bdc97738148aafadb4
This commit is contained in:
@@ -3190,18 +3190,35 @@
|
|||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<!-- Alias for IME & Language in new IA. Should merge into TargetActivity when launch -->
|
<!-- Alias for IME & Language in new IA. Should merge into TargetActivity when launch -->
|
||||||
<activity-alias android:name="LanguageAndInputDashboardAlias"
|
<activity android:name=".Settings$LanguageAndRegionSettingsActivity"
|
||||||
android:targetActivity="Settings$InputMethodAndLanguageSettingsActivity">
|
android:label="@string/language_and_region_settings_title"
|
||||||
<intent-filter android:priority="250">
|
android:icon="@drawable/ic_settings_language">
|
||||||
|
<intent-filter android:priority="260">
|
||||||
|
<action android:name="com.android.settings.action.SETTINGS"/>
|
||||||
|
</intent-filter>
|
||||||
|
<meta-data android:name="com.android.settings.category"
|
||||||
|
android:value="com.android.settings.category.ia.system"/>
|
||||||
|
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
||||||
|
android:value="com.android.settings.language.LanguageAndRegionSettings"/>
|
||||||
|
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
|
||||||
|
android:value="true"/>
|
||||||
|
<!-- Inherit intent-filter from LanguageSettingsActivity -->
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
<activity android:name=".Settings$InputAndGestureSettingsActivity"
|
||||||
|
android:label="@string/input_gesture_settings_title"
|
||||||
|
android:icon="@drawable/ic_settings_language">
|
||||||
|
<intent-filter android:priority="255">
|
||||||
<action android:name="com.android.settings.action.SETTINGS" />
|
<action android:name="com.android.settings.action.SETTINGS" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
|
||||||
android:value="com.android.settings.inputmethod.InputMethodAndLanguageSettings" />
|
|
||||||
<meta-data android:name="com.android.settings.category"
|
<meta-data android:name="com.android.settings.category"
|
||||||
android:value="com.android.settings.category.ia.system" />
|
android:value="com.android.settings.category.ia.system" />
|
||||||
|
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
||||||
|
android:value="com.android.settings.inputmethod.InputAndGestureSettings" />
|
||||||
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
|
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
|
||||||
android:value="true" />
|
android:value="true" />
|
||||||
</activity-alias>
|
<!-- Inherit intent-filter from LanguageSettingsActivity -->
|
||||||
|
</activity>
|
||||||
|
|
||||||
<!-- Alias for Date & Time in new IA. Should merge into TargetActivity when launch -->
|
<!-- Alias for Date & Time in new IA. Should merge into TargetActivity when launch -->
|
||||||
<activity-alias android:name="DateTimeDashboardAlias"
|
<activity-alias android:name="DateTimeDashboardAlias"
|
||||||
|
@@ -3717,6 +3717,10 @@
|
|||||||
<string name="language_settings">Languages & input</string>
|
<string name="language_settings">Languages & input</string>
|
||||||
<!-- Title of Languages & input settings screen -->
|
<!-- Title of Languages & input settings screen -->
|
||||||
<string name="language_keyboard_settings_title">Languages & input</string>
|
<string name="language_keyboard_settings_title">Languages & input</string>
|
||||||
|
<!-- Title of Languages & region settings screen -->
|
||||||
|
<string name="language_and_region_settings_title">Languages & region</string>
|
||||||
|
<!-- Title of Input & gesture settings screen -->
|
||||||
|
<string name="input_gesture_settings_title">Input & gestures</string>
|
||||||
<!-- On Languages & input settings screen, heading. Inside the "Languages & input settings" screen, this is the header for settings that relate to keyboard (enable/disable each keyboard, settings for each keyboard). -->
|
<!-- On Languages & input settings screen, heading. Inside the "Languages & input settings" screen, this is the header for settings that relate to keyboard (enable/disable each keyboard, settings for each keyboard). -->
|
||||||
<string name="keyboard_settings_category">Keyboard & input methods</string>
|
<string name="keyboard_settings_category">Keyboard & input methods</string>
|
||||||
<!-- On Text & language settings screen, setting option name. title of the setting to take the user to a screen to select the locale. -->
|
<!-- On Text & language settings screen, setting option name. title of the setting to take the user to a screen to select the locale. -->
|
||||||
|
53
res/xml/input_and_gesture.xml
Normal file
53
res/xml/input_and_gesture.xml
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
Copyright (C) 2016 The Android Open Source Project
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<PreferenceCategory
|
||||||
|
android:title="@string/keyboard_and_input_methods_category">
|
||||||
|
<Preference
|
||||||
|
android:title="@string/virtual_keyboard_category"
|
||||||
|
android:fragment="com.android.settings.inputmethod.VirtualKeyboardFragment"/>
|
||||||
|
<Preference
|
||||||
|
android:title="@string/physical_keyboard_title"
|
||||||
|
android:fragment="com.android.settings.inputmethod.PhysicalKeyboardFragment"/>
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
<PreferenceCategory
|
||||||
|
android:key="pointer_settings_category"
|
||||||
|
android:title="@string/pointer_settings_category">
|
||||||
|
|
||||||
|
<com.android.settings.PointerSpeedPreference
|
||||||
|
android:key="pointer_speed"
|
||||||
|
android:title="@string/pointer_speed"
|
||||||
|
android:dialogTitle="@string/pointer_speed"/>
|
||||||
|
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
<PreferenceCategory
|
||||||
|
android:key="game_controller_settings_category"
|
||||||
|
android:title="@string/game_controller_settings_category">
|
||||||
|
|
||||||
|
<SwitchPreference
|
||||||
|
android:key="vibrate_input_devices"
|
||||||
|
android:title="@string/vibrate_input_devices"
|
||||||
|
android:summaryOn="@string/vibrate_input_devices_summary"
|
||||||
|
android:summaryOff="@string/vibrate_input_devices_summary"/>
|
||||||
|
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
</PreferenceScreen>
|
50
res/xml/language_and_region.xml
Normal file
50
res/xml/language_and_region.xml
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
Copyright (C) 2016 The Android Open Source Project
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<Preference
|
||||||
|
android:key="phone_language"
|
||||||
|
android:title="@string/phone_language"
|
||||||
|
android:fragment="com.android.settings.localepicker.LocaleListEditor"/>
|
||||||
|
|
||||||
|
<!-- Spell checker preference title, summary and fragment will be set programmatically. -->
|
||||||
|
<!-- Note: Mark this as persistent="false" to remove unnecessarily saved shared preference.
|
||||||
|
See: InputMethodAndSubtypeUtil.removeUnnecessaryNonPersistentPreference. -->
|
||||||
|
<Preference
|
||||||
|
android:key="spellcheckers_settings"
|
||||||
|
android:title="@string/spellcheckers_settings_title"
|
||||||
|
android:persistent="false"/>
|
||||||
|
|
||||||
|
<!-- User dictionary preference title and fragment will be set programmatically. -->
|
||||||
|
<Preference
|
||||||
|
android:key="key_user_dictionary_settings"
|
||||||
|
android:title="@string/user_dict_settings_title"/>
|
||||||
|
|
||||||
|
<!-- TTS -->
|
||||||
|
<PreferenceCategory
|
||||||
|
android:key="voice_category"
|
||||||
|
android:title="@string/voice_category">
|
||||||
|
|
||||||
|
<Preference
|
||||||
|
android:key="tts_settings"
|
||||||
|
android:title="@string/tts_settings_title"
|
||||||
|
android:fragment="com.android.settings.tts.TextToSpeechSettings"/>
|
||||||
|
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
</PreferenceScreen>
|
@@ -41,12 +41,14 @@ public class Settings extends SettingsActivity {
|
|||||||
public static class WifiSettingsActivity extends SettingsActivity { /* empty */ }
|
public static class WifiSettingsActivity extends SettingsActivity { /* empty */ }
|
||||||
public static class WifiP2pSettingsActivity extends SettingsActivity { /* empty */ }
|
public static class WifiP2pSettingsActivity extends SettingsActivity { /* empty */ }
|
||||||
public static class InputMethodAndLanguageSettingsActivity extends SettingsActivity { /* empty */ }
|
public static class InputMethodAndLanguageSettingsActivity extends SettingsActivity { /* empty */ }
|
||||||
|
public static class InputAndGestureSettingsActivity extends SettingsActivity { /* empty */ }
|
||||||
public static class AvailableVirtualKeyboardActivity extends SettingsActivity { /* empty */ }
|
public static class AvailableVirtualKeyboardActivity extends SettingsActivity { /* empty */ }
|
||||||
public static class KeyboardLayoutPickerActivity extends SettingsActivity { /* empty */ }
|
public static class KeyboardLayoutPickerActivity extends SettingsActivity { /* empty */ }
|
||||||
public static class PhysicalKeyboardActivity extends SettingsActivity { /* empty */ }
|
public static class PhysicalKeyboardActivity extends SettingsActivity { /* empty */ }
|
||||||
public static class InputMethodAndSubtypeEnablerActivity extends SettingsActivity { /* empty */ }
|
public static class InputMethodAndSubtypeEnablerActivity extends SettingsActivity { /* empty */ }
|
||||||
public static class SpellCheckersSettingsActivity extends SettingsActivity { /* empty */ }
|
public static class SpellCheckersSettingsActivity extends SettingsActivity { /* empty */ }
|
||||||
public static class LocalePickerActivity extends SettingsActivity { /* empty */ }
|
public static class LocalePickerActivity extends SettingsActivity { /* empty */ }
|
||||||
|
public static class LanguageAndRegionSettingsActivity extends SettingsActivity { /* empty */ }
|
||||||
public static class UserDictionarySettingsActivity extends SettingsActivity { /* empty */ }
|
public static class UserDictionarySettingsActivity extends SettingsActivity { /* empty */ }
|
||||||
public static class HomeSettingsActivity extends SettingsActivity { /* empty */ }
|
public static class HomeSettingsActivity extends SettingsActivity { /* empty */ }
|
||||||
public static class DisplaySettingsActivity extends SettingsActivity { /* empty */ }
|
public static class DisplaySettingsActivity extends SettingsActivity { /* empty */ }
|
||||||
|
@@ -99,11 +99,13 @@ import com.android.settings.fuelgauge.PowerUsageDetail;
|
|||||||
import com.android.settings.fuelgauge.PowerUsageSummary;
|
import com.android.settings.fuelgauge.PowerUsageSummary;
|
||||||
import com.android.settings.gestures.GestureSettings;
|
import com.android.settings.gestures.GestureSettings;
|
||||||
import com.android.settings.inputmethod.AvailableVirtualKeyboardFragment;
|
import com.android.settings.inputmethod.AvailableVirtualKeyboardFragment;
|
||||||
|
import com.android.settings.inputmethod.InputAndGestureSettings;
|
||||||
import com.android.settings.inputmethod.InputMethodAndLanguageSettings;
|
import com.android.settings.inputmethod.InputMethodAndLanguageSettings;
|
||||||
import com.android.settings.inputmethod.KeyboardLayoutPickerFragment;
|
import com.android.settings.inputmethod.KeyboardLayoutPickerFragment;
|
||||||
import com.android.settings.inputmethod.PhysicalKeyboardFragment;
|
import com.android.settings.inputmethod.PhysicalKeyboardFragment;
|
||||||
import com.android.settings.inputmethod.SpellCheckersSettings;
|
import com.android.settings.inputmethod.SpellCheckersSettings;
|
||||||
import com.android.settings.inputmethod.UserDictionaryList;
|
import com.android.settings.inputmethod.UserDictionaryList;
|
||||||
|
import com.android.settings.language.LanguageAndRegionSettings;
|
||||||
import com.android.settings.localepicker.LocaleListEditor;
|
import com.android.settings.localepicker.LocaleListEditor;
|
||||||
import com.android.settings.location.LocationSettings;
|
import com.android.settings.location.LocationSettings;
|
||||||
import com.android.settings.network.NetworkDashboardFragment;
|
import com.android.settings.network.NetworkDashboardFragment;
|
||||||
@@ -291,7 +293,8 @@ public class SettingsActivity extends SettingsDrawerActivity
|
|||||||
// Home page > Security
|
// Home page > Security
|
||||||
"com.android.settings.Settings.LocationDashboardAlias",
|
"com.android.settings.Settings.LocationDashboardAlias",
|
||||||
// Home page > System
|
// Home page > System
|
||||||
"com.android.settings.Settings.LanguageAndInputDashboardAlias",
|
Settings.LanguageAndRegionSettingsActivity.class.getName(),
|
||||||
|
Settings.InputAndGestureSettingsActivity.class.getName(),
|
||||||
"com.android.settings.Settings.DateTimeDashboardAlias",
|
"com.android.settings.Settings.DateTimeDashboardAlias",
|
||||||
"com.android.settings.Settings.AccessibilityDashboardAlias",
|
"com.android.settings.Settings.AccessibilityDashboardAlias",
|
||||||
"com.android.settings.Settings.AboutDeviceDashboardAlias",
|
"com.android.settings.Settings.AboutDeviceDashboardAlias",
|
||||||
@@ -311,6 +314,8 @@ public class SettingsActivity extends SettingsDrawerActivity
|
|||||||
LocaleListEditor.class.getName(),
|
LocaleListEditor.class.getName(),
|
||||||
InputMethodAndLanguageSettings.class.getName(),
|
InputMethodAndLanguageSettings.class.getName(),
|
||||||
AvailableVirtualKeyboardFragment.class.getName(),
|
AvailableVirtualKeyboardFragment.class.getName(),
|
||||||
|
InputAndGestureSettings.class.getName(),
|
||||||
|
LanguageAndRegionSettings.class.getName(),
|
||||||
SpellCheckersSettings.class.getName(),
|
SpellCheckersSettings.class.getName(),
|
||||||
UserDictionaryList.class.getName(),
|
UserDictionaryList.class.getName(),
|
||||||
UserDictionarySettings.class.getName(),
|
UserDictionarySettings.class.getName(),
|
||||||
|
@@ -40,6 +40,8 @@ public abstract class InstrumentedFragment extends ObservablePreferenceFragment
|
|||||||
protected final int NETWORK_CATEGORY_FRAGMENT = PLACEHOLDER_METRIC + 3;
|
protected final int NETWORK_CATEGORY_FRAGMENT = PLACEHOLDER_METRIC + 3;
|
||||||
protected final int CONNECTED_DEVICE_CATEGORY_FRAGMENT = PLACEHOLDER_METRIC + 4;
|
protected final int CONNECTED_DEVICE_CATEGORY_FRAGMENT = PLACEHOLDER_METRIC + 4;
|
||||||
protected final int APP_AND_NOTIFICATION_CATEGORY_FRAGMENT = PLACEHOLDER_METRIC + 5;
|
protected final int APP_AND_NOTIFICATION_CATEGORY_FRAGMENT = PLACEHOLDER_METRIC + 5;
|
||||||
|
protected final int INPUT_AND_GESTURE_CATEGORY_FRAGMENT = PLACEHOLDER_METRIC + 6;
|
||||||
|
protected final int LANGUAGE_AND_REGION_CATEGORY_FRAGMENT = PLACEHOLDER_METRIC + 7;
|
||||||
|
|
||||||
public InstrumentedFragment() {
|
public InstrumentedFragment() {
|
||||||
// Mixin that logs visibility change for activity.
|
// Mixin that logs visibility change for activity.
|
||||||
|
@@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2016 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.settings.inputmethod;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.core.PreferenceController;
|
||||||
|
import com.android.settings.dashboard.DashboardFragment;
|
||||||
|
import com.android.settingslib.drawer.CategoryKey;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class InputAndGestureSettings extends DashboardFragment {
|
||||||
|
|
||||||
|
private static final String TAG = "InputAndGestureSettings";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMetricsCategory() {
|
||||||
|
return INPUT_AND_GESTURE_CATEGORY_FRAGMENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getCategoryKey() {
|
||||||
|
return CategoryKey.CATEGORY_SYSTEM_INPUT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getLogTag() {
|
||||||
|
return TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getPreferenceScreenResId() {
|
||||||
|
return R.xml.input_and_gesture;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<PreferenceController> getPreferenceControllers(Context context) {
|
||||||
|
final GameControllerPreferenceController gameControllerPreferenceController
|
||||||
|
= new GameControllerPreferenceController(context);
|
||||||
|
getLifecycle().addObserver(gameControllerPreferenceController);
|
||||||
|
|
||||||
|
final List<PreferenceController> controllers = new ArrayList<>();
|
||||||
|
controllers.add(gameControllerPreferenceController);
|
||||||
|
|
||||||
|
return controllers;
|
||||||
|
}
|
||||||
|
}
|
@@ -51,6 +51,11 @@ import com.android.settingslib.drawer.CategoryKey;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated New features should use {@code InputAndGestureSettings} and
|
||||||
|
* {@code LanguageAndRegionSettings} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public class InputMethodAndLanguageSettings extends DashboardFragment
|
public class InputMethodAndLanguageSettings extends DashboardFragment
|
||||||
implements KeyboardLayoutDialogFragment.OnSetupKeyboardLayoutsListener, Indexable {
|
implements KeyboardLayoutDialogFragment.OnSetupKeyboardLayoutsListener, Indexable {
|
||||||
|
|
||||||
|
@@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2016 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.settings.language;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.speech.tts.TtsEngines;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.core.PreferenceController;
|
||||||
|
import com.android.settings.dashboard.DashboardFragment;
|
||||||
|
import com.android.settings.inputmethod.SpellCheckerPreferenceController;
|
||||||
|
import com.android.settingslib.drawer.CategoryKey;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class LanguageAndRegionSettings extends DashboardFragment {
|
||||||
|
|
||||||
|
private static final String TAG = "LangAndRegionSettings";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMetricsCategory() {
|
||||||
|
return LANGUAGE_AND_REGION_CATEGORY_FRAGMENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getCategoryKey() {
|
||||||
|
return CategoryKey.CATEGORY_SYSTEM_LANGUAGE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getLogTag() {
|
||||||
|
return TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getPreferenceScreenResId() {
|
||||||
|
return R.xml.language_and_region;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<PreferenceController> getPreferenceControllers(Context context) {
|
||||||
|
final List<PreferenceController> controllers = new ArrayList<>();
|
||||||
|
controllers.add(new PhoneLanguagePreferenceController(context));
|
||||||
|
controllers.add(new SpellCheckerPreferenceController(context));
|
||||||
|
controllers.add(new UserDictionaryPreferenceController(context));
|
||||||
|
controllers.add(new TtsPreferenceController(context, new TtsEngines(context)));
|
||||||
|
return controllers;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,102 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2016 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.settings.inputmethod;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.hardware.input.InputManager;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.SettingsRobolectricTestRunner;
|
||||||
|
import com.android.settings.TestConfig;
|
||||||
|
import com.android.settings.core.PreferenceController;
|
||||||
|
import com.android.settings.core.lifecycle.Lifecycle;
|
||||||
|
import com.android.settings.core.lifecycle.LifecycleObserver;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.Answers;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.MockitoAnnotations;
|
||||||
|
import org.robolectric.annotation.Config;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
import static org.mockito.Matchers.any;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.times;
|
||||||
|
import static org.mockito.Mockito.verify;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
@RunWith(SettingsRobolectricTestRunner.class)
|
||||||
|
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||||
|
public class InputAndGestureSettingsTest {
|
||||||
|
|
||||||
|
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||||
|
private Context mContext;
|
||||||
|
private TestFragment mFragment;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() {
|
||||||
|
MockitoAnnotations.initMocks(this);
|
||||||
|
when(mContext.getSystemService(Context.INPUT_SERVICE)).thenReturn(mock(InputManager.class));
|
||||||
|
mFragment = new TestFragment(mContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetPreferenceScreenResId() {
|
||||||
|
assertThat(mFragment.getPreferenceScreenResId()).isEqualTo(R.xml.input_and_gesture);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetPreferenceControllers_shouldRegisterLifecycleObservers() {
|
||||||
|
final List<PreferenceController> controllers = mFragment.getPreferenceControllers(mContext);
|
||||||
|
int lifecycleObserverCount = 0;
|
||||||
|
for (PreferenceController controller : controllers) {
|
||||||
|
if (controller instanceof LifecycleObserver) {
|
||||||
|
lifecycleObserverCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
verify(mFragment.getLifecycle(), times(lifecycleObserverCount))
|
||||||
|
.addObserver(any(LifecycleObserver.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class TestFragment extends InputAndGestureSettings {
|
||||||
|
|
||||||
|
private Lifecycle mLifecycle;
|
||||||
|
private Context mContext;
|
||||||
|
|
||||||
|
public TestFragment(Context context) {
|
||||||
|
mContext = context;
|
||||||
|
mLifecycle = mock(Lifecycle.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Context getContext() {
|
||||||
|
return mContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Lifecycle getLifecycle() {
|
||||||
|
if (mLifecycle == null) {
|
||||||
|
return super.getLifecycle();
|
||||||
|
}
|
||||||
|
return mLifecycle;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,83 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2016 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.settings.language;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.view.textservice.TextServicesManager;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.SettingsRobolectricTestRunner;
|
||||||
|
import com.android.settings.TestConfig;
|
||||||
|
import com.android.settings.core.PreferenceController;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.Answers;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.MockitoAnnotations;
|
||||||
|
import org.robolectric.annotation.Config;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
@RunWith(SettingsRobolectricTestRunner.class)
|
||||||
|
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||||
|
public class LanguageAndRegionSettingsTest {
|
||||||
|
|
||||||
|
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||||
|
private Context mContext;
|
||||||
|
private TestFragment mFragment;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() {
|
||||||
|
MockitoAnnotations.initMocks(this);
|
||||||
|
when(mContext.getSystemService(Context.TEXT_SERVICES_MANAGER_SERVICE))
|
||||||
|
.thenReturn(mock(TextServicesManager.class));
|
||||||
|
mFragment = new TestFragment(mContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetPreferenceScreenResId() {
|
||||||
|
assertThat(mFragment.getPreferenceScreenResId()).isEqualTo(R.xml.language_and_region);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetPreferenceControllers_shouldAllBeCreated() {
|
||||||
|
final List<PreferenceController> controllers = mFragment.getPreferenceControllers(mContext);
|
||||||
|
|
||||||
|
assertThat(controllers.isEmpty()).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class TestFragment extends LanguageAndRegionSettings {
|
||||||
|
|
||||||
|
private Context mContext;
|
||||||
|
|
||||||
|
public TestFragment(Context context) {
|
||||||
|
mContext = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Context getContext() {
|
||||||
|
return mContext;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Reference in New Issue
Block a user