Example usage for android.app Activity getWindow

List of usage examples for android.app Activity getWindow

Introduction

In this page you can find the example usage for android.app Activity getWindow.

Prototype

public Window getWindow() 

Source Link

Document

Retrieve the current android.view.Window for the activity.

Usage

From source file:de.baumann.browser.helper.helper_main.java

public static void onStart(Activity from) {

    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(from);
    class_SecurePreferences sharedPrefSec = new class_SecurePreferences(from, "sharedPrefSec",
            "Ywn-YM.XK$b:/:&CsL8;=L,y4", true);
    String pw = sharedPrefSec.getString("protect_PW");

    if (pw != null && pw.length() > 0) {
        if (sharedPref.getBoolean("isOpened", true)) {
            helper_main.switchToActivity(from, Activity_password.class, "", false);
        }/*w  w w. j ava 2 s  .  co  m*/
    }
    if (sharedPref.getString("fullscreen", "2").equals("1")
            || sharedPref.getString("fullscreen", "2").equals("3")) {
        from.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
    }
    if (sharedPref.getString("orientation", "auto").equals("landscape")) {
        from.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    }
    if (sharedPref.getString("orientation", "auto").equals("portrait")) {
        from.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }
}

From source file:com.cranberrygame.cordova.plugin.navigationbar.NavigationBar.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void _hideNavigationBar() {
    Activity activity = cordova.getActivity();
    activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION//
            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
            //| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
            //| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
            | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
}

From source file:org.getlantern.firetweet.util.ThemeUtils.java

public static Drawable getCompatToolbarOverlay(Activity activity) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
        return null;
    final View view = activity.getWindow().findViewById(android.support.v7.appcompat.R.id.decor_content_parent);
    if (!(view instanceof ActionBarOverlayLayout))
        return null;
    try {// www  .jav a  2 s  . c  om
        final Field field = ActionBarOverlayLayout.class.getDeclaredField("mWindowContentOverlay");
        field.setAccessible(true);
        return (Drawable) field.get(view);
    } catch (Exception ignore) {
    }
    return null;
}

From source file:br.com.hotforms.StatusBarManager.java

public synchronized void setColor(final int r, final int g, final int b) {
    final Activity activity = this.cordova.getActivity();
    final Window window = activity.getWindow();

    this.cordova.getActivity().runOnUiThread(new Runnable() {
        @Override/*from w ww. j  a va2  s .c  o m*/
        public void run() {
            window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
            window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);

            window.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);

            window.setStatusBarColor(android.graphics.Color.rgb(r, g, b));
        }
    });
}

From source file:com.smapley.vehicle.utils.LicenseKeyboardUtil.java

private void setSoftKeyboradHide(Activity ctx, EditText edit) {
    ctx.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
    try {/*from  w  w w .j av  a 2 s .c o m*/
        Class<EditText> cls = EditText.class;
        String method_setSoftInputOnFocus = "setShowSoftInputOnFocus";
        //            method_setSoftInputOnFocus = "setSoftInputOnFocus";
        Method setShowSoftInputOnFocus = cls.getMethod(method_setSoftInputOnFocus, boolean.class);
        setShowSoftInputOnFocus.setAccessible(false);
        setShowSoftInputOnFocus.invoke(edit, false);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.dw.bartinter.BarTinter.java

@Override
public boolean execute(final String action, final CordovaArgs args, final CallbackContext callbackContext)
        throws JSONException {
    Log.v(PLUGIN, "Executing action: " + action);
    final Activity activity = this.cordova.getActivity();
    final Window window = activity.getWindow();

    if ("_ready".equals(action)) {
        boolean statusBarVisible = (window.getAttributes().flags
                & WindowManager.LayoutParams.FLAG_FULLSCREEN) == 0;
        callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, statusBarVisible));
        return true;
    }//from   w ww  .ja  v a  2s . com

    if ("statusBar".equals(action)) {
        this.cordova.getActivity().runOnUiThread(new Runnable() {
            @Override
            public void run() {
                try {
                    statusBar(args.getString(0));
                } catch (JSONException ignore) {
                    Log.e(PLUGIN, "Invalid hexString argument.");
                }
            }
        });
        return true;
    }

    if ("navigationBar".equals(action)) {
        this.cordova.getActivity().runOnUiThread(new Runnable() {
            @Override
            public void run() {
                try {
                    navigationBar(args.getString(0));
                } catch (JSONException ignore) {
                    Log.e(PLUGIN, "Invalid hexString argument.");
                }
            }
        });
        return true;
    }

    return false;
}

From source file:org.getlantern.firetweet.util.ThemeUtils.java

public static void setCompatToolbarOverlay(Activity activity, Drawable background) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
        return;//w ww. java 2 s .  co m
    final View view = activity.getWindow().findViewById(android.support.v7.appcompat.R.id.decor_content_parent);
    if (!(view instanceof ActionBarOverlayLayout))
        return;
    try {
        final Field field = ActionBarOverlayLayout.class.getDeclaredField("mWindowContentOverlay");
        field.setAccessible(true);
        field.set(view, background);
    } catch (Exception ignore) {
    }
}

From source file:com.phonegap.bossbolo.plugin.statusbar.StatusBar.java

/**
 * Executes the request and returns PluginResult.
 *
 * @param action            The action to execute.
 * @param args              JSONArry of arguments for the plugin.
 * @param callbackContext   The callback id used when calling back into JavaScript.
 * @return                  True if the action was valid, false otherwise.
 *//*from  w ww.j av a  2s. co  m*/
@Override
public boolean execute(final String action, final CordovaArgs args, final CallbackContext callbackContext)
        throws JSONException {
    Log.v(TAG, "Executing action: " + action);
    final Activity activity = this.cordova.getActivity();
    final Window window = activity.getWindow();
    if ("_ready".equals(action)) {
        boolean statusBarVisible = (window.getAttributes().flags
                & WindowManager.LayoutParams.FLAG_FULLSCREEN) == 0;
        callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, statusBarVisible));
    }

    if ("show".equals(action)) {
        this.cordova.getActivity().runOnUiThread(new Runnable() {
            @Override
            public void run() {
                window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
            }
        });
        return true;
    }

    if ("hide".equals(action)) {
        this.cordova.getActivity().runOnUiThread(new Runnable() {
            @Override
            public void run() {
                window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
            }
        });
        return true;
    }

    if ("backgroundColorByHexString".equals(action)) {
        this.cordova.getActivity().runOnUiThread(new Runnable() {
            @Override
            public void run() {
                try {
                    setStatusBarBackgroundColor(args.getString(0));
                } catch (JSONException ignore) {
                    Log.e(TAG, "Invalid hexString argument, use f.i. '#777777'");
                }
            }
        });
        return true;
    }

    return false;
}

From source file:com.lokiy.x.XQuery.java

public XQuery(Activity activity) {
    if (activity != null) {
        mContainer = activity.getWindow().getDecorView();
        target = activity;/*from w ww.  j  a v a  2  s  . c  o m*/
    } else
        throw new IllegalArgumentException("activity is null");
}

From source file:org.apache.cordova.statusbar.StatusBar.java

/**
 * Executes the request and returns PluginResult.
 *
 * @param action            The action to execute.
 * @param args              JSONArry of arguments for the plugin.
 * @param callbackContext   The callback id used when calling back into JavaScript.
 * @return                  True if the action was valid, false otherwise.
 *///from   w  w  w. j  av  a  2 s.  co  m
@Override
public boolean execute(final String action, final CordovaArgs args, final CallbackContext callbackContext)
        throws JSONException {
    Log.v(TAG, "Executing action: " + action);
    final Activity activity = this.cordova.getActivity();
    final Window window = activity.getWindow();
    if ("_ready".equals(action)) {
        boolean statusBarVisible = (window.getAttributes().flags
                & WindowManager.LayoutParams.FLAG_FULLSCREEN) == 0;
        callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, statusBarVisible));
        return true;
    }

    if ("show".equals(action)) {
        this.cordova.getActivity().runOnUiThread(new Runnable() {
            @Override
            public void run() {
                window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
            }
        });
        return true;
    }

    if ("hide".equals(action)) {
        this.cordova.getActivity().runOnUiThread(new Runnable() {
            @Override
            public void run() {
                window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
            }
        });
        return true;
    }

    if ("backgroundColorByHexString".equals(action)) {
        this.cordova.getActivity().runOnUiThread(new Runnable() {
            @Override
            public void run() {
                try {
                    setStatusBarBackgroundColor(args.getString(0));
                } catch (JSONException ignore) {
                    Log.e(TAG, "Invalid hexString argument, use f.i. '#777777'");
                }
            }
        });
        return true;
    }

    return false;
}