Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

initial checkin

  • Loading branch information...
commit b5ece87c73aa02062c537c3b20e88d16e59eb680 1 parent 3ffbbe7
Tim Thomas authored
29 AndroidManifest.xml
View
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.buyplaytix.webreader"
+ android:versionCode="1"
+ android:versionName="1.0" >
+
+ <uses-sdk
+ android:minSdkVersion="8"
+ android:targetSdkVersion="17" />
+
+ <application
+ android:allowBackup="true"
+ android:icon="@drawable/ic_launcher"
+ android:label="@string/app_name"
+ android:theme="@style/AppTheme" >
+ <activity
+ android:name="com.buyplaytix.webreader.ReaderActivity"
+ android:configChanges="orientation|keyboardHidden|screenSize"
+ android:label="@string/app_name"
+ android:theme="@style/FullscreenTheme" >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+
+</manifest>
BIN  ic_launcher-web.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  libs/android-support-v4.jar
View
Binary file not shown
20 proguard-project.txt
View
@@ -0,0 +1,20 @@
+# To enable ProGuard in your project, edit project.properties
+# to define the proguard.config property as described in that file.
+#
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in ${sdk.dir}/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the ProGuard
+# include property in project.properties.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
14 project.properties
View
@@ -0,0 +1,14 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system edit
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+#
+# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
+#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
+
+# Project target.
+target=android-16
BIN  res/drawable-hdpi/ic_launcher.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  res/drawable-ldpi/ic_launcher.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  res/drawable-mdpi/ic_launcher.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  res/drawable-xhdpi/ic_launcher.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
55 res/layout/activity_reader.xml
View
@@ -0,0 +1,55 @@
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="#0099cc"
+ tools:context=".ReaderActivity" >
+
+ <!--
+ The primary full-screen view. This can be replaced with whatever view
+ is needed to present your content, e.g. VideoView, SurfaceView,
+ TextureView, etc.
+ -->
+
+ <TextView
+ android:id="@+id/fullscreen_content"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:gravity="center"
+ android:keepScreenOn="true"
+ android:text="@string/dummy_content"
+ android:textColor="#33b5e5"
+ android:textSize="50sp"
+ android:textStyle="bold" />
+
+ <!--
+ This FrameLayout insets its children based on system windows using
+ android:fitsSystemWindows.
+ -->
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:fitsSystemWindows="true" >
+
+ <LinearLayout
+ android:id="@+id/fullscreen_content_controls"
+ style="?buttonBarStyle"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="bottom|center_horizontal"
+ android:background="@color/black_overlay"
+ android:orientation="horizontal"
+ tools:ignore="UselessParent" >
+
+ <Button
+ android:id="@+id/dummy_button"
+ style="?buttonBarButtonStyle"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="@string/dummy_button" />
+ </LinearLayout>
+ </FrameLayout>
+
+</FrameLayout>
24 res/values-v11/styles.xml
View
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+ <!--
+ Base application theme for API 11+. This theme completely replaces
+ AppBaseTheme from res/values/styles.xml on API 11+ devices.
+ -->
+ <style name="AppBaseTheme" parent="android:Theme.Holo.Light">
+ <!-- API 11 theme customizations can go here. -->
+ </style>
+
+ <style name="FullscreenActionBarStyle" parent="android:Widget.Holo.ActionBar">
+ <item name="android:background">@color/black_overlay</item>
+ </style>
+
+ <style name="FullscreenTheme" parent="android:Theme.Holo">
+ <item name="android:actionBarStyle">@style/FullscreenActionBarStyle</item>
+ <item name="android:windowActionBarOverlay">true</item>
+ <item name="android:windowBackground">@null</item>
+ <item name="buttonBarStyle">?android:attr/buttonBarStyle</item>
+ <item name="buttonBarButtonStyle">?android:attr/buttonBarButtonStyle</item>
+ </style>
+
+</resources>
12 res/values-v14/styles.xml
View
@@ -0,0 +1,12 @@
+<resources>
+
+ <!--
+ Base application theme for API 14+. This theme completely replaces
+ AppBaseTheme from BOTH res/values/styles.xml and
+ res/values-v11/styles.xml on API 14+ devices.
+ -->
+ <style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
+ <!-- API 14 theme customizations can go here. -->
+ </style>
+
+</resources>
14 res/values/attrs.xml
View
@@ -0,0 +1,14 @@
+<resources>
+
+ <!--
+ Declare custom theme attributes that allow changing which styles are
+ used for button bars depending on the API level.
+ ?android:attr/buttonBarStyle is new as of API 11 so this is
+ necessary to support previous API levels.
+ -->
+ <declare-styleable name="ButtonBarContainerTheme">
+ <attr name="buttonBarStyle" format="reference" />
+ <attr name="buttonBarButtonStyle" format="reference" />
+ </declare-styleable>
+
+</resources>
5 res/values/colors.xml
View
@@ -0,0 +1,5 @@
+<resources>
+
+ <color name="black_overlay">#66000000</color>
+
+</resources>
8 res/values/strings.xml
View
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+ <string name="app_name">WebReader</string>
+ <string name="dummy_content">DUMMY\nCONTENT</string>
+ <string name="dummy_button">Dummy Button</string>
+
+</resources>
38 res/values/styles.xml
View
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+ <!--
+ Base application theme, dependent on API level. This theme is replaced
+ by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
+ -->
+ <style name="AppBaseTheme" parent="android:Theme.Light">
+ <!--
+ Theme customizations available in newer API levels can go in
+ res/values-vXX/styles.xml, while customizations related to
+ backward-compatibility can go here.
+ -->
+ </style>
+
+ <!-- Application theme. -->
+ <style name="AppTheme" parent="AppBaseTheme">
+ <!-- All customizations that are NOT specific to a particular API-level can go here. -->
+ </style>
+
+ <style name="ButtonBarButton" />
+
+ <style name="ButtonBar">
+ <item name="android:paddingLeft">2dp</item>
+ <item name="android:paddingTop">5dp</item>
+ <item name="android:paddingRight">2dp</item>
+ <item name="android:paddingBottom">0dp</item>
+ <item name="android:background">@android:drawable/bottom_bar</item>
+ </style>
+
+ <style name="FullscreenTheme" parent="android:Theme.NoTitleBar">
+ <item name="android:windowContentOverlay">@null</item>
+ <item name="android:windowBackground">@null</item>
+ <item name="buttonBarStyle">@style/ButtonBar</item>
+ <item name="buttonBarButtonStyle">@style/ButtonBarButton</item>
+ </style>
+
+</resources>
162 src/com/buyplaytix/webreader/ReaderActivity.java
View
@@ -0,0 +1,162 @@
+package com.buyplaytix.webreader;
+
+import com.buyplaytix.webreader.util.SystemUiHider;
+
+import android.annotation.TargetApi;
+import android.app.Activity;
+import android.os.Build;
+import android.os.Bundle;
+import android.os.Handler;
+import android.view.MotionEvent;
+import android.view.View;
+
+/**
+ * An example full-screen activity that shows and hides the system UI (i.e.
+ * status bar and navigation/system bar) with user interaction.
+ *
+ * @see SystemUiHider
+ */
+public class ReaderActivity extends Activity {
+ /**
+ * Whether or not the system UI should be auto-hidden after
+ * {@link #AUTO_HIDE_DELAY_MILLIS} milliseconds.
+ */
+ private static final boolean AUTO_HIDE = true;
+
+ /**
+ * If {@link #AUTO_HIDE} is set, the number of milliseconds to wait after
+ * user interaction before hiding the system UI.
+ */
+ private static final int AUTO_HIDE_DELAY_MILLIS = 3000;
+
+ /**
+ * If set, will toggle the system UI visibility upon interaction. Otherwise,
+ * will show the system UI visibility upon interaction.
+ */
+ private static final boolean TOGGLE_ON_CLICK = true;
+
+ /**
+ * The flags to pass to {@link SystemUiHider#getInstance}.
+ */
+ private static final int HIDER_FLAGS = SystemUiHider.FLAG_HIDE_NAVIGATION;
+
+ /**
+ * The instance of the {@link SystemUiHider} for this activity.
+ */
+ private SystemUiHider mSystemUiHider;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ setContentView(R.layout.activity_reader);
+
+ final View controlsView = findViewById(R.id.fullscreen_content_controls);
+ final View contentView = findViewById(R.id.fullscreen_content);
+
+ // Set up an instance of SystemUiHider to control the system UI for
+ // this activity.
+ mSystemUiHider = SystemUiHider.getInstance(this, contentView,
+ HIDER_FLAGS);
+ mSystemUiHider.setup();
+ mSystemUiHider
+ .setOnVisibilityChangeListener(new SystemUiHider.OnVisibilityChangeListener() {
+ // Cached values.
+ int mControlsHeight;
+ int mShortAnimTime;
+
+ @Override
+ @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
+ public void onVisibilityChange(boolean visible) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
+ // If the ViewPropertyAnimator API is available
+ // (Honeycomb MR2 and later), use it to animate the
+ // in-layout UI controls at the bottom of the
+ // screen.
+ if (mControlsHeight == 0) {
+ mControlsHeight = controlsView.getHeight();
+ }
+ if (mShortAnimTime == 0) {
+ mShortAnimTime = getResources().getInteger(
+ android.R.integer.config_shortAnimTime);
+ }
+ controlsView
+ .animate()
+ .translationY(visible ? 0 : mControlsHeight)
+ .setDuration(mShortAnimTime);
+ } else {
+ // If the ViewPropertyAnimator APIs aren't
+ // available, simply show or hide the in-layout UI
+ // controls.
+ controlsView.setVisibility(visible ? View.VISIBLE
+ : View.GONE);
+ }
+
+ if (visible && AUTO_HIDE) {
+ // Schedule a hide().
+ delayedHide(AUTO_HIDE_DELAY_MILLIS);
+ }
+ }
+ });
+
+ // Set up the user interaction to manually show or hide the system UI.
+ contentView.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ if (TOGGLE_ON_CLICK) {
+ mSystemUiHider.toggle();
+ } else {
+ mSystemUiHider.show();
+ }
+ }
+ });
+
+ // Upon interacting with UI controls, delay any scheduled hide()
+ // operations to prevent the jarring behavior of controls going away
+ // while interacting with the UI.
+ findViewById(R.id.dummy_button).setOnTouchListener(
+ mDelayHideTouchListener);
+ }
+
+ @Override
+ protected void onPostCreate(Bundle savedInstanceState) {
+ super.onPostCreate(savedInstanceState);
+
+ // Trigger the initial hide() shortly after the activity has been
+ // created, to briefly hint to the user that UI controls
+ // are available.
+ delayedHide(100);
+ }
+
+ /**
+ * Touch listener to use for in-layout UI controls to delay hiding the
+ * system UI. This is to prevent the jarring behavior of controls going away
+ * while interacting with activity UI.
+ */
+ View.OnTouchListener mDelayHideTouchListener = new View.OnTouchListener() {
+ @Override
+ public boolean onTouch(View view, MotionEvent motionEvent) {
+ if (AUTO_HIDE) {
+ delayedHide(AUTO_HIDE_DELAY_MILLIS);
+ }
+ return false;
+ }
+ };
+
+ Handler mHideHandler = new Handler();
+ Runnable mHideRunnable = new Runnable() {
+ @Override
+ public void run() {
+ mSystemUiHider.hide();
+ }
+ };
+
+ /**
+ * Schedules a call to hide() in [delay] milliseconds, canceling any
+ * previously scheduled calls.
+ */
+ private void delayedHide(int delayMillis) {
+ mHideHandler.removeCallbacks(mHideRunnable);
+ mHideHandler.postDelayed(mHideRunnable, delayMillis);
+ }
+}
178 src/com/buyplaytix/webreader/util/SystemUiHider.java
View
@@ -0,0 +1,178 @@
+package com.buyplaytix.webreader.util;
+
+import android.app.Activity;
+import android.os.Build;
+import android.view.View;
+
+/**
+ * A utility class that helps with showing and hiding system UI such as the
+ * status bar and navigation/system bar. This class uses backward-compatibility
+ * techniques described in <a href=
+ * "http://developer.android.com/training/backward-compatible-ui/index.html">
+ * Creating Backward-Compatible UIs</a> to ensure that devices running any
+ * version of ndroid OS are supported. More specifically, there are separate
+ * implementations of this abstract class: for newer devices,
+ * {@link #getInstance} will return a {@link SystemUiHiderHoneycomb} instance,
+ * while on older devices {@link #getInstance} will return a
+ * {@link SystemUiHiderBase} instance.
+ * <p>
+ * For more on system bars, see <a href=
+ * "http://developer.android.com/design/get-started/ui-overview.html#system-bars"
+ * > System Bars</a>.
+ *
+ * @see android.view.View#setSystemUiVisibility(int)
+ * @see android.view.WindowManager.LayoutParams#FLAG_FULLSCREEN
+ */
+public abstract class SystemUiHider {
+ /**
+ * When this flag is set, the
+ * {@link android.view.WindowManager.LayoutParams#FLAG_LAYOUT_IN_SCREEN}
+ * flag will be set on older devices, making the status bar "float" on top
+ * of the activity layout. This is most useful when there are no controls at
+ * the top of the activity layout.
+ * <p>
+ * This flag isn't used on newer devices because the <a
+ * href="http://developer.android.com/design/patterns/actionbar.html">action
+ * bar</a>, the most important structural element of an Android app, should
+ * be visible and not obscured by the system UI.
+ */
+ public static final int FLAG_LAYOUT_IN_SCREEN_OLDER_DEVICES = 0x1;
+
+ /**
+ * When this flag is set, {@link #show()} and {@link #hide()} will toggle
+ * the visibility of the status bar. If there is a navigation bar, show and
+ * hide will toggle low profile mode.
+ */
+ public static final int FLAG_FULLSCREEN = 0x2;
+
+ /**
+ * When this flag is set, {@link #show()} and {@link #hide()} will toggle
+ * the visibility of the navigation bar, if it's present on the device and
+ * the device allows hiding it. In cases where the navigation bar is present
+ * but cannot be hidden, show and hide will toggle low profile mode.
+ */
+ public static final int FLAG_HIDE_NAVIGATION = FLAG_FULLSCREEN | 0x4;
+
+ /**
+ * The activity associated with this UI hider object.
+ */
+ protected Activity mActivity;
+
+ /**
+ * The view on which {@link View#setSystemUiVisibility(int)} will be called.
+ */
+ protected View mAnchorView;
+
+ /**
+ * The current UI hider flags.
+ *
+ * @see #FLAG_FULLSCREEN
+ * @see #FLAG_HIDE_NAVIGATION
+ * @see #FLAG_LAYOUT_IN_SCREEN_OLDER_DEVICES
+ */
+ protected int mFlags;
+
+ /**
+ * The current visibility callback.
+ */
+ protected OnVisibilityChangeListener mOnVisibilityChangeListener = sDummyListener;
+
+ /**
+ * Creates and returns an instance of {@link SystemUiHider} that is
+ * appropriate for this device. The object will be either a
+ * {@link SystemUiHiderBase} or {@link SystemUiHiderHoneycomb} depending on
+ * the device.
+ *
+ * @param activity
+ * The activity whose window's system UI should be controlled by
+ * this class.
+ * @param anchorView
+ * The view on which {@link View#setSystemUiVisibility(int)} will
+ * be called.
+ * @param flags
+ * Either 0 or any combination of {@link #FLAG_FULLSCREEN},
+ * {@link #FLAG_HIDE_NAVIGATION}, and
+ * {@link #FLAG_LAYOUT_IN_SCREEN_OLDER_DEVICES}.
+ */
+ public static SystemUiHider getInstance(Activity activity, View anchorView,
+ int flags) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
+ return new SystemUiHiderHoneycomb(activity, anchorView, flags);
+ } else {
+ return new SystemUiHiderBase(activity, anchorView, flags);
+ }
+ }
+
+ protected SystemUiHider(Activity activity, View anchorView, int flags) {
+ mActivity = activity;
+ mAnchorView = anchorView;
+ mFlags = flags;
+ }
+
+ /**
+ * Sets up the system UI hider. Should be called from
+ * {@link Activity#onCreate}.
+ */
+ public abstract void setup();
+
+ /**
+ * Returns whether or not the system UI is visible.
+ */
+ public abstract boolean isVisible();
+
+ /**
+ * Hide the system UI.
+ */
+ public abstract void hide();
+
+ /**
+ * Show the system UI.
+ */
+ public abstract void show();
+
+ /**
+ * Toggle the visibility of the system UI.
+ */
+ public void toggle() {
+ if (isVisible()) {
+ hide();
+ } else {
+ show();
+ }
+ }
+
+ /**
+ * Registers a callback, to be triggered when the system UI visibility
+ * changes.
+ */
+ public void setOnVisibilityChangeListener(
+ OnVisibilityChangeListener listener) {
+ if (listener == null) {
+ listener = sDummyListener;
+ }
+
+ mOnVisibilityChangeListener = listener;
+ }
+
+ /**
+ * A dummy no-op callback for use when there is no other listener set.
+ */
+ private static OnVisibilityChangeListener sDummyListener = new OnVisibilityChangeListener() {
+ @Override
+ public void onVisibilityChange(boolean visible) {
+ }
+ };
+
+ /**
+ * A callback interface used to listen for system UI visibility changes.
+ */
+ public interface OnVisibilityChangeListener {
+ /**
+ * Called when the system UI visibility has changed.
+ *
+ * @param visible
+ * True if the system UI is visible.
+ */
+ public void onVisibilityChange(boolean visible);
+ }
+}
62 src/com/buyplaytix/webreader/util/SystemUiHiderBase.java
View
@@ -0,0 +1,62 @@
+package com.buyplaytix.webreader.util;
+
+import android.app.Activity;
+import android.view.View;
+import android.view.WindowManager;
+
+/**
+ * A base implementation of {@link SystemUiHider}. Uses APIs available in all
+ * API levels to show and hide the status bar.
+ */
+public class SystemUiHiderBase extends SystemUiHider {
+ /**
+ * Whether or not the system UI is currently visible. This is a cached value
+ * from calls to {@link #hide()} and {@link #show()}.
+ */
+ private boolean mVisible = true;
+
+ /**
+ * Constructor not intended to be called by clients. Use
+ * {@link SystemUiHider#getInstance} to obtain an instance.
+ */
+ protected SystemUiHiderBase(Activity activity, View anchorView, int flags) {
+ super(activity, anchorView, flags);
+ }
+
+ @Override
+ public void setup() {
+ if ((mFlags & FLAG_LAYOUT_IN_SCREEN_OLDER_DEVICES) == 0) {
+ mActivity.getWindow().setFlags(
+ WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
+ | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
+ WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
+ | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
+ }
+ }
+
+ @Override
+ public boolean isVisible() {
+ return mVisible;
+ }
+
+ @Override
+ public void hide() {
+ if ((mFlags & FLAG_FULLSCREEN) != 0) {
+ mActivity.getWindow().setFlags(
+ WindowManager.LayoutParams.FLAG_FULLSCREEN,
+ WindowManager.LayoutParams.FLAG_FULLSCREEN);
+ }
+ mOnVisibilityChangeListener.onVisibilityChange(false);
+ mVisible = false;
+ }
+
+ @Override
+ public void show() {
+ if ((mFlags & FLAG_FULLSCREEN) != 0) {
+ mActivity.getWindow().setFlags(0,
+ WindowManager.LayoutParams.FLAG_FULLSCREEN);
+ }
+ mOnVisibilityChangeListener.onVisibilityChange(true);
+ mVisible = true;
+ }
+}
133 src/com/buyplaytix/webreader/util/SystemUiHiderHoneycomb.java
View
@@ -0,0 +1,133 @@
+package com.buyplaytix.webreader.util;
+
+import android.annotation.TargetApi;
+import android.app.Activity;
+import android.os.Build;
+import android.view.View;
+import android.view.WindowManager;
+
+/**
+ * An API 11+ implementation of {@link SystemUiHider}. Uses APIs available in
+ * Honeycomb and later (specifically {@link View#setSystemUiVisibility(int)}) to
+ * show and hide the system UI.
+ */
+@TargetApi(Build.VERSION_CODES.HONEYCOMB)
+public class SystemUiHiderHoneycomb extends SystemUiHiderBase {
+ /**
+ * Flags for {@link View#setSystemUiVisibility(int)} to use when showing the
+ * system UI.
+ */
+ private int mShowFlags;
+
+ /**
+ * Flags for {@link View#setSystemUiVisibility(int)} to use when hiding the
+ * system UI.
+ */
+ private int mHideFlags;
+
+ /**
+ * Flags to test against the first parameter in
+ * {@link android.view.View.OnSystemUiVisibilityChangeListener#onSystemUiVisibilityChange(int)}
+ * to determine the system UI visibility state.
+ */
+ private int mTestFlags;
+
+ /**
+ * Whether or not the system UI is currently visible. This is cached from
+ * {@link android.view.View.OnSystemUiVisibilityChangeListener}.
+ */
+ private boolean mVisible = true;
+
+ /**
+ * Constructor not intended to be called by clients. Use
+ * {@link SystemUiHider#getInstance} to obtain an instance.
+ */
+ protected SystemUiHiderHoneycomb(Activity activity, View anchorView,
+ int flags) {
+ super(activity, anchorView, flags);
+
+ mShowFlags = View.SYSTEM_UI_FLAG_VISIBLE;
+ mHideFlags = View.SYSTEM_UI_FLAG_LOW_PROFILE;
+ mTestFlags = View.SYSTEM_UI_FLAG_LOW_PROFILE;
+
+ if ((mFlags & FLAG_FULLSCREEN) != 0) {
+ // If the client requested fullscreen, add flags relevant to hiding
+ // the status bar. Note that some of these constants are new as of
+ // API 16 (Jelly Bean). It is safe to use them, as they are inlined
+ // at compile-time and do nothing on pre-Jelly Bean devices.
+ mShowFlags |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
+ mHideFlags |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
+ | View.SYSTEM_UI_FLAG_FULLSCREEN;
+ }
+
+ if ((mFlags & FLAG_HIDE_NAVIGATION) != 0) {
+ // If the client requested hiding navigation, add relevant flags.
+ mShowFlags |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
+ mHideFlags |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
+ | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
+ mTestFlags = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void setup() {
+ mAnchorView
+ .setOnSystemUiVisibilityChangeListener(mSystemUiVisibilityChangeListener);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void hide() {
+ mAnchorView.setSystemUiVisibility(mHideFlags);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void show() {
+ mAnchorView.setSystemUiVisibility(mShowFlags);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public boolean isVisible() {
+ return mVisible;
+ }
+
+ private View.OnSystemUiVisibilityChangeListener mSystemUiVisibilityChangeListener = new View.OnSystemUiVisibilityChangeListener() {
+ @Override
+ public void onSystemUiVisibilityChange(int vis) {
+ // Test against mTestFlags to see if the system UI is visible.
+ if ((vis & mTestFlags) != 0) {
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
+ // Pre-Jelly Bean, we must manually hide the action bar
+ // and use the old window flags API.
+ mActivity.getActionBar().hide();
+ mActivity.getWindow().setFlags(
+ WindowManager.LayoutParams.FLAG_FULLSCREEN,
+ WindowManager.LayoutParams.FLAG_FULLSCREEN);
+ }
+
+ // Trigger the registered listener and cache the visibility
+ // state.
+ mOnVisibilityChangeListener.onVisibilityChange(false);
+ mVisible = false;
+
+ } else {
+ mAnchorView.setSystemUiVisibility(mShowFlags);
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
+ // Pre-Jelly Bean, we must manually show the action bar
+ // and use the old window flags API.
+ mActivity.getActionBar().show();
+ mActivity.getWindow().setFlags(0,
+ WindowManager.LayoutParams.FLAG_FULLSCREEN);
+ }
+
+ // Trigger the registered listener and cache the visibility
+ // state.
+ mOnVisibilityChangeListener.onVisibilityChange(true);
+ mVisible = true;
+ }
+ }
+ };
+}
Please sign in to comment.
Something went wrong with that request. Please try again.