Merge "Allow StubVolume to be browseable in Settings"
diff --git a/res/drawable-hdpi/ic_menu_3d_globe.png b/res/drawable-hdpi/ic_menu_3d_globe.png
deleted file mode 100644
index 1b55f09..0000000
--- a/res/drawable-hdpi/ic_menu_3d_globe.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_menu_3d_globe.png b/res/drawable-mdpi/ic_menu_3d_globe.png
deleted file mode 100644
index 6755d5e..0000000
--- a/res/drawable-mdpi/ic_menu_3d_globe.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_menu_3d_globe.png b/res/drawable-xhdpi/ic_menu_3d_globe.png
deleted file mode 100644
index 1fda0a2..0000000
--- a/res/drawable-xhdpi/ic_menu_3d_globe.png
+++ /dev/null
Binary files differ
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 34b23e7..533c130 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -774,16 +774,8 @@
<string name="date_time_search_region">Search region</string>
<!-- Setting option title to select region in time zone setting screen [CHAR LIMIT=30] -->
<string name="date_time_select_region">Region</string>
- <!-- Setting option title to select time zone in time zone setting screen [CHAR LIMIT=30]-->
- <string name="date_time_select_zone">Time Zone</string>
- <!-- Setting option title to select time zone in a region -->
- <string name="date_time_set_timezone_in_region">Time zones in <xliff:g id="region" example="United States">%1$s</xliff:g></string>
<!-- Setting option title in time zone setting screen [CHAR LIMIT=30] -->
<string name="date_time_select_fixed_offset_time_zones">Select UTC offset</string>
- <!-- Menu item on Select time zone screen -->
- <string name="zone_list_menu_sort_alphabetically">Sort alphabetically</string>
- <!-- Menu item on Select time zone screen -->
- <string name="zone_list_menu_sort_by_timezone">Sort by time zone</string>
<!-- Label describing when a given time zone changes to DST or standard time -->
<string name="zone_change_to_from_dst"><xliff:g id="time_type" example="Pacific Summer Time">%1$s</xliff:g> starts on <xliff:g id="transition_date" example="Mar 11 2018">%2$s</xliff:g>.</string>
<!-- Label describing a exemplar location and time zone offset[CHAR LIMIT=NONE] -->
diff --git a/res/xml/date_time_prefs.xml b/res/xml/date_time_prefs.xml
index 511b39f..edda1ba 100644
--- a/res/xml/date_time_prefs.xml
+++ b/res/xml/date_time_prefs.xml
@@ -56,7 +56,7 @@
settings:userRestriction="no_config_date_time" />
<com.android.settingslib.RestrictedPreference
- android:fragment="com.android.settings.datetime.ZonePicker"
+ android:fragment="com.android.settings.datetime.timezone.TimeZoneSettings"
android:key="timezone"
android:title="@string/date_time_set_timezone"
android:summary="@string/summary_placeholder"
diff --git a/src/com/android/settings/datetime/TimeZonePreferenceController.java b/src/com/android/settings/datetime/TimeZonePreferenceController.java
index 743cb33..92169e6 100644
--- a/src/com/android/settings/datetime/TimeZonePreferenceController.java
+++ b/src/com/android/settings/datetime/TimeZonePreferenceController.java
@@ -21,9 +21,7 @@
import androidx.preference.Preference;
import android.util.FeatureFlagUtils;
-import com.android.settings.core.FeatureFlags;
import com.android.settings.core.PreferenceControllerMixin;
-import com.android.settings.datetime.timezone.TimeZoneSettings;
import com.android.settingslib.RestrictedPreference;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.datetime.ZoneGetter;
@@ -36,13 +34,11 @@
private static final String KEY_TIMEZONE = "timezone";
private final AutoTimeZonePreferenceController mAutoTimeZonePreferenceController;
- private final boolean mZonePickerV2;
public TimeZonePreferenceController(Context context,
AutoTimeZonePreferenceController autoTimeZonePreferenceController) {
super(context);
mAutoTimeZonePreferenceController = autoTimeZonePreferenceController;
- mZonePickerV2 = FeatureFlagUtils.isEnabled(mContext, FeatureFlags.ZONE_PICKER_V2);
}
@Override
@@ -50,9 +46,6 @@
if (!(preference instanceof RestrictedPreference)) {
return;
}
- if (mZonePickerV2) {
- preference.setFragment(TimeZoneSettings.class.getName());
- }
preference.setSummary(getTimeZoneOffsetAndName());
if( !((RestrictedPreference) preference).isDisabledByAdmin()) {
preference.setEnabled(!mAutoTimeZonePreferenceController.isEnabled());
diff --git a/src/com/android/settings/datetime/ZonePicker.java b/src/com/android/settings/datetime/ZonePicker.java
deleted file mode 100644
index 559a8b3..0000000
--- a/src/com/android/settings/datetime/ZonePicker.java
+++ /dev/null
@@ -1,306 +0,0 @@
-/*
- * Copyright (C) 2017 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.datetime;
-
-import android.annotation.NonNull;
-import android.app.Activity;
-import android.app.AlarmManager;
-import android.app.ListFragment;
-import android.content.Context;
-import android.os.Bundle;
-import androidx.annotation.VisibleForTesting;
-import android.view.LayoutInflater;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ListView;
-import android.widget.SimpleAdapter;
-import android.widget.TextView;
-
-import com.android.internal.logging.nano.MetricsProto;
-import com.android.settings.R;
-import com.android.settings.overlay.FeatureFactory;
-import com.android.settingslib.core.instrumentation.Instrumentable;
-import com.android.settingslib.core.instrumentation.VisibilityLoggerMixin;
-import com.android.settingslib.datetime.ZoneGetter;
-
-import java.text.Collator;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.TimeZone;
-
-/**
- * The class displaying a list of time zones that match a filter string
- * such as "Africa", "Europe", etc. Choosing an item from the list will set
- * the time zone. Pressing Back without choosing from the list will not
- * result in a change in the time zone setting.
- */
-public class ZonePicker extends ListFragment implements Instrumentable {
-
- private static final int MENU_TIMEZONE = Menu.FIRST+1;
- private static final int MENU_ALPHABETICAL = Menu.FIRST;
- private VisibilityLoggerMixin mVisibilityLoggerMixin;
-
- private boolean mSortedByTimezone;
-
- private SimpleAdapter mTimezoneSortedAdapter;
- private SimpleAdapter mAlphabeticalAdapter;
-
- /**
- * Constructs an adapter with TimeZone list. Sorted by TimeZone in default.
- *
- * @param sortedByName use Name for sorting the list.
- */
- public static SimpleAdapter constructTimezoneAdapter(Context context,
- boolean sortedByName) {
- return constructTimezoneAdapter(context, sortedByName,
- R.layout.date_time_custom_list_item_2);
- }
-
- /**
- * Constructs an adapter with TimeZone list. Sorted by TimeZone in default.
- *
- * @param sortedByName use Name for sorting the list.
- */
- public static SimpleAdapter constructTimezoneAdapter(Context context,
- boolean sortedByName, int layoutId) {
- final String[] from = new String[] {
- ZoneGetter.KEY_DISPLAY_LABEL,
- ZoneGetter.KEY_OFFSET_LABEL
- };
- final int[] to = new int[] {android.R.id.text1, android.R.id.text2};
-
- final String sortKey = (sortedByName
- ? ZoneGetter.KEY_DISPLAY_LABEL
- : ZoneGetter.KEY_OFFSET);
- final MyComparator comparator = new MyComparator(sortKey);
- final List<Map<String, Object>> sortedList = ZoneGetter.getZonesList(context);
- Collections.sort(sortedList, comparator);
- final SimpleAdapter adapter = new SimpleAdapter(context,
- sortedList,
- layoutId,
- from,
- to);
- adapter.setViewBinder(new TimeZoneViewBinder());
- return adapter;
- }
-
- private static class TimeZoneViewBinder implements SimpleAdapter.ViewBinder {
-
- /**
- * Set the text to the given {@link CharSequence} as is, instead of calling toString, so
- * that additional information stored in the CharSequence is, like spans added to a
- * {@link android.text.SpannableString} are preserved.
- */
- @Override
- public boolean setViewValue(View view, Object data, String textRepresentation) {
- TextView textView = (TextView) view;
- textView.setText((CharSequence) data);
- return true;
- }
- }
-
- /**
- * Searches {@link TimeZone} from the given {@link SimpleAdapter} object, and returns
- * the index for the TimeZone.
- *
- * @param adapter SimpleAdapter constructed by
- * {@link #constructTimezoneAdapter(Context, boolean)}.
- * @param tz TimeZone to be searched.
- * @return Index for the given TimeZone. -1 when there's no corresponding list item.
- * returned.
- */
- public static int getTimeZoneIndex(SimpleAdapter adapter, TimeZone tz) {
- final String defaultId = tz.getID();
- final int listSize = adapter.getCount();
- for (int i = 0; i < listSize; i++) {
- // Using HashMap<String, Object> induces unnecessary warning.
- final HashMap<?,?> map = (HashMap<?,?>)adapter.getItem(i);
- final String id = (String)map.get(ZoneGetter.KEY_ID);
- if (defaultId.equals(id)) {
- // If current timezone is in this list, move focus to it
- return i;
- }
- }
- return -1;
- }
-
- @Override
- public int getMetricsCategory() {
- return MetricsProto.MetricsEvent.ZONE_PICKER;
- }
-
- @Override
- public void onActivityCreated(Bundle savedInstanceState) {
- super.onActivityCreated(savedInstanceState);
-
- final Activity activity = getActivity();
- mTimezoneSortedAdapter = constructTimezoneAdapter(activity, false);
- mAlphabeticalAdapter = constructTimezoneAdapter(activity, true);
-
- // Sets the adapter
- setSorting(true);
- setHasOptionsMenu(true);
- activity.setTitle(R.string.date_time_set_timezone);
- }
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- mVisibilityLoggerMixin = new VisibilityLoggerMixin(getMetricsCategory(),
- FeatureFactory.getFactory(getContext()).getMetricsFeatureProvider());
- }
-
- @Override
- public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- final View view = super.onCreateView(inflater, container, savedInstanceState);
- final ListView list = view.findViewById(android.R.id.list);
- prepareCustomPreferencesList(list);
- return view;
- }
-
- @Override
- public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
- menu.add(0, MENU_ALPHABETICAL, 0, R.string.zone_list_menu_sort_alphabetically)
- .setIcon(android.R.drawable.ic_menu_sort_alphabetically);
- menu.add(0, MENU_TIMEZONE, 0, R.string.zone_list_menu_sort_by_timezone)
- .setIcon(R.drawable.ic_menu_3d_globe);
- super.onCreateOptionsMenu(menu, inflater);
- }
-
- @Override
- public void onPrepareOptionsMenu(Menu menu) {
- if (mSortedByTimezone) {
- menu.findItem(MENU_TIMEZONE).setVisible(false);
- menu.findItem(MENU_ALPHABETICAL).setVisible(true);
- } else {
- menu.findItem(MENU_TIMEZONE).setVisible(true);
- menu.findItem(MENU_ALPHABETICAL).setVisible(false);
- }
- }
-
- @Override
- public void onResume() {
- super.onResume();
- mVisibilityLoggerMixin.onResume();
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
-
- case MENU_TIMEZONE:
- setSorting(true);
- return true;
-
- case MENU_ALPHABETICAL:
- setSorting(false);
- return true;
-
- default:
- return false;
- }
- }
-
- static void prepareCustomPreferencesList(ListView list) {
- list.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY);
- list.setClipToPadding(false);
- list.setDivider(null);
- }
-
- private void setSorting(boolean sortByTimezone) {
- final SimpleAdapter adapter =
- sortByTimezone ? mTimezoneSortedAdapter : mAlphabeticalAdapter;
- setListAdapter(adapter);
- mSortedByTimezone = sortByTimezone;
- final int defaultIndex = getTimeZoneIndex(adapter, TimeZone.getDefault());
- if (defaultIndex >= 0) {
- setSelection(defaultIndex);
- }
- }
-
- @Override
- public void onListItemClick(ListView listView, View v, int position, long id) {
- // Ignore extra clicks
- if (!isResumed()) return;
- final Map<?, ?> map = (Map<?, ?>)listView.getItemAtPosition(position);
- final String tzId = (String) map.get(ZoneGetter.KEY_ID);
-
- // Update the system timezone value
- final Activity activity = getActivity();
- final AlarmManager alarm = (AlarmManager) activity.getSystemService(Context.ALARM_SERVICE);
- alarm.setTimeZone(tzId);
-
- getActivity().onBackPressed();
-
- }
-
- @Override
- public void onPause() {
- super.onPause();
- mVisibilityLoggerMixin.onPause();
- }
-
- @VisibleForTesting
- static class MyComparator implements Comparator<Map<?, ?>> {
- private final Collator mCollator;
- private String mSortingKey;
- private boolean mSortedByName;
-
- public MyComparator(String sortingKey) {
- mCollator = Collator.getInstance();
- mSortingKey = sortingKey;
- mSortedByName = ZoneGetter.KEY_DISPLAY_LABEL.equals(sortingKey);
- }
-
- public void setSortingKey(String sortingKey) {
- mSortingKey = sortingKey;
- mSortedByName = ZoneGetter.KEY_DISPLAY_LABEL.equals(sortingKey);
- }
-
- public int compare(Map<?, ?> map1, Map<?, ?> map2) {
- Object value1 = map1.get(mSortingKey);
- Object value2 = map2.get(mSortingKey);
-
- /*
- * This should never happen, but just in-case, put non-comparable
- * items at the end.
- */
- if (!isComparable(value1)) {
- return isComparable(value2) ? 1 : 0;
- } else if (!isComparable(value2)) {
- return -1;
- }
-
- if (mSortedByName) {
- return mCollator.compare(value1, value2);
- } else {
- return ((Comparable) value1).compareTo(value2);
- }
- }
-
- private boolean isComparable(Object value) {
- return (value != null) && (value instanceof Comparable);
- }
- }
-}
diff --git a/src/com/android/settings/network/ApnPreference.java b/src/com/android/settings/network/ApnPreference.java
index ee53ca9..27d275f 100755
--- a/src/com/android/settings/network/ApnPreference.java
+++ b/src/com/android/settings/network/ApnPreference.java
@@ -27,15 +27,12 @@
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
-import android.view.View.OnClickListener;
import android.widget.CompoundButton;
import android.widget.RadioButton;
-import android.widget.RelativeLayout;
import com.android.settings.R;
-public class ApnPreference extends Preference implements
- CompoundButton.OnCheckedChangeListener, OnClickListener {
+public class ApnPreference extends Preference implements CompoundButton.OnCheckedChangeListener {
final static String TAG = "ApnPreference";
private int mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
@@ -81,11 +78,6 @@
rb.setVisibility(View.GONE);
}
}
-
- View textLayout = view.findViewById(R.id.text_layout);
- if ((textLayout != null) && textLayout instanceof RelativeLayout) {
- textLayout.setOnClickListener(this);
- }
}
public boolean isChecked() {
@@ -115,16 +107,16 @@
}
}
- public void onClick(android.view.View v) {
- if ((v != null) && (R.id.text_layout == v.getId())) {
- Context context = getContext();
- if (context != null) {
- int pos = Integer.parseInt(getKey());
- Uri url = ContentUris.withAppendedId(Telephony.Carriers.CONTENT_URI, pos);
- Intent editIntent = new Intent(Intent.ACTION_EDIT, url);
- editIntent.putExtra(ApnSettings.SUB_ID, mSubId);
- context.startActivity(editIntent);
- }
+ @Override
+ protected void onClick() {
+ super.onClick();
+ Context context = getContext();
+ if (context != null) {
+ int pos = Integer.parseInt(getKey());
+ Uri url = ContentUris.withAppendedId(Telephony.Carriers.CONTENT_URI, pos);
+ Intent editIntent = new Intent(Intent.ACTION_EDIT, url);
+ editIntent.putExtra(ApnSettings.SUB_ID, mSubId);
+ context.startActivity(editIntent);
}
}
diff --git a/src/com/android/settings/network/ApnSettings.java b/src/com/android/settings/network/ApnSettings.java
index 013ae8c..5bc52cc 100755
--- a/src/com/android/settings/network/ApnSettings.java
+++ b/src/com/android/settings/network/ApnSettings.java
@@ -21,7 +21,6 @@
import android.app.ProgressDialog;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
-import android.content.ContentUris;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
@@ -64,8 +63,7 @@
import java.util.ArrayList;
-public class ApnSettings extends RestrictedSettingsFragment implements
- Preference.OnPreferenceChangeListener {
+public class ApnSettings extends RestrictedSettingsFragment {
static final String TAG = "ApnSettings";
public static final String EXTRA_POSITION = "position";
@@ -312,7 +310,6 @@
pref.setTitle(name);
pref.setSummary(apn);
pref.setPersistent(false);
- pref.setOnPreferenceChangeListener(this);
pref.setSubId(subId);
boolean selectable = ((type == null) || !type.equals("mms"));
@@ -404,14 +401,6 @@
startActivity(intent);
}
- @Override
- public boolean onPreferenceTreeClick(Preference preference) {
- int pos = Integer.parseInt(preference.getKey());
- Uri url = ContentUris.withAppendedId(Telephony.Carriers.CONTENT_URI, pos);
- startActivity(new Intent(Intent.ACTION_EDIT, url));
- return true;
- }
-
public boolean onPreferenceChange(Preference preference, Object newValue) {
Log.d(TAG, "onPreferenceChange(): Preference - " + preference
+ ", newValue - " + newValue + ", newValue type - "
diff --git a/tests/robotests/src/com/android/settings/ZonePickerTest.java b/tests/robotests/src/com/android/settings/ZonePickerTest.java
deleted file mode 100644
index 7816a58..0000000
--- a/tests/robotests/src/com/android/settings/ZonePickerTest.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * 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;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import android.text.Spanned;
-import android.text.style.TtsSpan;
-import android.view.ViewGroup;
-import android.widget.FrameLayout;
-import android.widget.SimpleAdapter;
-import android.widget.TextView;
-
-import com.android.settings.datetime.ZonePicker;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settings.testutils.shadow.ShadowLibcoreTimeZoneNames;
-import com.android.settings.testutils.shadow.ShadowTimeZoneNames;
-import com.android.settings.testutils.shadow.ShadowZoneGetterData;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.robolectric.RuntimeEnvironment;
-import org.robolectric.annotation.Config;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-@Config(shadows = {
- ShadowLibcoreTimeZoneNames.class,
- ShadowLibcoreTimeZoneNames.ShadowZoneStringsCache.class,
- ShadowTimeZoneNames.class,
- ShadowZoneGetterData.class,
-}
-)
-public class ZonePickerTest {
-
- @Test
- public void testConstructTimeZoneAdapter() {
- final SimpleAdapter adapter =
- ZonePicker.constructTimezoneAdapter(RuntimeEnvironment.application, true);
- assertThat(adapter).isNotNull();
-
- ViewGroup parent = new FrameLayout(RuntimeEnvironment.application);
- ViewGroup convertView = new FrameLayout(RuntimeEnvironment.application);
- TextView text1 = new TextView(RuntimeEnvironment.application);
- text1.setId(android.R.id.text1);
- convertView.addView(text1);
- TextView text2 = new TextView(RuntimeEnvironment.application);
- text2.setId(android.R.id.text2);
- convertView.addView(text2);
-
- adapter.getView(0, convertView, parent);
- final CharSequence text = text2.getText();
- assertThat(text).isInstanceOf(Spanned.class);
- final TtsSpan[] spans = ((Spanned) text).getSpans(0, text.length(), TtsSpan.class);
- // GMT offset label should have TTS spans
- assertThat(spans.length).isGreaterThan(0);
- }
-}
diff --git a/tests/robotests/src/com/android/settings/datetime/ZonePickerComparatorTest.java b/tests/robotests/src/com/android/settings/datetime/ZonePickerComparatorTest.java
deleted file mode 100644
index 5e07308..0000000
--- a/tests/robotests/src/com/android/settings/datetime/ZonePickerComparatorTest.java
+++ /dev/null
@@ -1,109 +0,0 @@
-package com.android.settings.datetime;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settingslib.datetime.ZoneGetter;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.TimeZone;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-public class ZonePickerComparatorTest {
-
- // Strings in Chinese are sorted by alphabet order of their Pinyin.
- // "伦敦" -> "lundun"; "纽约" -> "niuyue"; "悉尼" -> "xini"
- // "开罗" -> "kailuo"; "雅典" -> "yadian"; "上海" -> "shanghai"
- private static final String[] TEST_CHINESE_NAME =
- {"伦敦", "纽约", "悉尼", "开罗", "雅典", "上海"};
- private static final String[] ORDERED_CHINESE_NAME =
- {"开罗", "伦敦", "纽约", "上海", "悉尼", "雅典"};
-
- private static final String[] TEST_ENGLISH_NAME =
- {"London", "New York", "Sydney", "Cairo", "Athens", "Shanghai"};
- private static final String[] ORDERED_ENGLISH_NAME =
- {"Athens", "Cairo", "London", "New York", "Shanghai", "Sydney"};
-
- private static final Locale INIT_LOCALE = Locale.getDefault();
-
- private Map<String, List<String>> mTestDataMap;
- private List<Map<String, Object>> mTestList;
-
- @Before
- public void setUp() {
- mTestDataMap = new HashMap<>();
- mTestDataMap.put("zh_CN", Arrays.asList(TEST_CHINESE_NAME));
- mTestDataMap.put("en_US", Arrays.asList(TEST_ENGLISH_NAME));
- }
-
- @After
- public void tearDown() {
- Locale.setDefault(INIT_LOCALE);
- }
-
- @Test
- public void testComparator_sortChineseString() {
- String sortKey = ZoneGetter.KEY_DISPLAY_LABEL;
- mTestList = getMockZonesList("zh_CN");
- Locale.setDefault(new Locale("zh"));
- mTestList.sort(new ZonePicker.MyComparator(sortKey));
- for (int i = 0; i < mTestList.size(); i++) {
- assertThat(mTestList.get(i).get(sortKey).toString()).isEqualTo(ORDERED_CHINESE_NAME[i]);
- }
- }
-
- @Test
- public void testComparator_sortEnglishString() {
- String sortKey = ZoneGetter.KEY_DISPLAY_LABEL;
- mTestList = getMockZonesList("en_US");
- Locale.setDefault(new Locale("en"));
- mTestList.sort(new ZonePicker.MyComparator(sortKey));
- for (int i = 0; i < mTestList.size(); i++) {
- assertThat(mTestList.get(i).get(sortKey).toString()).isEqualTo(ORDERED_ENGLISH_NAME[i]);
- }
- }
-
- @Test
- public void testComparator_sortInteger() {
- String sortKey = ZoneGetter.KEY_OFFSET;
- // TestList of any locale can be selected to test integer sorting.
- mTestList = getMockZonesList("en_US");
- mTestList.sort(new ZonePicker.MyComparator(sortKey));
- for (int i = 0; i < mTestList.size(); i++) {
- assertThat(mTestList.get(i).get(sortKey)).isEqualTo(i);
- }
- }
-
- private List<Map<String, Object>> getMockZonesList(String locale) {
- List<Map<String, Object>> zones = new ArrayList<>();
- List<String> testData = mTestDataMap.get(locale);
- TimeZone tz = TimeZone.getDefault();
- int testSize = testData.size();
- for (int i = 0; i < testSize; i++) {
- zones.add(createMockDisplayEntry(tz, "GMT+08:00", testData.get(i), testSize - i - 1));
- }
- return zones;
- }
-
- private Map<String, Object> createMockDisplayEntry(
- TimeZone tz, CharSequence gmtOffsetText, CharSequence displayName, int offsetMillis) {
- Map<String, Object> map = new HashMap<>();
- map.put(ZoneGetter.KEY_ID, tz.getID());
- map.put(ZoneGetter.KEY_DISPLAYNAME, displayName.toString());
- map.put(ZoneGetter.KEY_DISPLAY_LABEL, displayName);
- map.put(ZoneGetter.KEY_GMT, gmtOffsetText.toString());
- map.put(ZoneGetter.KEY_OFFSET_LABEL, gmtOffsetText);
- map.put(ZoneGetter.KEY_OFFSET, offsetMillis);
- return map;
- }
-}
diff --git a/tests/robotests/src/com/android/settings/datetime/ZonePickerTest.java b/tests/robotests/src/com/android/settings/datetime/ZonePickerTest.java
deleted file mode 100644
index e6a9ca7..0000000
--- a/tests/robotests/src/com/android/settings/datetime/ZonePickerTest.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2017 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.datetime;
-
-import static org.mockito.ArgumentMatchers.nullable;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.verify;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.ViewGroup;
-
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settings.testutils.shadow.ShadowZoneGetter;
-import com.android.settingslib.core.instrumentation.VisibilityLoggerMixin;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.robolectric.Robolectric;
-import org.robolectric.annotation.Config;
-import org.robolectric.util.ReflectionHelpers;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-public class ZonePickerTest {
-
- private Activity mActivity;
- private ZonePicker mZonePicker;
-
- @Before
- public void setUp() {
- mActivity = Robolectric.setupActivity(Activity.class);
- mZonePicker = spy(ZonePicker.class);
- ReflectionHelpers.setField(mZonePicker, "mVisibilityLoggerMixin",
- mock(VisibilityLoggerMixin.class));
- }
-
- @Test
- @Config(shadows = ShadowZoneGetter.class)
- public void testLaunch() {
- // Shouldn't crash
- mActivity.getFragmentManager().beginTransaction().add(mZonePicker, "test_tag").commit();
-
- // Should render
- verify(mZonePicker).onCreateView(
- nullable(LayoutInflater.class),
- nullable(ViewGroup.class),
- nullable(Bundle.class));
- }
-}