Merge "Remove font size & screen size setup flow instance" into tm-dev am: d3ec64104d

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/17049975

Change-Id: I9f2fe85a7ddd78bc093878f8ad81ac19083d2735
This commit is contained in:
Menghan Li
2022-03-03 15:12:06 +00:00
committed by Automerger Merge Worker
18 changed files with 0 additions and 1012 deletions

View File

@@ -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);
}
}

View File

@@ -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();
}
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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();
}
}

View File

@@ -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();
}
}