[1/2] Slims Hardware Key Rebinding

THANKS @Mahdi-Rom for the initial port!

Possible mapping are:
ACTION_HOME
ACTION_BACK
ACTION_SEARCH (in app search)
ACTION_VOICE_SEARCH
ACTION_MENU_BIG
ACTION_POWER
ACTION_NOTIFICATIONS
ACTION_QS
ACTION_RECENTS
ACTION_SCREENSHOT
ACTION_IME
ACTION_LAST_APP
ACTION_KILL
ACTION_ASSIST
ACTION_VIB
ACTION_SILENT
ACTION_VIB_SILENT
ACTION_POWER_MENU
ACTION_TORCH
ACTION_EXPANDED_DESKTOP
ACTION_THEME_SWITCH

and custom app/shorcut of course

Possible actions on all keys are:
normal tap / longpress / double tap

So to sumarize if it is in settings array enabled user can bind whatever of the above
actions to every hardware key action.

Main changes to prior solutions are:
- do not depend anymore on hardcoded integer values. We use now strings. This has
  the advantage that we can save whatever shorcut or intent URI we have into this
  value. And gives us the possibility in future without changing anything on the hw
  key rebinding code to get more options/or modify the options. Actions are holded
  like on all other of our features in ButtonsConstants.java
- All actions are peformed over our SlimActions like all other features. SlimActions
  takes care about all possible solutions the user can run into and sets the right
  open animation, keyguard handling etc etc. As well it is easier to maintain only
  one code base.
- Only observe and update the values on hardware key devices. On non hw key devices
  the complete code is non operational
- Removed in settings the not needed overlay due that we can use the fb one to
  check if it is a hw key device or not.
- Major cleanup of a lot old code.

This patch add as well one new SlimActions action....VOICE_SEARCH

To configure your device you need to add the device overlay as usual:

overlay/frameworks/base/core/res/res/values/config.xml
<!-- Hardware "softkeys" present on the device, stored as a bit field.
         This integer should equal the sum of the corresponding value for each
         of the following keys present:
            1 - Home
            2 - Back
            4 - Menu
            8 - Assistant (search)
           16 - App switch
        For example, a device with Home, Back and Menu keys would set this
        config to 7. -->
    <integer name="config_deviceHardwareKeys">7</integer>

Also requires Settings commit (https://gerrit.slimroms.net/#/c/2389/)
and overlay to function correctly

cheers HCP and kufi

PS:
- code cleanup and some code comments
PS:
- fix softkey devices
PS:
- fix back button (I think lol)
PS:
- fix wrong null checks lol
PS
- revert back to last ps due of more derp
PS
- added some debbugging lines
PS
- redefine injectInputEvent code and get rid of the handler we used to fix
  exception due that PhoneWindowManager is no UI thread and cannot handle the handler
  and to speed up navbar/navring etc. No need to delay it for 30ms
PS
- reworked the complete interpretation code. To fix up the initial issues we had on first patchsets
  and as well the new ones. Nuked vibrations as well and lets handle it like all other over SlimActions
  cleanup again
PS
- I remember that jeff had similar problem in the past and got the solution. We just check now
  who is really calling home key event. If it is a VIRTUAL key then launch home....for all other
  lauch the saved action on the home event. As well this fixes the wrong launch if DoubleTap
  timed out and launches home (now it launches the saved action for home like it should).
PS
- cleanup
PS
- finally fixed home button
PS
- last major cleanup
- cancel recent preloads only if it is really required
PS
- introduce central HwKeyHelper class to avoid code duplication in PhoneWindowManager and as well
  in Settings
PS
- fix small logical error in home key handling to avoid to go over SlimActions if button is set to default
  home
PS
- fix wrong menu default value
PS
- added double tap to all bindable buttons
- fixed reported missing vibration on longpress
- possible fix menu shows up on longpress menu
PS
- small cleanup
PS
- fix home/assist/appswitch call when it is set on the natural button as longpress or doubletapp.
PS
- attempt to fix the problem mentioned in PatchSet above on the other keys + simplify this fix
  Please test
PS
- fix navbar
PS
- fix double vibration if double tap is pending
- fix deprecated System.SHOW_PROCESS value call and call Global instead
- execute on assist and appswitch default action if no other action was executed before
- HwKeyHelper do not call provider values if not needed
- cleanup
PS
- menu and back button: if normal tap action does not equal natural back action return -1
  to avoid processing back/menu action
PS
- reset the indicating boolean for prevend second vibration when we reset the doubletap
  callback - this fixes the reported issue that vibration is suddenly completly gone
PS
- return on back and menu hardware trigger always the action and let it use the virtual
  key to process the final action
PS
- handle virtual key on back and menu a bit other
- rename vibration var
PS
- fix double vibration if double tap is disabled
PS
- fix back key wrong condition on double tap which caused 2 action calls
PS
- do not assume that double tap has always a pending vibration...check for the action
- respect keyguard on APP_SWITCH key
PS
- remove again the keyguard check lol....I forgot that I was some months ago allready
intelligent enough to check this in SlimActions lol. So no need to check it twice

Change-Id: Ic5c9b4eb03d2baa3b0ddfb3e9fcaf10d6e45dcd3

This commit replaces CM's hardware key rebinding with Slims, the orignal patch is here:

https://github.com/SlimRoms/frameworks_base/commit/2cfd9aa74fe0fc7bc388ce01bc243bbf6ec06790

Conflicts:
	core/java/android/provider/Settings.java
	core/java/com/android/internal/util/mahdi/ButtonsConstants.java
	core/java/com/android/internal/util/mahdi/MahdiActions.java
	core/res/res/values/config.xml
	core/res/res/values/mahdi_config.xml
	core/res/res/values/mahdi_strings.xml
	core/res/res/values/mahdi_symbols.xml
	policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
Revert "NavigationBar : Customization"

This reverts commit 61941dd7b5d04af790cbaa4f902bb352a4725783.

Change-Id: I37a22b8a523c03e5e89c3eb6dd3e315edff8aefc

Conflicts:
	core/java/android/provider/Settings.java
	packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
SystemUI: add customizable navigation bar

Change-Id: Ibad1ecf52c7db0ac352892aed7529de68476c092
Signed-off-by: Roman Birg <romanbirg@gmail.com>

Conflicts:
	core/java/android/provider/Settings.java
	packages/SystemUI/res/layout-sw600dp/navigation_bar.xml
	packages/SystemUI/res/layout/navigation_bar.xml
	packages/SystemUI/res/values/config.xml
	packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarTransitions.java
	packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
	packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
	packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java
SystemUI: Fix NavBar FC

Change-Id: I5cfa3110e0239023801c5233164c6cafae5f8498
SystemUI: fix alt back icon; navbar button fc

Change-Id: I61cb2a3d5ad024922016a1ff03564bc114bd0f0b
Signed-off-by: Roman Birg <romanbirg@gmail.com>
SystemUI: add legacy menu button back

Change-Id: I32d687c2dd2682036ceee1032b777b9b10987ffd
Signed-off-by: Roman Birg <romanbirg@gmail.com>
Fix navbar layout

Before: http://owain.nl/before.png
After:  http://owain.nl/after.png

Change-Id: Ie3e3c54a9644d232b1d9b74cbc9fa0eeed072b98
SystemUI: update navigation bar layouts

For tablets, mimic stock button paddings.
Except for when 5 buttons are used, then
distribute them equally across the navbar.

Change-Id: I99ccc07d31bc7b719c44be74f164d88d7dc542d5
Signed-off-by: Roman Birg <romanbirg@gmail.com>
SystemUI: align lights out mode properly in nav bar

We need a little spacer for lights out mode to offset
the menu button!

Change-Id: I322acaea927470c09337823839249953e7558391
Signed-off-by: Roman Birg <romanbirg@gmail.com>
SystemUI: fix nav bar alignment with 4+ buttons

The menu button at the end is now a constant size,
so the separator in the front needs to also be constant now.

Change-Id: I83c33942509e6cf76750b806e828462f3df9c8a8
Signed-off-by: Roman Birg <romanbirg@gmail.com>
SystemUI: fix custom back button image not restoring

Change-Id: I4f564662da21860ab03d10300f52b70590c0f8fc
Signed-off-by: Roman Birg <romanbirg@gmail.com>
Fix cherry-picks

Change-Id: I719eb2462f0be39f5bf6a1af004872e34df068ad

Conflicts:
	core/res/res/values/pac_strings.xml
	core/res/res/values/pac_symbols.xml
SystemUI: update custom nav bar icons

Give them a drop shadow like the new buttons

Change-Id: Iff7d0b1230e824925c98faba99f1a0daa07f0dd4
Signed-off-by: Roman Birg <romanbirg@gmail.com>

Conflicts:
	packages/SystemUI/res/drawable-hdpi/ic_sysbar_null.png
	packages/SystemUI/res/drawable-xhdpi/ic_sysbar_null.png
More fixes

Change-Id: Idd1388bf414177555144b788742a27b44ef7443f

Conflicts:
	packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
AwesomeAction Background thread and kill app changes

launchAction can be handled off the UI thread.
kill app should remove the task from recents too.

Change-Id: I9c24a68667a859fae7df1a71a18e30cc66ff69a5
reimplement navbar cursor keys (1/2)

Change-Id: Iffd8d7f98dc5ec3e5f208821e8eb09723f00b1df
Signed-off-by: Dirk Rettschlag <dirk.rettschlag@gmail.com>
Merge with old branch

Change-Id: I3e9025f60badbc40cf0b9433483dcc095cf79e78

Conflicts:
	packages/SystemUI/res/layout/navigation_bar.xml
	packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
	packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java
fix lights out layout

Buttons during lights out were shifted due to the right arrow button
only being invisible. Set the button to be gone and make Petr happy.

Change-Id: Iafdcb2696809cf5129244833d49595fa448b8b44
Signed-off-by: Dirk Rettschlag <dirk.rettschlag@gmail.com>
NavBar Buttons FC fix.

Change-Id: Ic68c4926971e4f94152c4eabd15463e3f7efdf94
Signed-off-by: Lokesh Chamane <lokesh.c703@gmail.com>
NavigationButtonView: remove redundant onchange from setting observer, and prevent double (un)registration.

Change-Id: I05de2946823647345e34ced6c3b4394afecb22f4

Conflicts:
	packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java