Java Code Examples for android.view.View.getSystemUiVisibility()

The following are Jave code examples for showing how to use getSystemUiVisibility() of the android.view.View class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: androidnative.pri   File: Util.java   Source Code and License Vote up 6 votes
static void setFullScreen(Map message) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP ) { 
        return;
    }

    final Boolean value = (Boolean) message.get("value");
    final Activity activity = QtNative.activity();

    Runnable runnable = new Runnable () {
        public void run() {
            Window w = activity.getWindow(); // in Activity's onCreate() for instance
            View decorView = w.getDecorView();

            int config = decorView.getSystemUiVisibility();

            if (value) {
                config &= ~View.SYSTEM_UI_FLAG_FULLSCREEN;
            } else {
                config |= View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
            }
            decorView.setSystemUiVisibility(config);
        }
    };

    activity.runOnUiThread(runnable);

}
 
Example 2
Project: SetupWizardLibCompat   File: SystemBarHelper.java   Source Code and License Vote up 5 votes
/**
 * Convenience method to remove a visibility flag from the view, leaving other flags that are
 * not specified intact.
 */
public static void removeVisibilityFlag(final View view, final int flag) {
    if (VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB) {
        final int vis = view.getSystemUiVisibility();
        view.setSystemUiVisibility(vis & ~flag);
    }
}
 
Example 3
Project: MakiLite   File: MainActivity.java   Source Code and License Vote up 5 votes
@TargetApi(Build.VERSION_CODES.KITKAT)
private void showSystemUI() {
    View decorView = getWindow().getDecorView();
    previousUiVisibility = decorView.getSystemUiVisibility();
    onConfigurationChanged(getResources().getConfiguration());

}
 
Example 4
Project: FriendBook   File: SystemBarUtils.java   Source Code and License Vote up 5 votes
public static void setFlag(Activity activity, int flag){
    if (Build.VERSION.SDK_INT >= 19){
        View decorView = activity.getWindow().getDecorView();
        int option = decorView.getSystemUiVisibility() | flag;
        decorView.setSystemUiVisibility(option);
    }
}
 
Example 5
Project: AmenEye   File: ViewUtil.java   Source Code and License Vote up 5 votes
public static void clearLightStatusBar(@NonNull View view) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        int flags = view.getSystemUiVisibility();
        flags &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
        view.setSystemUiVisibility(flags);
    }
}
 
Example 6
Project: BrotherWeather   File: StatusBarTextColorUtils.java   Source Code and License Vote up 5 votes
public static void setWindowLightStatusBar(Activity activity, Boolean lightStatusBar) {
  Window window = activity.getWindow();
  View decor = window.getDecorView();
  //取消设置透明状态栏,使 ContentView 内容不再覆盖状态栏
  window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
  //需要设置这个 flag 才能调用 setStatusBarColor 来设置状态栏颜色
  window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
  int ui = decor.getSystemUiVisibility();
  if (lightStatusBar) {
    ui |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
  } else {
    ui &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
  }
  decor.setSystemUiVisibility(ui);
}
 
Example 7
Project: Farmacias   File: Utils.java   Source Code and License Vote up 5 votes
public static void setLightStatusBar(View view, Activity activity) {

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            View decor = activity.getWindow().getDecorView();
            oldStatusBarFlags = decor.getSystemUiVisibility();
            int flags = view.getSystemUiVisibility();
            flags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
            view.setSystemUiVisibility(flags);
            activity.getWindow().setStatusBarColor(Color.WHITE);
        }


    }
 
Example 8
Project: siiMobilityAppKit   File: StatusBar.java   Source Code and License Vote up 5 votes
private void setStatusBarStyle(final String style) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        if (style != null && !style.isEmpty()) {
            View decorView = cordova.getActivity().getWindow().getDecorView();
            int uiOptions = decorView.getSystemUiVisibility();

            String[] darkContentStyles = {
                "default",
            };

            String[] lightContentStyles = {
                "lightcontent",
                "blacktranslucent",
                "blackopaque",
            };

            if (Arrays.asList(darkContentStyles).contains(style.toLowerCase())) {
                decorView.setSystemUiVisibility(uiOptions | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
                return;
            }

            if (Arrays.asList(lightContentStyles).contains(style.toLowerCase())) {
                decorView.setSystemUiVisibility(uiOptions & ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
                return;
            }

            LOG.e(TAG, "Invalid style, must be either 'default', 'lightcontent' or the deprecated 'blacktranslucent' and 'blackopaque'");
        }
    }
}
 
Example 9
Project: music-player   File: ViewUtils.java   Source Code and License Vote up 5 votes
public static void setLightStatusBar(@NonNull View view) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        int flags = view.getSystemUiVisibility();
        flags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
        view.setSystemUiVisibility(flags);
    }
}
 
Example 10
Project: siiMobilityAppKit   File: StatusBar.java   Source Code and License Vote up 5 votes
private void setStatusBarStyle(final String style) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        if (style != null && !style.isEmpty()) {
            View decorView = cordova.getActivity().getWindow().getDecorView();
            int uiOptions = decorView.getSystemUiVisibility();

            String[] darkContentStyles = {
                "default",
            };

            String[] lightContentStyles = {
                "lightcontent",
                "blacktranslucent",
                "blackopaque",
            };

            if (Arrays.asList(darkContentStyles).contains(style.toLowerCase())) {
                decorView.setSystemUiVisibility(uiOptions | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
                return;
            }

            if (Arrays.asList(lightContentStyles).contains(style.toLowerCase())) {
                decorView.setSystemUiVisibility(uiOptions & ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
                return;
            }

            LOG.e(TAG, "Invalid style, must be either 'default', 'lightcontent' or the deprecated 'blacktranslucent' and 'blackopaque'");
        }
    }
}
 
Example 11
Project: FastAndroid   File: MeiZuStatusbarColorUtils.java   Source Code and License Vote up 5 votes
/**
 * 设置状态栏颜色
 *
 * @param view
 * @param dark
 */
private static void setStatusBarDarkIcon(View view, boolean dark) {
    int oldVis = view.getSystemUiVisibility();
    int newVis = oldVis;
    if (dark) {
        newVis |= SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
    } else {
        newVis &= ~SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
    }
    if (newVis != oldVis) {
        view.setSystemUiVisibility(newVis);
    }
}
 
Example 12
Project: featurea   File: AndroidInputUtil.java   Source Code and License Vote up 5 votes
public static void showNavigationBar(Window window) {
    if (window == null) {
        return;
    }

    window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    window.addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);

    final View decorView = window.getDecorView();

    if (decorView != null) {
        int uiOptions = decorView.getSystemUiVisibility();

        if (Build.VERSION.SDK_INT >= 14) {
            uiOptions &= ~View.SYSTEM_UI_FLAG_LOW_PROFILE;
        }

        if (Build.VERSION.SDK_INT >= 16) {
            uiOptions &= ~View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
        }

        if (Build.VERSION.SDK_INT >= 19) {
            uiOptions &= ~View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
        }

        decorView.setSystemUiVisibility(uiOptions);
    }
}
 
Example 13
Project: NovelReader   File: SystemBarUtils.java   Source Code and License Vote up 5 votes
public static void clearFlag(Activity activity, int flag){
    if (Build.VERSION.SDK_INT >= 19){
        View decorView = activity.getWindow().getDecorView();
        int option = decorView.getSystemUiVisibility() & (~flag);
        decorView.setSystemUiVisibility(option);
    }
}
 
Example 14
Project: Paper-Launcher   File: SystemBarUtil.java   Source Code and License Vote up 5 votes
public static void enableLightStatusBar(Activity activity) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        View view = activity.getWindow().getDecorView();

        int flags = view.getSystemUiVisibility();
        flags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
        view.setSystemUiVisibility(flags);
    }
}
 
Example 15
Project: dkplayer   File: WindowUtil.java   Source Code and License Vote up 5 votes
private static void showNavigationBar(Context context) {
    View decorView = scanForActivity(context).getWindow().getDecorView();
    int systemUiVisibility = decorView.getSystemUiVisibility();
    int flags = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_FULLSCREEN;
    systemUiVisibility &= ~flags;
    decorView.setSystemUiVisibility(systemUiVisibility);
}
 
Example 16
Project: featurea   File: AndroidInputUtil.java   Source Code and License Vote up 5 votes
/**
 * <pre>{@code
 * @Override
 * public void onWindowFocusChanged(boolean hasFocus) {
 *   super.onWindowFocusChanged(hasFocus);
 *   if (hasFocus) {
 *     // place here
 *   }
 * }
 * }</pre>
 */

public static void hideNavigationBar(Window window) {
    if (window == null) {
        return;
    }

    window.clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
    window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

    final View decorView = window.getDecorView();

    if (decorView != null) {
        int uiOptions = decorView.getSystemUiVisibility();

        if (Build.VERSION.SDK_INT >= 14) {
            uiOptions |= View.SYSTEM_UI_FLAG_LOW_PROFILE;
        }

        if (Build.VERSION.SDK_INT >= 16) {
            uiOptions |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
        }

        if (Build.VERSION.SDK_INT >= 19) {
            uiOptions |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
        }

        decorView.setSystemUiVisibility(uiOptions);
    }
}
 
Example 17
Project: SetupWizardLibCompat   File: SystemBarHelper.java   Source Code and License Vote up 5 votes
/**
 * Convenience method to add a visibility flag in addition to the existing ones.
 */
public static void addVisibilityFlag(final View view, final int flag) {
    if (VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB) {
        final int vis = view.getSystemUiVisibility();
        view.setSystemUiVisibility(vis | flag);
    }
}
 
Example 18
Project: Hello-Music-droid   File: ATEUtils.java   Source Code and License Vote up 4 votes
public static void setStatusBarColor(Activity activity, String key, int color) {
    try {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            final Window window = activity.getWindow();
            if (Config.coloredStatusBar(activity, key))
                window.setStatusBarColor(getStatusBarColor(color));
            else window.setStatusBarColor(Color.BLACK);
            if (Config.coloredNavigationBar(activity, key))
                window.setNavigationBarColor(color);
            else window.setNavigationBarColor(Color.BLACK);
            applyTaskDescription(activity, key, color);
        }
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            final View decorView = activity.getWindow().getDecorView();
            final int lightStatusMode = Config.lightStatusBarMode(activity, key);
            boolean lightStatusEnabled = false;
            switch (lightStatusMode) {
                case Config.LIGHT_STATUS_BAR_OFF:
                default:
                    break;
                case Config.LIGHT_STATUS_BAR_ON:
                    lightStatusEnabled = true;
                    break;
                case Config.LIGHT_STATUS_BAR_AUTO:
                    lightStatusEnabled = Util.isColorLight(color);
                    break;
            }

            final int systemUiVisibility = decorView.getSystemUiVisibility();
            if (lightStatusEnabled) {
                decorView.setSystemUiVisibility(systemUiVisibility | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
            } else {
                decorView.setSystemUiVisibility(systemUiVisibility & ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
            }
        }

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            final int color2 = Config.coloredStatusBar(activity, key) ?
                    Color.TRANSPARENT : Color.BLACK;
            activity.getWindow().setStatusBarColor(color2);
        }
        if (Config.coloredStatusBar(activity, key))
            ((DrawerLayout) ((ViewGroup) activity.findViewById(android.R.id.content)).getChildAt(0)).setStatusBarBackgroundColor(getStatusBarColor(color));
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 19
Project: BilibiliClient   File: SystemUiVisibilityUtil.java   Source Code and License Vote up 2 votes
public static boolean hasFlags(View view, int flags) {

    return (view.getSystemUiVisibility() & flags) == flags;
  }
 
Example 20
Project: BilibiliClient   File: SystemUiVisibilityUtil.java   Source Code and License Vote up 2 votes
public static boolean hasFlags(View view, int flags) {

    return (view.getSystemUiVisibility() & flags) == flags;
  }