Example usage for android.app Dialog getWindow

List of usage examples for android.app Dialog getWindow

Introduction

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

Prototype

public @Nullable Window getWindow() 

Source Link

Document

Retrieve the current Window for the activity.

Usage

From source file:Main.java

/**
 * Sets the parameter to show IME when the given dialog is shown.
 *//*w ww  . j  av a 2  s. co m*/
static void showInputMethod(Dialog dialog) {
    dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
}

From source file:Main.java

public static void keepScreenOn(final Dialog pDialog) {
    pDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}

From source file:Main.java

public static void closeKeyboard(Dialog dialog) {
    View view = dialog.getWindow().peekDecorView();
    if (view != null) {
        InputMethodManager inputMethodManager = (InputMethodManager) dialog.getContext()
                .getSystemService(Context.INPUT_METHOD_SERVICE);
        inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
    }/*  w w  w .  j av  a 2  s  .  c om*/
}

From source file:Main.java

@TargetApi(19)
public static void setUIVisibility(Dialog activity) {
    View decorView = activity.getWindow().getDecorView();
    int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
    if (Build.VERSION.SDK_INT >= 16) {
        uiOptions = uiOptions | View.SYSTEM_UI_FLAG_FULLSCREEN;
    }/*ww w.j a va 2  s  .co  m*/
    if (Build.VERSION.SDK_INT >= 19) {
        uiOptions = uiOptions | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
    }
    decorView.setSystemUiVisibility(uiOptions);
}

From source file:Main.java

public static void onResume(Dialog dialog) {
    View decorView = dialog.getWindow().getDecorView();
    dialog.getWindow().setFlags(FLAG_NOT_FOCUSABLE, FLAG_NOT_FOCUSABLE);
    dialog.setOnShowListener(d -> dialog.getWindow().clearFlags(FLAG_NOT_FOCUSABLE));
    hideSystemUI(decorView);//from  www  . j ava  2s  . c  o  m
    decorView.setOnSystemUiVisibilityChangeListener(visibility -> {
        if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
            hideSystemUI(decorView);
        }
    });
}

From source file:Main.java

@SuppressWarnings("deprecation")
static public void setDlgBoxSizeHeightMax(Dialog dlg) {
    if (dlg == null)
        return;//from w  w  w.  j a va  2 s.co m
    dlg.getWindow().setLayout(LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT);
}

From source file:Main.java

/**
 * update Window attributes/*w ww  . j  a v a2  s . c o m*/
 * 
 * windowParams.width = WindowManager.LayoutParams.MATCH_PARENT
 * windowParams.height = WindowManager.LayoutParams.WRAP_CONTENT
 *
 * @param context
 * @param d
 */
public static void updatewWindowParamsWH4PupfromBottom(Context context, Dialog d) {
    if (null == d)
        return;

    WindowManager.LayoutParams windowParams = d.getWindow().getAttributes();
    if (null == windowParams)
        return;

    windowParams.width = WindowManager.LayoutParams.MATCH_PARENT;
    windowParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
    d.getWindow().setAttributes(windowParams);
}

From source file:Main.java

@SuppressWarnings("deprecation")
static public void setDlgBoxSizeCompact(Dialog dlg) {
    if (dlg == null)
        return;/*from  w  w w .ja va  2 s. co  m*/
    int w = dlg.getWindow().getWindowManager().getDefaultDisplay().getWidth();
    int h = dlg.getWindow().getWindowManager().getDefaultDisplay().getHeight();
    int nw = 0;

    if (w > h) {//Landscape
        //         Log.v("","Landscape");
        if (w > 800) {
            if (w >= 1200)
                nw = (w / 3) * 2;
            else
                nw = 800;
        } else
            nw = LayoutParams.FILL_PARENT;
    } else {//Portrait
        //         Log.v("","Portlait");
        nw = LayoutParams.FILL_PARENT;
    }
    dlg.getWindow().setLayout(nw, LayoutParams.WRAP_CONTENT);
    //      Log.v("","w="+w+", h="+h+", nw="+nw);

}

From source file:org.wahtod.wififixer.ui.BaseDialogFragment.java

protected static void setDialog(DialogFragment f) {
    Dialog d = f.getDialog();
    if (d != null) {
        d.setCanceledOnTouchOutside(true);
        d.getWindow().getAttributes().softInputMode = WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN;
    }/*from ww  w  . j av a  2  s.co m*/
}

From source file:Main.java

public static Dialog creativeDialog(Context context, int layout) {
    Dialog dialog = new Dialog(context, android.R.style.Theme_Holo_Light_Dialog);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    dialog.setContentView(layout);/*from  ww  w.j  a v  a 2 s . c om*/
    return dialog;
}