OverscrollPlugin.java 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Copyright (C) 2019 The Android Open Source Project
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package com.android.systemui.plugins;
  17. import android.view.MotionEvent;
  18. import com.android.systemui.plugins.annotations.ProvidesInterface;
  19. /**
  20. * Implement this interface to receive a callback when the user swipes right
  21. * to left on the gesture area. It won't fire if the user has quick switched to a previous app
  22. * (swiped right) and the current app isn't yet the active one (i.e., if swiping left would take
  23. * the user to a more recent app).
  24. */
  25. @ProvidesInterface(action = com.android.systemui.plugins.OverscrollPlugin.ACTION,
  26. version = com.android.systemui.plugins.OverscrollPlugin.VERSION)
  27. public interface OverscrollPlugin extends Plugin {
  28. String ACTION = "com.android.systemui.action.PLUGIN_LAUNCHER_OVERSCROLL";
  29. int VERSION = 4;
  30. String DEVICE_STATE_LOCKED = "Locked";
  31. String DEVICE_STATE_LAUNCHER = "Launcher";
  32. String DEVICE_STATE_APP = "App";
  33. String DEVICE_STATE_UNKNOWN = "Unknown";
  34. /**
  35. * @return true if the plugin is active and will accept overscroll gestures
  36. */
  37. boolean isActive();
  38. /**
  39. * Called when a touch has been recognized as an overscroll gesture.
  40. * @param horizontalDistancePx Horizontal distance from the last finger location to the finger
  41. * location when it first touched the screen.
  42. * @param verticalDistancePx Horizontal distance from the last finger location to the finger
  43. * location when it first touched the screen.
  44. * @param thresholdPx Minimum distance for gesture.
  45. * @param flingDistanceThresholdPx Minimum distance for gesture by fling.
  46. * @param flingVelocityThresholdPx Minimum velocity for gesture by fling.
  47. * @param deviceState String representing the current device state
  48. * @param underlyingActivity String representing the currently active Activity
  49. */
  50. void onTouchEvent(MotionEvent event,
  51. int horizontalDistancePx,
  52. int verticalDistancePx,
  53. int thresholdPx,
  54. int flingDistanceThresholdPx,
  55. int flingVelocityThresholdPx,
  56. String deviceState,
  57. String underlyingActivity);
  58. /**
  59. * @return `true` if overscroll gesture handling should override all other gestures.
  60. */
  61. boolean blockOtherGestures();
  62. /**
  63. * @return `true` if the overscroll gesture can pan the underlying app.
  64. */
  65. boolean allowsUnderlyingActivityOverscroll();
  66. }