Add config to disable app tray preview in display size.

Also move some files

Change-Id: I4636fcd81425991acadede0b703e09513c82543c
Fixes: 113374067
Test: robotests
This commit is contained in:
Fan Zhang
2018-09-07 17:06:07 -07:00
parent 6312aa28e3
commit 9aca4cb48c
17 changed files with 194 additions and 99 deletions

View File

@@ -174,6 +174,9 @@
<!-- Whether wifi_mac_address should be shown or not. --> <!-- Whether wifi_mac_address should be shown or not. -->
<bool name="config_show_wifi_mac_address">true</bool> <bool name="config_show_wifi_mac_address">true</bool>
<!-- Whether to disable "Uninstall Updates" menu item for System apps or not.. --> <!-- Whether to disable "Uninstall Updates" menu item for System apps or not. -->
<bool name="config_disable_uninstall_update">false</bool> <bool name="config_disable_uninstall_update">false</bool>
<!-- Whether or not extra preview panels should be used for screen zoom setting. -->
<bool name="config_enable_extra_screen_zoom_preview">true</bool>
</resources> </resources>

View File

@@ -47,7 +47,7 @@
android:title="@string/display_category_title"> android:title="@string/display_category_title">
<Preference <Preference
android:fragment="com.android.settings.accessibility.ToggleFontSizePreferenceFragment" android:fragment="com.android.settings.display.ToggleFontSizePreferenceFragment"
android:key="font_size_preference_screen" android:key="font_size_preference_screen"
android:title="@string/title_font_size" android:title="@string/title_font_size"
settings:searchable="false"/> settings:searchable="false"/>

View File

@@ -33,7 +33,7 @@
<Preference <Preference
android:fragment= android:fragment=
"com.android.settings.accessibility.FontSizePreferenceFragmentForSetupWizard" "com.android.settings.display.FontSizePreferenceFragmentForSetupWizard"
android:key="font_size_preference" android:key="font_size_preference"
android:title="@string/title_font_size" android:title="@string/title_font_size"
android:summary="@string/short_summary_font_size" /> android:summary="@string/short_summary_font_size" />

View File

@@ -83,7 +83,7 @@
<Preference <Preference
android:key="font_size" android:key="font_size"
android:title="@string/title_font_size" android:title="@string/title_font_size"
android:fragment="com.android.settings.accessibility.ToggleFontSizePreferenceFragment" android:fragment="com.android.settings.display.ToggleFontSizePreferenceFragment"
settings:controller="com.android.settings.display.FontSizePreferenceController" /> settings:controller="com.android.settings.display.FontSizePreferenceController" />
<com.android.settings.display.ScreenZoomPreference <com.android.settings.display.ScreenZoomPreference

View File

@@ -55,6 +55,7 @@ import com.android.internal.view.RotationPolicy.RotationPolicyListener;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment; import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.Utils; import com.android.settings.Utils;
import com.android.settings.display.ToggleFontSizePreferenceFragment;
import com.android.settings.search.BaseSearchIndexProvider; import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin; import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
import com.android.settingslib.RestrictedLockUtilsInternal; import com.android.settingslib.RestrictedLockUtilsInternal;

View File

@@ -18,7 +18,6 @@ import android.content.res.Resources;
import android.provider.Settings; import android.provider.Settings;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.accessibility.ToggleFontSizePreferenceFragment;
import com.android.settings.core.BasePreferenceController; import com.android.settings.core.BasePreferenceController;
public class FontSizePreferenceController extends BasePreferenceController { public class FontSizePreferenceController extends BasePreferenceController {

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2016 The Android Open Source Project * Copyright (C) 2018 The Android Open Source Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package com.android.settings.accessibility; package com.android.settings.display;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent; import com.android.internal.logging.nano.MetricsProto.MetricsEvent;

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2016 The Android Open Source Project * Copyright (C) 2018 The Android Open Source Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.android.settings; package com.android.settings.display;
import android.animation.Animator; import android.animation.Animator;
import android.animation.Animator.AnimatorListener; import android.animation.Animator.AnimatorListener;
@@ -32,6 +32,8 @@ import android.widget.LinearLayout;
import androidx.viewpager.widget.PagerAdapter; import androidx.viewpager.widget.PagerAdapter;
import com.android.settings.support.actionbar.HelpResourceProvider;
/** /**
* A PagerAdapter used by PreviewSeekBarPreferenceFragment that for showing multiple preview screen * A PagerAdapter used by PreviewSeekBarPreferenceFragment that for showing multiple preview screen
* regarding a single setting and allowing the user to swipe across them. * regarding a single setting and allowing the user to swipe across them.
@@ -76,16 +78,12 @@ public class PreviewPagerAdapter extends PagerAdapter {
final Context configContext = context.createConfigurationContext(configurations[j]); final Context configContext = context.createConfigurationContext(configurations[j]);
configContext.getTheme().setTo(context.getTheme()); configContext.getTheme().setTo(context.getTheme());
final LayoutInflater configInflater = LayoutInflater.from(configContext);
final ViewStub sampleViewStub = new ViewStub(configContext); final ViewStub sampleViewStub = new ViewStub(configContext);
sampleViewStub.setLayoutResource(previewSampleResIds[i]); sampleViewStub.setLayoutResource(previewSampleResIds[i]);
final int fi = i, fj = j; final int fi = i, fj = j;
sampleViewStub.setOnInflateListener(new OnInflateListener() { sampleViewStub.setOnInflateListener((stub, inflated) -> {
@Override inflated.setVisibility(stub.getVisibility());
public void onInflate(ViewStub stub, View inflated) { mViewStubInflated[fi][fj] = true;
inflated.setVisibility(stub.getVisibility());
mViewStubInflated[fi][fj] = true;
}
}); });
mPreviewFrames[p].addView(sampleViewStub); mPreviewFrames[p].addView(sampleViewStub);
@@ -94,7 +92,7 @@ public class PreviewPagerAdapter extends PagerAdapter {
} }
@Override @Override
public void destroyItem (ViewGroup container, int position, Object object) { public void destroyItem(ViewGroup container, int position, Object object) {
container.removeView((View) object); container.removeView((View) object);
} }
@@ -164,29 +162,29 @@ public class PreviewPagerAdapter extends PagerAdapter {
if (visibility == View.VISIBLE) { if (visibility == View.VISIBLE) {
// Fade in animation. // Fade in animation.
view.animate() view.animate()
.alpha(alpha) .alpha(alpha)
.setInterpolator(FADE_IN_INTERPOLATOR) .setInterpolator(FADE_IN_INTERPOLATOR)
.setDuration(CROSS_FADE_DURATION_MS) .setDuration(CROSS_FADE_DURATION_MS)
.setListener(new PreviewFrameAnimatorListener()) .setListener(new PreviewFrameAnimatorListener())
.withStartAction(new Runnable() { .withStartAction(new Runnable() {
@Override @Override
public void run() { public void run() {
view.setVisibility(visibility); view.setVisibility(visibility);
} }
}); });
} else { } else {
// Fade out animation. // Fade out animation.
view.animate() view.animate()
.alpha(alpha) .alpha(alpha)
.setInterpolator(FADE_OUT_INTERPOLATOR) .setInterpolator(FADE_OUT_INTERPOLATOR)
.setDuration(CROSS_FADE_DURATION_MS) .setDuration(CROSS_FADE_DURATION_MS)
.setListener(new PreviewFrameAnimatorListener()) .setListener(new PreviewFrameAnimatorListener())
.withEndAction(new Runnable() { .withEndAction(new Runnable() {
@Override @Override
public void run() { public void run() {
view.setVisibility(visibility); view.setVisibility(visibility);
} }
}); });
} }
} }
} }

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2018 The Android Open Source Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -14,14 +14,13 @@
* limitations under the License. * limitations under the License.
*/ */
package com.android.settings; package com.android.settings.display;
import android.content.Context; import android.content.Context;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityEvent;
import android.widget.SeekBar; import android.widget.SeekBar;
@@ -31,6 +30,8 @@ import android.widget.TextView;
import androidx.viewpager.widget.ViewPager; import androidx.viewpager.widget.ViewPager;
import androidx.viewpager.widget.ViewPager.OnPageChangeListener; import androidx.viewpager.widget.ViewPager.OnPageChangeListener;
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.widget.DotsPageIndicator; import com.android.settings.widget.DotsPageIndicator;
import com.android.settings.widget.LabeledSeekBar; import com.android.settings.widget.LabeledSeekBar;
@@ -48,12 +49,6 @@ public abstract class PreviewSeekBarPreferenceFragment extends SettingsPreferenc
/** Index of the entry corresponding to current value of the settings. */ /** Index of the entry corresponding to current value of the settings. */
protected int mCurrentIndex; protected int mCurrentIndex;
/** Resource id of the layout for this preference fragment. */
protected int mActivityLayoutResId;
/** Resource id of the layout that defines the contents inside preview screen. */
protected int[] mPreviewSampleResIds;
private ViewPager mPreviewPager; private ViewPager mPreviewPager;
private PreviewPagerAdapter mPreviewPagerAdapter; private PreviewPagerAdapter mPreviewPagerAdapter;
private DotsPageIndicator mPageIndicator; private DotsPageIndicator mPageIndicator;
@@ -82,12 +77,7 @@ public abstract class PreviewSeekBarPreferenceFragment extends SettingsPreferenc
@Override @Override
public void onStopTrackingTouch(SeekBar seekBar) { public void onStopTrackingTouch(SeekBar seekBar) {
if (mPreviewPagerAdapter.isAnimating()) { if (mPreviewPagerAdapter.isAnimating()) {
mPreviewPagerAdapter.setAnimationEndAction(new Runnable() { mPreviewPagerAdapter.setAnimationEndAction(() -> commit());
@Override
public void run() {
commit();
}
});
} else { } else {
commit(); commit();
} }
@@ -102,39 +92,33 @@ public abstract class PreviewSeekBarPreferenceFragment extends SettingsPreferenc
final ViewGroup listContainer = root.findViewById(android.R.id.list_container); final ViewGroup listContainer = root.findViewById(android.R.id.list_container);
listContainer.removeAllViews(); listContainer.removeAllViews();
final View content = inflater.inflate(mActivityLayoutResId, listContainer, false); final View content = inflater.inflate(getActivityLayoutResId(), listContainer, false);
listContainer.addView(content); listContainer.addView(content);
mLabel = (TextView) content.findViewById(R.id.current_label); mLabel = content.findViewById(R.id.current_label);
// The maximum SeekBar value always needs to be non-zero. If there's // The maximum SeekBar value always needs to be non-zero. If there's
// only one available value, we'll handle this by disabling the // only one available value, we'll handle this by disabling the
// seek bar. // seek bar.
final int max = Math.max(1, mEntries.length - 1); final int max = Math.max(1, mEntries.length - 1);
mSeekBar = (LabeledSeekBar) content.findViewById(R.id.seek_bar); mSeekBar = content.findViewById(R.id.seek_bar);
mSeekBar.setLabels(mEntries); mSeekBar.setLabels(mEntries);
mSeekBar.setMax(max); mSeekBar.setMax(max);
mSmaller = content.findViewById(R.id.smaller); mSmaller = content.findViewById(R.id.smaller);
mSmaller.setOnClickListener(new OnClickListener() { mSmaller.setOnClickListener(v -> {
@Override final int progress = mSeekBar.getProgress();
public void onClick(View v) { if (progress > 0) {
final int progress = mSeekBar.getProgress(); mSeekBar.setProgress(progress - 1, true);
if (progress > 0) {
mSeekBar.setProgress(progress - 1, true);
}
} }
}); });
mLarger = content.findViewById(R.id.larger); mLarger = content.findViewById(R.id.larger);
mLarger.setOnClickListener(new OnClickListener() { mLarger.setOnClickListener(v -> {
@Override final int progress = mSeekBar.getProgress();
public void onClick(View v) { if (progress < mSeekBar.getMax()) {
final int progress = mSeekBar.getProgress(); mSeekBar.setProgress(progress + 1, true);
if (progress < mSeekBar.getMax()) {
mSeekBar.setProgress(progress + 1, true);
}
} }
}); });
@@ -152,15 +136,16 @@ public abstract class PreviewSeekBarPreferenceFragment extends SettingsPreferenc
configurations[i] = createConfig(origConfig, i); configurations[i] = createConfig(origConfig, i);
} }
mPreviewPager = (ViewPager) content.findViewById(R.id.preview_pager); final int[] previews = getPreviewSampleResIds();
mPreviewPager = content.findViewById(R.id.preview_pager);
mPreviewPagerAdapter = new PreviewPagerAdapter(context, isLayoutRtl, mPreviewPagerAdapter = new PreviewPagerAdapter(context, isLayoutRtl,
mPreviewSampleResIds, configurations); previews, configurations);
mPreviewPager.setAdapter(mPreviewPagerAdapter); mPreviewPager.setAdapter(mPreviewPagerAdapter);
mPreviewPager.setCurrentItem(isLayoutRtl ? mPreviewSampleResIds.length - 1 : 0); mPreviewPager.setCurrentItem(isLayoutRtl ? previews.length - 1 : 0);
mPreviewPager.addOnPageChangeListener(mPreviewPageChangeListener); mPreviewPager.addOnPageChangeListener(mPreviewPageChangeListener);
mPageIndicator = (DotsPageIndicator) content.findViewById(R.id.page_indicator); mPageIndicator = content.findViewById(R.id.page_indicator);
if (mPreviewSampleResIds.length > 1) { if (previews.length > 1) {
mPageIndicator.setViewPager(mPreviewPager); mPageIndicator.setViewPager(mPreviewPager);
mPageIndicator.setVisibility(View.VISIBLE); mPageIndicator.setVisibility(View.VISIBLE);
mPageIndicator.setOnPageChangeListener(mPageIndicatorPageChangeListener); mPageIndicator.setOnPageChangeListener(mPageIndicatorPageChangeListener);
@@ -187,6 +172,12 @@ public abstract class PreviewSeekBarPreferenceFragment extends SettingsPreferenc
mSeekBar.setOnSeekBarChangeListener(null); mSeekBar.setOnSeekBarChangeListener(null);
} }
/** Resource id of the layout for this preference fragment. */
protected abstract int getActivityLayoutResId();
/** Resource id of the layout that defines the contents inside preview screen. */
protected abstract int[] getPreviewSampleResIds();
/** /**
* Creates new configuration based on the current position of the SeekBar. * Creates new configuration based on the current position of the SeekBar.
*/ */
@@ -210,8 +201,8 @@ public abstract class PreviewSeekBarPreferenceFragment extends SettingsPreferenc
private void setPagerIndicatorContentDescription(int position) { private void setPagerIndicatorContentDescription(int position) {
mPageIndicator.setContentDescription( mPageIndicator.setContentDescription(
getPrefContext().getString(R.string.preview_page_indicator_content_description, getString(R.string.preview_page_indicator_content_description,
position + 1, mPreviewSampleResIds.length)); position + 1, getPreviewSampleResIds().length));
} }
private OnPageChangeListener mPreviewPageChangeListener = new OnPageChangeListener() { private OnPageChangeListener mPreviewPageChangeListener = new OnPageChangeListener() {

View File

@@ -18,8 +18,7 @@ package com.android.settings.display;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent; import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
public class ScreenZoomPreferenceFragmentForSetupWizard public class ScreenZoomPreferenceFragmentForSetupWizard extends ScreenZoomSettings {
extends ScreenZoomSettings {
@Override @Override
public int getMetricsCategory() { public int getMetricsCategory() {

View File

@@ -24,9 +24,9 @@ import android.os.Bundle;
import android.view.Display; import android.view.Display;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent; import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.PreviewSeekBarPreferenceFragment;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.search.BaseSearchIndexProvider; import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
import com.android.settings.search.SearchIndexableRaw; import com.android.settings.search.SearchIndexableRaw;
import com.android.settingslib.display.DisplayDensityUtils; import com.android.settingslib.display.DisplayDensityUtils;
import com.android.settingslib.search.SearchIndexable; import com.android.settingslib.search.SearchIndexable;
@@ -43,17 +43,26 @@ public class ScreenZoomSettings extends PreviewSeekBarPreferenceFragment {
private int mDefaultDensity; private int mDefaultDensity;
private int[] mValues; private int[] mValues;
@Override
protected int getActivityLayoutResId() {
return R.layout.screen_zoom_activity;
}
@Override
protected int[] getPreviewSampleResIds() {
return getContext().getResources().getBoolean(
R.bool.config_enable_extra_screen_zoom_preview)
? new int[]{
R.layout.screen_zoom_preview_1,
R.layout.screen_zoom_preview_2,
R.layout.screen_zoom_preview_settings}
: new int[]{R.layout.screen_zoom_preview_1};
}
@Override @Override
public void onCreate(@Nullable Bundle savedInstanceState) { public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
mActivityLayoutResId = R.layout.screen_zoom_activity;
// This should be replaced once the final preview sample screen is in place.
mPreviewSampleResIds = new int[] {R.layout.screen_zoom_preview_1,
R.layout.screen_zoom_preview_2,
R.layout.screen_zoom_preview_settings};
final DisplayDensityUtils density = new DisplayDensityUtils(getContext()); final DisplayDensityUtils density = new DisplayDensityUtils(getContext());
final int initialIndex = density.getCurrentIndex(); final int initialIndex = density.getCurrentIndex();
@@ -62,8 +71,8 @@ public class ScreenZoomSettings extends PreviewSeekBarPreferenceFragment {
// connect to the window manager service. Just use the current // connect to the window manager service. Just use the current
// density and don't let the user change anything. // density and don't let the user change anything.
final int densityDpi = getResources().getDisplayMetrics().densityDpi; final int densityDpi = getResources().getDisplayMetrics().densityDpi;
mValues = new int[] {densityDpi}; mValues = new int[]{densityDpi};
mEntries = new String[] {getString(DisplayDensityUtils.SUMMARY_DEFAULT)}; mEntries = new String[]{getString(DisplayDensityUtils.SUMMARY_DEFAULT)};
mInitialIndex = 0; mInitialIndex = 0;
mDefaultDensity = densityDpi; mDefaultDensity = densityDpi;
} else { } else {
@@ -108,7 +117,7 @@ public class ScreenZoomSettings extends PreviewSeekBarPreferenceFragment {
} }
/** Index provider used to expose this fragment in search. */ /** Index provider used to expose this fragment in search. */
public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider() { new BaseSearchIndexProvider() {
@Override @Override
public List<SearchIndexableRaw> getRawDataToIndex(Context context, public List<SearchIndexableRaw> getRawDataToIndex(Context context,

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2018 The Android Open Source Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package com.android.settings.accessibility; package com.android.settings.display;
import android.annotation.Nullable; import android.annotation.Nullable;
import android.content.ContentResolver; import android.content.ContentResolver;
@@ -25,7 +25,6 @@ import android.os.Bundle;
import android.provider.Settings; import android.provider.Settings;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent; import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.PreviewSeekBarPreferenceFragment;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.search.BaseSearchIndexProvider; import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable; import com.android.settings.search.Indexable;
@@ -43,14 +42,21 @@ public class ToggleFontSizePreferenceFragment extends PreviewSeekBarPreferenceFr
private float[] mValues; private float[] mValues;
@Override
protected int getActivityLayoutResId() {
return R.layout.font_size_activity;
}
@Override
protected int[] getPreviewSampleResIds() {
return new int[]{R.layout.font_size_preview};
}
@Override @Override
public void onCreate(@Nullable Bundle savedInstanceState) { public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
mActivityLayoutResId = R.layout.font_size_activity; final Resources res = getContext().getResources();
mPreviewSampleResIds = new int[] {R.layout.font_size_preview};
Resources res = getContext().getResources();
final ContentResolver resolver = getContext().getContentResolver(); final ContentResolver resolver = getContext().getContentResolver();
// Mark the appropriate item in the preferences list. // Mark the appropriate item in the preferences list.
mEntries = res.getStringArray(R.array.entries_font_size); mEntries = res.getStringArray(R.array.entries_font_size);

View File

@@ -1,3 +1,3 @@
com.android.settings.accessibility.FontSizePreferenceFragmentForSetupWizard com.android.settings.display.FontSizePreferenceFragmentForSetupWizard
com.android.settings.display.ScreenZoomPreferenceFragmentForSetupWizard com.android.settings.display.ScreenZoomPreferenceFragmentForSetupWizard
com.android.settings.search.FakeSettingsFragment com.android.settings.search.FakeSettingsFragment

View File

@@ -1,3 +1,5 @@
manifest=packages/apps/Settings/AndroidManifest.xml manifest=packages/apps/Settings/AndroidManifest.xml
sdk=NEWEST_SDK sdk=NEWEST_SDK
shadows=com.android.settings.testutils.shadow.ShadowThreadUtils shadows=\
com.android.settings.testutils.shadow.ShadowThreadUtils,\
com.android.settings.testutils.shadow.ShadowXmlUtils

View File

@@ -63,6 +63,9 @@
<bool name="config_disable_uninstall_update">true</bool> <bool name="config_disable_uninstall_update">true</bool>
<bool name="config_show_device_name">false</bool> <bool name="config_show_device_name">false</bool>
<!-- Whether or not extra preview panels should be used for screen zoom setting. -->
<bool name="config_enable_extra_screen_zoom_preview">false</bool>
<!-- List of a11y components on the device allowed to be enabled by Settings Slices --> <!-- List of a11y components on the device allowed to be enabled by Settings Slices -->
<string-array name="config_settings_slices_accessibility_components" translatable="false"> <string-array name="config_settings_slices_accessibility_components" translatable="false">
<item>fake_package/fake_service</item> <item>fake_package/fake_service</item>
@@ -72,5 +75,4 @@
<string-array name="slice_whitelist_package_names" translatable="false"> <string-array name="slice_whitelist_package_names" translatable="false">
<item>com.android.settings.slice_whitelist_package</item> <item>com.android.settings.slice_whitelist_package</item>
</string-array> </string-array>
</resources> </resources>

View File

@@ -0,0 +1,57 @@
/*
* Copyright (C) 2018 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.display;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
import android.content.Context;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
public class ScreenZoomSettingsTest {
private ScreenZoomSettings mSettings;
private Context mContext;
@Before
public void setUp() {
mContext = RuntimeEnvironment.application;
mSettings = spy(new ScreenZoomSettings());
doReturn(mContext).when(mSettings).getContext();
}
@Test
public void getPreviewSampleResIds_default_return3Previews() {
assertThat(mSettings.getPreviewSampleResIds()).hasLength(3);
}
@Test
@Config(qualifiers = "mcc999")
public void getPreviewSampleResIds_extraPreviewDisabled_return1Preview() {
assertThat(mSettings.getPreviewSampleResIds()).hasLength(1);
}
}

View File

@@ -0,0 +1,28 @@
package com.android.settings.testutils.shadow;
import static org.robolectric.shadow.api.Shadow.directlyOn;
import com.android.internal.util.XmlUtils;
import org.robolectric.Robolectric;
import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
import org.robolectric.util.ReflectionHelpers;
import org.robolectric.util.ReflectionHelpers.ClassParameter;
@Implements(XmlUtils.class)
public class ShadowXmlUtils {
@Implementation
public static final int convertValueToInt(CharSequence charSeq, int defaultValue) {
final Class<?> xmlUtilsClass = ReflectionHelpers.loadClass(
Robolectric.class.getClassLoader(), "com.android.internal.util.XmlUtils");
try {
return directlyOn(xmlUtilsClass, "convertValueToInt",
ClassParameter.from(CharSequence.class, charSeq),
ClassParameter.from(int.class, new Integer(defaultValue)));
} catch (NumberFormatException e) {
return defaultValue;
}
}
}