Example usage for android.view View SYSTEM_UI_FLAG_IMMERSIVE_STICKY

List of usage examples for android.view View SYSTEM_UI_FLAG_IMMERSIVE_STICKY

Introduction

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

Prototype

int SYSTEM_UI_FLAG_IMMERSIVE_STICKY

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

Click Source Link

Document

Flag for #setSystemUiVisibility(int) : View would like to remain interactive when hiding the status bar with #SYSTEM_UI_FLAG_FULLSCREEN and/or hiding the navigation bar with #SYSTEM_UI_FLAG_HIDE_NAVIGATION .

Usage

From source file:gl.iglou.scenegraph.MatModeInterface.java

@Override
public void onWindowFocusChanged(boolean hasFocus) {
    super.onWindowFocusChanged(hasFocus);
    if (hasFocus) {
        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);
    }// w  w w  . j av  a2  s .c o  m
}

From source file:org.uoyabause.android.YabauseHandler.java

/** Called when the activity is first created. */
@Override/*from   w w w  .j  a va  2  s. c o m*/
public void onCreate(Bundle savedInstanceState) {
    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(Yabause.this);
    boolean lock_landscape = sharedPref.getBoolean("pref_landscape", false);
    if (lock_landscape == true) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    } else {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
    }

    super.onCreate(savedInstanceState);
    System.gc();

    YabauseApplication application = (YabauseApplication) getApplication();
    mTracker = application.getDefaultTracker();

    setContentView(R.layout.main);
    getWindow().setSustainedPerformanceMode(true);
    getWindow().addFlags(
            WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_FULLSCREEN);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerLayout.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);
    mNavigationView = (NavigationView) findViewById(R.id.nav_view);
    mNavigationView.setNavigationItemSelectedListener(this);
    if (sharedPref.getBoolean("pref_analog_pad", false) == true) {
        mNavigationView.setCheckedItem(R.id.pad_mode);
    }

    DrawerLayout.DrawerListener drawerListener = new DrawerLayout.DrawerListener() {
        @Override
        public void onDrawerSlide(View view, float v) {

        }

        @Override
        public void onDrawerOpened(View view) {
            if (menu_showing == false) {
                menu_showing = true;
                YabauseRunnable.pause();
                audio.mute(audio.SYSTEM);
                String name = YabauseRunnable.getGameTitle();
                TextView tx = (TextView) findViewById(R.id.menu_title);
                if (tx != null) {
                    tx.setText(name);
                }

                if (adView != null) {
                    LinearLayout lp = (LinearLayout) findViewById(R.id.navilayer);
                    if (lp != null) {
                        final int mCount = lp.getChildCount();
                        boolean find = false;
                        for (int i = 0; i < mCount; ++i) {
                            final View mChild = lp.getChildAt(i);
                            if (mChild == adView) {
                                find = true;
                            }
                        }
                        if (find == false) {
                            lp.addView(adView);
                        }
                        AdRequest adRequest = new AdRequest.Builder()
                                .addTestDevice("303A789B146C169D4BDB5652D928FF8E").build();
                        adView.loadAd(adRequest);
                    }
                }

            }
        }

        @Override
        public void onDrawerClosed(View view) {

            if (waiting_reault == false && menu_showing == true) {
                menu_showing = false;
                YabauseRunnable.resume();
                audio.unmute(audio.SYSTEM);
            }

        }

        @Override
        public void onDrawerStateChanged(int i) {
        }
    };
    this.mDrawerLayout.setDrawerListener(drawerListener);

    audio = new YabauseAudio(this);

    Intent intent = getIntent();
    String game = intent.getStringExtra("org.uoyabause.android.FileName");
    if (game != null && game.length() > 0) {
        YabauseStorage storage = YabauseStorage.getStorage();
        gamepath = storage.getGamePath(game);
    } else
        gamepath = "";

    String exgame = intent.getStringExtra("org.uoyabause.android.FileNameEx");
    if (exgame != null) {
        gamepath = exgame;
    }

    PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
    readPreferences();

    padm = PadManager.getPadManager();
    padm.loadSettings();
    waiting_reault = false;

    handler = new YabauseHandler(this);
    yabauseThread = new YabauseRunnable(this);

    UiModeManager uiModeManager = (UiModeManager) getSystemService(Context.UI_MODE_SERVICE);
    if (uiModeManager.getCurrentModeType() != Configuration.UI_MODE_TYPE_TELEVISION) {
        SharedPreferences prefs = getSharedPreferences("private", Context.MODE_PRIVATE);
        Boolean hasDonated = prefs.getBoolean("donated", false);
        if (hasDonated) {
            adView = null;
        } else {
            adView = new AdView(this);
            adView.setAdUnitId(getString(R.string.banner_ad_unit_id2));
            adView.setAdSize(AdSize.BANNER);
            AdRequest adRequest = new AdRequest.Builder().build();
            adView.loadAd(adRequest);
            adView.setAdListener(new AdListener() {
                @Override
                public void onAdOpened() {
                    // Save app state before going to the ad overlay.
                }
            });
        }
    } else {
        adView = null;
    }

}

From source file:io.v.android.apps.syncslides.PresentationActivity.java

/**
 * Set the system UI to be immersive or not.
 *///from   w  w w . ja  v a2  s .  c o m
public void setUiImmersive(boolean immersive) {
    if (immersive) {
        getSupportActionBar().hide();
        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);
    } else {
        getSupportActionBar().show();
        // See the comment at the top of fragment_slide_list.xml for why we don't simply
        // use View.SYSTEM_UI_FLAG_VISIBLE.
        getWindow().getDecorView().setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
    }
}

From source file:com.gigathinking.simpleapplock.Welcome.java

@TargetApi(19)
private void startImmersiveMode(View view) {
    view.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);
}

From source file:com.example.maxuan.photoutils.ViewPagerActivity.java

@Override
public void onClick(View v) {
    if (v.getId() == R.id.selectCancel) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle("").setPositiveButton("", new DialogInterface.OnClickListener() {
            @Override/*from w w  w.ja v a  2 s.  c  o  m*/
            public void onClick(DialogInterface dialog, int which) {
                finish();
            }
        }).setNegativeButton("?", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT)
                    return;
                getWindow().getDecorView()
                        .setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                                | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_FULLSCREEN
                                | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
            }
        }).create().show();
    } else if (v.getId() == R.id.checkbox) {
        Photo photo = photos.get(mViewPager.getCurrentItem());
        int pos = selectedPhotoArray.indexOfKey(photo.id);
        if (selectCheckBox.isChecked() && pos < 0) {
            if (selectedPhotoArray.size() < 9) {
                selectedPhotoArray.append(photo.id, photo);
                selectedPhotoAdapter.notifyDataSetChanged();
                recyclerView.scrollToPosition(selectedPhotoArray.indexOfKey(photo.id));
            } else {
                Toast.makeText(this, "??", Toast.LENGTH_SHORT).show();
                selectCheckBox.setChecked(false);
            }
        } else if (!selectCheckBox.isChecked() && pos >= 0) {
            selectedPhotoArray.remove(photo.id);
            selectedPhotoAdapter.notifyItemRemoved(pos);
            //                recyclerView.scrollToPosition(pos>0?pos-1:0);
        }
        completeBtn.setText(String.format(format, selectedPhotoArray.size()));
        handleSelectedPhotoView(selectedPhotoArray.size() != 0);
    } else if (v.getId() == R.id.completeBtn) {
        Intent intent = new Intent();
        Bundle bundle = new Bundle();
        bundle.putSparseParcelableArray("selectedPhotos", selectedPhotoArray);
        intent.putExtra("data", bundle);
        setResult(RESULT_OK, intent);
        finish();
    }
}

From source file:edu.cmu.ece.ece551.uis.MainActivity.java

@Override
protected void onResume() {
    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);
    super.onResume();
    NativeClickTrack.addReference();//from  w w  w  .  j a  v  a 2s  .c o  m
}

From source file:edu.cmu.ece.ece551.uis.MainActivity.java

@Override
protected void onStart() {
    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);
    super.onStart();
}

From source file:org.apache.cordova.CordovaActivity.java

/**
 * Called when view focus is changed/* ww w  .  ja  v a 2s  .  c om*/
 */
@Override
public void onWindowFocusChanged(boolean hasFocus) {
    super.onWindowFocusChanged(hasFocus);
    if (hasFocus && immersiveMode) {
        final int uiOptions = 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;

        getWindow().getDecorView().setSystemUiVisibility(uiOptions);
    }
}

From source file:com.example.android.advancedimmersivemode.AdvancedImmersiveModeFragment.java

/**
 * Detects and toggles immersive mode (also known as "hidey bar" mode).
 *//*from w  w  w  .  j a  v a  2  s.c o  m*/
public void toggleUiFlags() {

    // BEGIN_INCLUDE (get_current_ui_flags)
    // The "Decor View" is the parent view of the Activity.  It's also conveniently the easiest
    // one to find from within a fragment, since there's a handy helper method to pull it, and
    // we don't have to bother with picking a view somewhere deeper in the hierarchy and calling
    // "findViewById" on it.
    View decorView = getActivity().getWindow().getDecorView();
    int uiOptions = decorView.getSystemUiVisibility();
    int newUiOptions = uiOptions;
    // END_INCLUDE (get_current_ui_flags)

    // BEGIN_INCLUDE (toggle_lowprofile_mode)
    // Low profile mode doesn't resize the screen at all, but it covers the nav & status bar
    // icons with black so they're less distracting.  Unlike "full screen" and "hide nav bar,"
    // this mode doesn't interact with immersive mode at all, but it's instructive when running
    // this sample to observe the differences in behavior.
    if (mLowProfileCheckBox.isChecked()) {
        newUiOptions |= View.SYSTEM_UI_FLAG_LOW_PROFILE;
    } else {
        newUiOptions &= ~View.SYSTEM_UI_FLAG_LOW_PROFILE;
    }
    // END_INCLUDE (toggle_lowprofile_mode)

    // BEGIN_INCLUDE (toggle_fullscreen_mode)
    // When enabled, this flag hides non-critical UI, such as the status bar,
    // which usually shows notification icons, battery life, etc
    // on phone-sized devices.  The bar reappears when the user swipes it down.  When immersive
    // mode is also enabled, the app-drawable area expands, and when the status bar is swiped
    // down, it appears semi-transparently and slides in over the app, instead of pushing it
    // down.
    if (mHideStatusBarCheckBox.isChecked()) {
        newUiOptions |= View.SYSTEM_UI_FLAG_FULLSCREEN;
    } else {
        newUiOptions &= ~View.SYSTEM_UI_FLAG_FULLSCREEN;
    }
    // END_INCLUDE (toggle_fullscreen_mode)

    // BEGIN_INCLUDE (toggle_hidenav_mode)
    // When enabled, this flag hides the black nav bar along the bottom,
    // where the home/back buttons are.  The nav bar normally instantly reappears
    // when the user touches the screen.  When immersive mode is also enabled, the nav bar
    // stays hidden until the user swipes it back.
    if (mHideNavCheckbox.isChecked()) {
        newUiOptions |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
    } else {
        newUiOptions &= ~View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
    }
    // END_INCLUDE (toggle_hidenav_mode)

    // BEGIN_INCLUDE (toggle_immersive_mode)
    // Immersive mode doesn't do anything without at least one of the previous flags
    // enabled.  When enabled, it allows the user to swipe the status and/or nav bars
    // off-screen.  When the user swipes the bars back onto the screen, the flags are cleared
    // and immersive mode is automatically disabled.
    if (mImmersiveModeCheckBox.isChecked()) {
        newUiOptions |= View.SYSTEM_UI_FLAG_IMMERSIVE;
    } else {
        newUiOptions &= ~View.SYSTEM_UI_FLAG_IMMERSIVE;
    }
    // END_INCLUDE (toggle_immersive_mode)

    // BEGIN_INCLUDE (toggle_immersive_mode_sticky)
    // There's actually two forms of immersive mode, normal and "sticky".  Sticky immersive mode
    // is different in 2 key ways:
    //
    // * Uses semi-transparent bars for the nav and status bars
    // * This UI flag will *not* be cleared when the user interacts with the UI.
    //   When the user swipes, the bars will temporarily appear for a few seconds and then
    //   disappear again.
    if (mImmersiveModeStickyCheckBox.isChecked()) {
        newUiOptions |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
    } else {
        newUiOptions &= ~View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
    }
    // END_INCLUDE (toggle_immersive_mode_sticky)

    // BEGIN_INCLUDE (set_ui_flags)
    //Set the new UI flags.
    decorView.setSystemUiVisibility(newUiOptions);
    // END_INCLUDE (set_ui_flags)

    dumpFlagStateToLog(uiOptions);
}

From source file:com.heinrichreimersoftware.materialintro.app.IntroActivity.java

@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void setFullscreenFlags(boolean fullscreen) {
    int fullscreenFlags = View.SYSTEM_UI_FLAG_FULLSCREEN;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        fullscreenFlags |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
    }//from  ww  w.j  av a 2  s  .  c  o m

    setSystemUiFlags(fullscreenFlags, fullscreen);
}