Merge "Smartspace - Allow clicks to avoid intent launch" into sc-v2-dev

This commit is contained in:
TreeHugger Robot
2021-10-27 18:58:22 +00:00
committed by Android (Google) Code Review
2 changed files with 25 additions and 9 deletions

View File

@@ -123,18 +123,18 @@ public interface BcSmartspaceDataPlugin extends Plugin {
/** Interface for launching Intents, which can differ on the lockscreen */
interface IntentStarter {
default void startFromAction(SmartspaceAction action, View v) {
default void startFromAction(SmartspaceAction action, View v, boolean showOnLockscreen) {
if (action.getIntent() != null) {
startIntent(v, action.getIntent());
startIntent(v, action.getIntent(), showOnLockscreen);
} else if (action.getPendingIntent() != null) {
startPendingIntent(action.getPendingIntent());
startPendingIntent(action.getPendingIntent(), showOnLockscreen);
}
}
/** Start the intent */
void startIntent(View v, Intent i);
void startIntent(View v, Intent i, boolean showOnLockscreen);
/** Start the PendingIntent */
void startPendingIntent(PendingIntent pi);
void startPendingIntent(PendingIntent pi, boolean showOnLockscreen);
}
}

View File

@@ -34,6 +34,7 @@ import android.view.View
import android.view.ViewGroup
import com.android.settingslib.Utils
import com.android.systemui.R
import com.android.systemui.animation.ActivityLaunchAnimator
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.plugins.ActivityStarter
@@ -188,13 +189,28 @@ class LockscreenSmartspaceController @Inject constructor(
val ssView = plugin.getView(parent)
ssView.registerDataProvider(plugin)
val animationController = ActivityLaunchAnimator.Controller.fromView(
ssView as View,
null /* cujType */
)
ssView.setIntentStarter(object : BcSmartspaceDataPlugin.IntentStarter {
override fun startIntent(v: View?, i: Intent?) {
activityStarter.startActivity(i, true /* dismissShade */)
override fun startIntent(v: View?, i: Intent?, showOnLockscreen: Boolean) {
activityStarter.startActivity(
i,
true, /* dismissShade */
animationController,
showOnLockscreen
)
}
override fun startPendingIntent(pi: PendingIntent?) {
activityStarter.startPendingIntentDismissingKeyguard(pi)
override fun startPendingIntent(pi: PendingIntent?, showOnLockscreen: Boolean) {
if (showOnLockscreen) {
pi?.send()
} else {
activityStarter.startPendingIntentDismissingKeyguard(pi)
}
}
})
ssView.setFalsingManager(falsingManager)