Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1b334260 authored by Darrell Shi's avatar Darrell Shi Committed by Automerger Merge Worker
Browse files

Merge "Add content description for weather complication." into tm-qpr-dev am: 86c7277c

parents 5f5799af 86c7277c
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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>
+24 −3
Original line number Diff line number Diff line
@@ -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;
@@ -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;
        }
@@ -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 =
@@ -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();
@@ -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);
        }
    }
}
+10 −0
Original line number Diff line number Diff line
@@ -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;

@@ -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;
@@ -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);
    }
}
+2 −1
Original line number Diff line number Diff line
@@ -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;

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