Example usage for android.view Window setFlags

List of usage examples for android.view Window setFlags

Introduction

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

Prototype

public void setFlags(int flags, int mask) 

Source Link

Document

Set the flags of the window, as per the WindowManager.LayoutParams WindowManager.LayoutParams flags.

Usage

From source file:me.wizos.loread.view.webview.VideoImpl.java

public void onShowCustomView(View view, WebChromeClient.CustomViewCallback callback) {
    Activity mActivity;//from  www  . ja v  a 2s . c o  m
    if ((mActivity = this.mActivity) == null || mActivity.isFinishing()) {
        return;
    }
    // ?
    mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

    Window mWindow = mActivity.getWindow();
    Pair<Integer, Integer> mPair;
    // ????
    if ((mWindow.getAttributes().flags & WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) == 0) {
        mPair = new Pair<>(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, 0);
        mWindow.setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
                WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        mFlags.add(mPair);
    }

    if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
            && (mWindow.getAttributes().flags & WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED) == 0) {
        mPair = new Pair<>(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, 0);
        mWindow.setFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
                WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
        mFlags.add(mPair);
    }

    if (videoView != null) {
        callback.onCustomViewHidden();
        return;
    }
    //        KLog.e("" + mWebView  + "   "  + videoParentView);
    if (mWebView != null) {
        mWebView.setVisibility(View.GONE);
    }

    if (videoParentView == null) {
        FrameLayout mDecorView = (FrameLayout) mActivity.getWindow().getDecorView();
        videoParentView = new FrameLayout(mActivity);
        videoParentView.setBackgroundColor(Color.BLACK);
        videoParentView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN); // ?
        mDecorView.addView(videoParentView);
    }

    //        KLog.e("" + mWebView.getVisibility()  + "   "  + videoParentView);
    this.mCallback = callback;
    this.videoView = view;
    videoParentView.addView(videoView, WindowManager.LayoutParams.MATCH_PARENT,
            WindowManager.LayoutParams.MATCH_PARENT);
    videoParentView.setVisibility(View.VISIBLE);
    isPlaying = true;
}

From source file:com.example.caique.educam.Activities.TimelineActivity.java

@TargetApi(19)
private void setTranslucentStatus(boolean on) {
    Window win = getWindow();
    WindowManager.LayoutParams winParams = win.getAttributes();
    win.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION,
            WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
    /* win.setFlags(/*from w  ww . j av a2  s . co  m*/
        WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
        WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    */ final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
    if (on) {
        winParams.flags |= bits;
    } else {
        winParams.flags &= ~bits;
    }
    win.setAttributes(winParams);
}

From source file:com.just.agentweb.VideoImpl.java

@Override
public void onShowCustomView(View view, WebChromeClient.CustomViewCallback callback) {
    Activity mActivity;/*  w  w  w.ja v a 2  s  .c om*/
    if ((mActivity = this.mActivity) == null || mActivity.isFinishing()) {
        return;
    }
    mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

    Window mWindow = mActivity.getWindow();
    Pair<Integer, Integer> mPair = null;
    // ????
    if ((mWindow.getAttributes().flags & WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) == 0) {
        mPair = new Pair<>(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, 0);
        mWindow.setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
                WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        mFlags.add(mPair);
    }

    if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
            && (mWindow.getAttributes().flags & WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED) == 0) {
        mPair = new Pair<>(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, 0);
        mWindow.setFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
                WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
        mFlags.add(mPair);
    }

    if (mMoiveView != null) {
        callback.onCustomViewHidden();
        return;
    }

    if (mWebView != null) {
        mWebView.setVisibility(View.GONE);
    }

    if (mMoiveParentView == null) {
        FrameLayout mDecorView = (FrameLayout) mActivity.getWindow().getDecorView();
        mMoiveParentView = new FrameLayout(mActivity);
        mMoiveParentView.setBackgroundColor(Color.BLACK);
        mDecorView.addView(mMoiveParentView);
    }
    this.mCallback = callback;
    mMoiveParentView.addView(this.mMoiveView = view);
    mMoiveParentView.setVisibility(View.VISIBLE);

}

From source file:uk.org.downiesoft.slideshow.SlidesFragment.java

/**
 * Stop the current slideshow.//  w w w .  ja  va 2s.  c  o  m
 * Resets any filter and randomisation while still showing the slide we stopped at.
 */
private void stopSlideshow() {
    mSlideshowHandler.removeCallbacks(slideshowRunnable);
    mSlideshowRunning = false;
    mUiHider.showUi(true);
    sPresentation.clearFilter();
    sPresentation.setRandomise(false);
    setImage(getCurrentImage());
    Window window = getActivity().getWindow();
    window.setFlags(0, WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    getActivity().invalidateOptionsMenu();
}

From source file:com.nextgis.ngm_clink_monitoring.dialogs.YesNoDialog.java

@NonNull
@Override/*from  w w w .  j a v a2s. c  o  m*/
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // Idea from here
    // http://thanhcs.blogspot.ru/2014/10/android-custom-dialog-fragment.html
    Dialog dialog = new Dialog(getActivity());

    Window window = dialog.getWindow();
    window.requestFeature(Window.FEATURE_NO_TITLE);
    window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
    window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));

    dialog.setContentView(R.layout.dialog_yes_no);

    mIcon = (ImageView) dialog.findViewById(R.id.title_icon);
    mTitle = (TextView) dialog.findViewById(R.id.title_text);

    mDialogBodyScroll = (ScrollView) dialog.findViewById(R.id.dialog_body_scroll);
    mDialogBodyLayoutScrolled = (LinearLayout) dialog.findViewById(R.id.dialog_body_scrolled);
    mDialogBodyLayout = (LinearLayout) dialog.findViewById(R.id.dialog_body);

    mButtons = (TableLayout) dialog.findViewById(R.id.dialog_buttons_yn);
    mBtnPositive = (Button) dialog.findViewById(R.id.dialog_btn_positive_yn);
    mBtnNegative = (Button) dialog.findViewById(R.id.dialog_btn_negative_yn);

    if (null != mIconId) {
        mIcon.setVisibility(View.VISIBLE);
        mIcon.setImageResource(mIconId);
    }

    if (null != mTitleId) {
        mTitle.setText(mTitleId);
    }
    if (null != mTitleText) {
        mTitle.setText(mTitleText);
    }

    if (null != mMessageId) {
        setMessageView();
        mMessage.setText(mMessageId);
    }
    if (null != mMessageText) {
        setMessageView();
        mMessage.setText(mMessageText);
    }

    if (null != mView) {
        if (mAddScrollForView) {
            mDialogBodyScroll.setVisibility(View.VISIBLE);
            mDialogBodyLayoutScrolled.addView(mView);
        } else {
            mDialogBodyLayout.setVisibility(View.VISIBLE);
            mDialogBodyLayout.addView(mView);
        }
    }

    if (null != mPositiveTextId) {
        mButtons.setVisibility(View.VISIBLE);
        mBtnPositive.setVisibility(View.VISIBLE);
        mBtnPositive.setText(mPositiveTextId);
    }
    if (null != mPositiveText) {
        mButtons.setVisibility(View.VISIBLE);
        mBtnPositive.setVisibility(View.VISIBLE);
        mBtnPositive.setText(mPositiveText);
    }

    if (null != mNegativeTextId) {
        mButtons.setVisibility(View.VISIBLE);
        mBtnNegative.setVisibility(View.VISIBLE);
        mBtnNegative.setText(mNegativeTextId);
    }
    if (null != mNegativeText) {
        mButtons.setVisibility(View.VISIBLE);
        mBtnNegative.setVisibility(View.VISIBLE);
        mBtnNegative.setText(mNegativeText);
    }

    if (null != mOnPositiveClickedListener) {
        mButtons.setVisibility(View.VISIBLE);
        mBtnPositive.setVisibility(View.VISIBLE);
        mBtnPositive.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (null != mOnPositiveClickedListener) {
                    mOnPositiveClickedListener.onPositiveClicked();
                }
                dismiss();
            }
        });
    }

    if (null != mOnNegativeClickedListener) {
        mButtons.setVisibility(View.VISIBLE);
        mBtnNegative.setVisibility(View.VISIBLE);
        mBtnNegative.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (null != mOnNegativeClickedListener) {
                    mOnNegativeClickedListener.onNegativeClicked();
                }
                dismiss();
            }
        });
    }

    return dialog;
}

From source file:com.nextgis.libngui.dialog.StyledDialogFragment.java

@NonNull
@Override// w ww  .j  av a  2s  .  c om
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // Idea from here
    // http://thanhcs.blogspot.ru/2014/10/android-custom-dialog-fragment.html

    Dialog dialog = new Dialog(mContext);

    Window window = dialog.getWindow();
    window.requestFeature(Window.FEATURE_NO_TITLE);
    window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
    window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));

    return dialog;
}

From source file:com.ovrhere.android.morseflash.ui.MainActivity.java

/**
 * Sets the activity to be fullscreen, removing the action bar and status
 * bar. Also sets isFullscreen to the value passed.
 * @param fullscreen <code>true</code> to set fullscreen,
 * <code>false</code> to return to normal screen.
 *//*from   w ww.j  a v  a 2  s.c o m*/
private void setFullscreen(boolean fullscreen) {
    Window window = getWindow();
    if (fullscreen) {
        window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        window.clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
        getSupportActionBar().hide();
    } else {
        window.setFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
        window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
        getSupportActionBar().show();
    }
    //ensure redraw
    findViewById(R.id.container).requestLayout();
    isFullscreen = fullscreen;
}

From source file:uk.org.downiesoft.slideshow.SlidesFragment.java

/**
 * Start a slideshow./* w w  w. ja  v a  2  s .  c  o  m*/
 * @param aMatchOrientation If true, filter the slides to match the current orientation and callback.
 */
private void startSlideshow(boolean aMatchOrientation) {
    if (aMatchOrientation) {
        mEmptyText.setText(R.string.text_finding_images);
        new FilterTask().executeOnExecutor(SlideShowActivity.THREAD_POOL_EXECUTOR);
    } else {
        if (sPresentation.getCount() > 0) {
            sPresentation.setRandomise(randomise());
            int interval = Integer
                    .parseInt(mSlideshowSettings.getString(getString(R.string.PREFS_INTERVAL), "5"));
            mSlideshowHandler.postDelayed(slideshowRunnable, interval * 1000);
            if (!mAutostart) {
                mUiHider.delayedHide(100);
            } else {
                mUiHider.hideUi();
            }
            mSlideshowRunning = true;
            Activity activity = getActivity();
            if (activity != null) {
                Window window = getActivity().getWindow();
                window.setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
                        WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
                sSlideBuffer.showSlide(sPresentation.currentEntry());
            }
        } else {
            mEmptyText.setText(R.string.text_no_suitable_image);
            Toast.makeText(getActivity(), R.string.text_no_suitable_image, Toast.LENGTH_SHORT).show();
            sPresentation.clearFilter();
            getActivity().finish();
        }
    }
    getActivity().invalidateOptionsMenu();
}

From source file:org.docrj.smartcard.reader.GroupViewActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_group_view);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);// w  w  w. jav a 2  s.  c o  m
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onBackPressed();
        }
    });

    mNote = (TextView) findViewById(R.id.note);
    mGrpListView = (AnimatedExpandableListView) findViewById(R.id.listView);

    // custom click handler so we can ignore and not collapse
    mGrpListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
        @Override
        public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {
            return true;
        }
    });

    mGrpListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
        @Override
        public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition,
                long id) {
            SmartcardApp app = mGrpAdapter.getChild(groupPosition, childPosition);
            // view app
            Intent i = new Intent(GroupViewActivity.this, AppViewActivity.class);
            i.setAction(ACTION_VIEW_APP);
            i.putExtra(EXTRA_APP_POS, mApps.indexOf(app));
            startActivity(i);
            return true;
        }
    });

    // persistent data in shared prefs
    SharedPreferences ss = getSharedPreferences("prefs", Context.MODE_PRIVATE);
    mEditor = ss.edit();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window w = getWindow();
        w.setFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS,
                WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS
                        | WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        w.setStatusBarColor(getResources().getColor(R.color.primary_dark));
    }
}

From source file:org.catrobat.catroid.ui.dialogs.AddBrickDialog.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.dialog_brick_add, null);

    ImageButton closeButton = (ImageButton) rootView.findViewById(R.id.dialog_brick_title_button_close);
    TextView textView = (TextView) rootView.findViewById(R.id.dialog_brick_title_text_view_title);
    listView = (ListView) rootView.findViewById(R.id.dialog_brick_add_list_view);

    closeButton.setOnClickListener(new View.OnClickListener() {
        @Override/* ww w.  j  ava  2s  .co  m*/
        public void onClick(View v) {
            dismiss();
        }
    });

    textView.setText(selectedCategory);

    Window window = getDialog().getWindow();
    window.requestFeature(Window.FEATURE_NO_TITLE);
    window.setGravity(Gravity.CENTER | Gravity.FILL_HORIZONTAL | Gravity.FILL_VERTICAL);
    window.setLayout(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

    return rootView;
}