From 1a4ca56796bbd4070377968be2ef2100eacc7313 Mon Sep 17 00:00:00 2001 From: menghanli Date: Thu, 17 Feb 2022 14:39:32 +0800 Subject: [PATCH 1/3] Fix two intro strings for Magnification page during Suw - Keep the SuW intro and hide the setting intro Bug: 220025399 Test: Manual testing Change-Id: Ie4e9eace8dbd638bd141c14a22603644d93d458a --- .../accessibility/ToggleFeaturePreferenceFragment.java | 9 +++++---- ...eenMagnificationPreferenceFragmentForSetupWizard.java | 4 +++- ...ggleScreenReaderPreferenceFragmentForSetupWizard.java | 3 +++ ...gleSelectToSpeakPreferenceFragmentForSetupWizard.java | 3 +++ 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java index 5747d0a1101..8ee7c8df3fe 100644 --- a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java +++ b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java @@ -78,6 +78,7 @@ import java.util.Locale; public abstract class ToggleFeaturePreferenceFragment extends SettingsPreferenceFragment implements ShortcutPreference.OnClickCallback, OnMainSwitchChangeListener { + protected TopIntroPreference mTopIntroPreference; protected SettingsMainSwitchPreference mToggleServiceSwitchPreference; protected ShortcutPreference mShortcutPreference; protected Preference mSettingsPreference; @@ -476,10 +477,10 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference if (TextUtils.isEmpty(mTopIntroTitle)) { return; } - final TopIntroPreference topIntroPreference = new TopIntroPreference(getPrefContext()); - topIntroPreference.setKey(KEY_TOP_INTRO_PREFERENCE); - topIntroPreference.setTitle(mTopIntroTitle); - getPreferenceScreen().addPreference(topIntroPreference); + mTopIntroPreference = new TopIntroPreference(getPrefContext()); + mTopIntroPreference.setKey(KEY_TOP_INTRO_PREFERENCE); + mTopIntroPreference.setTitle(mTopIntroTitle); + getPreferenceScreen().addPreference(mTopIntroPreference); } private void initToggleServiceSwitchPreference() { diff --git a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentForSetupWizard.java b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentForSetupWizard.java index d92fd510056..cb5ca759df1 100644 --- a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentForSetupWizard.java +++ b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentForSetupWizard.java @@ -40,7 +40,7 @@ public class ToggleScreenMagnificationPreferenceFragmentForSetupWizard final String title = getContext().getString( R.string.accessibility_screen_magnification_title); final String description = getContext().getString( - R.string.accessibility_preference_magnification_summary); + R.string.accessibility_screen_magnification_intro_text); final Drawable icon = getContext().getDrawable(R.drawable.ic_accessibility_visibility); AccessibilitySetupWizardUtils.updateGlifPreferenceLayout(getContext(), layout, title, description, icon); @@ -51,6 +51,8 @@ public class ToggleScreenMagnificationPreferenceFragmentForSetupWizard * Hide the magnification preference settings in the SuW's vision settings. */ private void hidePreferenceSettingComponents() { + // Intro + mTopIntroPreference.setVisible(false); // Setting of magnification type mSettingsPreference.setVisible(false); // Setting of following typing diff --git a/src/com/android/settings/accessibility/ToggleScreenReaderPreferenceFragmentForSetupWizard.java b/src/com/android/settings/accessibility/ToggleScreenReaderPreferenceFragmentForSetupWizard.java index 7adddf9a3ab..f9a1113c054 100644 --- a/src/com/android/settings/accessibility/ToggleScreenReaderPreferenceFragmentForSetupWizard.java +++ b/src/com/android/settings/accessibility/ToggleScreenReaderPreferenceFragmentForSetupWizard.java @@ -46,6 +46,9 @@ public class ToggleScreenReaderPreferenceFragmentForSetupWizard description, icon); mToggleSwitchWasInitiallyChecked = mToggleServiceSwitchPreference.isChecked(); + if (mTopIntroPreference != null) { + mTopIntroPreference.setVisible(false); + } } @Override diff --git a/src/com/android/settings/accessibility/ToggleSelectToSpeakPreferenceFragmentForSetupWizard.java b/src/com/android/settings/accessibility/ToggleSelectToSpeakPreferenceFragmentForSetupWizard.java index b5c11233ac2..a4604191b81 100644 --- a/src/com/android/settings/accessibility/ToggleSelectToSpeakPreferenceFragmentForSetupWizard.java +++ b/src/com/android/settings/accessibility/ToggleSelectToSpeakPreferenceFragmentForSetupWizard.java @@ -46,6 +46,9 @@ public class ToggleSelectToSpeakPreferenceFragmentForSetupWizard description, icon); mToggleSwitchWasInitiallyChecked = mToggleServiceSwitchPreference.isChecked(); + if (mTopIntroPreference != null) { + mTopIntroPreference.setVisible(false); + } } @Override From 6cd9fc0a7eaa89b6852e68200986b8a58ba4d88d Mon Sep 17 00:00:00 2001 From: Wesley Wang Date: Wed, 16 Feb 2022 14:52:43 +0800 Subject: [PATCH 2/3] Refactor compact battery status method (1/2) - Move compact battery status logic into libs Bug: 219650786 Test: make SettingsRoboTests Change-Id: Icc53c8d88235bffedfb51a3526668277fcbf4f40 --- .../fuelgauge/BatteryBroadcastReceiver.java | 3 +- .../settings/fuelgauge/BatteryInfo.java | 41 ++++--------------- .../BatteryBroadcastReceiverTest.java | 10 ++--- 3 files changed, 14 insertions(+), 40 deletions(-) diff --git a/src/com/android/settings/fuelgauge/BatteryBroadcastReceiver.java b/src/com/android/settings/fuelgauge/BatteryBroadcastReceiver.java index 71e65bfdd6b..436cde809a8 100644 --- a/src/com/android/settings/fuelgauge/BatteryBroadcastReceiver.java +++ b/src/com/android/settings/fuelgauge/BatteryBroadcastReceiver.java @@ -112,7 +112,8 @@ public class BatteryBroadcastReceiver extends BroadcastReceiver { if (intent != null && mBatteryListener != null) { if (Intent.ACTION_BATTERY_CHANGED.equals(intent.getAction())) { final String batteryLevel = Utils.getBatteryPercentage(intent); - final String batteryStatus = Utils.getBatteryStatus(mContext, intent); + final String batteryStatus = + Utils.getBatteryStatus(mContext, intent, /* compactStatus= */ false); final int batteryHealth = intent.getIntExtra( BatteryManager.EXTRA_HEALTH, BatteryManager.BATTERY_HEALTH_UNKNOWN); if (!Utils.isBatteryPresent(intent)) { diff --git a/src/com/android/settings/fuelgauge/BatteryInfo.java b/src/com/android/settings/fuelgauge/BatteryInfo.java index 4e90710a639..98f19fedb3d 100644 --- a/src/com/android/settings/fuelgauge/BatteryInfo.java +++ b/src/com/android/settings/fuelgauge/BatteryInfo.java @@ -37,7 +37,6 @@ import com.android.settings.Utils; import com.android.settings.overlay.FeatureFactory; import com.android.settings.widget.UsageView; import com.android.settingslib.R; -import com.android.settingslib.fuelgauge.BatteryStatus; import com.android.settingslib.fuelgauge.Estimate; import com.android.settingslib.fuelgauge.EstimateKt; import com.android.settingslib.utils.PowerUtil; @@ -244,6 +243,8 @@ public class BatteryInfo { @NonNull BatteryUsageStats batteryUsageStats, Estimate estimate, long elapsedRealtimeUs, boolean shortString) { final long startTime = System.currentTimeMillis(); + final boolean isCompactStatus = context.getResources().getBoolean( + com.android.settings.R.bool.config_use_compact_battery_status); BatteryInfo info = new BatteryInfo(); info.mBatteryUsageStats = batteryUsageStats; info.batteryLevel = Utils.getBatteryLevel(batteryBroadcast); @@ -254,21 +255,21 @@ public class BatteryInfo { BatteryManager.EXTRA_HEALTH, BatteryManager.BATTERY_HEALTH_UNKNOWN) == BatteryManager.BATTERY_HEALTH_OVERHEAT; - info.statusLabel = getBatteryStatus(context, batteryBroadcast); + info.statusLabel = Utils.getBatteryStatus(context, batteryBroadcast, isCompactStatus); info.batteryStatus = batteryBroadcast.getIntExtra( BatteryManager.EXTRA_STATUS, BatteryManager.BATTERY_STATUS_UNKNOWN); if (!info.mCharging) { updateBatteryInfoDischarging(context, shortString, estimate, info); } else { updateBatteryInfoCharging(context, batteryBroadcast, batteryUsageStats, - info); + info, isCompactStatus); } BatteryUtils.logRuntime(LOG_TAG, "time for getBatteryInfo", startTime); return info; } private static void updateBatteryInfoCharging(Context context, Intent batteryBroadcast, - BatteryUsageStats stats, BatteryInfo info) { + BatteryUsageStats stats, BatteryInfo info, boolean compactStatus) { final Resources resources = context.getResources(); final long chargeTimeMs = stats.getChargeTimeRemainingMs(); final int status = batteryBroadcast.getIntExtra(BatteryManager.EXTRA_STATUS, @@ -292,7 +293,8 @@ public class BatteryInfo { R.string.power_remaining_charging_duration_only, timeString); info.chargeLabel = context.getString(resId, info.batteryPercentString, timeString); } else { - final String chargeStatusLabel = getBatteryStatus(context, batteryBroadcast); + final String chargeStatusLabel = + Utils.getBatteryStatus(context, batteryBroadcast, compactStatus); info.remainingLabel = null; info.chargeLabel = info.batteryLevel == 100 ? info.batteryPercentString : resources.getString(R.string.power_charging, info.batteryPercentString, @@ -326,35 +328,6 @@ public class BatteryInfo { } } - private static String getBatteryStatus(Context context, Intent batteryChangedIntent) { - final Resources res = context.getResources(); - final boolean isShortStatus = - res.getBoolean(com.android.settings.R.bool.config_use_compact_battery_status); - - if (!isShortStatus) { - return Utils.getBatteryStatus(context, batteryChangedIntent); - } - - final int status = batteryChangedIntent.getIntExtra(BatteryManager.EXTRA_STATUS, - BatteryManager.BATTERY_STATUS_UNKNOWN); - final BatteryStatus batteryStatus = new BatteryStatus(batteryChangedIntent); - String statusString = res.getString(R.string.battery_info_status_unknown); - - if (batteryStatus.isCharged()) { - statusString = res.getString(R.string.battery_info_status_full); - } else { - if (status == BatteryManager.BATTERY_STATUS_CHARGING) { - statusString = res.getString(R.string.battery_info_status_charging); - } else if (status == BatteryManager.BATTERY_STATUS_DISCHARGING) { - statusString = res.getString(R.string.battery_info_status_discharging); - } else if (status == BatteryManager.BATTERY_STATUS_NOT_CHARGING) { - statusString = res.getString(R.string.battery_info_status_not_charging); - } - } - - return statusString; - } - public interface BatteryDataParser { void onParsingStarted(long startTime, long endTime); diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatteryBroadcastReceiverTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryBroadcastReceiverTest.java index 5f08698b4bd..d4469301894 100644 --- a/tests/robotests/src/com/android/settings/fuelgauge/BatteryBroadcastReceiverTest.java +++ b/tests/robotests/src/com/android/settings/fuelgauge/BatteryBroadcastReceiverTest.java @@ -85,8 +85,8 @@ public class BatteryBroadcastReceiverTest { assertThat(mBatteryBroadcastReceiver.mBatteryLevel) .isEqualTo(Utils.getBatteryPercentage(mChargingIntent)); - assertThat(mBatteryBroadcastReceiver.mBatteryStatus) - .isEqualTo(Utils.getBatteryStatus(mContext, mChargingIntent)); + assertThat(mBatteryBroadcastReceiver.mBatteryStatus).isEqualTo( + Utils.getBatteryStatus(mContext, mChargingIntent, /* compactStatus= */ false)); verify(mBatteryListener).onBatteryChanged(BatteryUpdateType.BATTERY_LEVEL); } @@ -134,7 +134,7 @@ public class BatteryBroadcastReceiverTest { public void testOnReceive_batteryDataNotChanged_listenerNotInvoked() { final String batteryLevel = Utils.getBatteryPercentage(mChargingIntent); final String batteryStatus = - Utils.getBatteryStatus(mContext, mChargingIntent); + Utils.getBatteryStatus(mContext, mChargingIntent, /* compactStatus= */ false); mBatteryBroadcastReceiver.mBatteryLevel = batteryLevel; mBatteryBroadcastReceiver.mBatteryStatus = batteryStatus; @@ -159,8 +159,8 @@ public class BatteryBroadcastReceiverTest { assertThat(mBatteryBroadcastReceiver.mBatteryLevel) .isEqualTo(Utils.getBatteryPercentage(mChargingIntent)); - assertThat(mBatteryBroadcastReceiver.mBatteryStatus) - .isEqualTo(Utils.getBatteryStatus(mContext, mChargingIntent)); + assertThat(mBatteryBroadcastReceiver.mBatteryStatus).isEqualTo( + Utils.getBatteryStatus(mContext, mChargingIntent, /* compactStatus= */ false)); assertThat(mBatteryBroadcastReceiver.mBatteryHealth) .isEqualTo(BatteryManager.BATTERY_HEALTH_UNKNOWN); // 2 times because register will force update the battery From cad616bd9aaa610a7cfa45b07140c1c1da550f0f Mon Sep 17 00:00:00 2001 From: menghanli Date: Mon, 21 Feb 2022 11:47:02 +0800 Subject: [PATCH 3/3] Show different tooltips for QS features auto-added and non-auto-added There are 2 different kinds of auto-added / non-auto-added illustrations in QS tooltips for framework features. Show animation in the settings page for full flow for non-framework services. Bug: 218968108 Test: manual testing Change-Id: I9c95c9f3e60ce94ce4059e27ef93c1dacce7a5c7 --- ...ty_auto_added_qs_tooltips_illustration.xml | 62 +++++++++++++++++++ ...cessibilityShortcutPreferenceFragment.java | 4 +- .../ToggleFeaturePreferenceFragment.java | 4 +- 3 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 res/drawable/accessibility_auto_added_qs_tooltips_illustration.xml diff --git a/res/drawable/accessibility_auto_added_qs_tooltips_illustration.xml b/res/drawable/accessibility_auto_added_qs_tooltips_illustration.xml new file mode 100644 index 00000000000..2583b6f32bc --- /dev/null +++ b/res/drawable/accessibility_auto_added_qs_tooltips_illustration.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + diff --git a/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragment.java b/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragment.java index 57987237636..59618d643fd 100644 --- a/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragment.java +++ b/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragment.java @@ -509,7 +509,9 @@ public abstract class AccessibilityShortcutPreferenceFragment extends DashboardF ? R.string.accessibility_service_qs_tooltips_content : R.string.accessibility_service_auto_added_qs_tooltips_content; final String title = getString(titleResId, tileName); - final int imageResId = R.drawable.accessibility_qs_tooltips_illustration; + final int imageResId = mNeedsQSTooltipType == QuickSettingsTooltipType.GUIDE_TO_EDIT + ? R.drawable.accessibility_qs_tooltips_illustration + : R.drawable.accessibility_auto_added_qs_tooltips_illustration; mTooltipWindow = new AccessibilityQuickSettingsTooltipWindow(getContext()); mTooltipWindow.setup(title, imageResId); mTooltipWindow.showAtTopCenter(getView()); diff --git a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java index 5992ceb1c1c..9cf2c26967c 100644 --- a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java +++ b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java @@ -879,7 +879,9 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference ? R.string.accessibility_service_qs_tooltips_content : R.string.accessibility_service_auto_added_qs_tooltips_content; final String title = getString(titleResId, tileName); - final int imageResId = R.drawable.accessibility_qs_tooltips_illustration; + final int imageResId = mNeedsQSTooltipType == QuickSettingsTooltipType.GUIDE_TO_EDIT + ? R.drawable.accessibility_qs_tooltips_illustration + : R.drawable.accessibility_auto_added_qs_tooltips_illustration; mTooltipWindow = new AccessibilityQuickSettingsTooltipWindow(getContext()); mTooltipWindow.setup(title, imageResId); mTooltipWindow.showAtTopCenter(getView());