Example usage for android.view View SYSTEM_UI_FLAG_FULLSCREEN

List of usage examples for android.view View SYSTEM_UI_FLAG_FULLSCREEN

Introduction

In this page you can find the example usage for android.view View SYSTEM_UI_FLAG_FULLSCREEN.

Prototype

int SYSTEM_UI_FLAG_FULLSCREEN

To view the source code for android.view View SYSTEM_UI_FLAG_FULLSCREEN.

Click Source Link

Document

Flag for #setSystemUiVisibility(int) : View has requested to go into the normal fullscreen mode so that its content can take over the screen while still allowing the user to interact with the application.

Usage

From source file:com.segma.trim.MainActivity.java

private void hideNavigationBar() {

    //TODO: 11-4-2016 FIX: Hide Navigation Bar
    final int flags = View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_FULLSCREEN
            //| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
            | View.SYSTEM_UI_FLAG_IMMERSIVE | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
    final View decorView = getWindow().getDecorView();
    decorView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
        @Override/*  w ww .j  av  a2 s  . co m*/
        public void onSystemUiVisibilityChange(int visibility) {
            // Note that system bars will only be "visible" if none of the
            // LOW_PROFILE, HIDE_NAVIGATION, or FULLSCREEN flags are set.
            if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
                // TODO: The system bars are visible. Make any desired
                // adjustments to your UI, such as showing the action bar or
                // other navigational controls.

                //decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
                //decorView.setSystemUiVisibility(decorView.getSystemUiVisibility());
                //getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
                decorView.setSystemUiVisibility(flags);
                getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                        WindowManager.LayoutParams.FLAG_FULLSCREEN);
            } else {
                // TODO: The system bars are NOT visible. Make any desired
                // adjustments to your UI, such as hiding the action bar or
                // other navigational controls.
            }
        }
    });
    decorView.setSystemUiVisibility(flags);
}

From source file:org.godotengine.godot.Godot.java

@Override
protected void onCreate(Bundle icicle) {

    super.onCreate(icicle);
    Window window = getWindow();//from w  w w .ja v a  2s  . com
    //window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
    mClipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);

    //check for apk expansion API
    if (true) {
        boolean md5mismatch = false;
        command_line = getCommandLine();
        String main_pack_md5 = null;
        String main_pack_key = null;

        List<String> new_args = new LinkedList<String>();

        for (int i = 0; i < command_line.length; i++) {

            boolean has_extra = i < command_line.length - 1;
            if (command_line[i].equals("--use_depth_32")) {
                use_32_bits = true;
            } else if (command_line[i].equals("--debug_opengl")) {
                use_debug_opengl = true;
            } else if (command_line[i].equals("--use_immersive")) {
                use_immersive = true;
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { // check if the application runs on an android 4.4+
                    window.getDecorView().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 | // hide nav bar
                            View.SYSTEM_UI_FLAG_FULLSCREEN | // hide status bar
                            View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);

                    UiChangeListener();
                }
            } else if (command_line[i].equals("--use_apk_expansion")) {
                use_apk_expansion = true;
            } else if (has_extra && command_line[i].equals("--apk_expansion_md5")) {
                main_pack_md5 = command_line[i + 1];
                i++;
            } else if (has_extra && command_line[i].equals("--apk_expansion_key")) {
                main_pack_key = command_line[i + 1];
                SharedPreferences prefs = getSharedPreferences("app_data_keys", MODE_PRIVATE);
                Editor editor = prefs.edit();
                editor.putString("store_public_key", main_pack_key);

                editor.apply();
                i++;
            } else if (command_line[i].trim().length() != 0) {
                new_args.add(command_line[i]);
            }
        }

        if (new_args.isEmpty()) {
            command_line = null;
        } else {

            command_line = new_args.toArray(new String[new_args.size()]);
        }
        if (use_apk_expansion && main_pack_md5 != null && main_pack_key != null) {
            //check that environment is ok!
            if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
                //show popup and die
            }

            // Build the full path to the app's expansion files
            try {
                expansion_pack_path = Helpers.getSaveFilePath(getApplicationContext());
                expansion_pack_path += "/main."
                        + getPackageManager().getPackageInfo(getPackageName(), 0).versionCode + "."
                        + this.getPackageName() + ".obb";
            } catch (Exception e) {
                e.printStackTrace();
            }

            File f = new File(expansion_pack_path);

            boolean pack_valid = true;

            if (!f.exists()) {

                pack_valid = false;

            } else if (obbIsCorrupted(expansion_pack_path, main_pack_md5)) {
                pack_valid = false;
                try {
                    f.delete();
                } catch (Exception e) {
                }
            }

            if (!pack_valid) {

                Intent notifierIntent = new Intent(this, this.getClass());
                notifierIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);

                PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notifierIntent,
                        PendingIntent.FLAG_UPDATE_CURRENT);

                int startResult;
                try {
                    startResult = DownloaderClientMarshaller.startDownloadServiceIfRequired(
                            getApplicationContext(), pendingIntent, GodotDownloaderService.class);

                    if (startResult != DownloaderClientMarshaller.NO_DOWNLOAD_REQUIRED) {
                        // This is where you do set up to display the download
                        // progress (next step)
                        mDownloaderClientStub = DownloaderClientMarshaller.CreateStub(this,
                                GodotDownloaderService.class);

                        setContentView(com.godot.game.R.layout.downloading_expansion);
                        mPB = (ProgressBar) findViewById(com.godot.game.R.id.progressBar);
                        mStatusText = (TextView) findViewById(com.godot.game.R.id.statusText);
                        mProgressFraction = (TextView) findViewById(com.godot.game.R.id.progressAsFraction);
                        mProgressPercent = (TextView) findViewById(com.godot.game.R.id.progressAsPercentage);
                        mAverageSpeed = (TextView) findViewById(com.godot.game.R.id.progressAverageSpeed);
                        mTimeRemaining = (TextView) findViewById(com.godot.game.R.id.progressTimeRemaining);
                        mDashboard = findViewById(com.godot.game.R.id.downloaderDashboard);
                        mCellMessage = findViewById(com.godot.game.R.id.approveCellular);
                        mPauseButton = (Button) findViewById(com.godot.game.R.id.pauseButton);
                        mWiFiSettingsButton = (Button) findViewById(com.godot.game.R.id.wifiSettingsButton);

                        return;
                    } else {
                    }
                } catch (NameNotFoundException e) {
                    // TODO Auto-generated catch block
                }
            }
        }
    }

    mCurrentIntent = getIntent();

    initializeGodot();

    //instanceSingleton( new GodotFacebook(this) );
}

From source file:com.cerema.cloud2.ui.preview.PreviewImageActivity.java

@SuppressLint("InlinedApi")
private void hideSystemUI(View anchorView) {
    anchorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hides NAVIGATION BAR; Android >= 4.0
            | View.SYSTEM_UI_FLAG_FULLSCREEN // hides STATUS BAR;     Android >= 4.1
            | View.SYSTEM_UI_FLAG_IMMERSIVE // stays interactive;    Android >= 4.4
            | View.SYSTEM_UI_FLAG_LAYOUT_STABLE // draw full window;     Android >= 4.1
            | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN // draw full window;     Android >= 4.1
            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION // draw full window;     Android >= 4.1
    );//from w w w  . ja  v a2  s .c  o  m
}

From source file:im.ene.lab.toro.ext.layeredvideo.PlaybackControlLayer.java

/**
 * Fullscreen mode will rotate to landscape mode, hide the action bar, hide the navigation bar,
 * hide the system tray, and make the video player take up the full size of the display.
 * The developer who is using this function must ensure the following:
 *
 * <p>1) Inside the android manifest, the activity that uses the video player has the attribute
 * android:configChanges="orientation"./*from w  ww  . j  av a  2s . com*/
 *
 * <p>2) Other views in the activity (or fragment) are
 * hidden (or made visible) when this method is called.
 */
public void doToggleFullscreen() {
    // If there is no callback for handling fullscreen, don't do anything.
    if (fullscreenCallback == null) {
        return;
    }

    ObservablePlayerControl playerControl = layerManager.getControl();
    if (playerControl == null) {
        return;
    }

    Activity activity = layerManager.getActivity();
    FrameLayout container = layerManager.getContainer();

    if (isFullscreen) {
        activity.setRequestedOrientation(savedOrientation);

        // Make the status bar and navigation bar visible again.
        activity.getWindow().getDecorView().setSystemUiVisibility(0);

        container.setLayoutParams(originalContainerLayoutParams);

        fullscreenButton.setImageResource(R.drawable.toro_ext_ic_fullscreen_enter);

        fullscreenCallback.onReturnFromFullscreen();
        isFullscreen = false;
    } else {
        savedOrientation = activity.getResources().getConfiguration().orientation;
        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

        activity.getWindow().getDecorView().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);

        container.setLayoutParams(PlayerUtil.getLayoutParamsBasedOnParent(container,
                ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

        fullscreenButton.setImageResource(R.drawable.toro_ext_ic_fullscreen_exit);
        fullscreenCallback.onGoToFullscreen();
        isFullscreen = true;
    }
}

From source file:pct.droid.fragments.VideoPlayerFragment.java

@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public void hideOverlay() {
    // Can only hide 1000 millisec after show, because navbar doesn't seem to hide otherwise.
    if (mLastSystemShowTime + 1000 < System.currentTimeMillis()) {
        AnimUtils.fadeOut(mControlLayout);
        AnimUtils.fadeOut(mToolbar);//from   w  w w  .j a  v  a2s. co m

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN;
            mDecorView.setSystemUiVisibility(uiOptions);
        } else {
            getAppCompatActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
            getAppCompatActivity().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
        }

        mDisplayHandler.removeCallbacks(mOverlayHideRunnable);
        mOverlayVisible = false;
    }
}

From source file:com.lemon.lime.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    final View coordinatorLayoutView = findViewById(R.id.snackbarPosition);
    switch (item.getItemId()) {

    case R.id.back:
        mWebView.goBack();//from w w  w. j a v  a  2  s  . c  om
        break;

    case R.id.forward:
        mWebView.goForward();
        break;

    case R.id.reload:
        mWebView.reload();
        break;

    case R.id.new_tab:
        Intent c = new Intent(this, MainActivity.class);
        startActivityForResult(c, RESULT_SETTINGS);
        break;

    case R.id.add_bookmark:
        Intent book = new Intent(this, BookMarkActivity.class);
        startActivityForResult(book, RESULT_SETTINGS);
        break;

    case R.id.share:
        String url = mWebView.getUrl().toString();
        ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
        clipboard.setText(url);
        Snackbar snackbar = Snackbar.make(coordinatorLayoutView, R.string.clipboard, Snackbar.LENGTH_LONG);
        snackbar.show();
        break;

    case R.id.menu_settings:
        Intent i = new Intent(this, UserSettingActivity.class);
        startActivityForResult(i, RESULT_SETTINGS);
        break;

    case R.id.invert:

        if (night == 0) {
            getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.BLACK));
            mWebView.setBackgroundColor(Color.parseColor("#000000"));
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

                window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
                window.setNavigationBarColor(Color.BLACK);
                window.setStatusBarColor(Color.BLACK);
            }

            night = 1;
        } else {
            getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#7AB317")));
            mWebView.setBackgroundColor(Color.TRANSPARENT);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

                window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
                window.setNavigationBarColor(Color.parseColor("#7AB317"));
                window.setStatusBarColor(Color.parseColor("#7AB317"));
            }

            night = 0;
        }

        break;

    case R.id.hide:
        View decorView = window.getDecorView();
        int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
        decorView.setSystemUiVisibility(uiOptions);
        getSupportActionBar().hide();
        break;

    case R.id.easteregg:
        Toast.makeText(this, "(  Y  )", Toast.LENGTH_SHORT).show();
        mPlayer.start();
        addBarGraphRenderers();
        break;

    }

    return true;
}

From source file:uk.co.armedpineapple.cth.SDLActivity.java

@SuppressLint("NewApi")
public void hideSystemUi() {
    if (Build.VERSION.SDK_INT >= 19) {

        // Hide the navigation buttons if supported
        getWindow().getDecorView().setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                        | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_FULLSCREEN);
    } else if (Build.VERSION.SDK_INT >= 11) {

        // Use low profile mode if supported
        getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);

    }/*from ww  w  . j  a v  a2  s .  c o  m*/
}

From source file:org.chromium.latency.walt.ScreenResponseFragment.java

private void setFullScreen(boolean enable) {
    final AppCompatActivity activity = (AppCompatActivity) getActivity();
    final ActionBar actionBar = activity != null ? activity.getSupportActionBar() : null;
    int newVisibility = 0;
    if (enable) {
        if (actionBar != null)
            actionBar.hide();//  www . j a v a 2 s  .  c o m
        buttonBarView.setVisibility(View.GONE);
        newVisibility |= View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
    } else {
        if (actionBar != null)
            actionBar.show();
        buttonBarView.setVisibility(View.VISIBLE);
    }
    if (activity != null)
        activity.getWindow().getDecorView().setSystemUiVisibility(newVisibility);
}

From source file:com.retroteam.studio.retrostudio.EditorLandscape.java

/**
 * Toggle Immersive Mode for more room on small devices.
 *//*  w  w  w  .ja  va2  s .  co  m*/

private void toggleHideyBar() {

    // The UI options currently enabled are represented by a bitfield.
    // getSystemUiVisibility() gives us that bitfield.
    int uiOptions = this.getWindow().getDecorView().getSystemUiVisibility();
    int newUiOptions = uiOptions;
    boolean isImmersiveModeEnabled = ((uiOptions | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY) == uiOptions);
    if (isImmersiveModeEnabled) {
        Log.i("EditorLandscape", "Turning immersive mode mode off. ");
    } else {
        Log.i("EditorLandscape", "Turning immersive mode mode on.");
    }

    // Navigation bar hiding:  Backwards compatible to ICS.
    if (Build.VERSION.SDK_INT >= 14) {
        newUiOptions ^= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
    }

    // Status bar hiding: Backwards compatible to Jellybean
    if (Build.VERSION.SDK_INT >= 16) {
        newUiOptions ^= View.SYSTEM_UI_FLAG_FULLSCREEN;
    }

    // Immersive mode: Backward compatible to KitKat.
    // Note that this flag doesn't do anything by itself, it only augments the behavior
    // of HIDE_NAVIGATION and FLAG_FULLSCREEN.  For the purposes of this sample
    // all three flags are being toggled together.
    // Note that there are two immersive mode UI flags, one of which is referred to as "sticky".
    // Sticky immersive mode differs in that it makes the navigation and status bars
    // semi-transparent, and the UI flag does not get cleared when the user interacts with
    // the screen.
    if (Build.VERSION.SDK_INT >= 18) {
        newUiOptions ^= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
    }

    this.getWindow().getDecorView().setSystemUiVisibility(newUiOptions);
}

From source file:com.mishiranu.dashchan.ui.gallery.GalleryActivity.java

@TargetApi(Build.VERSION_CODES.KITKAT)
private void invalidateSystemUiVisibility() {
    ActionBar actionBar = getActionBar();
    boolean visible = isSystemUiVisible();
    if (visible) {
        actionBar.show();//from w  w w.j av  a 2s. c om
    } else {
        actionBar.hide();
    }
    if (C.API_LOLLIPOP && expandedScreen) {
        View decorView = getWindow().getDecorView();
        int visibility = decorView.getSystemUiVisibility();
        visibility = FlagUtils.set(visibility, View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE
                | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION, !visible);
        decorView.setSystemUiVisibility(visibility);
    }
    if (pagerUnit != null) {
        pagerUnit.invalidateControlsVisibility();
    }
}