diff --git a/res/layout/date_time_custom_list_item_2.xml b/res/layout/date_time_custom_list_item_2.xml
index ed32fb73f20..49027588937 100644
--- a/res/layout/date_time_custom_list_item_2.xml
+++ b/res/layout/date_time_custom_list_item_2.xml
@@ -15,29 +15,28 @@
-->
-
+ android:minHeight="?android:attr/listPreferredItemHeight"
+ android:orientation="vertical"
+ android:paddingStart="@dimen/preference_no_icon_padding_start"
+ android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">
-
+
-
+
-
+
diff --git a/res/xml/date_time_prefs.xml b/res/xml/date_time_prefs.xml
index 34d48f12670..78591198fe3 100644
--- a/res/xml/date_time_prefs.xml
+++ b/res/xml/date_time_prefs.xml
@@ -44,7 +44,7 @@
/>
)item).get(ZoneGetter.KEY_ID));
- }
-
@Override
public void onAttach(Context context) {
super.onAttach(context);
@@ -185,8 +170,8 @@ public class ZonePicker extends ListFragment implements Instrumentable {
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
final View view = super.onCreateView(inflater, container, savedInstanceState);
- final ListView list = (ListView) view.findViewById(android.R.id.list);
- Utils.forcePrepareCustomPreferencesList(container, view, list, false);
+ final ListView list = view.findViewById(android.R.id.list);
+ prepareCustomPreferencesList(list);
return view;
}
@@ -233,8 +218,10 @@ public class ZonePicker extends ListFragment implements Instrumentable {
}
}
- public void setZoneSelectionListener(ZoneSelectionListener listener) {
- mListener = listener;
+ static void prepareCustomPreferencesList(ListView list) {
+ list.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY);
+ list.setClipToPadding(false);
+ list.setDivider(null);
}
private void setSorting(boolean sortByTimezone) {
@@ -259,12 +246,9 @@ public class ZonePicker extends ListFragment implements Instrumentable {
final Activity activity = getActivity();
final AlarmManager alarm = (AlarmManager) activity.getSystemService(Context.ALARM_SERVICE);
alarm.setTimeZone(tzId);
- final TimeZone tz = TimeZone.getTimeZone(tzId);
- if (mListener != null) {
- mListener.onZoneSelected(tz);
- } else {
- getActivity().onBackPressed();
- }
+
+ getActivity().onBackPressed();
+
}
@Override
diff --git a/tests/robotests/src/com/android/settings/ZonePickerTest.java b/tests/robotests/src/com/android/settings/ZonePickerTest.java
index 344eea3dff5..6ab0c2d2985 100644
--- a/tests/robotests/src/com/android/settings/ZonePickerTest.java
+++ b/tests/robotests/src/com/android/settings/ZonePickerTest.java
@@ -25,6 +25,7 @@ import android.widget.FrameLayout;
import android.widget.SimpleAdapter;
import android.widget.TextView;
+import com.android.settings.datetime.ZonePicker;
import com.android.settings.testutils.shadow.ShadowLibcoreTimeZoneNames;
import com.android.settings.testutils.shadow.ShadowTimeZoneNames;
diff --git a/tests/robotests/src/com/android/settings/datetime/ZonePickerTest.java b/tests/robotests/src/com/android/settings/datetime/ZonePickerTest.java
new file mode 100644
index 00000000000..4acac705b2a
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/datetime/ZonePickerTest.java
@@ -0,0 +1,71 @@
+/*
+ * 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.app.Activity;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.ViewGroup;
+
+import com.android.settings.SettingsRobolectricTestRunner;
+import com.android.settings.TestConfig;
+import com.android.settings.core.instrumentation.VisibilityLoggerMixin;
+import com.android.settings.testutils.shadow.ShadowZoneGetter;
+
+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;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+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(
+ any(LayoutInflater.class),
+ any(ViewGroup.class),
+ any(Bundle.class));
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowZoneGetter.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowZoneGetter.java
new file mode 100644
index 00000000000..655acf14798
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowZoneGetter.java
@@ -0,0 +1,53 @@
+/*
+ * 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.testutils.shadow;
+
+import android.content.Context;
+
+import com.android.settingslib.datetime.ZoneGetter;
+
+import org.robolectric.annotation.Implementation;
+import org.robolectric.annotation.Implements;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.TimeZone;
+
+@Implements(ZoneGetter.class)
+public class ShadowZoneGetter {
+
+ @Implementation
+ public static List