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

Commit 0cb3a6e0 authored by Danesh Mondegarian's avatar Danesh Mondegarian Committed by Danesh M
Browse files

NavTargets : Show highlight for google search

- Show highlight for google now icon
- Update launching logic to upstream
- Don't hideTargets in doFinish

Change-Id: I6027bc30b4bc98bf1dbadd9cb02e46349745bfbb
parent 47a25227
Loading
Loading
Loading
Loading
+29 −1
Original line number Diff line number Diff line
@@ -279,9 +279,37 @@ public class NavigationRingHelpers {
        if (intent != null) {
            ComponentName component = intent.getComponent();
            if (component != null) {
                view.replaceTargetDrawablesIfPresent(component,
                boolean replaced = view.replaceTargetDrawablesIfPresent(component,
                        ASSIST_ICON_METADATA_NAME,
                        com.android.internal.R.drawable.ic_action_assist_generic);
                if (replaced) {
                    addFocusedStateToSearchIconIfMissing(context, view);
                }
            }
        }
    }

    private static void addFocusedStateToSearchIconIfMissing(Context context, GlowPadView view) {
        for (TargetDrawable target : view.getTargetDrawables()) {
            if (target != null && target.getResourceId() ==
                    com.android.internal.R.drawable.ic_action_assist_generic) {
                Drawable drawable = target.getDrawable();
                if (drawable instanceof StateListDrawable) {
                    StateListDrawable d = (StateListDrawable) drawable;
                    int inActiveIndex = d.getStateDrawableIndex(TargetDrawable.STATE_INACTIVE);
                    int activeIndex = d.getStateDrawableIndex(TargetDrawable.STATE_ACTIVE);
                    if (inActiveIndex != -1 && activeIndex != -1) {
                        StateListDrawable selector = new StateListDrawable();
                        selector.addState(TargetDrawable.STATE_INACTIVE,
                                d.getStateDrawable(inActiveIndex));
                        selector.addState(TargetDrawable.STATE_ACTIVE,
                                d.getStateDrawable(activeIndex));
                        selector.addState(TargetDrawable.STATE_FOCUSED,
                                d.getStateDrawable(activeIndex));
                        target.setDrawable(selector);
                    }
                }
                break;
            }
        }
    }
+0 −1
Original line number Diff line number Diff line
@@ -468,7 +468,6 @@ public class GlowPadView extends View {
                // Force ring and targets to finish animation to final expanded state
                mTargetAnimations.stop();
            }
            hideTargets(false, false);
        } else {
            // Animate handle back to the center based on current state.
            hideGlow(HIDE_ANIMATION_DURATION, 0, 0.0f, mResetListenerWithPing);
+10 −0
Original line number Diff line number Diff line
@@ -63,6 +63,12 @@ public class TargetDrawable {
        setState(STATE_INACTIVE);
    }

    public void setDrawable(Drawable drawable) {
        mDrawable = drawable != null ? drawable.mutate() : null;
        resizeDrawables();
        setState(STATE_INACTIVE);
    }

    public TargetDrawable(Resources res, Drawable drawable) {
        mResourceId = 0;
        // Mutate the drawable so we can animate shared drawable properties.
@@ -217,6 +223,10 @@ public class TargetDrawable {
        return mDrawable != null ? mDrawable.getIntrinsicHeight() : 0;
    }

    public Drawable getDrawable() {
        return mDrawable;
    }

    public void draw(Canvas canvas) {
        if (mDrawable == null || !mEnabled) {
            return;
+6 −2
Original line number Diff line number Diff line
@@ -107,12 +107,16 @@ public class SearchPanelView extends FrameLayout implements
            Bundle options = null;

            if (isAssist) {
                mWaitingForLaunch = true;
                vibrate();
                if (!mBar.isDeviceProvisioned()) {
                    return;
                }
                mBar.animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_SEARCH_PANEL);
                ActivityOptions opts = ActivityOptions.makeCustomAnimation(mContext,
                        R.anim.search_launch_enter, R.anim.search_launch_exit,
                        getHandler(), SearchPanelView.this);
                options = opts.toBundle();
                mWaitingForLaunch = true;
                vibrate();
            }

            boolean result = mActionTarget.launchAction(
+20 −3
Original line number Diff line number Diff line
@@ -19,6 +19,9 @@ package com.android.systemui.cm;

import android.app.ActivityManager;
import android.app.ActivityManagerNative;
import android.app.ActivityOptions;
import android.app.KeyguardManager;
import android.app.SearchManager;
import android.content.ActivityNotFoundException;
import android.content.ComponentName;
import android.content.Context;
@@ -50,6 +53,7 @@ import com.android.internal.util.cm.TorchConstants;
import static com.android.internal.util.cm.NavigationRingConstants.*;
import com.android.systemui.R;
import com.android.systemui.screenshot.TakeScreenshotService;
import com.android.systemui.statusbar.phone.KeyguardTouchDelegate;

import java.net.URISyntaxException;

@@ -62,7 +66,7 @@ public class ActionTarget {
    private AudioManager mAm;
    private Context mContext;
    private Handler mHandler;

    private KeyguardManager mKeyguardManager;
    private int mInjectKeyCode;

    private final Object mScreenshotLock = new Object();
@@ -72,6 +76,7 @@ public class ActionTarget {
        mContext = context;
        mHandler = new Handler();
        mAm = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
        mKeyguardManager = (KeyguardManager) mContext.getSystemService(Context.KEYGUARD_SERVICE);
    }

    public boolean launchAction(String action) {
@@ -109,9 +114,21 @@ public class ActionTarget {
            takeScreenshot();
            return true;
        } else if (action.equals(ACTION_ASSIST)) {
            Intent intent = new Intent(Intent.ACTION_ASSIST);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            boolean isKeyguardShowing = mKeyguardManager.isKeyguardLocked();
            if (isKeyguardShowing) {
                // Have keyguard show the bouncer and launch the activity if the user succeeds.
                KeyguardTouchDelegate.getInstance(mContext).showAssistant();
                return false;
            }

            // Otherwise, keyguard isn't showing so launch it from here.
            SearchManager searchManager = ((SearchManager) mContext
                    .getSystemService(Context.SEARCH_SERVICE));
            Intent intent = searchManager.getAssistIntent(mContext, true, UserHandle.USER_CURRENT);
            if (intent == null) {
                return false;
            }
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            try {
                dismissKeyguard();
                mContext.startActivityAsUser(intent, opts, UserHandle.CURRENT);