Loading packages/SystemUI/res/values/strings.xml +4 −0 Original line number Diff line number Diff line Loading @@ -2562,6 +2562,10 @@ =1 {# notification} other {# notifications} }</string> <!-- Accessibility label for weather complication on dreams with weather condition and temperature [CHAR_LIMIT=200] --> <string name="dream_overlay_weather_complication_desc"> <xliff:g id="weather_condition" example="Partly cloudy">%1$s</xliff:g>, <xliff:g id="temperature" example="7°C">%2$s</xliff:g> </string> <!-- [CHAR LIMIT=NONE] Le audio broadcast dialog, media app is broadcasting --> <string name="broadcasting_description_is_broadcasting">Broadcasting</string> Loading packages/SystemUI/src/com/android/systemui/dreams/complication/DreamWeatherComplication.java +24 −3 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.app.smartspace.SmartspaceAction; import android.app.smartspace.SmartspaceTarget; import android.content.Context; import android.content.Intent; import android.content.res.Resources; import android.graphics.drawable.Drawable; import android.graphics.drawable.Icon; import android.text.TextUtils; Loading Loading @@ -133,16 +134,19 @@ public class DreamWeatherComplication implements Complication { private final ActivityStarter mActivityStarter; private final String mSmartspaceTrampolineActivityComponent; private SmartspaceTargetListener mSmartspaceTargetListener; private final Resources mResources; @Inject DreamWeatherViewController( @Named(DREAM_WEATHER_COMPLICATION_VIEW) TextView view, @Named(SMARTSPACE_TRAMPOLINE_ACTIVITY_COMPONENT) String smartspaceTrampoline, ActivityStarter activityStarter, DreamSmartspaceController smartspaceController DreamSmartspaceController smartspaceController, Resources resources ) { super(view); mActivityStarter = activityStarter; mResources = resources; mSmartSpaceController = smartspaceController; mSmartspaceTrampolineActivityComponent = smartspaceTrampoline; } Loading @@ -161,8 +165,10 @@ public class DreamWeatherComplication implements Complication { return; } String temperature = headerAction.getTitle().toString(); final CharSequence temperature = headerAction.getTitle(); mView.setText(temperature); mView.setContentDescription(getFormattedContentDescription(temperature, headerAction.getContentDescription())); final Icon icon = headerAction.getIcon(); if (icon != null) { final int iconSize = Loading @@ -174,7 +180,6 @@ public class DreamWeatherComplication implements Complication { mView.setCompoundDrawablePadding( getResources().getDimensionPixelSize( R.dimen.smart_action_button_icon_padding)); } mView.setOnClickListener(v -> { final Intent intent = headerAction.getIntent(); Loading @@ -196,5 +201,21 @@ public class DreamWeatherComplication implements Complication { protected void onViewDetached() { mSmartSpaceController.removeUnfilteredListener(mSmartspaceTargetListener); } /** * Returns a formatted content description for accessibility of the weather condition and * temperature. */ private CharSequence getFormattedContentDescription(CharSequence temperature, CharSequence weatherCondition) { if (TextUtils.isEmpty(temperature)) { return weatherCondition; } else if (TextUtils.isEmpty(weatherCondition)) { return temperature; } return mResources.getString(R.string.dream_overlay_weather_complication_desc, weatherCondition, temperature); } } } packages/SystemUI/src/com/android/systemui/dreams/complication/dagger/DreamWeatherComplicationComponent.java +10 −0 Original line number Diff line number Diff line Loading @@ -19,12 +19,14 @@ package com.android.systemui.dreams.complication.dagger; import static java.lang.annotation.RetentionPolicy.RUNTIME; import android.content.res.Resources; import android.view.LayoutInflater; import android.view.ViewGroup; import android.widget.TextView; import com.android.internal.util.Preconditions; import com.android.systemui.R; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.dreams.complication.ComplicationLayoutParams; import com.android.systemui.dreams.complication.DreamWeatherComplication.DreamWeatherViewHolder; Loading @@ -34,6 +36,7 @@ import java.lang.annotation.Retention; import javax.inject.Named; import javax.inject.Scope; import dagger.Binds; import dagger.Module; import dagger.Provides; import dagger.Subcomponent; Loading Loading @@ -106,5 +109,12 @@ public interface DreamWeatherComplicationComponent { ComplicationLayoutParams.DIRECTION_END, INSERT_ORDER_WEIGHT, /* snapToGuide= */ true); } /** * Binds resources in the dream weather complication scope. */ @Binds @DreamWeatherComplicationScope Resources getResources(@Main Resources resources); } } packages/SystemUI/tests/src/com/android/systemui/dreams/complication/DreamWeatherComplicationTest.java +2 −1 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import android.content.Context; import android.content.res.Resources; import android.testing.AndroidTestingRunner; import android.widget.TextView; Loading Loading @@ -79,7 +80,7 @@ public class DreamWeatherComplicationTest extends SysuiTestCase { final DreamWeatherComplication.DreamWeatherViewController controller = new DreamWeatherComplication.DreamWeatherViewController(mock( TextView.class), TRAMPOLINE_COMPONENT, mock(ActivityStarter.class), mDreamSmartspaceController); mDreamSmartspaceController, mock(Resources.class)); controller.onViewAttached(); verify(mDreamSmartspaceController).addUnfilteredListener(any()); controller.onViewDetached(); Loading Loading
packages/SystemUI/res/values/strings.xml +4 −0 Original line number Diff line number Diff line Loading @@ -2562,6 +2562,10 @@ =1 {# notification} other {# notifications} }</string> <!-- Accessibility label for weather complication on dreams with weather condition and temperature [CHAR_LIMIT=200] --> <string name="dream_overlay_weather_complication_desc"> <xliff:g id="weather_condition" example="Partly cloudy">%1$s</xliff:g>, <xliff:g id="temperature" example="7°C">%2$s</xliff:g> </string> <!-- [CHAR LIMIT=NONE] Le audio broadcast dialog, media app is broadcasting --> <string name="broadcasting_description_is_broadcasting">Broadcasting</string> Loading
packages/SystemUI/src/com/android/systemui/dreams/complication/DreamWeatherComplication.java +24 −3 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.app.smartspace.SmartspaceAction; import android.app.smartspace.SmartspaceTarget; import android.content.Context; import android.content.Intent; import android.content.res.Resources; import android.graphics.drawable.Drawable; import android.graphics.drawable.Icon; import android.text.TextUtils; Loading Loading @@ -133,16 +134,19 @@ public class DreamWeatherComplication implements Complication { private final ActivityStarter mActivityStarter; private final String mSmartspaceTrampolineActivityComponent; private SmartspaceTargetListener mSmartspaceTargetListener; private final Resources mResources; @Inject DreamWeatherViewController( @Named(DREAM_WEATHER_COMPLICATION_VIEW) TextView view, @Named(SMARTSPACE_TRAMPOLINE_ACTIVITY_COMPONENT) String smartspaceTrampoline, ActivityStarter activityStarter, DreamSmartspaceController smartspaceController DreamSmartspaceController smartspaceController, Resources resources ) { super(view); mActivityStarter = activityStarter; mResources = resources; mSmartSpaceController = smartspaceController; mSmartspaceTrampolineActivityComponent = smartspaceTrampoline; } Loading @@ -161,8 +165,10 @@ public class DreamWeatherComplication implements Complication { return; } String temperature = headerAction.getTitle().toString(); final CharSequence temperature = headerAction.getTitle(); mView.setText(temperature); mView.setContentDescription(getFormattedContentDescription(temperature, headerAction.getContentDescription())); final Icon icon = headerAction.getIcon(); if (icon != null) { final int iconSize = Loading @@ -174,7 +180,6 @@ public class DreamWeatherComplication implements Complication { mView.setCompoundDrawablePadding( getResources().getDimensionPixelSize( R.dimen.smart_action_button_icon_padding)); } mView.setOnClickListener(v -> { final Intent intent = headerAction.getIntent(); Loading @@ -196,5 +201,21 @@ public class DreamWeatherComplication implements Complication { protected void onViewDetached() { mSmartSpaceController.removeUnfilteredListener(mSmartspaceTargetListener); } /** * Returns a formatted content description for accessibility of the weather condition and * temperature. */ private CharSequence getFormattedContentDescription(CharSequence temperature, CharSequence weatherCondition) { if (TextUtils.isEmpty(temperature)) { return weatherCondition; } else if (TextUtils.isEmpty(weatherCondition)) { return temperature; } return mResources.getString(R.string.dream_overlay_weather_complication_desc, weatherCondition, temperature); } } }
packages/SystemUI/src/com/android/systemui/dreams/complication/dagger/DreamWeatherComplicationComponent.java +10 −0 Original line number Diff line number Diff line Loading @@ -19,12 +19,14 @@ package com.android.systemui.dreams.complication.dagger; import static java.lang.annotation.RetentionPolicy.RUNTIME; import android.content.res.Resources; import android.view.LayoutInflater; import android.view.ViewGroup; import android.widget.TextView; import com.android.internal.util.Preconditions; import com.android.systemui.R; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.dreams.complication.ComplicationLayoutParams; import com.android.systemui.dreams.complication.DreamWeatherComplication.DreamWeatherViewHolder; Loading @@ -34,6 +36,7 @@ import java.lang.annotation.Retention; import javax.inject.Named; import javax.inject.Scope; import dagger.Binds; import dagger.Module; import dagger.Provides; import dagger.Subcomponent; Loading Loading @@ -106,5 +109,12 @@ public interface DreamWeatherComplicationComponent { ComplicationLayoutParams.DIRECTION_END, INSERT_ORDER_WEIGHT, /* snapToGuide= */ true); } /** * Binds resources in the dream weather complication scope. */ @Binds @DreamWeatherComplicationScope Resources getResources(@Main Resources resources); } }
packages/SystemUI/tests/src/com/android/systemui/dreams/complication/DreamWeatherComplicationTest.java +2 −1 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import android.content.Context; import android.content.res.Resources; import android.testing.AndroidTestingRunner; import android.widget.TextView; Loading Loading @@ -79,7 +80,7 @@ public class DreamWeatherComplicationTest extends SysuiTestCase { final DreamWeatherComplication.DreamWeatherViewController controller = new DreamWeatherComplication.DreamWeatherViewController(mock( TextView.class), TRAMPOLINE_COMPONENT, mock(ActivityStarter.class), mDreamSmartspaceController); mDreamSmartspaceController, mock(Resources.class)); controller.onViewAttached(); verify(mDreamSmartspaceController).addUnfilteredListener(any()); controller.onViewDetached(); Loading