From e0d5ccd331e694afdc3c8462a1b845df329de2b8 Mon Sep 17 00:00:00 2001 From: Matthew Ng Date: Wed, 8 May 2019 15:13:22 -0700 Subject: [PATCH] Remove plugin logical from NavigationBarView (1/2) Fixes: 129860064 Test: manual Change-Id: I8cfa77cf40f62ab1e5f1ad8d1957107aca1557f2 --- .../statusbar/phone/NavBarButtonProvider.java | 56 -------------- .../plugins/statusbar/phone/NavGesture.java | 54 -------------- .../res/layout/nav_bar_tuner_inflater.xml | 27 ------- .../statusbar/phone/ButtonDispatcher.java | 1 - .../statusbar/phone/ButtonInterface.java | 33 +++++++++ .../phone/NavigationBarFragment.java | 3 - .../phone/NavigationBarInflaterView.java | 58 +-------------- .../phone/NavigationBarTransitions.java | 1 - .../statusbar/phone/NavigationBarView.java | 72 +----------------- .../statusbar/phone/NavigationHandle.java | 1 - .../statusbar/policy/KeyButtonView.java | 2 +- .../systemui/tuner/PreviewNavInflater.java | 74 ------------------- 12 files changed, 38 insertions(+), 344 deletions(-) delete mode 100644 packages/SystemUI/plugin/src/com/android/systemui/plugins/statusbar/phone/NavBarButtonProvider.java delete mode 100644 packages/SystemUI/plugin/src/com/android/systemui/plugins/statusbar/phone/NavGesture.java delete mode 100644 packages/SystemUI/res/layout/nav_bar_tuner_inflater.xml create mode 100644 packages/SystemUI/src/com/android/systemui/statusbar/phone/ButtonInterface.java delete mode 100644 packages/SystemUI/src/com/android/systemui/tuner/PreviewNavInflater.java diff --git a/packages/SystemUI/plugin/src/com/android/systemui/plugins/statusbar/phone/NavBarButtonProvider.java b/packages/SystemUI/plugin/src/com/android/systemui/plugins/statusbar/phone/NavBarButtonProvider.java deleted file mode 100644 index e25930c18947f..0000000000000 --- a/packages/SystemUI/plugin/src/com/android/systemui/plugins/statusbar/phone/NavBarButtonProvider.java +++ /dev/null @@ -1,56 +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.statusbar.phone; - -import android.annotation.Nullable; -import android.graphics.drawable.Drawable; -import android.view.View; -import android.view.ViewGroup; - -import com.android.systemui.plugins.Plugin; -import com.android.systemui.plugins.annotations.ProvidesInterface; - -@ProvidesInterface(action = NavBarButtonProvider.ACTION, version = NavBarButtonProvider.VERSION) -public interface NavBarButtonProvider extends Plugin { - - public static final String ACTION = "com.android.systemui.action.PLUGIN_NAV_BUTTON"; - - public static final int VERSION = 2; - - /** - * Returns a view in the nav bar. If the id is set "back", "home", "recent_apps", "menu", - * or "ime_switcher", it is expected to implement ButtonInterface. - */ - public View createView(String spec, ViewGroup parent); - - /** - * Interface for button actions. - */ - interface ButtonInterface { - - void setImageDrawable(@Nullable Drawable drawable); - - void abortCurrentGesture(); - - void setVertical(boolean vertical); - - default void setCarMode(boolean carMode) { - } - - void setDarkIntensity(float intensity); - - void setDelayTouchFeedback(boolean shouldDelay); - } -} 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 deleted file mode 100644 index 99cc3a37d7394..0000000000000 --- a/packages/SystemUI/plugin/src/com/android/systemui/plugins/statusbar/phone/NavGesture.java +++ /dev/null @@ -1,54 +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.statusbar.phone; - -import android.graphics.Canvas; -import android.view.MotionEvent; -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 { - - public static final String ACTION = "com.android.systemui.action.PLUGIN_NAV_GESTURE"; - - public static final int VERSION = 1; - - public GestureHelper getGestureHelper(); - - public interface GestureHelper { - public boolean onTouchEvent(MotionEvent event); - - public boolean onInterceptTouchEvent(MotionEvent event); - - public void setBarState(boolean isRtl, int navBarPosition); - - public void onDraw(Canvas canvas); - - public void onDarkIntensityChange(float intensity); - - public void onLayout(boolean changed, int left, int top, int right, int bottom); - - public void onNavigationButtonLongPress(View v); - - public default void destroy() { } - - public default void dump(PrintWriter pw) { } - } - -} diff --git a/packages/SystemUI/res/layout/nav_bar_tuner_inflater.xml b/packages/SystemUI/res/layout/nav_bar_tuner_inflater.xml deleted file mode 100644 index 133b2158c7711..0000000000000 --- a/packages/SystemUI/res/layout/nav_bar_tuner_inflater.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ButtonDispatcher.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ButtonDispatcher.java index 6a93c7c9e5c42..539bc7bcb3f65 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ButtonDispatcher.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ButtonDispatcher.java @@ -23,7 +23,6 @@ import android.animation.ValueAnimator; import android.view.View; import android.view.View.AccessibilityDelegate; -import com.android.systemui.plugins.statusbar.phone.NavBarButtonProvider.ButtonInterface; import com.android.systemui.statusbar.policy.KeyButtonDrawable; import java.util.ArrayList; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ButtonInterface.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ButtonInterface.java new file mode 100644 index 0000000000000..150a9603a1241 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ButtonInterface.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2019 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.statusbar.phone; + +import android.annotation.Nullable; +import android.graphics.drawable.Drawable; + +public interface ButtonInterface { + + void setImageDrawable(@Nullable Drawable drawable); + + void abortCurrentGesture(); + + void setVertical(boolean vertical); + + void setDarkIntensity(float intensity); + + void setDelayTouchFeedback(boolean shouldDelay); +} diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java index 8aa4f03826491..03d607dbce68d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java @@ -709,7 +709,6 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback if (shouldDisableNavbarGestures()) { return false; } - mNavigationBarView.onNavigationButtonLongPress(v); mMetricsLogger.action(MetricsEvent.ACTION_ASSIST_LONG_PRESS); Bundle args = new Bundle(); args.putInt( @@ -749,12 +748,10 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback } private boolean onLongPressBackHome(View v) { - mNavigationBarView.onNavigationButtonLongPress(v); return onLongPressNavigationButtons(v, R.id.back, R.id.home); } private boolean onLongPressBackRecents(View v) { - mNavigationBarView.onNavigationButtonLongPress(v); return onLongPressNavigationButtons(v, R.id.back, R.id.recent_apps); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarInflaterView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarInflaterView.java index 7ab8da9d25618..a12ae96f57b06 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarInflaterView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarInflaterView.java @@ -35,23 +35,15 @@ import android.widget.Space; import com.android.internal.annotations.VisibleForTesting; import com.android.systemui.Dependency; import com.android.systemui.R; -import com.android.systemui.plugins.PluginListener; -import com.android.systemui.plugins.statusbar.phone.NavBarButtonProvider; import com.android.systemui.recents.OverviewProxyService; -import com.android.systemui.shared.plugins.PluginManager; import com.android.systemui.shared.system.QuickStepContract; import com.android.systemui.statusbar.phone.ReverseLinearLayout.ReverseRelativeLayout; import com.android.systemui.statusbar.policy.KeyButtonView; -import com.android.systemui.tuner.TunerService; -import com.android.systemui.tuner.TunerService.Tunable; -import java.util.ArrayList; -import java.util.List; import java.util.Objects; public class NavigationBarInflaterView extends FrameLayout - implements Tunable, PluginListener, - NavigationModeController.ModeChangedListener { + implements NavigationModeController.ModeChangedListener { private static final String TAG = "NavBarInflater"; @@ -87,8 +79,6 @@ public class NavigationBarInflaterView extends FrameLayout private static final String ABSOLUTE_SUFFIX = "A"; private static final String ABSOLUTE_VERTICAL_CENTERED_SUFFIX = "C"; - private final List mPlugins = new ArrayList<>(); - protected LayoutInflater mLayoutInflater; protected LayoutInflater mLandscapeInflater; @@ -159,33 +149,12 @@ public class NavigationBarInflaterView extends FrameLayout onLikelyDefaultLayoutChange(); } - @Override - protected void onAttachedToWindow() { - super.onAttachedToWindow(); - Dependency.get(TunerService.class).addTunable(this, NAV_BAR_VIEWS, NAV_BAR_LEFT, - NAV_BAR_RIGHT); - Dependency.get(PluginManager.class).addPluginListener(this, - NavBarButtonProvider.class, true /* Allow multiple */); - } - @Override protected void onDetachedFromWindow() { - Dependency.get(TunerService.class).removeTunable(this); - Dependency.get(PluginManager.class).removePluginListener(this); Dependency.get(NavigationModeController.class).removeListener(this); super.onDetachedFromWindow(); } - @Override - public void onTuningChanged(String key, String newValue) { - if (NAV_BAR_VIEWS.equals(key)) { - setNavigationBarLayout(newValue); - } else if (NAV_BAR_LEFT.equals(key) || NAV_BAR_RIGHT.equals(key)) { - clearViews(); - inflateLayout(mCurrentLayout); - } - } - public void setNavigationBarLayout(String layoutValue) { if (!Objects.equals(mCurrentLayout, layoutValue)) { mUsingCustomLayout = layoutValue != null; @@ -404,16 +373,9 @@ public class NavigationBarInflaterView extends FrameLayout View v = null; String button = extractButton(buttonSpec); if (LEFT.equals(button)) { - String s = Dependency.get(TunerService.class).getValue(NAV_BAR_LEFT, NAVSPACE); - button = extractButton(s); + button = extractButton(NAVSPACE); } else if (RIGHT.equals(button)) { - String s = Dependency.get(TunerService.class).getValue(NAV_BAR_RIGHT, MENU_IME_ROTATE); - button = extractButton(s); - } - // Let plugins go first so they can override a standard view if they want. - for (NavBarButtonProvider provider : mPlugins) { - v = provider.createView(buttonSpec, parent); - if (v != null) return v; + button = extractButton(MENU_IME_ROTATE); } if (HOME.equals(button)) { v = inflater.inflate(R.layout.home, parent, false); @@ -522,18 +484,4 @@ public class NavigationBarInflaterView extends FrameLayout private static float convertDpToPx(Context context, float dp) { return dp * context.getResources().getDisplayMetrics().density; } - - @Override - public void onPluginConnected(NavBarButtonProvider plugin, Context context) { - mPlugins.add(plugin); - clearViews(); - inflateLayout(mCurrentLayout); - } - - @Override - public void onPluginDisconnected(NavBarButtonProvider plugin) { - mPlugins.remove(plugin); - clearViews(); - inflateLayout(mCurrentLayout); - } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarTransitions.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarTransitions.java index 4e4a6aec57b5f..9e0aff0703647 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarTransitions.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarTransitions.java @@ -174,7 +174,6 @@ public final class NavigationBarTransitions extends BarTransitions implements if (mAutoDim) { applyLightsOut(false, true); } - mView.onDarkIntensityChange(darkIntensity); } @Override diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java index 831d882d68a71..0b8ad5895d0ce 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java @@ -16,7 +16,6 @@ package com.android.systemui.statusbar.phone; -import static android.view.WindowManagerPolicyConstants.NAV_BAR_INVALID; import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON; import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED; @@ -38,10 +37,8 @@ import android.graphics.Rect; import android.graphics.Region; import android.graphics.Region.Op; import android.os.Bundle; -import android.os.RemoteException; import android.util.AttributeSet; import android.util.Log; -import android.util.Slog; import android.util.SparseArray; import android.view.Display; import android.view.MotionEvent; @@ -52,7 +49,6 @@ import android.view.ViewTreeObserver.InternalInsetsInfo; import android.view.ViewTreeObserver.OnComputeInternalInsetsListener; import android.view.WindowInsets; import android.view.WindowManager; -import android.view.WindowManagerGlobal; import android.view.accessibility.AccessibilityNodeInfo; import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction; import android.view.inputmethod.InputMethodManager; @@ -65,13 +61,9 @@ import com.android.systemui.Interpolators; import com.android.systemui.R; import com.android.systemui.SysUiServiceProvider; import com.android.systemui.assist.AssistManager; -import com.android.systemui.plugins.PluginListener; -import com.android.systemui.plugins.statusbar.phone.NavGesture; -import com.android.systemui.plugins.statusbar.phone.NavGesture.GestureHelper; import com.android.systemui.recents.OverviewProxyService; import com.android.systemui.recents.Recents; import com.android.systemui.recents.RecentsOnboarding; -import com.android.systemui.shared.plugins.PluginManager; import com.android.systemui.shared.system.ActivityManagerWrapper; import com.android.systemui.shared.system.QuickStepContract; import com.android.systemui.shared.system.WindowManagerWrapper; @@ -82,7 +74,7 @@ import java.io.FileDescriptor; import java.io.PrintWriter; import java.util.function.Consumer; -public class NavigationBarView extends FrameLayout implements PluginListener, +public class NavigationBarView extends FrameLayout implements NavigationModeController.ModeChangedListener { final static boolean DEBUG = false; final static String TAG = "StatusBar/NavBarView"; @@ -118,7 +110,6 @@ public class NavigationBarView extends FrameLayout implements PluginListener