Advertisement
Guest User

Untitled

a guest
Apr 24th, 2014
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. public static void toggleHideyBar(final ForgeTask task) {
  2. task.performUI(new Runnable() {
  3. public void run() {
  4. // The UI options currently enabled are represented by a bitfield.
  5. // getSystemUiVisibility() gives us that bitfield.
  6. int uiOptions = ForgeApp.getActivity().getWindow().getDecorView().getSystemUiVisibility();
  7. int newUiOptions = uiOptions;
  8. boolean isImmersiveModeEnabled = ((uiOptions | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY) == uiOptions);
  9. if (isImmersiveModeEnabled) {
  10. ForgeLog.d("Turning immersive mode mode off.");
  11. } else {
  12. ForgeLog.d("Turning immersive mode mode on.");
  13. }
  14.  
  15. // Navigation bar hiding: Backwards compatible to ICS.
  16. if (Build.VERSION.SDK_INT >= 14) {
  17. newUiOptions ^= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
  18. }
  19.  
  20. // Status bar hiding: Backwards compatible to Jellybean
  21. if (Build.VERSION.SDK_INT >= 16) {
  22. newUiOptions ^= View.SYSTEM_UI_FLAG_FULLSCREEN;
  23. }
  24.  
  25. // Immersive mode: Backward compatible to KitKat.
  26. // Note that this flag doesn't do anything by itself, it only augments the behavior
  27. // of HIDE_NAVIGATION and FLAG_FULLSCREEN. For the purposes of this sample
  28. // all three flags are being toggled together.
  29. // Note that there are two immersive mode UI flags, one of which is referred to as "sticky".
  30. // Sticky immersive mode differs in that it makes the navigation and status bars
  31. // semi-transparent, and the UI flag does not get cleared when the user interacts with
  32. // the screen.
  33. if (Build.VERSION.SDK_INT >= 18) {
  34. newUiOptions ^= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
  35. }
  36.  
  37. ForgeApp.getActivity().getWindow().getDecorView().setSystemUiVisibility(newUiOptions);
  38. task.success();
  39. }
  40. });
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement