Merge "Allow wireless charging label to customize content descriptions" into main
This commit is contained in:
@@ -97,6 +97,9 @@ public class BatteryHeaderPreferenceController extends BasePreferenceController
|
|||||||
final CharSequence wirelessChargingLabel =
|
final CharSequence wirelessChargingLabel =
|
||||||
mBatterySettingsFeatureProvider.getWirelessChargingLabel(mContext, info);
|
mBatterySettingsFeatureProvider.getWirelessChargingLabel(mContext, info);
|
||||||
if (wirelessChargingLabel != null) {
|
if (wirelessChargingLabel != null) {
|
||||||
|
mBatteryUsageProgressBarPref.setBottomSummaryContentDescription(
|
||||||
|
mBatterySettingsFeatureProvider
|
||||||
|
.getWirelessChargingContentDescription(mContext, info));
|
||||||
return wirelessChargingLabel;
|
return wirelessChargingLabel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -49,6 +49,11 @@ public interface BatterySettingsFeatureProvider {
|
|||||||
@Nullable
|
@Nullable
|
||||||
CharSequence getWirelessChargingLabel(@NonNull Context context, @NonNull BatteryInfo info);
|
CharSequence getWirelessChargingLabel(@NonNull Context context, @NonNull BatteryInfo info);
|
||||||
|
|
||||||
|
/** Return a content description for the bottom summary during wireless charging. */
|
||||||
|
@Nullable
|
||||||
|
CharSequence getWirelessChargingContentDescription(
|
||||||
|
@NonNull Context context, @NonNull BatteryInfo info);
|
||||||
|
|
||||||
/** Return a charging remaining time label for wireless charging. */
|
/** Return a charging remaining time label for wireless charging. */
|
||||||
@Nullable
|
@Nullable
|
||||||
CharSequence getWirelessChargingRemainingLabel(
|
CharSequence getWirelessChargingRemainingLabel(
|
||||||
|
@@ -61,6 +61,13 @@ public class BatterySettingsFeatureProviderImpl implements BatterySettingsFeatur
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public CharSequence getWirelessChargingContentDescription(
|
||||||
|
@NonNull Context context, @NonNull BatteryInfo info) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public CharSequence getWirelessChargingRemainingLabel(
|
public CharSequence getWirelessChargingRemainingLabel(
|
||||||
|
@@ -19,6 +19,7 @@ import static com.google.common.truth.Truth.assertThat;
|
|||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Mockito.doReturn;
|
import static org.mockito.Mockito.doReturn;
|
||||||
|
import static org.mockito.Mockito.never;
|
||||||
import static org.mockito.Mockito.spy;
|
import static org.mockito.Mockito.spy;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.verifyNoInteractions;
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
@@ -278,6 +279,7 @@ public class BatteryHeaderPreferenceControllerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void updateBatteryStatus_customizedWirelessChargingLabel_customizedLabel() {
|
public void updateBatteryStatus_customizedWirelessChargingLabel_customizedLabel() {
|
||||||
var label = "Customized Wireless Charging Label";
|
var label = "Customized Wireless Charging Label";
|
||||||
|
var contentDescription = "Customized Wireless Charging description";
|
||||||
var batteryInfo =
|
var batteryInfo =
|
||||||
arrangeUpdateBatteryStatusTestWithRemainingLabel(
|
arrangeUpdateBatteryStatusTestWithRemainingLabel(
|
||||||
/* remainingLabel= */ "Full by 1:30 PM",
|
/* remainingLabel= */ "Full by 1:30 PM",
|
||||||
@@ -288,14 +290,19 @@ public class BatteryHeaderPreferenceControllerTest {
|
|||||||
when(mFactory.batterySettingsFeatureProvider.getWirelessChargingLabel(
|
when(mFactory.batterySettingsFeatureProvider.getWirelessChargingLabel(
|
||||||
eq(mContext), any(BatteryInfo.class)))
|
eq(mContext), any(BatteryInfo.class)))
|
||||||
.thenReturn(label);
|
.thenReturn(label);
|
||||||
|
when(mFactory.batterySettingsFeatureProvider.getWirelessChargingContentDescription(
|
||||||
|
eq(mContext), any(BatteryInfo.class)))
|
||||||
|
.thenReturn(contentDescription);
|
||||||
|
|
||||||
mController.updateBatteryStatus(/* label= */ null, batteryInfo);
|
mController.updateBatteryStatus(/* label= */ null, batteryInfo);
|
||||||
|
|
||||||
verify(mBatteryUsageProgressBarPref).setBottomSummary(label);
|
verify(mBatteryUsageProgressBarPref).setBottomSummary(label);
|
||||||
|
verify(mBatteryUsageProgressBarPref).setBottomSummaryContentDescription(contentDescription);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateBatteryStatus_noCustomizedWirelessChargingLabel_statusWithRemainingLabel() {
|
public void updateBatteryStatus_noCustomizedWirelessChargingLabel_statusWithRemainingLabel() {
|
||||||
|
var contentDescription = "Customized Wireless Charging description";
|
||||||
var batteryInfo =
|
var batteryInfo =
|
||||||
arrangeUpdateBatteryStatusTestWithRemainingLabel(
|
arrangeUpdateBatteryStatusTestWithRemainingLabel(
|
||||||
/* remainingLabel= */ "Full by 1:30 PM",
|
/* remainingLabel= */ "Full by 1:30 PM",
|
||||||
@@ -308,10 +315,13 @@ public class BatteryHeaderPreferenceControllerTest {
|
|||||||
mController.updateBatteryStatus(/* label= */ null, batteryInfo);
|
mController.updateBatteryStatus(/* label= */ null, batteryInfo);
|
||||||
|
|
||||||
verify(mBatteryUsageProgressBarPref).setBottomSummary(expectedChargingString);
|
verify(mBatteryUsageProgressBarPref).setBottomSummary(expectedChargingString);
|
||||||
|
verify(mBatteryUsageProgressBarPref, never())
|
||||||
|
.setBottomSummaryContentDescription(contentDescription);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateBatteryStatus_noCustomizedWirelessChargingLabel_v1StatusWithRemainingLabel() {
|
public void updateBatteryStatus_noCustomizedWirelessChargingLabel_v1StatusWithRemainingLabel() {
|
||||||
|
var contentDescription = "Customized Wireless Charging description";
|
||||||
var batteryInfo =
|
var batteryInfo =
|
||||||
arrangeUpdateBatteryStatusTestWithRemainingLabel(
|
arrangeUpdateBatteryStatusTestWithRemainingLabel(
|
||||||
/* remainingLabel= */ "1 hr, 40 min left until full",
|
/* remainingLabel= */ "1 hr, 40 min left until full",
|
||||||
@@ -324,6 +334,8 @@ public class BatteryHeaderPreferenceControllerTest {
|
|||||||
mController.updateBatteryStatus(/* label= */ null, batteryInfo);
|
mController.updateBatteryStatus(/* label= */ null, batteryInfo);
|
||||||
|
|
||||||
verify(mBatteryUsageProgressBarPref).setBottomSummary(expectedChargingString);
|
verify(mBatteryUsageProgressBarPref).setBottomSummary(expectedChargingString);
|
||||||
|
verify(mBatteryUsageProgressBarPref, never())
|
||||||
|
.setBottomSummaryContentDescription(contentDescription);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@@ -76,6 +76,12 @@ public class BatterySettingsFeatureProviderImplTest {
|
|||||||
assertThat(mImpl.getWirelessChargingLabel(mContext, new BatteryInfo())).isNull();
|
assertThat(mImpl.getWirelessChargingLabel(mContext, new BatteryInfo())).isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getWirelessChargingContentDescription_returnNull() {
|
||||||
|
assertThat(mImpl.getWirelessChargingContentDescription(mContext, new BatteryInfo()))
|
||||||
|
.isNull();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getWirelessChargingRemainingLabel_returnNull() {
|
public void getWirelessChargingRemainingLabel_returnNull() {
|
||||||
assertThat(mImpl.getWirelessChargingRemainingLabel(mContext, 1000L, 1000L)).isNull();
|
assertThat(mImpl.getWirelessChargingRemainingLabel(mContext, 1000L, 1000L)).isNull();
|
||||||
|
Reference in New Issue
Block a user