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

Commit d7937b34 authored by Jason Monk's avatar Jason Monk Committed by Android (Google) Code Review
Browse files

Merge "New system for versioning sysui plugins"

parents dc71f6c2 5bec68fb
Loading
Loading
Loading
Loading
+2 −6
Original line number Diff line number Diff line
@@ -24,7 +24,9 @@ import android.view.ViewGroup;
import android.view.ViewTreeObserver.InternalInsetsInfo;
import android.view.ViewTreeObserver.OnComputeInternalInsetsListener;
import com.android.systemui.plugins.OverlayPlugin;
import com.android.systemui.plugins.annotations.Requires;

@Requires(target = OverlayPlugin.class, version = OverlayPlugin.VERSION)
public class SampleOverlayPlugin implements OverlayPlugin {
    private static final String TAG = "SampleOverlayPlugin";
    private Context mPluginContext;
@@ -35,12 +37,6 @@ public class SampleOverlayPlugin implements OverlayPlugin {
    private boolean mCollapseDesired;
    private float mStatusBarHeight;

    @Override
    public int getVersion() {
        Log.d(TAG, "getVersion " + VERSION);
        return VERSION;
    }

    @Override
    public void onCreate(Context sysuiContext, Context pluginContext) {
        Log.d(TAG, "onCreate");
+3 −0
Original line number Diff line number Diff line
@@ -14,6 +14,8 @@

package com.android.systemui.plugins;

import com.android.systemui.plugins.annotations.ProvidesInterface;

import android.content.Intent;
import android.graphics.drawable.Drawable;

@@ -21,6 +23,7 @@ import android.graphics.drawable.Drawable;
 * An Intent Button represents a triggerable element in SysUI that consists of an
 * Icon and an intent to trigger when it is activated (clicked, swiped, etc.).
 */
@ProvidesInterface(version = IntentButtonProvider.VERSION)
public interface IntentButtonProvider extends Plugin {

    public static final int VERSION = 1;
+4 −1
Original line number Diff line number Diff line
@@ -13,12 +13,15 @@
 */
package com.android.systemui.plugins;

import com.android.systemui.plugins.annotations.ProvidesInterface;

import android.view.View;

@ProvidesInterface(action = OverlayPlugin.ACTION, version = OverlayPlugin.VERSION)
public interface OverlayPlugin extends Plugin {

    String ACTION = "com.android.systemui.action.PLUGIN_OVERLAY";
    int VERSION = 1;
    int VERSION = 2;

    void setup(View statusBar, View navBar);

+8 −11
Original line number Diff line number Diff line
@@ -13,6 +13,8 @@
 */
package com.android.systemui.plugins;

import com.android.systemui.plugins.annotations.Requires;

import android.content.Context;

/**
@@ -111,18 +113,13 @@ import android.content.Context;
public interface Plugin {

    /**
     * Should be implemented as the following directly referencing the version constant
     * from the plugin interface being implemented, this will allow recompiles to automatically
     * pick up the current version.
     * <pre class="prettyprint">
     * {@literal
     * public int getVersion() {
     *     return VERSION;
     * }
     * }
     * @return
     * @deprecated
     * @see Requires
     */
    int getVersion();
    default int getVersion() {
        // Default of -1 indicates the plugin supports the new Requires model.
        return -1;
    }

    default void onCreate(Context sysuiContext, Context pluginContext) {
    }
+27 −0
Original line number Diff line number Diff line
/*
 * 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();
}
Loading