Accomodating multiple preview screen with ViewPager for the users to
swipe across, along with some UI refinements. Change-Id: I9487bcce88cdab490a4b6baa752224acddc5be52
This commit is contained in:
25
res/drawable/ic_font_size_24dp.xml
Normal file
25
res/drawable/ic_font_size_24dp.xml
Normal file
@@ -0,0 +1,25 @@
|
||||
<!--
|
||||
~ Copyright (C) 2015 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
|
||||
-->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?android:attr/colorAccent">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M5 17v2h14v-2H5zm4.5-4.2h5l.9 2.2h2.1L12.75 4h-1.5L6.5 15h2.1l.9-2.2zM12 5.98L13.87 11h-3.74L12 5.98z"/>
|
||||
</vector>
|
25
res/drawable/ic_font_size_36dp.xml
Normal file
25
res/drawable/ic_font_size_36dp.xml
Normal file
@@ -0,0 +1,25 @@
|
||||
<!--
|
||||
~ Copyright (C) 2015 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
|
||||
-->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="36dp"
|
||||
android:height="36dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?android:attr/colorAccent">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M5 17v2h14v-2H5zm4.5-4.2h5l.9 2.2h2.1L12.75 4h-1.5L6.5 15h2.1l.9-2.2zM12 5.98L13.87 11h-3.74L12 5.98z"/>
|
||||
</vector>
|
@@ -15,8 +15,9 @@
|
||||
-->
|
||||
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fillViewport="true">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
@@ -26,33 +27,27 @@
|
||||
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">
|
||||
|
||||
<FrameLayout
|
||||
<android.support.v4.view.ViewPager
|
||||
android:id="@+id/preview_pager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/font_size_preview_height"
|
||||
android:layout_weight="1"
|
||||
android:background="?android:attr/colorBackgroundFloating"
|
||||
android:elevation="2dp">
|
||||
android:elevation="2dp" />
|
||||
|
||||
<view class="com.android.settings.TouchBlockingFrameLayout"
|
||||
android:id="@+id/preview_frame"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/current_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal|bottom"
|
||||
android:padding="8dp"
|
||||
android:theme="@android:style/Theme.Material"
|
||||
android:background="?android:attr/colorBackgroundFloating"
|
||||
android:textAppearance="@android:style/TextAppearance.Material.Caption"
|
||||
android:textAllCaps="true"
|
||||
android:elevation="2dp" />
|
||||
</FrameLayout>
|
||||
<TextView
|
||||
android:id="@+id/current_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:padding="8dp"
|
||||
android:textAppearance="@android:style/TextAppearance.Material.Widget.TextView"
|
||||
android:elevation="2dp" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingTop="8dp">
|
||||
|
||||
<ImageView
|
||||
@@ -60,7 +55,7 @@
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||
android:src="@drawable/ic_remove_24dp"
|
||||
android:src="@drawable/ic_font_size_24dp"
|
||||
android:tint="?android:attr/colorControlNormal"
|
||||
android:tintMode="src_in"
|
||||
android:scaleType="center"
|
||||
@@ -79,12 +74,19 @@
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||
android:src="@drawable/ic_add_24dp"
|
||||
android:src="@drawable/ic_font_size_36dp"
|
||||
android:tint="?android:attr/colorControlNormal"
|
||||
android:tintMode="src_in"
|
||||
android:scaleType="center"
|
||||
android:focusable="true"
|
||||
android:contentDescription="@string/font_size_make_larger_desc" />
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/font_size_summary"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:textAppearance="@android:style/TextAppearance.Material.Subhead" />
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
20
res/layout/preview_frame_container.xml
Normal file
20
res/layout/preview_frame_container.xml
Normal file
@@ -0,0 +1,20 @@
|
||||
<?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.
|
||||
-->
|
||||
|
||||
<view xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
class="com.android.settings.TouchBlockingFrameLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
@@ -16,7 +16,8 @@
|
||||
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent"
|
||||
android:fillViewport="true">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
@@ -26,40 +27,27 @@
|
||||
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/screen_zoom_summary"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:textAppearance="@android:style/TextAppearance.Material.Subhead" />
|
||||
|
||||
<FrameLayout
|
||||
<android.support.v4.view.ViewPager
|
||||
android:id="@+id/preview_pager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/screen_zoom_preview_height"
|
||||
android:layout_weight="1"
|
||||
android:background="?android:attr/colorBackgroundFloating"
|
||||
android:elevation="2dp">
|
||||
android:elevation="2dp" />
|
||||
|
||||
<view class="com.android.settings.TouchBlockingFrameLayout"
|
||||
android:id="@+id/preview_frame"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/current_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal|bottom"
|
||||
android:padding="8dp"
|
||||
android:theme="@android:style/Theme.Material"
|
||||
android:background="?android:attr/colorBackgroundFloating"
|
||||
android:textAppearance="@android:style/TextAppearance.Material.Caption"
|
||||
android:textAllCaps="true"
|
||||
android:elevation="2dp" />
|
||||
</FrameLayout>
|
||||
<TextView
|
||||
android:id="@+id/current_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:padding="8dp"
|
||||
android:textAppearance="@android:style/TextAppearance.Material.Widget.TextView"
|
||||
android:elevation="2dp" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingTop="8dp">
|
||||
|
||||
<ImageView
|
||||
@@ -93,5 +81,12 @@
|
||||
android:focusable="true"
|
||||
android:contentDescription="@string/screen_zoom_make_larger_desc" />
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/screen_zoom_summary"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:textAppearance="@android:style/TextAppearance.Material.Subhead" />
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
@@ -147,6 +147,9 @@
|
||||
<!-- Used for diagnostic info screens, precise translation isn't needed. Formats the SD card in the phone, meaning it will be erased and reformatted -->
|
||||
<string name="sdcard_format" product="default">Erase SD card</string>
|
||||
|
||||
<!-- Summary of font size setting screen. [CHAR LIMIT=NONE] -->
|
||||
<string name="font_size_summary">Make text on screen smaller or larger.</string>
|
||||
|
||||
<!-- choice for the font size spinner -->
|
||||
<string name="small_font">Small</string>
|
||||
<!-- choice for the font size spinner -->
|
||||
@@ -6675,9 +6678,8 @@
|
||||
<string name="screen_zoom_title">Screen zoom</string>
|
||||
<!-- Keywords for setting that controls screen zoom (e.g. how large interface elements appear). [CHAR LIMIT=NONE] -->
|
||||
<string name="screen_zoom_keywords">display density, screen zoom, scale, scaling</string>
|
||||
|
||||
<string name="screen_zoom_summary">Choose how zoomed you want the screen using the slider below the preview image.</string>
|
||||
|
||||
<!-- Summary of screen zoom setting screen. [CHAR LIMIT=NONE] -->
|
||||
<string name="screen_zoom_summary">Make all items on screen smaller or larger. Some apps on your home screen may change position after changing this setting.</string>
|
||||
<!-- Title of the screen zoom preview activity. -->
|
||||
<string name="screen_zoom_preview_title">Preview</string>
|
||||
<!-- Description for the button that makes interface elements smaller. [CHAR_LIMIT=NONE] -->
|
||||
|
@@ -44,9 +44,9 @@
|
||||
android:title="@string/accessibility_screen_magnification_title"/>
|
||||
|
||||
<PreferenceScreen
|
||||
android:fragment="com.android.settings.accessibility.ToggleFontSizePreferenceFragment"
|
||||
android:key="font_size_preference_screen"
|
||||
android:title="@string/title_font_size"/>
|
||||
android:fragment="com.android.settings.accessibility.ToggleFontSizePreferenceFragment"
|
||||
android:key="font_size_preference_screen"
|
||||
android:title="@string/title_font_size"/>
|
||||
|
||||
<PreferenceScreen
|
||||
android:fragment="com.android.settings.accessibility.ToggleAutoclickPreferenceFragment"
|
||||
|
131
src/com/android/settings/PreviewPagerAdapter.java
Normal file
131
src/com/android/settings/PreviewPagerAdapter.java
Normal file
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
* 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 android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.support.v4.view.PagerAdapter;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.AccelerateInterpolator;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
import android.view.animation.Interpolator;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
/**
|
||||
* A PagerAdapter used by PreviewSeekBarPreferenceFragment that for showing multiple preview screen
|
||||
* regarding a single setting and allowing the user to swipe across them.
|
||||
*/
|
||||
public class PreviewPagerAdapter extends PagerAdapter {
|
||||
|
||||
private TouchBlockingFrameLayout[] mPreviewFrames;
|
||||
|
||||
/** Duration to use when cross-fading between previews. */
|
||||
private static final long CROSS_FADE_DURATION_MS = 400;
|
||||
|
||||
/** Interpolator to use when cross-fading between previews. */
|
||||
private static final Interpolator FADE_IN_INTERPOLATOR = new DecelerateInterpolator();
|
||||
|
||||
/** Interpolator to use when cross-fading between previews. */
|
||||
private static final Interpolator FADE_OUT_INTERPOLATOR = new AccelerateInterpolator();
|
||||
|
||||
public PreviewPagerAdapter(Context context, int[] previewSampleResIds,
|
||||
Configuration[] configurations) {
|
||||
mPreviewFrames = new TouchBlockingFrameLayout[previewSampleResIds.length];
|
||||
|
||||
for (int i = 0; i < previewSampleResIds.length; ++i) {
|
||||
mPreviewFrames[i] = (TouchBlockingFrameLayout) LayoutInflater.from(context)
|
||||
.inflate(R.layout.preview_frame_container, null);
|
||||
|
||||
for (Configuration configuration : configurations) {
|
||||
// Create a new configuration for the specified value. It won't
|
||||
// have any theme set, so manually apply the current theme.
|
||||
final Context configContext = context.createConfigurationContext(configuration);
|
||||
configContext.setTheme(context.getThemeResId());
|
||||
|
||||
final LayoutInflater configInflater = LayoutInflater.from(configContext);
|
||||
final View sampleView = configInflater.inflate(previewSampleResIds[i],
|
||||
mPreviewFrames[i], false);
|
||||
sampleView.setAlpha(0);
|
||||
sampleView.setVisibility(View.INVISIBLE);
|
||||
|
||||
mPreviewFrames[i].addView(sampleView);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroyItem (ViewGroup container, int position, Object object) {
|
||||
container.removeView((View) object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return mPreviewFrames.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object instantiateItem(ViewGroup container, int position) {
|
||||
container.addView(mPreviewFrames[position]);
|
||||
return mPreviewFrames[position];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isViewFromObject(View view, Object object) {
|
||||
return (view == object);
|
||||
}
|
||||
|
||||
void setPreviewLayer(int newIndex, int currentIndex, int currentItem, boolean animate) {
|
||||
for (FrameLayout previewFrame : mPreviewFrames) {
|
||||
if (currentIndex >= 0) {
|
||||
final View lastLayer = previewFrame.getChildAt(currentIndex);
|
||||
if (animate && previewFrame == mPreviewFrames[currentItem]) {
|
||||
lastLayer.animate()
|
||||
.alpha(0)
|
||||
.setInterpolator(FADE_OUT_INTERPOLATOR)
|
||||
.setDuration(CROSS_FADE_DURATION_MS)
|
||||
.withEndAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
lastLayer.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
lastLayer.setAlpha(0);
|
||||
lastLayer.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
final View nextLayer = previewFrame.getChildAt(newIndex);
|
||||
if (animate && previewFrame == mPreviewFrames[currentItem]) {
|
||||
nextLayer.animate()
|
||||
.alpha(1)
|
||||
.setInterpolator(FADE_IN_INTERPOLATOR)
|
||||
.setDuration(CROSS_FADE_DURATION_MS)
|
||||
.withStartAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
nextLayer.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
nextLayer.setVisibility(View.VISIBLE);
|
||||
nextLayer.setAlpha(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -16,20 +16,14 @@
|
||||
|
||||
package com.android.settings;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Bundle;
|
||||
import android.util.AttributeSet;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.AccelerateInterpolator;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
import android.view.animation.Interpolator;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.SeekBar.OnSeekBarChangeListener;
|
||||
import android.widget.TextView;
|
||||
@@ -53,18 +47,11 @@ public abstract class PreviewSeekBarPreferenceFragment extends SettingsPreferenc
|
||||
protected int mActivityLayoutResId;
|
||||
|
||||
/** Resource id of the layout that defines the contents instide preview screen. */
|
||||
protected int mPreviewSampleResId;
|
||||
protected int[] mPreviewSampleResIds;
|
||||
|
||||
/** Duration to use when cross-fading between previews. */
|
||||
private static final long CROSS_FADE_DURATION_MS = 400;
|
||||
private ViewPager mPreviewPager;
|
||||
private PreviewPagerAdapter mPreviewPagerAdapter;
|
||||
|
||||
/** Interpolator to use when cross-fading between previews. */
|
||||
private static final Interpolator FADE_IN_INTERPOLATOR = new DecelerateInterpolator();
|
||||
|
||||
/** Interpolator to use when cross-fading between previews. */
|
||||
private static final Interpolator FADE_OUT_INTERPOLATOR = new AccelerateInterpolator();
|
||||
|
||||
private ViewGroup mPreviewFrame;
|
||||
private TextView mLabel;
|
||||
private View mLarger;
|
||||
private View mSmaller;
|
||||
@@ -96,10 +83,12 @@ public abstract class PreviewSeekBarPreferenceFragment extends SettingsPreferenc
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {}
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {}
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
}
|
||||
});
|
||||
|
||||
mSmaller = content.findViewById(R.id.smaller);
|
||||
@@ -130,29 +119,19 @@ public abstract class PreviewSeekBarPreferenceFragment extends SettingsPreferenc
|
||||
seekBar.setEnabled(false);
|
||||
}
|
||||
|
||||
mPreviewFrame = (FrameLayout) content.findViewById(R.id.preview_frame);
|
||||
|
||||
// Populate the sample layouts.
|
||||
final Context context = getContext();
|
||||
final Configuration origConfig = context.getResources().getConfiguration();
|
||||
Configuration[] configurations = new Configuration[mEntries.length];
|
||||
for (int i = 0; i < mEntries.length; ++i) {
|
||||
final Configuration config = createConfig(origConfig, i);
|
||||
|
||||
// Create a new configuration for the specified value. It won't
|
||||
// have any theme set, so manually apply the current theme.
|
||||
final Context configContext = context.createConfigurationContext(config);
|
||||
configContext.setTheme(context.getThemeResId());
|
||||
|
||||
final LayoutInflater configInflater = LayoutInflater.from(configContext);
|
||||
final View sampleView = configInflater.inflate(mPreviewSampleResId, mPreviewFrame, false);
|
||||
sampleView.setAlpha(0);
|
||||
sampleView.setVisibility(View.INVISIBLE);
|
||||
|
||||
mPreviewFrame.addView(sampleView);
|
||||
configurations[i] = createConfig(origConfig, i);
|
||||
}
|
||||
|
||||
setPreviewLayer(mInitialIndex, false);
|
||||
mPreviewPagerAdapter = new PreviewPagerAdapter(context, mPreviewSampleResIds,
|
||||
configurations);
|
||||
mPreviewPager = (ViewPager) content.findViewById(R.id.preview_pager);
|
||||
mPreviewPager.setAdapter(mPreviewPagerAdapter);
|
||||
|
||||
setPreviewLayer(mInitialIndex, false);
|
||||
return root;
|
||||
}
|
||||
|
||||
@@ -172,46 +151,11 @@ public abstract class PreviewSeekBarPreferenceFragment extends SettingsPreferenc
|
||||
|
||||
private void setPreviewLayer(int index, boolean animate) {
|
||||
mLabel.setText(mEntries[index]);
|
||||
|
||||
if (mCurrentIndex >= 0) {
|
||||
final View lastLayer = mPreviewFrame.getChildAt(mCurrentIndex);
|
||||
if (animate) {
|
||||
lastLayer.animate()
|
||||
.alpha(0)
|
||||
.setInterpolator(FADE_OUT_INTERPOLATOR)
|
||||
.setDuration(CROSS_FADE_DURATION_MS)
|
||||
.withEndAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
lastLayer.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
lastLayer.setAlpha(0);
|
||||
lastLayer.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
final View nextLayer = mPreviewFrame.getChildAt(index);
|
||||
if (animate) {
|
||||
nextLayer.animate()
|
||||
.alpha(1)
|
||||
.setInterpolator(FADE_IN_INTERPOLATOR)
|
||||
.setDuration(CROSS_FADE_DURATION_MS)
|
||||
.withStartAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
nextLayer.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
nextLayer.setVisibility(View.VISIBLE);
|
||||
nextLayer.setAlpha(1);
|
||||
}
|
||||
|
||||
mSmaller.setEnabled(index > 0);
|
||||
mLarger.setEnabled(index < mEntries.length - 1);
|
||||
|
||||
mPreviewPagerAdapter.setPreviewLayer(index, mCurrentIndex, mPreviewPager.getCurrentItem(),
|
||||
animate);
|
||||
mCurrentIndex = index;
|
||||
}
|
||||
|
||||
|
@@ -24,6 +24,7 @@ import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ServiceInfo;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
@@ -95,6 +96,8 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
||||
"captioning_preference_screen";
|
||||
private static final String DISPLAY_MAGNIFICATION_PREFERENCE_SCREEN =
|
||||
"screen_magnification_preference_screen";
|
||||
private static final String FONT_SIZE_PREFERENCE_SCREEN =
|
||||
"font_size_preference_screen";
|
||||
private static final String AUTOCLICK_PREFERENCE_SCREEN =
|
||||
"autoclick_preference_screen";
|
||||
private static final String DISPLAY_DALTONIZER_PREFERENCE_SCREEN =
|
||||
@@ -188,6 +191,7 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
||||
private Preference mNoServicesMessagePreference;
|
||||
private PreferenceScreen mCaptioningPreferenceScreen;
|
||||
private PreferenceScreen mDisplayMagnificationPreferenceScreen;
|
||||
private PreferenceScreen mFontSizePreferenceScreen;
|
||||
private PreferenceScreen mAutoclickPreferenceScreen;
|
||||
private PreferenceScreen mGlobalGesturePreferenceScreen;
|
||||
private PreferenceScreen mDisplayDaltonizerPreferenceScreen;
|
||||
@@ -419,6 +423,10 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
||||
mDisplayMagnificationPreferenceScreen = (PreferenceScreen) findPreference(
|
||||
DISPLAY_MAGNIFICATION_PREFERENCE_SCREEN);
|
||||
|
||||
// Font size.
|
||||
mFontSizePreferenceScreen = (PreferenceScreen) findPreference(
|
||||
FONT_SIZE_PREFERENCE_SCREEN);
|
||||
|
||||
// Autoclick after pointer stops.
|
||||
mAutoclickPreferenceScreen = (PreferenceScreen) findPreference(
|
||||
AUTOCLICK_PREFERENCE_SCREEN);
|
||||
@@ -600,6 +608,8 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
||||
updateFeatureSummary(Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED,
|
||||
mDisplayDaltonizerPreferenceScreen);
|
||||
|
||||
updateFontSizeSummary(mFontSizePreferenceScreen);
|
||||
|
||||
updateAutoclickSummary(mAutoclickPreferenceScreen);
|
||||
|
||||
// Global gesture
|
||||
@@ -634,6 +644,15 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
||||
getResources(), delay));
|
||||
}
|
||||
|
||||
private void updateFontSizeSummary(Preference pref) {
|
||||
final Resources res = getContext().getResources();
|
||||
final String[] entries = res.getStringArray(R.array.entries_font_size);
|
||||
final String[] strEntryValues = res.getStringArray(R.array.entryvalues_font_size);
|
||||
final int index = ToggleFontSizePreferenceFragment.floatToIndex(
|
||||
res.getConfiguration().fontScale, strEntryValues);
|
||||
pref.setSummary(entries[index]);
|
||||
}
|
||||
|
||||
private void updateLockScreenRotationCheckbox() {
|
||||
Context context = getActivity();
|
||||
if (context != null) {
|
||||
|
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.settings.accessibility;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.support.v7.preference.Preference;
|
||||
@@ -35,12 +36,14 @@ public class AccessibilitySettingsForSetupWizard extends SettingsPreferenceFragm
|
||||
"screen_magnification_preference";
|
||||
private static final String DISPLAY_DALTONIZER_PREFERENCE = "daltonizer_preference";
|
||||
private static final String TALKBACK_PREFERENCE = "talkback_preference";
|
||||
private static final String FONT_SIZE_PREFERENCE = "font_size_preference";
|
||||
|
||||
private static final String TALKBACK_NAME = "Talkback";
|
||||
|
||||
// Preference controls.
|
||||
private Preference mDisplayMagnificationPreference;
|
||||
private Preference mDisplayDaltonizerPreference;
|
||||
private Preference mFontSizePreference;
|
||||
private Preference mTalkbackPreference;
|
||||
|
||||
@Override
|
||||
@@ -60,6 +63,7 @@ public class AccessibilitySettingsForSetupWizard extends SettingsPreferenceFragm
|
||||
|
||||
mDisplayMagnificationPreference = findPreference(DISPLAY_MAGNIFICATION_PREFERENCE);
|
||||
mDisplayDaltonizerPreference = findPreference(DISPLAY_DALTONIZER_PREFERENCE);
|
||||
mFontSizePreference = findPreference(FONT_SIZE_PREFERENCE);
|
||||
|
||||
mTalkbackPreference = findPreference(TALKBACK_PREFERENCE);
|
||||
mTalkbackPreference.setTitle(TALKBACK_NAME);
|
||||
@@ -104,6 +108,7 @@ public class AccessibilitySettingsForSetupWizard extends SettingsPreferenceFragm
|
||||
mDisplayMagnificationPreference);
|
||||
updateFeatureSummary(Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED,
|
||||
mDisplayDaltonizerPreference);
|
||||
updateFontSizeSummary(mFontSizePreference);
|
||||
}
|
||||
|
||||
private void updateFeatureSummary(String prefKey, Preference pref) {
|
||||
@@ -111,4 +116,13 @@ public class AccessibilitySettingsForSetupWizard extends SettingsPreferenceFragm
|
||||
pref.setSummary(enabled ? R.string.accessibility_feature_state_on
|
||||
: R.string.accessibility_feature_state_off);
|
||||
}
|
||||
|
||||
private void updateFontSizeSummary(Preference pref) {
|
||||
final Resources res = getContext().getResources();
|
||||
final String[] entries = res.getStringArray(R.array.entries_font_size);
|
||||
final String[] strEntryValues = res.getStringArray(R.array.entryvalues_font_size);
|
||||
final int index = ToggleFontSizePreferenceFragment.floatToIndex(
|
||||
res.getConfiguration().fontScale, strEntryValues);
|
||||
pref.setSummary(entries[index]);
|
||||
}
|
||||
}
|
||||
|
@@ -41,7 +41,7 @@ public class ToggleFontSizePreferenceFragment extends PreviewSeekBarPreferenceFr
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
mActivityLayoutResId = R.layout.font_size_activity;
|
||||
mPreviewSampleResId = R.layout.font_size_preview;
|
||||
mPreviewSampleResIds = new int[]{R.layout.font_size_preview};
|
||||
|
||||
Resources res = getContext().getResources();
|
||||
// Mark the appropriate item in the preferences list.
|
||||
@@ -82,7 +82,11 @@ public class ToggleFontSizePreferenceFragment extends PreviewSeekBarPreferenceFr
|
||||
return InstrumentedFragment.ACCESSIBILITY_FONT_SIZE;
|
||||
}
|
||||
|
||||
private int floatToIndex(float val, String[] indices) {
|
||||
/**
|
||||
* Utility function that returns the index in a string array with which the represented value is
|
||||
* the closest to a given float value.
|
||||
*/
|
||||
static int floatToIndex(float val, String[] indices) {
|
||||
float lastVal = Float.parseFloat(indices[0]);
|
||||
for (int i=1; i<indices.length; i++) {
|
||||
float thisVal = Float.parseFloat(indices[i]);
|
||||
|
@@ -46,7 +46,11 @@ public class ScreenZoomSettings extends PreviewSeekBarPreferenceFragment impleme
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
mActivityLayoutResId = R.layout.screen_zoom_activity;
|
||||
mPreviewSampleResId = R.layout.screen_zoom_preview;
|
||||
|
||||
// This should be replaced once the final preview sample screen is in place.
|
||||
mPreviewSampleResIds = new int[]{R.layout.screen_zoom_preview, R.layout.screen_zoom_preview,
|
||||
R.layout.screen_zoom_preview};
|
||||
|
||||
final DisplayDensityUtils density = new DisplayDensityUtils(getContext());
|
||||
|
||||
final int initialIndex = density.getCurrentIndex();
|
||||
|
Reference in New Issue
Block a user