Example usage for android.view Window getAttributes

List of usage examples for android.view Window getAttributes

Introduction

In this page you can find the example usage for android.view Window getAttributes.

Prototype

public final WindowManager.LayoutParams getAttributes() 

Source Link

Document

Retrieve the current window attributes associated with this panel.

Usage

From source file:com.example.levelup.core.app.PaymentCodeFragment.java

/**
 * Forces the screen to be full-brightness and not dim.
 * //from   www .  ja v a 2 s . com
 * @param isFullBrightness if true, sets the flags that force the screen to be fully bright and
 *        kept on. False clears the flags.
 */
private void setForceFullBrightness(boolean isFullBrightness) {
    Window window = getActivity().getWindow();

    // Bail if the window has gone away.
    if (window == null) {
        return;
    }

    if (isFullBrightness) {
        window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    } else {
        window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    }

    LayoutParams attributes = window.getAttributes();

    if (isFullBrightness) {
        attributes.screenBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_FULL;
    } else {
        attributes.screenBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_OFF;
    }

    window.setAttributes(attributes);
}

From source file:com.xuejian.client.lxp.module.toolbox.im.IMMainActivity.java

private void showActionDialog() {
    final Activity act = this;
    final AlertDialog dialog = new AlertDialog.Builder(act).create();
    View contentView = View.inflate(act, R.layout.dialog_city_detail_action, null);
    Button btn = (Button) contentView.findViewById(R.id.btn_go_plan);
    btn.setText("Talk");
    btn.setOnClickListener(new View.OnClickListener() {
        @Override//from   w  w  w  .  ja va  2  s.co m
        public void onClick(View view) {
            MobclickAgent.onEvent(mContext, "event_create_new_talk");
            startActivityForResult(new Intent(IMMainActivity.this, PickContactsWithCheckboxActivity.class)
                    .putExtra("request", NEW_CHAT_REQUEST_CODE), NEW_CHAT_REQUEST_CODE);
            dialog.dismiss();
        }
    });
    Button btn1 = (Button) contentView.findViewById(R.id.btn_go_share);
    btn1.setText("?");
    btn1.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            MobclickAgent.onEvent(mContext, "event_add_new_friend");
            startActivity(new Intent(IMMainActivity.this, AddContactActivity.class));
            dialog.dismiss();
        }
    });
    contentView.findViewById(R.id.btn_cancle).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.dismiss();
        }
    });
    dialog.show();
    WindowManager windowManager = act.getWindowManager();
    Window window = dialog.getWindow();
    window.setContentView(contentView);
    Display display = windowManager.getDefaultDisplay();
    WindowManager.LayoutParams lp = window.getAttributes();
    lp.width = (int) (display.getWidth()); // 
    window.setAttributes(lp);
    window.setGravity(Gravity.BOTTOM); // ?dialog?
    window.setWindowAnimations(R.style.SelectPicDialog); // 
}

From source file:com.mci.firstidol.activity.MainActivity.java

@TargetApi(19)
private void setTranslucentStatus(boolean on) {
    Window win = getWindow();
    WindowManager.LayoutParams winParams = win.getAttributes();
    final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
    if (on) {/* w  w  w.  ja  v  a 2 s .c o  m*/
        winParams.flags |= bits;
    } else {
        winParams.flags &= ~bits;
    }
    win.setAttributes(winParams);
}

From source file:com.cloverstudio.spika.GroupProfileActivity.java

private void getImageDialog() {
    final Dialog imageDialog = new Dialog(GroupProfileActivity.this, R.style.TransparentDialogTheme);
    imageDialog.getWindow().setGravity(Gravity.BOTTOM);
    imageDialog.setContentView(R.layout.dialog_get_image);
    WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams();
    Window window = imageDialog.getWindow();
    layoutParams.copyFrom(window.getAttributes());
    layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
    layoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
    window.setAttributes(layoutParams);/*from  w  w w. java  2  s .co  m*/

    final Button btnGallery = (Button) imageDialog.findViewById(R.id.btnGallery);
    btnGallery.setTypeface(SpikaApp.getTfMyriadProBold(), Typeface.BOLD);
    btnGallery.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {

            Intent galleryIntent = new Intent(GroupProfileActivity.this, CameraCropActivity.class);
            galleryIntent.putExtra("type", "gallery");
            galleryIntent.putExtra("groupUpdate", true);
            GroupProfileActivity.this.startActivityForResult(galleryIntent, UPDATE_IMAGE_REQUEST_CODE);
            imageDialog.dismiss();

        }
    });

    final Button btnCamera = (Button) imageDialog.findViewById(R.id.btnCamera);
    btnCamera.setTypeface(SpikaApp.getTfMyriadProBold(), Typeface.BOLD);
    btnCamera.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {

            Intent cameraIntent = new Intent(GroupProfileActivity.this, CameraCropActivity.class);
            cameraIntent.putExtra("type", "camera");
            cameraIntent.putExtra("groupUpdate", true);
            GroupProfileActivity.this.startActivityForResult(cameraIntent, UPDATE_IMAGE_REQUEST_CODE);
            imageDialog.dismiss();

        }
    });

    final Button btnRemovePhoto = (Button) imageDialog.findViewById(R.id.btnRemovePhoto);
    btnRemovePhoto.setTypeface(SpikaApp.getTfMyriadProBold(), Typeface.BOLD);
    btnRemovePhoto.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {

            mGroupAvatarId = "";
            gGroupImage = null;
            Utils.displayImage(mGroupAvatarId, mIvGroupImage, mPbLoading, ImageLoader.LARGE,
                    R.drawable.group_stub_large, false);
            imageDialog.dismiss();

        }
    });

    imageDialog.show();
}

From source file:info.hl.mediam.GroupProfileActivity.java

private void getImageDialog() {
    final Dialog imageDialog = new Dialog(GroupProfileActivity.this, R.style.TransparentDialogTheme);
    imageDialog.getWindow().setGravity(Gravity.BOTTOM);
    imageDialog.setContentView(R.layout.dialog_get_image);
    WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams();
    Window window = imageDialog.getWindow();
    layoutParams.copyFrom(window.getAttributes());
    layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
    layoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
    window.setAttributes(layoutParams);//w w  w  .j a  va 2  s .co  m

    final Button btnGallery = (Button) imageDialog.findViewById(R.id.btnGallery);
    btnGallery.setTypeface(MediamApp.getTfMyriadProBold(), Typeface.BOLD);
    btnGallery.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {

            Intent galleryIntent = new Intent(GroupProfileActivity.this, CameraCropActivity.class);
            galleryIntent.putExtra("type", "gallery");
            galleryIntent.putExtra("groupUpdate", true);
            GroupProfileActivity.this.startActivityForResult(galleryIntent, UPDATE_IMAGE_REQUEST_CODE);
            imageDialog.dismiss();

        }
    });

    final Button btnCamera = (Button) imageDialog.findViewById(R.id.btnCamera);
    btnCamera.setTypeface(MediamApp.getTfMyriadProBold(), Typeface.BOLD);
    btnCamera.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {

            Intent cameraIntent = new Intent(GroupProfileActivity.this, CameraCropActivity.class);
            cameraIntent.putExtra("type", "camera");
            cameraIntent.putExtra("groupUpdate", true);
            GroupProfileActivity.this.startActivityForResult(cameraIntent, UPDATE_IMAGE_REQUEST_CODE);
            imageDialog.dismiss();

        }
    });

    final Button btnRemovePhoto = (Button) imageDialog.findViewById(R.id.btnRemovePhoto);
    btnRemovePhoto.setTypeface(MediamApp.getTfMyriadProBold(), Typeface.BOLD);
    btnRemovePhoto.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {

            mGroupAvatarId = "";
            gGroupImage = null;
            Utils.displayImage(mGroupAvatarId, mIvGroupImage, mPbLoading, ImageLoader.LARGE,
                    R.drawable.group_stub_large, false);
            imageDialog.dismiss();

        }
    });

    imageDialog.show();
}

From source file:kz.qobyzbook.activities.DMPlayerBaseActivity.java

private void setTranslucentStatus(boolean on) {
    Log.d(TAG, "setTranslucentStatus()");
    Window win = getWindow();
    WindowManager.LayoutParams winParams = win.getAttributes();
    final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
    if (on) {//from www  . jav  a 2 s .c  o m
        winParams.flags |= bits;
    } else {
        winParams.flags &= ~bits;
    }
    win.setAttributes(winParams);
}

From source file:com.github.shareme.gwsmaterialuikit.library.material.app.Dialog.java

/**
 * Set the dim amount of the region outside this Dialog.
 * @param amount The dim amount in [0..1].
 * @return The Dialog for chaining methods.
 *//*  ww w.j  a  v  a2 s. c  o m*/
public Dialog dimAmount(float amount) {
    Window window = getWindow();
    if (amount > 0f) {
        window.addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
        WindowManager.LayoutParams lp = window.getAttributes();
        lp.dimAmount = amount;
        window.setAttributes(lp);
    } else
        window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
    return this;
}

From source file:jackpal.androidterm.Term.java

private void updatePrefs() {
    ActivityCompat.invalidateOptionsMenu(this);
    mUseKeyboardShortcuts = mSettings.getUseKeyboardShortcutsFlag();

    DisplayMetrics metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);

    setFunctionKeyVisibility();/*from  w ww.ja  va 2s.  c  o m*/
    mViewFlipper.updatePrefs(mSettings);

    for (View v : mViewFlipper) {
        ((EmulatorView) v).setDensity(metrics);
        ((TermView) v).updatePrefs(mSettings);
        setPreIMEShortsuts((EmulatorView) v);
        if (mSettings.useCookedIME() == false) {
            ((EmulatorView) v).setIMECtrlBeginBatchEditDisable(false);
        }
    }

    if (mTermSessions != null) {
        for (TermSession session : mTermSessions) {
            ((GenericTermSession) session).updatePrefs(mSettings);
        }
    }

    {
        Window win = getWindow();
        WindowManager.LayoutParams params = win.getAttributes();
        final int FULLSCREEN = WindowManager.LayoutParams.FLAG_FULLSCREEN;
        int desiredFlag = mSettings.showStatusBar() ? 0 : FULLSCREEN;
        if (desiredFlag != (params.flags & FULLSCREEN)
                || (AndroidCompat.SDK >= 11 && mActionBarMode != mSettings.actionBarMode())) {
            if (mAlreadyStarted) {
                // Can't switch to/from fullscreen after
                // starting the activity.
                restart();
            } else {
                win.setFlags(desiredFlag, FULLSCREEN);
                if (mActionBarMode >= TermSettings.ACTION_BAR_MODE_HIDES) {
                    if (mActionBar != null) {
                        mActionBar.hide();
                    }
                }
            }
        }
    }

    int orientation = mSettings.getScreenOrientation();
    int o = 0;
    if (orientation == 0) {
        o = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
    } else if (orientation == 1) {
        o = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
    } else if (orientation == 2) {
        o = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
    } else {
        /* Shouldn't be happened. */
    }
    setRequestedOrientation(o);
}

From source file:com.almalence.opencam.ApplicationScreen.java

public void setScreenBrightness(boolean setMax) {
    Window window = getWindow();
    WindowManager.LayoutParams layoutpars = window.getAttributes();

    // Set the brightness of this window
    if (setMax)//from   www  .  j  ava  2  s.  c om
        layoutpars.screenBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_FULL;
    else
        layoutpars.screenBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE;

    // Apply attribute changes to this window
    window.setAttributes(layoutpars);
}

From source file:com.mobiletin.inputmethod.indic.LatinIME.java

private void showOptionDialog(final AlertDialog dialog) {
    final IBinder windowToken = mKeyboardSwitcher.getMainKeyboardView().getWindowToken();
    if (windowToken == null) {
        return;/*from  w w w. j  av a  2s.co m*/
    }

    final Window window = dialog.getWindow();
    final WindowManager.LayoutParams lp = window.getAttributes();
    lp.token = windowToken;
    lp.type = WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG;
    window.setAttributes(lp);
    window.addFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);

    mOptionsDialog = dialog;
    dialog.show();
}