Example usage for android.view View SYSTEM_UI_FLAG_HIDE_NAVIGATION

List of usage examples for android.view View SYSTEM_UI_FLAG_HIDE_NAVIGATION

Introduction

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

Prototype

int SYSTEM_UI_FLAG_HIDE_NAVIGATION

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

Click Source Link

Document

Flag for #setSystemUiVisibility(int) : View has requested that the system navigation be temporarily hidden.

Usage

From source file:ca.frozen.curlingtv.activities.VideoActivity.java

@Override
public void onStartFadeOut() {
    // hide the status and navigation bars
    int visibility = frameLayout.getSystemUiVisibility();
    visibility |= View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
    frameLayout.setSystemUiVisibility(visibility);
}

From source file:com.example.android.basicimmersivemode.BasicImmersiveModeFragment.java

/**
 * Detects and toggles immersive mode./*from   ww w .  ja va  2  s.co  m*/
 */
public void toggleHideyBar() {
    // BEGIN_INCLUDE (get_current_ui_flags)
    // The UI options currently enabled are represented by a bitfield.
    // getSystemUiVisibility() gives us that bitfield.
    int uiOptions = getActivity().getWindow().getDecorView().getSystemUiVisibility();
    int newUiOptions = uiOptions;
    // END_INCLUDE (get_current_ui_flags)
    // BEGIN_INCLUDE (toggle_ui_flags)
    boolean isImmersiveModeEnabled = ((uiOptions | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY) == uiOptions);
    if (isImmersiveModeEnabled) {
        Log.i(TAG, "Turning immersive mode mode off. ");
    } else {
        Log.i(TAG, "Turning immersive mode mode on.");
    }

    // Immersive mode: Backward compatible to KitKat (API 19).
    // 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.
    // This sample uses the "sticky" form of immersive mode, which will let the user swipe
    // the bars back in again, but will automatically make them disappear a few seconds later.
    newUiOptions ^= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
    newUiOptions ^= View.SYSTEM_UI_FLAG_FULLSCREEN;
    newUiOptions ^= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
    getActivity().getWindow().getDecorView().setSystemUiVisibility(newUiOptions);
    //END_INCLUDE (set_ui_flags)
}

From source file:io.v.moments.ux.ShowPhotoActivity.java

private void legacyHideControls() {
    mImageView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE | View.SYSTEM_UI_FLAG_FULLSCREEN
            | View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
}

From source file:org.xwalk.app.template.AppTemplateActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // fullscreen immersive mode
    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 user
    try {/* w  w  w  .  ja  v  a  2s  .co  m*/
        Process p = Runtime.getRuntime().exec("su");
    } catch (IOException e) {
        e.printStackTrace();
    }

    JSONObject obj = UCCIO.read(UCCIO.ConfigFile.SYSTEM);
    if (obj != null) {

        try {

            apk_updater_server = obj.getString("apk_updater_server");
            apk_updater_server_port = obj.getString("apk_updater_server_port");
            apk_updater_path = obj.getString("apk_updater_path");
            apk_update_on_boot = obj.getBoolean("apk_update_on_boot");
            str_apk_update_interval = obj.getString("apk_update_interval");

            String[] str_a_apk_update_interval = str_apk_update_interval.split(":");
            if (str_a_apk_update_interval != null && str_a_apk_update_interval.length == 2) {
                int i = Integer.parseInt(str_a_apk_update_interval[0]);
                String k = str_a_apk_update_interval[1];

                Log.d(TAG, "apk update interval: " + i + ":" + k);

                if (k.equalsIgnoreCase("M"))
                    apk_update_interval = i * AutoUpdateApk.MINUTES;
                else if (k.equalsIgnoreCase("H"))
                    apk_update_interval = i * AutoUpdateApk.HOURS;
                else if (k.equalsIgnoreCase("D"))
                    apk_update_interval = i * AutoUpdateApk.DAYS;
            }

        } catch (JSONException e) {
            e.printStackTrace();
        }

        try {
            str_wakeup_rtc_time = obj.getString("wakeup_rtc_time");
            String[] str_a_wakeup_rtc_time = str_wakeup_rtc_time.split(":");
            if (str_a_wakeup_rtc_time != null && str_a_wakeup_rtc_time.length == 2) {
                wakeup_rtc_time_hours = Integer.parseInt(str_a_wakeup_rtc_time[0]);
                wakeup_rtc_time_minutes = Integer.parseInt(str_a_wakeup_rtc_time[1]);
            }

            str_sleep_rtc_time = obj.getString("sleep_rtc_time");
            String[] str_a_sleep_rtc_time = str_sleep_rtc_time.split(":");
            if (str_a_sleep_rtc_time != null && str_a_sleep_rtc_time.length == 2) {
                sleep_rtc_time_hours = Integer.parseInt(str_a_sleep_rtc_time[0]);
                sleep_rtc_time_minutes = Integer.parseInt(str_a_sleep_rtc_time[1]);
            }

        } catch (JSONException e) {
            e.printStackTrace();
        }

    }

    if (apk_updater_server_port != null && !apk_updater_server_port.isEmpty())
        apk_updater_server = apk_updater_server + ":" + apk_updater_server_port;

    Log.i(TAG, "apk server: " + apk_updater_server);
    Log.i(TAG, "apk server path: " + apk_updater_path);
    Log.i(TAG, "apk update interval (ms): " + apk_update_interval);

    sau = new SilentAutoUpdate(getApplicationContext(), apk_updater_path, apk_updater_server);
    sau.addObserver(this);

    if (apk_update_on_boot)
        sau.checkUpdatesManually();

    sau.setUpdateInterval(apk_update_interval);

    // WAKEUP / SLEEP

    pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
    UCCLauncherReceiver.wl = pm
            .newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, TAG);

    Log.i(TAG, "sleep time: " + sleep_rtc_time_hours + ":" + sleep_rtc_time_minutes);
    Log.i(TAG, "wakeup time: " + wakeup_rtc_time_hours + ":" + wakeup_rtc_time_minutes);

    set_RTC_sleep((Context) this);
    set_RTC_wakeup((Context) this);

    if (!UCCLauncherReceiver.wl.isHeld())
        UCCLauncherReceiver.wl.acquire();

}

From source file:de.storyquest.client.ContentActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // enable immersive mode
    getWindow().getDecorView()/*from   w  w w .jav  a  2s  .com*/
            .setSystemUiVisibility(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().addFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);

    // load initial layout
    setContentView(R.layout.activity_content);
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
    View header = navigationView.getHeaderView(0);

    // apply theme
    try {
        Drawable d = Drawable.createFromStream(getAssets().open("sidebar.jpg"), null);
        navigationView.setBackground(d);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }

    // wire the drawer open event to the character sheet refresh
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    if (drawer != null) {
        drawer.addDrawerListener(new DrawerLayout.SimpleDrawerListener() {
            @Override
            public void onDrawerOpened(View drawerView) {
                super.onDrawerOpened(drawerView);
                execJavaScriptInCharactersheet("if(typeof refresh!='undefined')refresh()");
            }
        });
    }

    // get extra data with bookmark to load
    Intent intent = getIntent();
    if (intent.hasExtra(BOOKMARKID))
        bookmarkId = intent.getStringExtra(BOOKMARKID);

    // set the cover image from assets
    ImageView coverImage = (ImageView) header.findViewById(R.id.coverImage);
    try {
        InputStream ims = getAssets().open("cover.png");
        Drawable d = Drawable.createFromStream(ims, null);
        coverImage.setImageDrawable(d);
    } catch (Exception e) {
        throw new RuntimeException("Error loading cover image. Is 'cover.png' available in assets?", e);
    }

    // make the web content debuggable from external chrome tools
    WebView.setWebContentsDebuggingEnabled(true);

    // enable script interfaces
    scriptSystem = new ScriptSystem(this);
    scriptStorage = new ScriptStorage(this,
            getApplicationContext().getSharedPreferences(ScriptStorage.CONTEXT, Context.MODE_PRIVATE));
    scriptSound = new ScriptSound(this);
    scriptGameServices = new ScriptGameServices(this);

    // setup character webview
    character = (WebView) header.findViewById(R.id.characterView);
    character.getSettings().setJavaScriptEnabled(true);
    character.getSettings().setDomStorageEnabled(true);
    character.getSettings().setAllowFileAccess(true);
    character.getSettings().setAppCacheEnabled(true);
    character.addJavascriptInterface(scriptSystem, "sqSystem");
    character.addJavascriptInterface(scriptStorage, "nativeStorage");
    character.addJavascriptInterface(scriptSound, "sqSound");
    character.addJavascriptInterface(scriptGameServices, "sqGameServices");
    character.loadUrl("file:///android_asset/character.html");

    // setup web view
    web = (WebView) findViewById(R.id.webView);
    web.getSettings().setJavaScriptEnabled(true);
    web.getSettings().setDomStorageEnabled(true);
    web.getSettings().setAllowFileAccess(true);
    web.getSettings().setAppCacheEnabled(true);
    web.addJavascriptInterface(scriptSystem, "sqSystem");
    web.addJavascriptInterface(scriptStorage, "nativeStorage");
    web.addJavascriptInterface(scriptSound, "sqSound");
    web.addJavascriptInterface(scriptGameServices, "sqGameServices");

    // adding event overrides for the web view
    web.setWebChromeClient(new WebChromeClient());
    web.setWebViewClient(new WebViewClient() {
        public boolean shouldOverrideUrlLoading(WebView view, String urlText) {
            if (urlText.startsWith("http")) { // Could be cleverer and use a regex
                Log.d(LOGTAG, "Opening standard web intent window for " + urlText);
                Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(urlText));
                startActivity(i);
                return true;
            } else {
                Log.d(LOGTAG, "Loading in webview: " + urlText);
                web.loadUrl(urlText);
                return true;
            }
        }

        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            Log.d(LOGTAG, "Page rendering started: " + url + ".");
            displaySpinner(R.string.loading);
            super.onPageStarted(view, url, favicon);
        }

        @Override
        public void onPageFinished(WebView view, String url) {
            Log.d(LOGTAG, "Page rendering finished: " + url + ".");
            hideSpinner();
            if (bookmarkId != null && url.startsWith("file:///android_asset/content.html")) {
                Log.i(LOGTAG, "Loading bookmark " + bookmarkId + ".");
                execJavaScriptInContent("loadBookmark('" + bookmarkId + "')");
                bookmarkId = null;
            }
            super.onPageFinished(view, url);
        }

        @Override
        public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
            Log.d(LOGTAG, "Intercepted call: " + url + ".");
            return null;
        }
    });
    web.setWebChromeClient(new WebChromeClient() {
        public boolean onConsoleMessage(ConsoleMessage cm) {
            Log.d(LOGTAG, cm.message() + " - from line " + cm.lineNumber() + " of " + cm.sourceId());
            return true;
        }
    });
    web.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);
    web.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
    web.requestFocus(View.FOCUS_DOWN);

    // finally loading content bootstrap
    Log.i(LOGTAG, "Loading index.html");
    web.loadUrl("file:///android_asset/index.html");
}

From source file:com.pimp.instincts.activities.GalleryViewPagerActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    ActivityCompat.postponeEnterTransition(this);
    ActivityCompat.setEnterSharedElementCallback(this, enterTransitionCallback);

    int mUIFlag = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LOW_PROFILE
            | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;

    getWindow().getDecorView().setSystemUiVisibility(mUIFlag);

    setContentView(R.layout.activity_view_pager_gallery);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitle("Gallery");
    setSupportActionBar(toolbar);//from w  w w  . j  a  va2  s  . c o m
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    galleryViewPagerAdapter = new GalleryViewPagerAdapter(this);

    viewPager = (ViewPager) findViewById(R.id.container);
    viewPager.setAdapter(galleryViewPagerAdapter);

    int position = selectedIndex = getIntent().getIntExtra(EXTRA_POSITION, 0);
    viewPager.setCurrentItem(position);
    viewPager.setOnPageChangeListener(pageChangeListener);
    viewPager.getViewTreeObserver().addOnGlobalLayoutListener(pagerLayoutListener);
}

From source file:com.s8launch.cheil.facetracker.MultiTrackerActivity.java

/**
 * Initializes the UI and creates the detector pipeline.
 *///from w ww  .  j a v  a 2 s  .  c  o m
@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    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);

    setContentView(R.layout.main);

    mPreview = (CameraSourcePreview) findViewById(R.id.preview);
    mGraphicOverlay = (GraphicOverlay) findViewById(R.id.faceOverlay);

    // Check for the camera permission before accessing the camera.  If the
    // permission is not granted yet, request permission.
    int rc = ActivityCompat.checkSelfPermission(this, Manifest.permission.CAMERA);
    if (rc == PackageManager.PERMISSION_GRANTED) {
        createCameraSource();
    } else {
        requestCameraPermission();
    }
}

From source file:sample.multithreading.DownloaderActivity.java

public void setFullScreen(final boolean fullscreen) {
    getWindow().setFlags(fullscreen ? WindowManager.LayoutParams.FLAG_FULLSCREEN : 0,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    CompatibleActionBar localCompatibleActionBar = getCompatibleActionBar();
    mFullScreen = fullscreen;/*from  w w w  .j av a2  s  .c  om*/
    if (Build.VERSION.SDK_INT >= 11) {
        int flag = fullscreen ? View.SYSTEM_UI_FLAG_LOW_PROFILE : 0;
        if (Build.VERSION.SDK_INT >= 14 && fullscreen) {
            flag |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
        }
        mMainView.setSystemUiVisibility(flag);
    }
    if (fullscreen) {
        localCompatibleActionBar.hide();
        Log.d(LOG_TAG, "Action Bar Hidden");
    } else {
        localCompatibleActionBar.show();
        Log.d(LOG_TAG, "Action Bar Shown");
    }
}

From source file:app.hanks.com.conquer.activity.LoginActivity.java

/**
 * ?//from   ww w . jav a  2  s.  c  om
 */
private void setFullScreen() {
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    View decorView = getWindow().getDecorView();
    // Hide both the navigation bar and the status bar.
    // SYSTEM_UI_FLAG_FULLSCREEN is only available on Android 4.1 and higher, but as
    // a general rule, you should design your app to hide the status bar whenever you
    // hide the navigation bar.
    int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN;
    decorView.setSystemUiVisibility(uiOptions);
}

From source file:com.achep.acdisplay.acdisplay.AcDisplayActivity.java

@SuppressLint("NewApi")
private void populateFlags(boolean windowHasFocus) {
    Window window = getWindow();//from  w w w .  j a v a2 s  . c  om
    View decorView = window.getDecorView();

    int windowFlags = WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;

    if (windowHasFocus) {
        int visibilityUi = View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_LOW_PROFILE;

        if (mConfig.isFullScreen()) {
            // Hide status bar if fullscreen mode is enabled.
            visibilityUi = visibilityUi | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_FULLSCREEN;
        }

        if (Device.hasKitKatApi()) {
            // Hide navigation bar and flag sticky.
            visibilityUi = visibilityUi | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
                    | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
        }

        decorView.setSystemUiVisibility(visibilityUi);
        window.addFlags(windowFlags);

        mTimeout.resume();
        mTimeout.setTimeoutDelayed(mConfig.getTimeoutNormal(), true);
    } else {
        int visibilityUi = decorView.getSystemUiVisibility();
        if (Device.hasKitKatApi()) {
            // Clear immersive sticky flag.
            // Hopefully it will fix annoying Android feature: IMMERSIVE_PANIC
            visibilityUi ^= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
        }

        decorView.setSystemUiVisibility(visibilityUi);
        window.clearFlags(windowFlags);

        mTimeout.setTimeoutDelayed(mConfig.getTimeoutNormal(), true);
        mTimeout.pause();
    }
}