Merge "Don't override expand count when page is opened from search"
This commit is contained in:
committed by
Android (Google) Code Review
commit
3b3da56e6f
@@ -83,8 +83,14 @@ public class DeviceInfoSettings extends DashboardFragment implements Indexable {
|
|||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle icicle) {
|
public void onCreate(Bundle icicle) {
|
||||||
super.onCreate(icicle);
|
super.onCreate(icicle);
|
||||||
|
final Bundle arguments = getArguments();
|
||||||
if (FeatureFlagUtils.isEnabled(getContext(), DEVICE_INFO_V2) || true) {
|
if (FeatureFlagUtils.isEnabled(getContext(), DEVICE_INFO_V2) || true) {
|
||||||
|
// Do not override initial expand children count if we come from
|
||||||
|
// search (EXTRA_FRAGMENT_ARG_KEY is set) - we need to display every if entry point
|
||||||
|
// is search.
|
||||||
|
if (arguments == null
|
||||||
|
|| !arguments.containsKey(SettingsActivity.EXTRA_FRAGMENT_ARG_KEY)) {
|
||||||
|
|
||||||
// Increase the number of children when the device contains more than 1 sim.
|
// Increase the number of children when the device contains more than 1 sim.
|
||||||
final TelephonyManager telephonyManager = (TelephonyManager) getSystemService(
|
final TelephonyManager telephonyManager = (TelephonyManager) getSystemService(
|
||||||
Context.TELEPHONY_SERVICE);
|
Context.TELEPHONY_SERVICE);
|
||||||
@@ -94,6 +100,7 @@ public class DeviceInfoSettings extends DashboardFragment implements Indexable {
|
|||||||
getPreferenceScreen().setInitialExpandedChildrenCount(numberOfChildren);
|
getPreferenceScreen().setInitialExpandedChildrenCount(numberOfChildren);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
|
@@ -18,6 +18,7 @@ package com.android.settings;
|
|||||||
|
|
||||||
import static com.android.settings.DeviceInfoSettings.NON_SIM_PREFERENCES_COUNT;
|
import static com.android.settings.DeviceInfoSettings.NON_SIM_PREFERENCES_COUNT;
|
||||||
import static com.android.settings.DeviceInfoSettings.SIM_PREFERENCES_COUNT;
|
import static com.android.settings.DeviceInfoSettings.SIM_PREFERENCES_COUNT;
|
||||||
|
import static com.android.settings.SettingsActivity.EXTRA_FRAGMENT_ARG_KEY;
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.Mockito.doNothing;
|
import static org.mockito.Mockito.doNothing;
|
||||||
@@ -28,6 +29,7 @@ import static org.mockito.Mockito.verify;
|
|||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
import android.os.Bundle;
|
||||||
import android.os.SystemProperties;
|
import android.os.SystemProperties;
|
||||||
import android.support.v7.preference.PreferenceScreen;
|
import android.support.v7.preference.PreferenceScreen;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
@@ -118,6 +120,19 @@ public class DeviceInfoSettingsTest {
|
|||||||
assertThat(keys).containsAllIn(niks);
|
assertThat(keys).containsAllIn(niks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Config(shadows = {SettingsShadowResources.SettingsShadowTheme.class,
|
||||||
|
SettingsShadowSystemProperties.class})
|
||||||
|
public void onCreate_fromSearch_shouldNotOverrideInitialExpandedCount() {
|
||||||
|
final Bundle args = new Bundle();
|
||||||
|
args.putString(EXTRA_FRAGMENT_ARG_KEY, "search_key");
|
||||||
|
mSettings.setArguments(args);
|
||||||
|
|
||||||
|
mSettings.onCreate(null /* icicle */);
|
||||||
|
|
||||||
|
verify(mScreen).setInitialExpandedChildrenCount(Integer.MAX_VALUE);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Config(shadows = {SettingsShadowResources.SettingsShadowTheme.class,
|
@Config(shadows = {SettingsShadowResources.SettingsShadowTheme.class,
|
||||||
SettingsShadowSystemProperties.class})
|
SettingsShadowSystemProperties.class})
|
||||||
|
Reference in New Issue
Block a user