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

Commit fbd0d98b authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Tap on weather complication to launch activity." into tm-qpr-dev

parents ed5d66a6 52c638ba
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -441,6 +441,9 @@
         they were added. -->
    <integer name="config_smart_replies_in_notifications_onclick_init_delay">200</integer>

    <!-- Smartspace trampoline activity that is used when the user taps smartspace. -->
    <string name="config_smartspaceTrampolineActivityComponent" translatable="false">com.google.android.apps.gsa.staticplugins.opa.smartspace.ExportedSmartspaceTrampolineActivity</string>

    <!-- Screenshot editing default activity.  Must handle ACTION_EDIT image/png intents.
         Blank sends the user to the Chooser first.
         This name is in the ComponentName flattened format (package/class)  -->
+18 −0
Original line number Diff line number Diff line
@@ -18,10 +18,12 @@ package com.android.systemui.dreams.complication;

import static com.android.systemui.dreams.complication.dagger.DreamWeatherComplicationComponent.DreamWeatherComplicationModule.DREAM_WEATHER_COMPLICATION_LAYOUT_PARAMS;
import static com.android.systemui.dreams.complication.dagger.DreamWeatherComplicationComponent.DreamWeatherComplicationModule.DREAM_WEATHER_COMPLICATION_VIEW;
import static com.android.systemui.dreams.complication.dagger.DreamWeatherComplicationComponent.DreamWeatherComplicationModule.SMARTSPACE_TRAMPOLINE_ACTIVITY_COMPONENT;

import android.app.smartspace.SmartspaceAction;
import android.app.smartspace.SmartspaceTarget;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Icon;
import android.text.TextUtils;
@@ -31,6 +33,7 @@ import com.android.systemui.CoreStartable;
import com.android.systemui.R;
import com.android.systemui.dreams.DreamOverlayStateController;
import com.android.systemui.dreams.complication.dagger.DreamWeatherComplicationComponent;
import com.android.systemui.plugins.ActivityStarter;
import com.android.systemui.plugins.BcSmartspaceDataPlugin.SmartspaceTargetListener;
import com.android.systemui.statusbar.lockscreen.LockscreenSmartspaceController;
import com.android.systemui.util.ViewController;
@@ -132,15 +135,21 @@ public class DreamWeatherComplication implements Complication {
     */
    static class DreamWeatherViewController extends ViewController<TextView> {
        private final LockscreenSmartspaceController mSmartSpaceController;
        private final ActivityStarter mActivityStarter;
        private final String mSmartspaceTrampolineActivityComponent;
        private SmartspaceTargetListener mSmartspaceTargetListener;

        @Inject
        DreamWeatherViewController(
                @Named(DREAM_WEATHER_COMPLICATION_VIEW) TextView view,
                @Named(SMARTSPACE_TRAMPOLINE_ACTIVITY_COMPONENT) String smartspaceTrampoline,
                ActivityStarter activityStarter,
                LockscreenSmartspaceController smartspaceController
        ) {
            super(view);
            mActivityStarter = activityStarter;
            mSmartSpaceController = smartspaceController;
            mSmartspaceTrampolineActivityComponent = smartspaceTrampoline;
        }

        @Override
@@ -172,6 +181,15 @@ public class DreamWeatherComplication implements Complication {
                                                R.dimen.smart_action_button_icon_padding));

                            }
                            mView.setOnClickListener(v -> {
                                final Intent intent = headerAction.getIntent();
                                if (intent != null && intent.getComponent() != null
                                        && intent.getComponent().getClassName()
                                        .equals(mSmartspaceTrampolineActivityComponent)) {
                                    mActivityStarter.postStartActivityDismissingKeyguard(
                                            intent, 0 /*delay*/);
                                }
                            });
                        }
                    });
            mSmartSpaceController.addListener(mSmartspaceTargetListener);
+12 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.systemui.dreams.complication.dagger;

import static java.lang.annotation.RetentionPolicy.RUNTIME;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.widget.TextView;
@@ -76,6 +77,7 @@ public interface DreamWeatherComplicationComponent {
        String DREAM_WEATHER_COMPLICATION_VIEW = "weather_complication_view";
        String DREAM_WEATHER_COMPLICATION_LAYOUT_PARAMS =
                "weather_complication_layout_params";
        String SMARTSPACE_TRAMPOLINE_ACTIVITY_COMPONENT = "smartspace_trampoline_activity";
        // Order weight of insert into parent container
        int INSERT_ORDER_WEIGHT = 1;

@@ -106,5 +108,15 @@ public interface DreamWeatherComplicationComponent {
                    ComplicationLayoutParams.DIRECTION_END,
                    INSERT_ORDER_WEIGHT);
        }

        /**
         * Provides the smartspace trampoline activity component.
         */
        @Provides
        @DreamWeatherComplicationScope
        @Named(SMARTSPACE_TRAMPOLINE_ACTIVITY_COMPONENT)
        static String provideSmartspaceTrampolineActivityComponent(Context context) {
            return context.getString(R.string.config_smartspaceTrampolineActivityComponent);
        }
    }
}