Fuse Community

Nav Bar reappear on pressing home and doesnt hide anymore

using Uno;
using Uno.Collections;
using Uno.Compiler.ExportTargetInterop;
using Fuse;
using Fuse.Scripting;

public class NavbarModule : NativeModule
{
    public NavbarModule()
    {
        AddMember(new NativeFunction("HideBar", (NativeCallback)HideBar));
        AddMember(new NativeFunction("ShowBar", (NativeCallback)ShowBar));
    }

    static object HideBar(Context c, object[] args)
    {
        SetNavigationBarVisible(false);

        return null;
    }

    static object ShowBar(Context c, object[] args)
    {
        SetNavigationBarVisible(true);

        return null;
    }


    [Foreign(Language.Java)]
    static extern(Android) void SetNavigationBarVisible(bool visible)
    @{
        android.app.Activity rootActivity = @(Activity.Package).@(Activity.Name).GetRootActivity();

        rootActivity.runOnUiThread(new Runnable() {
            @Override
            public void run() {                android.view.Window window = @(Activity.Package).@(Activity.Name).GetRootActivity().getWindow();
                // This code will always run on the UI thread, therefore is safe to modify UI elements.

                if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT)
                {
                    android.view.View decorView = window.getDecorView();

                    int uiOptions = decorView.getSystemUiVisibility();

                    if (visible)
                    {
                        uiOptions &= ~(android.view.View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | android.view.View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
                    }
                    else
                    {
                        uiOptions |= android.view.View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | android.view.View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
                    }

                    decorView.setSystemUiVisibility(uiOptions);
                }
            }
        });
    @}

    static extern(!Android) void SetNavigationBarVisible(bool visible)
    {
        debug_log "SetNavigationBarVisible not available on this platform";
    }
}

how to create onResume activity so navbar hide again after coming back from Home.

Try something like this function and overrides I found:

Thanks for help but i dont have much knowledge about Java (Thats why i choose Fuse). I have tried but it doesnt working. If you able to give an example it would be great. How to implement below code in Fuse?

@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
hideSystemUI();
}
}

private void hideSystemUI() {
// Enables regular immersive mode.
// For “lean back” mode, remove SYSTEM_UI_FLAG_IMMERSIVE.
// Or for “sticky immersive,” replace it with SYSTEM_UI_FLAG_IMMERSIVE_STICKY
View decorView = getWindow().getDecorView();
decorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_IMMERSIVE
// Set the content to appear under the system bars so that the
// content doesn’t resize when the system bars hide and show.
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
// Hide the nav bar and status bar
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN);
}

// Shows the system bars by removing all the flags
// except for the ones that make the content appear under the system bars.
private void showSystemUI() {
View decorView = getWindow().getDecorView();
decorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}