package org.zmc.qutils;

import android.util.Log;
import android.graphics.Color;
import android.view.Window;

import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;
import android.view.View;

import android.os.Build;

// qutils
import org.zmc.qutils.notification.CppCallbacks;
import org.zmc.qutils.QutilsActivity;
// Qt
import org.qtproject.qt5.android.bindings.QtActivity;

public class AndroidUtils extends QtActivity
{
    private static QutilsActivity m_MainContext;

    public AndroidUtils(QutilsActivity mainActivity)
    {
        m_MainContext = mainActivity;
    }

    public static void setStatusBarColor(String colorHexStr)
    {
        Window window = m_MainContext.getWindow();
        // clear FLAG_TRANSLUCENT_STATUS flag:
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        // add FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS flag to the window
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        // finally change the color
        window.setStatusBarColor(Color.parseColor(colorHexStr));
    }

    public static void setStatusBarVisible(boolean visible)
    {
        if (Build.VERSION.SDK_INT < 16) {
            m_MainContext.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        }
        else {
            View decorView = m_MainContext.getWindow().getDecorView();
            m_MainContext.setStatusBarVisible(visible);
            // Hide the status bar.
            if (visible == false) {
                decorView.setSystemUiVisibility(
                                                View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                                                | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                                                | View.SYSTEM_UI_FLAG_FULLSCREEN);
            }
            else {
                decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
            }
        }
    }

    public static void setImmersiveMode(boolean enabled)
    {
        if (Build.VERSION.SDK_INT >= 19) {
            View decorView = m_MainContext.getWindow().getDecorView();
            m_MainContext.setImmersiveModeEnabled(enabled);
            // Hide the status bar.
            if (enabled) {
                decorView.setSystemUiVisibility(
                                                View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                                                | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                                                | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                                                | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                                                | View.SYSTEM_UI_FLAG_FULLSCREEN
                                                | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
            }
            else {
                decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
            }
        }
    }
}

@@ -657,32 +657,90 @@
 orHexStr)%0A    %7B%0A
+        if (android.os.Build.VERSION.SDK_INT %3E= 21) %7B%0A    
         Window w
@@ -782,16 +782,20 @@
         
+    
 // clear
@@ -825,16 +825,20 @@
 S flag:%0A
+    
         
@@ -916,16 +916,20 @@
         
+   
+ 
 // add F
@@ -980,16 +980,20 @@
  window%0A
+    
         
@@ -1079,16 +1079,20 @@
         
+ 
+   
 // final
@@ -1115,24 +1115,28 @@
 lor%0A        
+   
+ 
 window.setSt
@@ -1180,16 +1180,26 @@
 xStr));%0A
+        %7D%0A
     %7D%0A%0A 

Check for valid SDK version