Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
dim status bar on android — Gideros Forum

dim status bar on android

keszeghkeszegh Member
edited April 2014 in General questions
Can we do this from gideros?
or is there an easy modification of the eclipse exported project that dims the status bar?

https://developer.android.com/training/system-ui/dim.html

thanks

Comments

  • ar2rsawseenar2rsawseen Maintainer
    edited April 2014 Accepted Answer
    Well if you want to do it only once, simply copy the dimming code in the Activity onCreate event.

    But if you want to control it yourself, dim or undim, the easiest way seems to be using Bridge, from Gideros Labs (aka Native UI http://giderosmobile.com/labs/native-ui)

    You can add two new functions to GBridge.java file:
    public static void dimBar(){
    	View decorView = sActivity.get().getWindow().getDecorView();
    	int uiOptions = View.SYSTEM_UI_FLAG_LOW_PROFILE;
    	decorView.setSystemUiVisibility(uiOptions);
    }
    public static void unDimBar(){
    	View decorView = sActivity.get().getWindow().getDecorView();
    	// Calling setSystemUiVisibility() with a value of 0 clears
    	// all flags.
    	decorView.setSystemUiVisibility(0);
    }
    and use it in lua through the bridge:
    local bridge = native.getClass("com.giderosmobile.android.plugins.bridge.GBridge")
    bridge.dimBar()
  • keszeghkeszegh Member
    edited April 2014
    thanks,
    for the first solution, the problem is that on each touch of the status bar (according to the android page explanation) the dimming is reseted and the app has to set it again manually at some point. i don't know if/how that's possible to make some 'eventlistener' in java that sets dimming on regularly.
    the second solution seems best with the native ui.
  • @keszegh

    Android has some rules regarding their UI, mostly that touching the status bar should undim it, and that touching anywhere the screen should show the software-buttons (if that device has them...)

    Doing a auto-dimming or auto-hiding again that is too agressive might make google delete your app when they find about it.

    What you should do instead if find another solution for dimming it again, most likely put the dimming code when the app comes to foreground, and after you handle the back-button (ie: if the reason the UI is undimmed was because you pressed the back button to change the screen, then it is safe to assume the person won't need the UI for now again, thus you can dim it again).
    I make games for children: http://www.kidoteca.com
  • edited April 2014
    By the way, both of these can be done from within Gideros Lua. (Gideros if I remember has events for hardware back button and for the app going or returning from background).
    I make games for children: http://www.kidoteca.com
  • ar2rsawseenar2rsawseen Maintainer
    Also to note, that most probably you will need to check for phone's API level to see if that is supported.
Sign In or Register to comment.