fixes more error
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package {
|
||||
default_team: "trendy_team_system_ui_please_use_a_more_specific_subteam_if_possible_",
|
||||
// See: http://go/android-license-faq
|
||||
// A large-scale-change added 'default_applicable_licenses' to import
|
||||
// all of the 'license_kinds' from "frameworks_base_packages_SystemUI_license"
|
||||
// to get the below license kinds:
|
||||
// SPDX-license-identifier-Apache-2.0
|
||||
default_applicable_licenses: ["frameworks_base_packages_SystemUI_license"],
|
||||
}
|
||||
|
||||
android_app {
|
||||
|
||||
name: "ExamplePlugin",
|
||||
use_resource_processor: true,
|
||||
|
||||
libs: ["SystemUIPluginLib"],
|
||||
|
||||
certificate: "platform",
|
||||
optimize: {
|
||||
enabled: false,
|
||||
},
|
||||
|
||||
srcs: ["src/**/*.java"],
|
||||
|
||||
platform_apis: true,
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2015 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.
|
||||
-->
|
||||
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.android.systemui.plugin.testoverlayplugin">
|
||||
|
||||
<uses-permission android:name="com.android.systemui.permission.PLUGIN" />
|
||||
|
||||
<application>
|
||||
<activity android:name=".PluginSettings"
|
||||
android:label="@string/plugin_label"
|
||||
android:exported="false">
|
||||
<intent-filter>
|
||||
<action android:name="com.android.systemui.action.PLUGIN_SETTINGS" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<service android:name=".SampleOverlayPlugin"
|
||||
android:label="@string/plugin_label"
|
||||
android:exported="false">
|
||||
<intent-filter>
|
||||
<action android:name="com.android.systemui.action.PLUGIN_OVERLAY" />
|
||||
</intent-filter>
|
||||
</service>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
** Copyright 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.
|
||||
-->
|
||||
|
||||
<com.android.systemui.plugin.testoverlayplugin.CustomView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#80ff0000" />
|
||||
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
** Copyright 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.
|
||||
-->
|
||||
|
||||
<TextView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:text="@string/plugin_settings_here"
|
||||
android:gravity="center" />
|
||||
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
-->
|
||||
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
|
||||
|
||||
<string name="plugin_settings_here" translatable="false">Plugin settings go here</string>
|
||||
<string name="plugin_label" translatable="false">Overlay Plugin</string>
|
||||
|
||||
</resources>
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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.plugin.testoverlayplugin;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
/**
|
||||
* View with some logging to show that its being run.
|
||||
*/
|
||||
public class CustomView extends View {
|
||||
|
||||
private static final String TAG = "CustomView";
|
||||
|
||||
public CustomView(Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
Log.d(TAG, "new instance");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
Log.d(TAG, "onAttachedToWindow");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
Log.d(TAG, "onDetachedFromWindow");
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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.plugin.testoverlayplugin;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
|
||||
/**
|
||||
* DO NOT Reference Plugin interfaces here, this runs in the plugin APK's process
|
||||
* and is only for modifying settings.
|
||||
*/
|
||||
public class PluginSettings extends Activity {
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.plugin_settings);
|
||||
}
|
||||
}
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* 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.plugin.testoverlayplugin;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
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;
|
||||
|
||||
private View mStatusBarView;
|
||||
private View mNavBarView;
|
||||
private boolean mInputSetup;
|
||||
private boolean mCollapseDesired;
|
||||
private float mStatusBarHeight;
|
||||
|
||||
@Override
|
||||
public void onCreate(Context sysuiContext, Context pluginContext) {
|
||||
Log.d(TAG, "onCreate");
|
||||
mPluginContext = pluginContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
if (mInputSetup) {
|
||||
mStatusBarView.getViewTreeObserver().removeOnComputeInternalInsetsListener(
|
||||
onComputeInternalInsetsListener);
|
||||
}
|
||||
Log.d(TAG, "onDestroy");
|
||||
if (mStatusBarView != null) {
|
||||
mStatusBarView.post(
|
||||
() -> ((ViewGroup) mStatusBarView.getParent()).removeView(mStatusBarView));
|
||||
}
|
||||
if (mNavBarView != null) {
|
||||
mNavBarView.post(() -> ((ViewGroup) mNavBarView.getParent()).removeView(mNavBarView));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup(View statusBar, View navBar) {
|
||||
Log.d(TAG, "Setup");
|
||||
|
||||
int id = mPluginContext.getResources().getIdentifier("status_bar_height", "dimen",
|
||||
"android");
|
||||
mStatusBarHeight = mPluginContext.getResources().getDimension(id);
|
||||
if (statusBar instanceof ViewGroup) {
|
||||
mStatusBarView = LayoutInflater.from(mPluginContext)
|
||||
.inflate(R.layout.colored_overlay, (ViewGroup) statusBar, false);
|
||||
((ViewGroup) statusBar).addView(mStatusBarView);
|
||||
}
|
||||
if (navBar instanceof ViewGroup) {
|
||||
mNavBarView = LayoutInflater.from(mPluginContext)
|
||||
.inflate(R.layout.colored_overlay, (ViewGroup) navBar, false);
|
||||
((ViewGroup) navBar).addView(mNavBarView);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCollapseDesired(boolean collapseDesired) {
|
||||
mCollapseDesired = collapseDesired;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean holdStatusBarOpen() {
|
||||
if (!mInputSetup) {
|
||||
mInputSetup = true;
|
||||
mStatusBarView.getViewTreeObserver().addOnComputeInternalInsetsListener(
|
||||
onComputeInternalInsetsListener);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
final OnComputeInternalInsetsListener onComputeInternalInsetsListener = inoutInfo -> {
|
||||
inoutInfo.setTouchableInsets(InternalInsetsInfo.TOUCHABLE_INSETS_REGION);
|
||||
if (mCollapseDesired) {
|
||||
inoutInfo.touchableRegion.set(new Rect(0, 0, 50000, (int) mStatusBarHeight));
|
||||
} else {
|
||||
inoutInfo.touchableRegion.set(new Rect(0, 0, 50000, 50000));
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user