Android Open Source - AndroidDesignPreview System Ui Hider






From Project

Back to project page AndroidDesignPreview.

License

The source code is released under:

Apache License

If you think the Android project AndroidDesignPreview listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*
 * Copyright 2012 Google Inc./* w w  w.j  av  a2  s  .  c  o  m*/
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.android.apps.proofer;

import android.os.Build;
import android.os.Handler;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

public class SystemUiHider {
    private static final int HIDE_DELAY_MILLIS = 2000;

    private Handler mHandler;
    private View mView;

    public SystemUiHider(View view) {
        mView = view;
    }

    public void setup(Window window) {
        hideSystemUi();

        // Pre-Jellybean just hide the status bar
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
            window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
        }

        mHandler = new Handler();
        mView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
            @Override
            public void onSystemUiVisibilityChange(int visibility) {
                if ((visibility & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0) {
                    delay();
                }
            }
        });
    }

    private void hideSystemUi() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            // On Jellybean we can use new System UI flags to allow showing titlebar/systembar
            // only upon touching the screen, while still having the content laid out in
            // the entire screen.
            mView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
        } else {
            mView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
        }
    }

    private Runnable mHideRunnable = new Runnable() {
        public void run() {
            hideSystemUi();
        }
    };

    public void delay() {
        mHandler.removeCallbacks(mHideRunnable);
        mHandler.postDelayed(mHideRunnable, HIDE_DELAY_MILLIS);
    }
}




Java Source Code List

com.google.android.apps.proofer.DesktopViewerActivity.java
com.google.android.apps.proofer.SystemUiHider.java
com.google.android.desktop.proofer.AdbRunner.java
com.google.android.desktop.proofer.Config.java
com.google.android.desktop.proofer.ControllerForm.java
com.google.android.desktop.proofer.ProoferException.java
com.google.android.desktop.proofer.Proofer.java
com.google.android.desktop.proofer.RegionSelector.java
com.google.android.desktop.proofer.Util.java
com.google.android.desktop.proofer.os.DefaultBinder.java
com.google.android.desktop.proofer.os.MacBinder.java
com.google.android.desktop.proofer.os.OSBinder.java