Advertisement
Guest User

Untitled

a guest
Dec 11th, 2015
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.99 KB | None | 0 0
  1. package com.example.planetarium_3d;
  2.  
  3. import com.example.planetarium_3d.util.SystemUiHider;
  4.  
  5. import android.annotation.TargetApi;
  6. import android.app.Activity;
  7. import android.os.Build;
  8. import android.os.Bundle;
  9. import android.os.Handler;
  10. import android.view.View;
  11. import org.mozilla.gecko.GeckoView;
  12.  
  13.  
  14.  
  15. /**
  16.  * An example full-screen activity that shows and hides the system UI (i.e.
  17.  * status bar and navigation/system bar) with user interaction.
  18.  *
  19.  * @see SystemUiHider
  20.  */
  21.  
  22. public class FullscreenActivity extends Activity {
  23.     /**
  24.      * Whether or not the system UI should be auto-hidden after
  25.      * {@link #AUTO_HIDE_DELAY_MILLIS} milliseconds.
  26.      */
  27.     private static final boolean AUTO_HIDE = true;
  28.     /**
  29.      * If {@link #AUTO_HIDE} is set, the number of milliseconds to wait after
  30.      * user interaction before hiding the system UI.
  31.      */
  32.     private static final int AUTO_HIDE_DELAY_MILLIS = 3000;
  33.  
  34.     /**
  35.      * If set, will toggle the system UI visibility upon interaction. Otherwise,
  36.      * will show the system UI visibility upon interaction.
  37.      */
  38.     private static final boolean TOGGLE_ON_CLICK = false;
  39.  
  40.     /**
  41.      * The flags to pass to {@link SystemUiHider#getInstance}.
  42.      */
  43.     private static final int HIDER_FLAGS = SystemUiHider.FLAG_HIDE_NAVIGATION;
  44.  
  45.     /**
  46.      * The instance of the {@link SystemUiHider} for this activity.
  47.      */
  48.     private SystemUiHider mSystemUiHider;
  49.  
  50.     @Override
  51.     protected void onCreate(Bundle savedInstanceState) {
  52.         super.onCreate(savedInstanceState);
  53.  
  54.         setContentView(R.layout.activity_fullscreen);
  55.  
  56.         //final View controlsView = findViewById(R.id.fullscreen_content_controls);
  57.         final View contentView = findViewById(R.id.fullscreen_content);
  58.  
  59.         // Set up an instance of SystemUiHider to control the system UI for
  60.         // this activity.
  61.         mSystemUiHider = SystemUiHider.getInstance(this, contentView, HIDER_FLAGS);
  62.         mSystemUiHider.setup();
  63.         mSystemUiHider
  64.                 .setOnVisibilityChangeListener(new SystemUiHider.OnVisibilityChangeListener() {
  65.                     // Cached values.
  66.                     int mControlsHeight;
  67.                     int mShortAnimTime;
  68.  
  69.                     @Override
  70.                     @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
  71.                     public void onVisibilityChange(boolean visible) {
  72.                         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
  73.                             // If the ViewPropertyAnimator API is available
  74.                             // (Honeycomb MR2 and later), use it to animate the
  75.                             // in-layout UI controls at the bottom of the
  76.                             // screen.
  77.                             if (mControlsHeight == 0) {
  78.                                 //mControlsHeight = controlsView.getHeight();
  79.                             }
  80.                             if (mShortAnimTime == 0) {
  81.                                 mShortAnimTime = getResources().getInteger(
  82.                                         android.R.integer.config_shortAnimTime);
  83.                             }
  84.                             /*controlsView.animate()
  85.                                     .translationY(visible ? 0 : mControlsHeight)
  86.                                     .setDuration(mShortAnimTime);*/
  87.                         } /*else {
  88.                             // If the ViewPropertyAnimator APIs aren't
  89.                             // available, simply show or hide the in-layout UI
  90.                             // controls.
  91.                             controlsView.setVisibility(visible ? View.VISIBLE : View.GONE);
  92.                         }*/
  93.  
  94.                         if (visible && AUTO_HIDE) {
  95.                             // Schedule a hide().
  96.                             //delayedHide(AUTO_HIDE_DELAY_MILLIS);
  97.                         }
  98.                     }
  99.                 });
  100.  
  101.  
  102.         mSystemUiHider.hide();
  103.  
  104.  
  105.         // Upon interacting with UI controls, delay any scheduled hide()
  106.         // operations to prevent the jarring behavior of controls going away
  107.         // while interacting with the UI.
  108.  
  109.  
  110.         /*WebView myWebView = (WebView) findViewById(R.id.webView);
  111.         WebSettings webSettings = myWebView.getSettings();
  112.         webSettings.setJavaScriptEnabled(true);
  113.         webSettings.setAllowFileAccessFromFileURLs(true);
  114.         webSettings.setAllowUniversalAccessFromFileURLs(true);
  115.         webSettings.setBuiltInZoomControls(true);
  116.         webSettings.setMediaPlaybackRequiresUserGesture(false);
  117.         //myWebView.addJavascriptInterface(new WebAppInterface(this), "Android");
  118.  
  119.         webSettings.setAllowFileAccess(true);
  120.         myWebView.setWebViewClient(new WebViewClient());
  121.  
  122.  
  123.         myWebView.loadUrl("file:///android_asset/MainMenu.html");*/
  124.         GeckoView geckoView = (GeckoView) findViewById(R.id.geckoViewObj);
  125.         geckoView.addBrowser("http://google.com");
  126.  
  127.     }
  128.  
  129.     @Override
  130.     protected void onPostCreate(Bundle savedInstanceState) {
  131.         super.onPostCreate(savedInstanceState);
  132.  
  133.         // Trigger the initial hide() shortly after the activity has been
  134.         // created, to briefly hint to the user that UI controls
  135.         // are available.
  136.         delayedHide(100);
  137.     }
  138.  
  139.  
  140.     /**
  141.      * Touch listener to use for in-layout UI controls to delay hiding the
  142.      * system UI. This is to prevent the jarring behavior of controls going away
  143.      * while interacting with activity UI.
  144.      */
  145.  
  146.  
  147.     Handler mHideHandler = new Handler();
  148.     Runnable mHideRunnable = new Runnable() {
  149.         @Override
  150.         public void run() {
  151.             mSystemUiHider.hide();
  152.         }
  153.     };
  154.  
  155.     /**
  156.      * Schedules a call to hide() in [delay] milliseconds, canceling any
  157.      * previously scheduled calls.
  158.      */
  159.     private void delayedHide(int delayMillis) {
  160.         mHideHandler.removeCallbacks(mHideRunnable);
  161.         mHideHandler.postDelayed(mHideRunnable, delayMillis);
  162.     }
  163. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement