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..69b8f75c060 100644 --- a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java +++ b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java @@ -79,6 +79,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; @@ -483,10 +484,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() { @@ -879,7 +880,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()); 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 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