PIE 2.0

Pie is an alternative navigation and system info interface. It replaces the
standard navbar/statusbar with a navigation arc decorated with statusbar info.

Important notes for developers:
* When PIE is enabled apps don't even have to support immersive mode, they just have
  to check for configuration updates (sadly not even this is done by all apps).
  When PIE is disabled, apps have to setup an "onSystemUiVisibilityChangeListener"
  (best practice for PIE enabled, too).
* Changed how ActivityInfo handles apps capabilities like recalculate screen
  size etc. Check code comment(s).

Some info:
* Quicksettings and notification panels are not available anymore, google now
  replace swipe up gesture.
* Switched to kitkat colors.
* General improvement to the code, reorganize classes.
* Cleanup a lot and remove useless code.
* Merge with immersive mode, they live in a homogenized state.
* Improve immersive code a bit.
* Upon first activation, toggling immersive tile, the user is presented with a dialog asking
  to enable or disable the feature. The preference can be resetted in "Backup & restore" in settings.
* Reduce and center its trigger area.
* While pie is triggered screen is keept on.
* Depending on immersive mode, will show full or lite pie.
* New circled snap points.
* Detach pie on every rotation and/or when screen goes off while you have it triggered.
* What else, what some slices?

Key contributors:
@BigBrother1984
@D4rKn3sSyS
@Anu6is
@David96
@drcmda

Signed-off-by: Carlo Savignano <stevewatersy@gmail.com>
Signed-off-by: Jesus David <jesdga95@gmail.com>
Signed-off-by: Curtis Mayers <curtis.mayers@gmail.com>
Signed-off-by: David L.-W. <david.leppla.weber@gmail.com>
Signed-off-by: Paul Henschel <drcmda@gmail.com>
Change-Id: I6d09b1e2124d14e6cec48b40ea0c7948ebbb02b3
PIE: Fix random showing of navbar when swiping from top.

We need to condition here aswell to be sure top swipe doesn't trigger up
navbar at all even if we set its height to 0 is an useless call.

Addressing JIRA AOSPA-151 issue.

Signed-off-by: Carlo Savignano <stevewatersy@gmail.com>
Fix: SysUi crash on Pie recents

https://paranoidandroid.atlassian.net/browse/AOSPA-79

When toggling recent apps using pie controls on secondary user account,
system ui crashes.

Change-Id: Id43b79dadf4cc4a88534aa18e1138b1daa7eece8
Fix: Graphics error when switching to recents using Pie controls

Attempt to fix https://paranoidandroid.atlassian.net/browse/AOSPA-65

I've never been able to reproduce the problem on Hammerhead, Mako or
Grouper, so I can't guarantee that this solves it.

Feedback is needed from a user that constantly experiences this bug.

Change-Id: I950e94dbb9b9d07dedee9b9f8cab6c5b6bceb6b0
PIE: Prevent a rare freeze that appears on quick iterations.

Signed-off-by: Carlo Savignano <stevewatersy@gmail.com>
PIE: Disable orientation sensor when we don't need it

Orientation sensor always enabled causing some device keep awake and
battery drain. This commit fix this issue.

  * Disable/Enable orientation listener when screen turn off/on if PIE
is enabled.
  * If PIE is disabled, recycle it.

Change-Id: I6bda168b3fd62d9f7047ffc3a3c6bfd08e655543
[TEMP] PIE: fix a freezing bug

How to reproduce:
- Enable PIE;
- Toggle between on/of;
- Without close expanded status bar click any tile that use one of this methods -> private void startSettingsActivity(String action) or private void startSettingsActivity(Intent intent);
- System will freez for some seconds and soft reboot;

Solution:
- When deteced PIE mode enabled use a runnable with a less time possible to give time to system colapse panels and perform needed actions

Change-Id: Idc5f112873aa7a31993e7a3c82a1760bb45f8b9b
PIE: Unlock screen on triggering recents

* Bring up unlock panel. Clear all is still hidden when lockscreen is showing.
  Thanks to community for pointing this out.

Signed-off-by: Carlo Savignano <stevewatersy@gmail.com>
Show IME back button in Pie.

Updated Pie to show the alternate back button when an IME is present like the stock navigation bar does.

Change-Id: I97b385904c183a42c6d76a9f238c4b9624668576
Picture: http://i.imgur.com/T0n9bVc.png

EDIT: Fixed whitespace and tabbing
Revert "[TEMP] PIE: fix a freezing bug"

This reverts commit 004b6dc18a6399cb592859188502ed6f0d265f19.
PIE: Use case upgrade and bugfixes:

1.Play with navigation bar height instead of view state. Just set navbar height to 0, even because
  swipe gesture is disabled aswell so it will never be called. This way we handle just one var
  that is height. PhoneWindowManager will take care to calculate decors since it uses height (width
  in landscape) as a param in the calculation.
2.Remove dependency from last systemui flags. Right now before this patch, pie showed no matter if you
  were in forced or native immersive mode. That made us bring a couple of hacks to keep this marriage,
  but there is no need in the end cause PIE is an alternative way you have to enable. That means apps will (should)
  use their own immersive mode at first unless you have already PIE mode on. Not all apps hide navigation bar,
  that means they can not cover the entire screen height (portrait). That's why there is forced mode, to supply this
  cause force the app to go immersive. Last but more important, immersive API works again now :)
3.Cleanup some vars not used anymore, just need observing main immersive mode now.

Change-Id: Ia17bb7ede36d5a14c8508841e32910e6e9595310
Signed-off-by: Carlo Savignano <stevewatersy@gmail.com>
SystemUI: Use EdgeGesture service to trigger Pie

EdgeGesture service triggers Pie when detecting gestures on
the WHOLE edge, not just the center.

Patch Set 2: Better trigger values

Change-Id: Id7d9d7f6f5a37ca3696cdddf0da78c88c067970e
SystemUI: Position Pie at gesture's triggered position

As the EdgeGesture service is triggered at the whole screen
edge, place Pie at the gesture's triggered position, instead
of always positioning it at the center of the edge.

This might be controversial and a matter of taste, but in
particular on tablets it's sometimes hard to hit the exact
center of the edge and therefore gestures often fail. Could
also imagine enabling this feature on tablets only. Needs
some discussion...

Change-Id: Ife28ac434667148583b34bcccd11262c111b5a67
SystemUI: Stick Pie to edge on phones

Apply the same UX of AOSP's navbar on phones to Pie
controls. When rotating the phone, Pie now sticks to the
same physical screen edge, to which it was pinned before. As
most people start holding their phone with two hands in
landscape mode, keeping Pie at the right or left edge might
be more comfortable to reach by thumbs. The behavior on
tablets should not be affected in any way by this change.

Changes:

PieControlPanel stores only the absolute gravity (the
rotation independent position in portrait mode) of Pie.
PieMenu and PieController query the gravity from Panel.
Query methods (getOrientation(), getDegree(),
isGravityPossible()) only return the relative gravity (the
position depending on current rotation). Therfore, only the
PieControlPanel is aware of, whether and how gravity is
converted.

The amount of snap points is reduced in landscape mode,
because Pie cannot be pinned to the top edge of the screen.

Change-Id: I263f16e1c59e134f374b9a3a007ecdce2d54dc46
SystemUI: Fixed stick Pie to edge
SystemUI: Force Pie centered on small display devices
PhoneWindowManager: EdgeGestureService: Bring compatibility with PIE service:

Remove all edges flags but TOP (for statusbar) regards to system edge gestures.
Pie covers the other edges with its service.

Signed-off-by: Carlo Savignano <stevewatersy@gmail.com>
PIE: EdgeGestureService: Add flags LONG_LIVING | UNRESTRICTED

Following PhoneWindowManager enforcing.

Signed-off-by: Carlo Savignano <stevewatersy@gmail.com>
PhoneWindowManager: Fix a couple of issues and cleanup recent PIE rewamp

SystemGestures is unregistered due to default new EdgeGestureService,
still for safety keep a boolean check on requestTransientBars().
Refresh height live.

Change-Id: Iae9c6079c21e65d01eea330fa17f3861a4c2e100
Signed-off-by: Carlo Savignano <stevewatersy@gmail.com>
PhoneWindowManager: Don't handle navigation bar visibility when switching to PIE

Right now when restoring full height after disabling immersive if pie mode is
on, navbar isn't showed until panel collapsing cause it should have been showed
(the view even with height zero) called by top swipe gesture that calls requestTransientBars().
Don't touch the API, cleanup old code traces and changes cause in any case navbar has height = 0
and its bottom/right gesture is disabled.

Signed-off-by: Carlo Savignano <stevewatersy@gmail.com>
Change-Id: Id05175a553aad2a5a2b36c3fe4e32a2d071dcc88