summaryrefslogtreecommitdiff
path: root/packages/SystemUI/plugin/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/SystemUI/plugin/src')
-rw-r--r--packages/SystemUI/plugin/src/com/android/systemui/plugins/ActivityStarter.java11
-rw-r--r--packages/SystemUI/plugin/src/com/android/systemui/plugins/ClockPlugin.java58
-rw-r--r--packages/SystemUI/plugin/src/com/android/systemui/plugins/FalsingPlugin.java39
-rw-r--r--packages/SystemUI/plugin/src/com/android/systemui/plugins/Plugin.java129
-rw-r--r--packages/SystemUI/plugin/src/com/android/systemui/plugins/PluginFragment.java45
-rw-r--r--packages/SystemUI/plugin/src/com/android/systemui/plugins/PluginListener.java38
-rw-r--r--packages/SystemUI/plugin/src/com/android/systemui/plugins/SensorManagerPlugin.java91
-rw-r--r--packages/SystemUI/plugin/src/com/android/systemui/plugins/annotations/Dependencies.java27
-rw-r--r--packages/SystemUI/plugin/src/com/android/systemui/plugins/annotations/DependsOn.java32
-rw-r--r--packages/SystemUI/plugin/src/com/android/systemui/plugins/annotations/ProvidesInterface.java30
-rw-r--r--packages/SystemUI/plugin/src/com/android/systemui/plugins/annotations/Requirements.java27
-rw-r--r--packages/SystemUI/plugin/src/com/android/systemui/plugins/annotations/Requires.java33
-rw-r--r--packages/SystemUI/plugin/src/com/android/systemui/plugins/qs/QSIconView.java2
-rw-r--r--packages/SystemUI/plugin/src/com/android/systemui/plugins/statusbar/NotificationMenuRowPlugin.java126
-rw-r--r--packages/SystemUI/plugin/src/com/android/systemui/plugins/statusbar/NotificationSwipeActionHelper.java2
-rw-r--r--packages/SystemUI/plugin/src/com/android/systemui/plugins/statusbar/phone/NavGesture.java5
16 files changed, 320 insertions, 375 deletions
diff --git a/packages/SystemUI/plugin/src/com/android/systemui/plugins/ActivityStarter.java b/packages/SystemUI/plugin/src/com/android/systemui/plugins/ActivityStarter.java
index b58ea00997ef..f4922088bb05 100644
--- a/packages/SystemUI/plugin/src/com/android/systemui/plugins/ActivityStarter.java
+++ b/packages/SystemUI/plugin/src/com/android/systemui/plugins/ActivityStarter.java
@@ -14,6 +14,7 @@
package com.android.systemui.plugins;
+import android.annotation.Nullable;
import android.app.PendingIntent;
import android.content.Intent;
@@ -36,7 +37,17 @@ public interface ActivityStarter {
void postStartActivityDismissingKeyguard(PendingIntent intent);
void postQSRunnableDismissingKeyguard(Runnable runnable);
+ void dismissKeyguardThenExecute(OnDismissAction action, @Nullable Runnable cancel,
+ boolean afterKeyguardGone);
+
interface Callback {
void onActivityStarted(int resultCode);
}
+
+ interface OnDismissAction {
+ /**
+ * @return {@code true} if the dismiss should be deferred
+ */
+ boolean onDismiss();
+ }
}
diff --git a/packages/SystemUI/plugin/src/com/android/systemui/plugins/ClockPlugin.java b/packages/SystemUI/plugin/src/com/android/systemui/plugins/ClockPlugin.java
new file mode 100644
index 000000000000..7cb63ea7f151
--- /dev/null
+++ b/packages/SystemUI/plugin/src/com/android/systemui/plugins/ClockPlugin.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package com.android.systemui.plugins;
+
+import android.graphics.Paint.Style;
+import android.view.View;
+
+import com.android.systemui.plugins.annotations.ProvidesInterface;
+
+/**
+ * This plugin is used to replace main clock in keyguard.
+ */
+@ProvidesInterface(action = ClockPlugin.ACTION, version = ClockPlugin.VERSION)
+public interface ClockPlugin extends Plugin {
+
+ String ACTION = "com.android.systemui.action.PLUGIN_CLOCK";
+ int VERSION = 1;
+
+ /**
+ * Get clock view.
+ * @return clock view from plugin.
+ */
+ View getView();
+
+ /**
+ * Set clock paint style.
+ * @param style The new style to set in the paint.
+ */
+ void setStyle(Style style);
+
+ /**
+ * Set clock text color.
+ * @param color A color value.
+ */
+ void setTextColor(int color);
+
+ /**
+ * Notifies that time tick alarm from doze service fired.
+ */
+ default void dozeTimeTick() { }
+
+ /**
+ * Set the amount (ratio) that the device has transitioned to doze.
+ * @param darkAmount Amount of transition to doze: 1f for doze and 0f for awake.
+ */
+ default void setDarkAmount(float darkAmount) {}
+}
diff --git a/packages/SystemUI/plugin/src/com/android/systemui/plugins/FalsingPlugin.java b/packages/SystemUI/plugin/src/com/android/systemui/plugins/FalsingPlugin.java
new file mode 100644
index 000000000000..dce02e1a6c56
--- /dev/null
+++ b/packages/SystemUI/plugin/src/com/android/systemui/plugins/FalsingPlugin.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.plugins;
+
+import com.android.systemui.plugins.annotations.ProvidesInterface;
+
+/**
+ * Used to capture Falsing data (related to unlocking the screen).
+ *
+ * The intent is that the data can later be analyzed to validate the quality of the
+ * {@link com.android.systemui.classifier.FalsingManager}.
+ */
+@ProvidesInterface(action = FalsingPlugin.ACTION, version = FalsingPlugin.VERSION)
+public interface FalsingPlugin extends Plugin {
+ String ACTION = "com.android.systemui.action.FALSING_PLUGIN";
+ int VERSION = 1;
+
+ /**
+ * Called when there is data to be recorded.
+ *
+ * @param success Indicates whether the action is considered a success.
+ * @param data The raw data to be recorded for analysis.
+ */
+ void dataCollected(boolean success, byte[] data);
+}
diff --git a/packages/SystemUI/plugin/src/com/android/systemui/plugins/Plugin.java b/packages/SystemUI/plugin/src/com/android/systemui/plugins/Plugin.java
deleted file mode 100644
index bb93367c3791..000000000000
--- a/packages/SystemUI/plugin/src/com/android/systemui/plugins/Plugin.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the
- * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-package com.android.systemui.plugins;
-
-import com.android.systemui.plugins.annotations.Requires;
-
-import android.content.Context;
-
-/**
- * Plugins are separate APKs that
- * are expected to implement interfaces provided by SystemUI. Their
- * code is dynamically loaded into the SysUI process which can allow
- * for multiple prototypes to be created and run on a single android
- * build.
- *
- * PluginLifecycle:
- * <pre class="prettyprint">
- *
- * plugin.onCreate(Context sysuiContext, Context pluginContext);
- * --- This is always called before any other calls
- *
- * pluginListener.onPluginConnected(Plugin p);
- * --- This lets the plugin hook know that a plugin is now connected.
- *
- * ** Any other calls back and forth between sysui/plugin **
- *
- * pluginListener.onPluginDisconnected(Plugin p);
- * --- Lets the plugin hook know that it should stop interacting with
- * this plugin and drop all references to it.
- *
- * plugin.onDestroy();
- * --- Finally the plugin can perform any cleanup to ensure that its not
- * leaking into the SysUI process.
- *
- * Any time a plugin APK is updated the plugin is destroyed and recreated
- * to load the new code/resources.
- *
- * </pre>
- *
- * Creating plugin hooks:
- *
- * To create a plugin hook, first create an interface in
- * frameworks/base/packages/SystemUI/plugin that extends Plugin.
- * Include in it any hooks you want to be able to call into from
- * sysui and create callback interfaces for anything you need to
- * pass through into the plugin.
- *
- * Then to attach to any plugins simply add a plugin listener and
- * onPluginConnected will get called whenever new plugins are installed,
- * updated, or enabled. Like this example from SystemUIApplication:
- *
- * <pre class="prettyprint">
- * {@literal
- * PluginManager.getInstance(this).addPluginListener(OverlayPlugin.COMPONENT,
- * new PluginListener<OverlayPlugin>() {
- * @Override
- * public void onPluginConnected(OverlayPlugin plugin) {
- * StatusBar phoneStatusBar = getComponent(StatusBar.class);
- * if (phoneStatusBar != null) {
- * plugin.setup(phoneStatusBar.getStatusBarWindow(),
- * phoneStatusBar.getNavigationBarView());
- * }
- * }
- * }, OverlayPlugin.VERSION, true /* Allow multiple plugins *\/);
- * }
- * </pre>
- * Note the VERSION included here. Any time incompatible changes in the
- * interface are made, this version should be changed to ensure old plugins
- * aren't accidentally loaded. Since the plugin library is provided by
- * SystemUI, default implementations can be added for new methods to avoid
- * version changes when possible.
- *
- * Implementing a Plugin:
- *
- * See the ExamplePlugin for an example Android.mk on how to compile
- * a plugin. Note that SystemUILib is not static for plugins, its classes
- * are provided by SystemUI.
- *
- * Plugin security is based around a signature permission, so plugins must
- * hold the following permission in their manifest.
- *
- * <pre class="prettyprint">
- * {@literal
- * <uses-permission android:name="com.android.systemui.permission.PLUGIN" />
- * }
- * </pre>
- *
- * A plugin is found through a querying for services, so to let SysUI know
- * about it, create a service with a name that points at your implementation
- * of the plugin interface with the action accompanying it:
- *
- * <pre class="prettyprint">
- * {@literal
- * <service android:name=".TestOverlayPlugin">
- * <intent-filter>
- * <action android:name="com.android.systemui.action.PLUGIN_COMPONENT" />
- * </intent-filter>
- * </service>
- * }
- * </pre>
- */
-public interface Plugin {
-
- /**
- * @deprecated
- * @see Requires
- */
- default int getVersion() {
- // Default of -1 indicates the plugin supports the new Requires model.
- return -1;
- }
-
- default void onCreate(Context sysuiContext, Context pluginContext) {
- }
-
- default void onDestroy() {
- }
-}
diff --git a/packages/SystemUI/plugin/src/com/android/systemui/plugins/PluginFragment.java b/packages/SystemUI/plugin/src/com/android/systemui/plugins/PluginFragment.java
deleted file mode 100644
index 1bfa567b6630..000000000000
--- a/packages/SystemUI/plugin/src/com/android/systemui/plugins/PluginFragment.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the
- * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package com.android.systemui.plugins;
-
-import android.app.Fragment;
-import android.content.Context;
-import android.os.Bundle;
-import android.view.LayoutInflater;
-
-public abstract class PluginFragment extends Fragment implements Plugin {
-
- private Context mPluginContext;
-
- @Override
- public void onCreate(Context sysuiContext, Context pluginContext) {
- mPluginContext = pluginContext;
- }
-
- @Override
- public LayoutInflater onGetLayoutInflater(Bundle savedInstanceState) {
- return super.onGetLayoutInflater(savedInstanceState).cloneInContext(getContext());
- }
-
- @Override
- public void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- }
-
- @Override
- public Context getContext() {
- return mPluginContext;
- }
-}
diff --git a/packages/SystemUI/plugin/src/com/android/systemui/plugins/PluginListener.java b/packages/SystemUI/plugin/src/com/android/systemui/plugins/PluginListener.java
deleted file mode 100644
index b488d2a84baa..000000000000
--- a/packages/SystemUI/plugin/src/com/android/systemui/plugins/PluginListener.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the
- * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package com.android.systemui.plugins;
-
-import android.content.Context;
-
-/**
- * Interface for listening to plugins being connected.
- */
-public interface PluginListener<T extends Plugin> {
- /**
- * Called when the plugin has been loaded and is ready to be used.
- * This may be called multiple times if multiple plugins are allowed.
- * It may also be called in the future if the plugin package changes
- * and needs to be reloaded.
- */
- void onPluginConnected(T plugin, Context pluginContext);
-
- /**
- * Called when a plugin has been uninstalled/updated and should be removed
- * from use.
- */
- default void onPluginDisconnected(T plugin) {
- // Optional.
- }
-}
diff --git a/packages/SystemUI/plugin/src/com/android/systemui/plugins/SensorManagerPlugin.java b/packages/SystemUI/plugin/src/com/android/systemui/plugins/SensorManagerPlugin.java
new file mode 100644
index 000000000000..ba4eb5f48528
--- /dev/null
+++ b/packages/SystemUI/plugin/src/com/android/systemui/plugins/SensorManagerPlugin.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.systemui.plugins;
+
+import android.hardware.Sensor;
+import android.hardware.TriggerEventListener;
+
+import com.android.systemui.plugins.annotations.ProvidesInterface;
+
+/**
+ * Allows for additional sensors to be retrieved from
+ * {@link com.android.systemui.util.AsyncSensorManager}.
+ */
+@ProvidesInterface(action = SensorManagerPlugin.ACTION, version = SensorManagerPlugin.VERSION)
+public interface SensorManagerPlugin extends Plugin {
+ String ACTION = "com.android.systemui.action.PLUGIN_SENSOR_MANAGER";
+ int VERSION = 1;
+
+ /**
+ * Registers for trigger events from the sensor. Trigger events are one-shot and need to
+ * re-registered in order for them to be fired again.
+ * @param sensor
+ * @param listener
+ * @see android.hardware.SensorManager#requestTriggerSensor(
+ * android.hardware.TriggerEventListener, android.hardware.Sensor)
+ */
+ void registerTriggerEvent(Sensor sensor, TriggerEventListener listener);
+
+ /**
+ * Unregisters trigger events from the sensor.
+ * @param sensor
+ * @param listener
+ */
+ void unregisterTriggerEvent(Sensor sensor, TriggerEventListener listener);
+
+ interface TriggerEventListener {
+ void onTrigger(TriggerEvent event);
+ }
+
+ class Sensor {
+ public static int TYPE_WAKE_LOCK_SCREEN = 1;
+
+ int mType;
+
+ public int getType() {
+ return mType;
+ }
+
+ public Sensor(int type) {
+ mType = type;
+ }
+ }
+
+ class TriggerEvent {
+ Sensor mSensor;
+ int mVendorType;
+
+ /**
+ * Creates a trigger event
+ * @param sensor The type of sensor, e.g. TYPE_WAKE_LOCK_SCREEN
+ * @param vendorType The vendor type, which should be unique for each type of sensor,
+ * e.g. SINGLE_TAP = 1, DOUBLE_TAP = 2, etc.
+ */
+ public TriggerEvent(Sensor sensor, int vendorType) {
+ mSensor = sensor;
+ mVendorType = vendorType;
+ }
+
+ public Sensor getSensor() {
+ return mSensor;
+ }
+
+ public int getVendorType() {
+ return mVendorType;
+ }
+ }
+}
diff --git a/packages/SystemUI/plugin/src/com/android/systemui/plugins/annotations/Dependencies.java b/packages/SystemUI/plugin/src/com/android/systemui/plugins/annotations/Dependencies.java
deleted file mode 100644
index dbbf047519bb..000000000000
--- a/packages/SystemUI/plugin/src/com/android/systemui/plugins/annotations/Dependencies.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the
- * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package com.android.systemui.plugins.annotations;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-/**
- * Used for repeated @DependsOn internally, not for plugin
- * use.
- */
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Dependencies {
- DependsOn[] value();
-}
diff --git a/packages/SystemUI/plugin/src/com/android/systemui/plugins/annotations/DependsOn.java b/packages/SystemUI/plugin/src/com/android/systemui/plugins/annotations/DependsOn.java
deleted file mode 100644
index b81d67306307..000000000000
--- a/packages/SystemUI/plugin/src/com/android/systemui/plugins/annotations/DependsOn.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the
- * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package com.android.systemui.plugins.annotations;
-
-import java.lang.annotation.Repeatable;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-/**
- * Used to indicate that an interface in the plugin library needs another
- * interface to function properly. When this is added, it will be enforced
- * that all plugins that @Requires the annotated interface also @Requires
- * the specified class as well.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Repeatable(value = Dependencies.class)
-public @interface DependsOn {
- Class<?> target();
-
-}
diff --git a/packages/SystemUI/plugin/src/com/android/systemui/plugins/annotations/ProvidesInterface.java b/packages/SystemUI/plugin/src/com/android/systemui/plugins/annotations/ProvidesInterface.java
deleted file mode 100644
index d0e14b8657ff..000000000000
--- a/packages/SystemUI/plugin/src/com/android/systemui/plugins/annotations/ProvidesInterface.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the
- * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package com.android.systemui.plugins.annotations;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-/**
- * Should be added to all interfaces in plugin lib to specify their
- * current version and optionally their action to implement the plugin.
- */
-@Retention(RetentionPolicy.RUNTIME)
-public @interface ProvidesInterface {
- int version();
-
- String action() default "";
-
-}
diff --git a/packages/SystemUI/plugin/src/com/android/systemui/plugins/annotations/Requirements.java b/packages/SystemUI/plugin/src/com/android/systemui/plugins/annotations/Requirements.java
deleted file mode 100644
index 9cfa279b9c19..000000000000
--- a/packages/SystemUI/plugin/src/com/android/systemui/plugins/annotations/Requirements.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the
- * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package com.android.systemui.plugins.annotations;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-/**
- * Used for repeated @Requires internally, not for plugin
- * use.
- */
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Requirements {
- Requires[] value();
-}
diff --git a/packages/SystemUI/plugin/src/com/android/systemui/plugins/annotations/Requires.java b/packages/SystemUI/plugin/src/com/android/systemui/plugins/annotations/Requires.java
deleted file mode 100644
index e1b1303b8cb5..000000000000
--- a/packages/SystemUI/plugin/src/com/android/systemui/plugins/annotations/Requires.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the
- * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package com.android.systemui.plugins.annotations;
-
-import java.lang.annotation.Repeatable;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-/**
- * Used to annotate which interfaces a given plugin depends on.
- *
- * At minimum all plugins should have at least one @Requires annotation
- * for the plugin interface that they are implementing. They will also
- * need an @Requires for each class that the plugin interface @DependsOn.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Repeatable(value = Requirements.class)
-public @interface Requires {
- Class<?> target();
- int version();
-}
diff --git a/packages/SystemUI/plugin/src/com/android/systemui/plugins/qs/QSIconView.java b/packages/SystemUI/plugin/src/com/android/systemui/plugins/qs/QSIconView.java
index c268d325bd02..0cdb509a5209 100644
--- a/packages/SystemUI/plugin/src/com/android/systemui/plugins/qs/QSIconView.java
+++ b/packages/SystemUI/plugin/src/com/android/systemui/plugins/qs/QSIconView.java
@@ -29,7 +29,7 @@ public abstract class QSIconView extends ViewGroup {
super(context);
}
- public abstract void setIcon(State state);
+ public abstract void setIcon(State state, boolean allowAnimations);
public abstract void disableAnimation();
public abstract View getIconView();
}
diff --git a/packages/SystemUI/plugin/src/com/android/systemui/plugins/statusbar/NotificationMenuRowPlugin.java b/packages/SystemUI/plugin/src/com/android/systemui/plugins/statusbar/NotificationMenuRowPlugin.java
index 680f14bcf399..0b1dab1c3bca 100644
--- a/packages/SystemUI/plugin/src/com/android/systemui/plugins/statusbar/NotificationMenuRowPlugin.java
+++ b/packages/SystemUI/plugin/src/com/android/systemui/plugins/statusbar/NotificationMenuRowPlugin.java
@@ -38,11 +38,12 @@ import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin.MenuItem
public interface NotificationMenuRowPlugin extends Plugin {
public static final String ACTION = "com.android.systemui.action.PLUGIN_NOTIFICATION_MENU_ROW";
- public static final int VERSION = 4;
+ public static final int VERSION = 5;
@ProvidesInterface(version = OnMenuEventListener.VERSION)
public interface OnMenuEventListener {
public static final int VERSION = 1;
+
public void onMenuClicked(View row, int x, int y, MenuItem menu);
public void onMenuReset(View row);
@@ -53,6 +54,7 @@ public interface NotificationMenuRowPlugin extends Plugin {
@ProvidesInterface(version = MenuItem.VERSION)
public interface MenuItem {
public static final int VERSION = 1;
+
public View getMenuView();
public View getGutsView();
@@ -84,34 +86,136 @@ public interface NotificationMenuRowPlugin extends Plugin {
public void setMenuClickListener(OnMenuEventListener listener);
- public void setSwipeActionHelper(NotificationSwipeActionHelper listener);
-
public void setAppName(String appName);
public void createMenu(ViewGroup parent, StatusBarNotification sbn);
+ public void resetMenu();
+
public View getMenuView();
+ /**
+ * Get the target position that a notification row should be snapped open to in order to reveal
+ * the menu. This is generally determined by the number of icons in the notification menu and the
+ * size of each icon. This method accounts for whether the menu appears on the left or ride side
+ * of the parent notification row.
+ *
+
+ * @return an int representing the x-offset in pixels that the notification should snap open to.
+ * Positive values imply that the notification should be offset to the right to reveal the menu,
+ * and negative alues imply that the notification should be offset to the right.
+ */
+ public int getMenuSnapTarget();
+
+ /**
+ * Determines whether or not the menu should be shown in response to user input.
+ * @return true if the menu should be shown, false otherwise.
+ */
+ public boolean shouldShowMenu();
+
+ /**
+ * Determines whether the menu is currently visible.
+ * @return true if the menu is visible, false otherwise.
+ */
public boolean isMenuVisible();
- public void resetMenu();
+ /**
+ * Determines whether a given movement is towards or away from the current location of the menu.
+ * @param movement
+ * @return true if the movement is towards the menu, false otherwise.
+ */
+ public boolean isTowardsMenu(float movement);
- public void onTranslationUpdate(float translation);
+ /**
+ * Determines whether the menu should snap closed instead of dismissing the
+ * parent notification, as a function of its current state.
+ *
+ * @return true if the menu should snap closed, false otherwise.
+ */
+ public boolean shouldSnapBack();
- public void onHeightUpdate();
+ /**
+ * Determines whether the menu was previously snapped open to the same side that it is currently
+ * being shown on.
+ * @return true if the menu is snapped open to the same side on which it currently appears,
+ * false otherwise.
+ */
+ public boolean isSnappedAndOnSameSide();
- public void onNotificationUpdated(StatusBarNotification sbn);
+ /**
+ * Determines whether the notification the menu is attached to is able to be dismissed.
+ * @return true if the menu's parent notification is dismissable, false otherwise.
+ */
+ public boolean canBeDismissed();
- public boolean onTouchEvent(View view, MotionEvent ev, float velocity);
+ /**
+ * Determines whether the menu should remain open given its current state, or snap closed.
+ * @return true if the menu should remain open, false otherwise.
+ */
+ public boolean isWithinSnapMenuThreshold();
+
+ /**
+ * Determines whether the menu has been swiped far enough to snap open.
+ * @return true if the menu has been swiped far enough to open, false otherwise.
+ */
+ public boolean isSwipedEnoughToShowMenu();
public default boolean onInterceptTouchEvent(View view, MotionEvent ev) {
return false;
}
- public default boolean useDefaultMenuItems() {
+ public default boolean shouldUseDefaultMenuItems() {
return false;
}
- public default void onConfigurationChanged() {
- }
+ /**
+ * Callback used to signal the menu that its parent's translation has changed.
+ * @param translation The new x-translation of the menu as a position (not an offset).
+ */
+ public void onParentTranslationUpdate(float translation);
+
+ /**
+ * Callback used to signal the menu that its parent's height has changed.
+ */
+ public void onParentHeightUpdate();
+
+ /**
+ * Callback used to signal the menu that its parent notification has been updated.
+ * @param sbn
+ */
+ public void onNotificationUpdated(StatusBarNotification sbn);
+
+ /**
+ * Callback used to signal the menu that a user is moving the parent notification.
+ * @param delta The change in the parent notification's position.
+ */
+ public void onTouchMove(float delta);
+
+ /**
+ * Callback used to signal the menu that a user has begun touching its parent notification.
+ */
+ public void onTouchStart();
+
+ /**
+ * Callback used to signal the menu that a user has finished touching its parent notification.
+ */
+ public void onTouchEnd();
+
+ /**
+ * Callback used to signal the menu that it has been snapped closed.
+ */
+ public void onSnapClosed();
+
+ /**
+ * Callback used to signal the menu that it has been snapped open.
+ */
+ public void onSnapOpen();
+
+ /**
+ * Callback used to signal the menu that its parent notification has been dismissed.
+ */
+ public void onDismiss();
+
+ public default void onConfigurationChanged() { }
+
}
diff --git a/packages/SystemUI/plugin/src/com/android/systemui/plugins/statusbar/NotificationSwipeActionHelper.java b/packages/SystemUI/plugin/src/com/android/systemui/plugins/statusbar/NotificationSwipeActionHelper.java
index f6cf03562014..8db0d02548b0 100644
--- a/packages/SystemUI/plugin/src/com/android/systemui/plugins/statusbar/NotificationSwipeActionHelper.java
+++ b/packages/SystemUI/plugin/src/com/android/systemui/plugins/statusbar/NotificationSwipeActionHelper.java
@@ -39,7 +39,7 @@ public interface NotificationSwipeActionHelper {
/**
* Call this to snap a notification to provided {@code targetLeft}.
*/
- public void snap(View animView, float velocity, float targetLeft);
+ public void snapOpen(View animView, int targetLeft, float velocity);
/**
* Call this to snooze a notification based on the provided {@link SnoozeOption}.
diff --git a/packages/SystemUI/plugin/src/com/android/systemui/plugins/statusbar/phone/NavGesture.java b/packages/SystemUI/plugin/src/com/android/systemui/plugins/statusbar/phone/NavGesture.java
index aa2fb32f13a8..99cc3a37d739 100644
--- a/packages/SystemUI/plugin/src/com/android/systemui/plugins/statusbar/phone/NavGesture.java
+++ b/packages/SystemUI/plugin/src/com/android/systemui/plugins/statusbar/phone/NavGesture.java
@@ -20,6 +20,7 @@ import android.view.View;
import com.android.systemui.plugins.Plugin;
import com.android.systemui.plugins.annotations.ProvidesInterface;
+import java.io.PrintWriter;
@ProvidesInterface(action = NavGesture.ACTION, version = NavGesture.VERSION)
public interface NavGesture extends Plugin {
@@ -35,7 +36,7 @@ public interface NavGesture extends Plugin {
public boolean onInterceptTouchEvent(MotionEvent event);
- public void setBarState(boolean vertical, boolean isRtl);
+ public void setBarState(boolean isRtl, int navBarPosition);
public void onDraw(Canvas canvas);
@@ -46,6 +47,8 @@ public interface NavGesture extends Plugin {
public void onNavigationButtonLongPress(View v);
public default void destroy() { }
+
+ public default void dump(PrintWriter pw) { }
}
}