Merge "Remove font size & screen size setup flow instance" into tm-dev
This commit is contained in:
@@ -1997,11 +1997,6 @@
|
||||
android:value="com.android.settings.accessibility.TextReadingPreferenceFragmentForSetupWizard" />
|
||||
</activity-alias>
|
||||
|
||||
<activity
|
||||
android:name=".accessibility.AccessibilityScreenSizeForSetupWizardActivity"
|
||||
android:theme="@android:style/Theme.DeviceDefault.Settings"
|
||||
android:exported="false"/>
|
||||
|
||||
<activity
|
||||
android:name="Settings$AccessibilityDaltonizerSettingsActivity"
|
||||
android:exported="true"
|
||||
|
@@ -1,31 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2021 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.
|
||||
-->
|
||||
<com.google.android.setupdesign.GlifLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/setup_wizard_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:icon="@drawable/ic_accessibility_visibility"
|
||||
app:sucHeaderText="@string/title_font_size"
|
||||
app:sudDescriptionText="@string/short_summary_font_size">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/content_frame"
|
||||
android:layout_marginTop="@dimen/preview_size_top_margin"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
</com.google.android.setupdesign.GlifLayout>
|
@@ -1,80 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2021 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.
|
||||
-->
|
||||
<androidx.core.widget.NestedScrollView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fillViewport="true">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<include layout="@layout/suw_preview_seek_bar_view_pager"/>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">
|
||||
|
||||
<com.android.settings.widget.DotsPageIndicator
|
||||
android:id="@+id/page_indicator"
|
||||
style="@style/PreviewPagerPageIndicator"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:padding="3dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/current_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:padding="6dp"
|
||||
android:textAppearance="@android:style/TextAppearance.DeviceDefault.Widget.TextView"
|
||||
android:elevation="2dp"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingTop="8dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/smaller"
|
||||
android:src="@drawable/ic_font_size_16dp"
|
||||
android:contentDescription="@string/font_size_make_smaller_desc"
|
||||
style="@style/screen_size_imageview_style"/>
|
||||
|
||||
<com.android.settings.widget.LabeledSeekBar
|
||||
android:id="@+id/seek_bar"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_weight="1"
|
||||
style="@android:style/Widget.Material.SeekBar.Discrete"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/larger"
|
||||
android:src="@drawable/ic_font_size_24dp"
|
||||
android:contentDescription="@string/font_size_make_larger_desc"
|
||||
style="@style/screen_size_imageview_style"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</androidx.core.widget.NestedScrollView>
|
@@ -1,42 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2021 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.
|
||||
-->
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical"
|
||||
android:paddingStart="@dimen/preview_pager_padding"
|
||||
android:paddingEnd="@dimen/preview_pager_padding"
|
||||
android:background="@drawable/preview_seek_bar_outline" >
|
||||
|
||||
<androidx.viewpager.widget.ViewPager
|
||||
android:id="@+id/preview_pager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="200dp"
|
||||
android:layout_weight="1"
|
||||
android:background="?android:attr/colorBackground"
|
||||
android:contentDescription="@string/preview_pager_content_description" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="36dp"
|
||||
android:paddingStart="32dp"
|
||||
android:gravity="start|center"
|
||||
android:text="@string/screen_zoom_preview_title"
|
||||
android:textAppearance="@android:style/TextAppearance.DeviceDefault.Widget.ActionBar.Title"
|
||||
android:importantForAccessibility="no" />
|
||||
</LinearLayout>
|
||||
|
@@ -1,79 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2021 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.
|
||||
-->
|
||||
<androidx.core.widget.NestedScrollView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fillViewport="true">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<include layout="@layout/suw_preview_seek_bar_view_pager"/>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">
|
||||
|
||||
<com.android.settings.widget.DotsPageIndicator
|
||||
android:id="@+id/page_indicator"
|
||||
style="@style/PreviewPagerPageIndicator"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:padding="3dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/current_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:padding="6dp"
|
||||
android:textAppearance="@android:style/TextAppearance.DeviceDefault.Widget.TextView"
|
||||
android:elevation="2dp"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/smaller"
|
||||
android:src="@drawable/ic_remove_24dp"
|
||||
android:contentDescription="@string/screen_zoom_make_smaller_desc"
|
||||
style="@style/screen_size_imageview_style"/>
|
||||
|
||||
<com.android.settings.widget.LabeledSeekBar
|
||||
android:id="@+id/seek_bar"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_weight="1"
|
||||
style="@android:style/Widget.Material.SeekBar.Discrete"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/larger"
|
||||
android:src="@drawable/ic_add_24dp"
|
||||
android:contentDescription="@string/screen_zoom_make_larger_desc"
|
||||
style="@style/screen_size_imageview_style"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</androidx.core.widget.NestedScrollView>
|
@@ -545,9 +545,6 @@
|
||||
<!-- Whether to show Smart Storage toggle -->
|
||||
<bool name="config_show_smart_storage_toggle">true</bool>
|
||||
|
||||
<!-- Whether suw to support two panes -->
|
||||
<bool name="config_suw_supported_two_panes">false</bool>
|
||||
|
||||
<!-- Whether to support large screen -->
|
||||
<bool name="config_supported_large_screen">false</bool>
|
||||
|
||||
|
@@ -429,9 +429,6 @@
|
||||
<!-- Choose SIM Activity dimens -->
|
||||
<dimen name="subtitle_bottom_padding">24dp</dimen>
|
||||
|
||||
<!-- Top margin for preview view pager -->
|
||||
<dimen name="preview_size_top_margin">-12dp</dimen>
|
||||
|
||||
<!-- Battery usage chart view component -->
|
||||
<dimen name="chartview_text_padding">6dp</dimen>
|
||||
<dimen name="chartview_divider_width">1dp</dimen>
|
||||
|
@@ -243,16 +243,6 @@
|
||||
<item name="android:textColor">?android:attr/textColorSecondary</item>
|
||||
</style>
|
||||
|
||||
<style name="screen_size_imageview_style">
|
||||
<item name="android:layout_width">48dp</item>
|
||||
<item name="android:layout_height">48dp</item>
|
||||
<item name="android:background">?android:attr/selectableItemBackgroundBorderless</item>
|
||||
<item name="android:tint">?android:attr/textColorPrimary</item>
|
||||
<item name="android:tintMode">src_in</item>
|
||||
<item name="android:scaleType">center</item>
|
||||
<item name="android:focusable">true</item>
|
||||
</style>
|
||||
|
||||
<style name="TextAppearance" parent="android:TextAppearance.DeviceDefault"/>
|
||||
|
||||
<style name="TextAppearance.info_label">
|
||||
|
@@ -1,174 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2021 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.accessibility;
|
||||
|
||||
import static com.android.settings.core.SettingsBaseActivity.EXTRA_PAGE_TRANSITION_TYPE;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.IntDef;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.PreferenceFragmentCompat;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.InstrumentedActivity;
|
||||
import com.android.settings.display.FontSizePreferenceFragmentForSetupWizard;
|
||||
import com.android.settings.display.ScreenZoomPreferenceFragmentForSetupWizard;
|
||||
import com.android.settingslib.transition.SettingsTransitionHelper.TransitionType;
|
||||
|
||||
import com.google.android.setupcompat.template.FooterBarMixin;
|
||||
import com.google.android.setupcompat.template.FooterButton;
|
||||
import com.google.android.setupdesign.GlifLayout;
|
||||
import com.google.android.setupdesign.util.ThemeHelper;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
/** Settings font/display size activity for SUW. */
|
||||
public class AccessibilityScreenSizeForSetupWizardActivity extends InstrumentedActivity {
|
||||
private static final String TAG = "ScreenSizeForSetup";
|
||||
|
||||
// A parameter decides which fragment ({@link FontSizePreferenceFragmentForSetupWizard} or
|
||||
// {@link ScreenZoomPreferenceFragmentForSetupWizard}) will be visioned.
|
||||
static final String VISION_FRAGMENT_NO = "vision_fragment_no";
|
||||
/**
|
||||
* Flags indicating the type of the fragment.
|
||||
*/
|
||||
@IntDef({
|
||||
FragmentType.FONT_SIZE,
|
||||
FragmentType.SCREEN_SIZE,
|
||||
})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface FragmentType {
|
||||
int FONT_SIZE = 1;
|
||||
int SCREEN_SIZE = 2;
|
||||
}
|
||||
|
||||
// Keep the last height of the scroll view in the {@link GlifLayout}
|
||||
private int mLastScrollViewHeight;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
final int appliedTheme = ThemeHelper.trySetDynamicColor(this)
|
||||
? R.style.SudDynamicColorThemeGlifV3_DayNight : R.style.SudThemeGlifV3_DayNight;
|
||||
setTheme(appliedTheme);
|
||||
setContentView(R.layout.accessibility_screen_size_setup_wizard);
|
||||
updateHeaderLayout();
|
||||
scrollToBottom();
|
||||
initFooterButton();
|
||||
if (savedInstanceState == null) {
|
||||
final PreferenceFragmentCompat fragment =
|
||||
getFragmentType(getIntent()) == FragmentType.FONT_SIZE
|
||||
? new FontSizePreferenceFragmentForSetupWizard()
|
||||
: new ScreenZoomPreferenceFragmentForSetupWizard();
|
||||
getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
.replace(R.id.content_frame, fragment)
|
||||
.commit();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
// For accessibility activities launched from setup wizard.
|
||||
if (getTransitionType(getIntent()) == TransitionType.TRANSITION_FADE) {
|
||||
overridePendingTransition(R.anim.sud_stay, android.R.anim.fade_out);
|
||||
}
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return getFragmentType(getIntent()) == FragmentType.FONT_SIZE
|
||||
? SettingsEnums.SUW_ACCESSIBILITY_FONT_SIZE
|
||||
: SettingsEnums.SUW_ACCESSIBILITY_DISPLAY_SIZE;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void updateHeaderLayout() {
|
||||
if (ThemeHelper.shouldApplyExtendedPartnerConfig(this) && isSuwSupportedTwoPanes()) {
|
||||
final GlifLayout layout = findViewById(R.id.setup_wizard_layout);
|
||||
final LinearLayout headerLayout = layout.findManagedViewById(R.id.sud_layout_header);
|
||||
if (headerLayout != null) {
|
||||
headerLayout.setPadding(0, layout.getPaddingTop(), 0,
|
||||
layout.getPaddingBottom());
|
||||
}
|
||||
}
|
||||
((TextView) findViewById(R.id.suc_layout_title)).setText(
|
||||
getFragmentType(getIntent()) == FragmentType.FONT_SIZE
|
||||
? R.string.title_font_size
|
||||
: R.string.screen_zoom_title);
|
||||
((TextView) findViewById(R.id.sud_layout_subtitle)).setText(
|
||||
getFragmentType(getIntent()) == FragmentType.FONT_SIZE
|
||||
? R.string.font_size_summary
|
||||
: R.string.screen_zoom_summary);
|
||||
}
|
||||
|
||||
private boolean isSuwSupportedTwoPanes() {
|
||||
return getResources().getBoolean(R.bool.config_suw_supported_two_panes);
|
||||
}
|
||||
|
||||
private void initFooterButton() {
|
||||
final GlifLayout layout = findViewById(R.id.setup_wizard_layout);
|
||||
final FooterBarMixin mixin = layout.getMixin(FooterBarMixin.class);
|
||||
final View.OnClickListener nextButtonListener = v -> onBackPressed();
|
||||
final FooterButton primaryButton =
|
||||
new FooterButton.Builder(this)
|
||||
.setText(R.string.done)
|
||||
.setListener(nextButtonListener)
|
||||
.setButtonType(FooterButton.ButtonType.NEXT)
|
||||
.setTheme(R.style.SudGlifButton_Primary)
|
||||
.build();
|
||||
mixin.setPrimaryButton(primaryButton);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scrolls to bottom while {@link ScrollView} layout changed.
|
||||
*/
|
||||
private void scrollToBottom() {
|
||||
mLastScrollViewHeight = 0;
|
||||
final GlifLayout layout = findViewById(R.id.setup_wizard_layout);
|
||||
final ScrollView scrollView = layout.getScrollView();
|
||||
scrollView.getViewTreeObserver().addOnGlobalLayoutListener(() -> {
|
||||
final int scrollViewHeight = scrollView.getHeight();
|
||||
if (scrollViewHeight > 0 && scrollViewHeight != mLastScrollViewHeight) {
|
||||
mLastScrollViewHeight = scrollViewHeight;
|
||||
scrollView.post(() -> {
|
||||
// Here is no need to show the scrolling animation. So disabled first and
|
||||
// then enabled it after scrolling finished.
|
||||
scrollView.setSmoothScrollingEnabled(false);
|
||||
scrollView.fullScroll(View.FOCUS_DOWN);
|
||||
scrollView.setSmoothScrollingEnabled(true);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private int getTransitionType(Intent intent) {
|
||||
return intent.getIntExtra(EXTRA_PAGE_TRANSITION_TYPE, TransitionType.TRANSITION_NONE);
|
||||
}
|
||||
|
||||
private int getFragmentType(Intent intent) {
|
||||
return intent.getIntExtra(VISION_FRAGMENT_NO, FragmentType.FONT_SIZE);
|
||||
}
|
||||
}
|
@@ -16,12 +16,7 @@
|
||||
|
||||
package com.android.settings.accessibility;
|
||||
|
||||
import static com.android.settings.accessibility.AccessibilityScreenSizeForSetupWizardActivity.VISION_FRAGMENT_NO;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.accessibility.AccessibilityEvent;
|
||||
|
||||
@@ -32,19 +27,16 @@ import androidx.preference.PreferenceFragmentCompat;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.SetupWizardUtils;
|
||||
import com.android.settings.accessibility.AccessibilityScreenSizeForSetupWizardActivity.FragmentType;
|
||||
import com.android.settings.core.SubSettingLauncher;
|
||||
import com.android.settings.search.actionbar.SearchMenuController;
|
||||
import com.android.settings.support.actionbar.HelpResourceProvider;
|
||||
import com.android.settingslib.core.instrumentation.Instrumentable;
|
||||
import com.android.settingslib.transition.SettingsTransitionHelper;
|
||||
|
||||
import com.google.android.setupcompat.util.WizardManagerHelper;
|
||||
import com.google.android.setupdesign.util.ThemeHelper;
|
||||
|
||||
public class AccessibilitySettingsForSetupWizardActivity extends SettingsActivity {
|
||||
|
||||
private static final String LOG_TAG = "A11ySettingsForSUW";
|
||||
private static final String SAVE_KEY_TITLE = "activity_title";
|
||||
|
||||
@VisibleForTesting
|
||||
@@ -105,7 +97,6 @@ public class AccessibilitySettingsForSetupWizardActivity extends SettingsActivit
|
||||
protected void onCreate(Bundle savedState) {
|
||||
super.onCreate(savedState);
|
||||
applyTheme();
|
||||
tryLaunchFontSizeSettings();
|
||||
findViewById(R.id.content_parent).setFitsSystemWindows(false);
|
||||
}
|
||||
|
||||
@@ -118,19 +109,4 @@ public class AccessibilitySettingsForSetupWizardActivity extends SettingsActivit
|
||||
setTheme(appliedTheme);
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void tryLaunchFontSizeSettings() {
|
||||
if (WizardManagerHelper.isAnySetupWizard(getIntent())
|
||||
&& new ComponentName(getPackageName(),
|
||||
CLASS_NAME_FONT_SIZE_SETTINGS_FOR_SUW).equals(
|
||||
getIntent().getComponent())) {
|
||||
final Intent intent = new Intent(this,
|
||||
AccessibilityScreenSizeForSetupWizardActivity.class);
|
||||
intent.putExtra(VISION_FRAGMENT_NO, FragmentType.FONT_SIZE);
|
||||
startActivity(intent);
|
||||
Log.d(LOG_TAG, "Launch font size settings");
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2021 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.accessibility;
|
||||
|
||||
import static com.android.settings.accessibility.AccessibilityScreenSizeForSetupWizardActivity.VISION_FRAGMENT_NO;
|
||||
import static com.android.settings.core.SettingsBaseActivity.EXTRA_PAGE_TRANSITION_TYPE;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.settings.accessibility.AccessibilityScreenSizeForSetupWizardActivity.FragmentType;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settingslib.transition.SettingsTransitionHelper.TransitionType;
|
||||
|
||||
/** PreferenceController for displaying font size page. */
|
||||
public class FontSizePreferenceController extends BasePreferenceController {
|
||||
|
||||
public FontSizePreferenceController(Context context, String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return AVAILABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handlePreferenceTreeClick(Preference preference) {
|
||||
if (!mPreferenceKey.equals(preference.getKey())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final Intent intent = new Intent(mContext,
|
||||
AccessibilityScreenSizeForSetupWizardActivity.class);
|
||||
intent.putExtra(VISION_FRAGMENT_NO, FragmentType.FONT_SIZE);
|
||||
intent.putExtra(EXTRA_PAGE_TRANSITION_TYPE, TransitionType.TRANSITION_FADE);
|
||||
mContext.startActivity(intent);
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2021 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.accessibility;
|
||||
|
||||
import static com.android.settings.accessibility.AccessibilityScreenSizeForSetupWizardActivity.VISION_FRAGMENT_NO;
|
||||
import static com.android.settings.core.SettingsBaseActivity.EXTRA_PAGE_TRANSITION_TYPE;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.settings.accessibility.AccessibilityScreenSizeForSetupWizardActivity.FragmentType;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settingslib.transition.SettingsTransitionHelper.TransitionType;
|
||||
|
||||
/** PreferenceController for displaying screen size page. */
|
||||
public class ScreenSizePreferenceController extends BasePreferenceController {
|
||||
|
||||
public ScreenSizePreferenceController(Context context, String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return AVAILABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handlePreferenceTreeClick(Preference preference) {
|
||||
if (!mPreferenceKey.equals(preference.getKey())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final Intent intent = new Intent(mContext,
|
||||
AccessibilityScreenSizeForSetupWizardActivity.class);
|
||||
intent.putExtra(VISION_FRAGMENT_NO, FragmentType.SCREEN_SIZE);
|
||||
intent.putExtra(EXTRA_PAGE_TRANSITION_TYPE, TransitionType.TRANSITION_FADE);
|
||||
mContext.startActivity(intent);
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -1,70 +0,0 @@
|
||||
/*
|
||||
* 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 android.app.settings.SettingsEnums;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
import com.android.settings.R;
|
||||
|
||||
public class FontSizePreferenceFragmentForSetupWizard
|
||||
extends ToggleFontSizePreferenceFragment {
|
||||
|
||||
@Override
|
||||
protected int getActivityLayoutResId() {
|
||||
return R.layout.suw_font_size_fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return SettingsEnums.SUW_ACCESSIBILITY_FONT_SIZE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
final View root = super.onCreateView(inflater, container, savedInstanceState);
|
||||
if (getResources().getBoolean(R.bool.config_supported_large_screen)) {
|
||||
final ViewPager viewPager = root.findViewById(R.id.preview_pager);
|
||||
final View view = (View) viewPager.getAdapter().instantiateItem(viewPager,
|
||||
viewPager.getCurrentItem());
|
||||
final LinearLayout layout = view.findViewById(R.id.font_size_preview_text_group);
|
||||
final int paddingStart = getResources().getDimensionPixelSize(
|
||||
R.dimen.font_size_preview_padding_start);
|
||||
layout.setPaddingRelative(paddingStart, layout.getPaddingTop(),
|
||||
layout.getPaddingEnd(), layout.getPaddingBottom());
|
||||
}
|
||||
return root;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
// Log the final choice in value if it's different from the previous value.
|
||||
if (mCurrentIndex != mInitialIndex) {
|
||||
mMetricsFeatureProvider.action(getContext(), SettingsEnums.SUW_ACCESSIBILITY_FONT_SIZE,
|
||||
mCurrentIndex);
|
||||
}
|
||||
|
||||
super.onStop();
|
||||
}
|
||||
}
|
@@ -1,46 +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.display;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
|
||||
import com.android.settings.R;
|
||||
|
||||
public class ScreenZoomPreferenceFragmentForSetupWizard extends ScreenZoomSettings {
|
||||
|
||||
@Override
|
||||
protected int getActivityLayoutResId() {
|
||||
return R.layout.suw_screen_zoom_fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return SettingsEnums.SUW_ACCESSIBILITY_DISPLAY_SIZE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
// Log the final choice in value if it's different from the previous value.
|
||||
if (mCurrentIndex != mInitialIndex) {
|
||||
mMetricsFeatureProvider.action(
|
||||
getContext(), SettingsEnums.SUW_ACCESSIBILITY_DISPLAY_SIZE, mCurrentIndex);
|
||||
}
|
||||
|
||||
super.onStop();
|
||||
}
|
||||
}
|
||||
|
@@ -1,140 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2021 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.accessibility;
|
||||
|
||||
import static com.android.settings.accessibility.AccessibilityScreenSizeForSetupWizardActivity.VISION_FRAGMENT_NO;
|
||||
import static com.android.settings.core.SettingsBaseActivity.EXTRA_PAGE_TRANSITION_TYPE;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.robolectric.Shadows.shadowOf;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.accessibility.AccessibilityScreenSizeForSetupWizardActivity.FragmentType;
|
||||
import com.android.settingslib.transition.SettingsTransitionHelper.TransitionType;
|
||||
|
||||
import com.google.android.setupcompat.template.FooterBarMixin;
|
||||
import com.google.android.setupdesign.GlifLayout;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.Robolectric;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
|
||||
/** Tests for {@link AccessibilityScreenSizeForSetupWizardActivity} */
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class AccessibilityScreenSizeForSetupWizardActivityTest {
|
||||
|
||||
private Context mContext = ApplicationProvider.getApplicationContext();
|
||||
|
||||
private AccessibilityScreenSizeForSetupWizardActivity setupActivity(int fragmentType) {
|
||||
final Intent intent = new Intent();
|
||||
intent.putExtra(VISION_FRAGMENT_NO, fragmentType);
|
||||
return Robolectric.buildActivity(AccessibilityScreenSizeForSetupWizardActivity.class,
|
||||
intent).create().get();
|
||||
}
|
||||
|
||||
private AccessibilityScreenSizeForSetupWizardActivity setupActivity(int fragmentType,
|
||||
int transitionType) {
|
||||
final Intent intent = new Intent();
|
||||
intent.putExtra(VISION_FRAGMENT_NO, fragmentType);
|
||||
intent.putExtra(EXTRA_PAGE_TRANSITION_TYPE, transitionType);
|
||||
return Robolectric.buildActivity(AccessibilityScreenSizeForSetupWizardActivity.class,
|
||||
intent).create().get();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setupActivity_fontSizePage_returnFontSizeTitle() {
|
||||
final AccessibilityScreenSizeForSetupWizardActivity activity =
|
||||
setupActivity(FragmentType.FONT_SIZE, TransitionType.TRANSITION_FADE);
|
||||
|
||||
final GlifLayout layout = activity.findViewById(R.id.setup_wizard_layout);
|
||||
assertThat(layout.getHeaderText()).isEqualTo(mContext.getText(R.string.title_font_size));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setupActivity_generateDoneButton() {
|
||||
final AccessibilityScreenSizeForSetupWizardActivity activity =
|
||||
setupActivity(FragmentType.FONT_SIZE, TransitionType.TRANSITION_FADE);
|
||||
|
||||
final GlifLayout layout = activity.findViewById(R.id.setup_wizard_layout);
|
||||
final FooterBarMixin mixin = layout.getMixin(FooterBarMixin.class);
|
||||
assertThat(mixin.getPrimaryButton().getText()).isEqualTo(mContext.getText(R.string.done));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onPause_getPendingTransitionEnterAnimationResourceId_transitionFade_should() {
|
||||
final AccessibilityScreenSizeForSetupWizardActivity activity =
|
||||
setupActivity(FragmentType.FONT_SIZE, TransitionType.TRANSITION_FADE);
|
||||
|
||||
activity.onPause();
|
||||
|
||||
assertThat(shadowOf(activity).getPendingTransitionEnterAnimationResourceId())
|
||||
.isEqualTo(R.anim.sud_stay);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onPause_getPendingTransitionExitAnimationResourceId_transitionFade_should() {
|
||||
final AccessibilityScreenSizeForSetupWizardActivity activity =
|
||||
setupActivity(FragmentType.FONT_SIZE, TransitionType.TRANSITION_FADE);
|
||||
|
||||
activity.onPause();
|
||||
|
||||
assertThat(shadowOf(activity).getPendingTransitionExitAnimationResourceId())
|
||||
.isEqualTo(android.R.anim.fade_out);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onPause_getPendingTransitionEnterAnimationResourceId_transitionNone_should() {
|
||||
final AccessibilityScreenSizeForSetupWizardActivity activity =
|
||||
setupActivity(FragmentType.FONT_SIZE);
|
||||
|
||||
activity.onPause();
|
||||
|
||||
assertThat(shadowOf(activity).getPendingTransitionEnterAnimationResourceId())
|
||||
.isNotEqualTo(R.anim.sud_stay);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onPause_getPendingTransitionExitAnimationResourceId_transitionNone_should() {
|
||||
final AccessibilityScreenSizeForSetupWizardActivity activity =
|
||||
setupActivity(FragmentType.FONT_SIZE);
|
||||
|
||||
activity.onPause();
|
||||
|
||||
assertThat(shadowOf(activity).getPendingTransitionExitAnimationResourceId())
|
||||
.isNotEqualTo(android.R.anim.fade_out);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateHeaderLayout_displaySizePage_returnDisplaySizeTitle() {
|
||||
final Intent intent = new Intent();
|
||||
intent.putExtra(VISION_FRAGMENT_NO, FragmentType.SCREEN_SIZE);
|
||||
intent.putExtra(EXTRA_PAGE_TRANSITION_TYPE, TransitionType.TRANSITION_FADE);
|
||||
final AccessibilityScreenSizeForSetupWizardActivity activity = Robolectric.buildActivity(
|
||||
AccessibilityScreenSizeForSetupWizardActivity.class, intent).get();
|
||||
activity.setContentView(R.layout.accessibility_screen_size_setup_wizard);
|
||||
activity.updateHeaderLayout();
|
||||
final GlifLayout layout = activity.findViewById(R.id.setup_wizard_layout);
|
||||
assertThat(layout.getHeaderText()).isEqualTo(mContext.getText(R.string.screen_zoom_title));
|
||||
}
|
||||
}
|
@@ -16,27 +16,18 @@
|
||||
|
||||
package com.android.settings.accessibility;
|
||||
|
||||
import static com.android.settings.accessibility.AccessibilityScreenSizeForSetupWizardActivity.VISION_FRAGMENT_NO;
|
||||
import static com.android.settings.accessibility.AccessibilitySettingsForSetupWizardActivity.CLASS_NAME_FONT_SIZE_SETTINGS_FOR_SUW;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Intent;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.accessibility.AccessibilityScreenSizeForSetupWizardActivity.FragmentType;
|
||||
|
||||
import com.google.android.setupcompat.util.WizardManagerHelper;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.Robolectric;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.Shadows;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@SmallTest
|
||||
@@ -51,38 +42,4 @@ public class AccessibilitySettingsForSetupWizardActivityTest {
|
||||
|
||||
assertThat(activity.getThemeResId()).isEqualTo(R.style.GlifV3Theme_Light);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onCreate_hasFontSizeComponent_shouldGoToFontSizePreferenceDirectly() {
|
||||
AccessibilitySettingsForSetupWizardActivity activity =
|
||||
Robolectric.buildActivity(AccessibilitySettingsForSetupWizardActivity.class,
|
||||
new Intent(Intent.ACTION_MAIN).setComponent(new ComponentName(
|
||||
RuntimeEnvironment.application,
|
||||
CLASS_NAME_FONT_SIZE_SETTINGS_FOR_SUW))
|
||||
.putExtra(WizardManagerHelper.EXTRA_IS_FIRST_RUN, true)
|
||||
.putExtra(WizardManagerHelper.EXTRA_IS_SETUP_FLOW, true)).get();
|
||||
|
||||
activity.tryLaunchFontSizeSettings();
|
||||
|
||||
final Intent launchIntent = Shadows.shadowOf(activity).getNextStartedActivity();
|
||||
assertThat(launchIntent).isNotNull();
|
||||
assertThat(launchIntent.getIntExtra(VISION_FRAGMENT_NO, -1)).isEqualTo(
|
||||
FragmentType.FONT_SIZE);
|
||||
assertThat(activity.isFinishing()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onCreate_noFontSizeComponent_shouldNotFinishCurrentActivity() {
|
||||
AccessibilitySettingsForSetupWizardActivity activity =
|
||||
Robolectric.buildActivity(AccessibilitySettingsForSetupWizardActivity.class,
|
||||
new Intent(Intent.ACTION_MAIN)
|
||||
.putExtra(WizardManagerHelper.EXTRA_IS_FIRST_RUN, true)
|
||||
.putExtra(WizardManagerHelper.EXTRA_IS_SETUP_FLOW, true)).get();
|
||||
|
||||
activity.tryLaunchFontSizeSettings();
|
||||
|
||||
final Intent launchIntent = Shadows.shadowOf(activity).getNextStartedActivity();
|
||||
assertThat(launchIntent).isNull();
|
||||
assertThat(activity.isFinishing()).isFalse();
|
||||
}
|
||||
}
|
||||
|
@@ -1,75 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2021 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.accessibility;
|
||||
|
||||
import static com.android.settings.accessibility.AccessibilityScreenSizeForSetupWizardActivity.VISION_FRAGMENT_NO;
|
||||
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
|
||||
import static com.android.settings.core.SettingsBaseActivity.EXTRA_PAGE_TRANSITION_TYPE;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.robolectric.Shadows.shadowOf;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.settings.accessibility.AccessibilityScreenSizeForSetupWizardActivity.FragmentType;
|
||||
import com.android.settingslib.transition.SettingsTransitionHelper.TransitionType;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.Robolectric;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
|
||||
/** Tests for {@link FontSizePreferenceController}. */
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class FontSizePreferenceControllerTest {
|
||||
private static final String TEST_KEY = "test_key";
|
||||
|
||||
private Activity mActivity;
|
||||
private FontSizePreferenceController mController;
|
||||
Preference mPreference;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mActivity = Robolectric.setupActivity(Activity.class);
|
||||
mController = new FontSizePreferenceController(mActivity, TEST_KEY);
|
||||
mPreference = new Preference(mActivity);
|
||||
mPreference.setKey(TEST_KEY);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailabilityStatus_returnAvailable() {
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void handlePreferenceTreeClick_launchActivityWithExpectedValues() {
|
||||
mController.handlePreferenceTreeClick(mPreference);
|
||||
|
||||
final Intent nextActivity = shadowOf(mActivity).getNextStartedActivity();
|
||||
assertThat(nextActivity.getIntExtra(VISION_FRAGMENT_NO, /* defaultValue= */-1))
|
||||
.isEqualTo(FragmentType.FONT_SIZE);
|
||||
assertThat(nextActivity.getIntExtra(EXTRA_PAGE_TRANSITION_TYPE, /* defaultValue= */-1))
|
||||
.isEqualTo(TransitionType.TRANSITION_FADE);
|
||||
}
|
||||
}
|
@@ -1,75 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2021 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.accessibility;
|
||||
|
||||
import static com.android.settings.accessibility.AccessibilityScreenSizeForSetupWizardActivity.VISION_FRAGMENT_NO;
|
||||
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
|
||||
import static com.android.settings.core.SettingsBaseActivity.EXTRA_PAGE_TRANSITION_TYPE;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.robolectric.Shadows.shadowOf;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.settings.accessibility.AccessibilityScreenSizeForSetupWizardActivity.FragmentType;
|
||||
import com.android.settingslib.transition.SettingsTransitionHelper.TransitionType;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.Robolectric;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
|
||||
/** Tests for {@link ScreenSizePreferenceController}. */
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class ScreenSizePreferenceControllerTest {
|
||||
private static final String TEST_KEY = "test_key";
|
||||
|
||||
private Activity mActivity;
|
||||
private ScreenSizePreferenceController mController;
|
||||
Preference mPreference;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mActivity = Robolectric.setupActivity(Activity.class);
|
||||
mController = new ScreenSizePreferenceController(mActivity, TEST_KEY);
|
||||
mPreference = new Preference(mActivity);
|
||||
mPreference.setKey(TEST_KEY);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailabilityStatus_returnAvailable() {
|
||||
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void handlePreferenceTreeClick_launchActivityWithExpectedValues() {
|
||||
mController.handlePreferenceTreeClick(mPreference);
|
||||
|
||||
final Intent nextActivity = shadowOf(mActivity).getNextStartedActivity();
|
||||
assertThat(nextActivity.getIntExtra(VISION_FRAGMENT_NO, /* defaultValue= */-1))
|
||||
.isEqualTo(FragmentType.SCREEN_SIZE);
|
||||
assertThat(nextActivity.getIntExtra(EXTRA_PAGE_TRANSITION_TYPE, /* defaultValue= */-1))
|
||||
.isEqualTo(TransitionType.TRANSITION_FADE);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user