Example usage for android.view Window addFlags

List of usage examples for android.view Window addFlags

Introduction

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

Prototype

public void addFlags(int flags) 

Source Link

Document

Convenience function to set the flag bits as specified in flags, as per #setFlags .

Usage

From source file:org.dmfs.tasks.TaskListActivity.java

@SuppressLint("NewApi")
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
@Override/*from   ww  w.ja va2s  .c om*/
protected void onCreate(Bundle savedInstanceState) {
    Log.d(TAG, "onCreate called again");
    super.onCreate(savedInstanceState);

    // check for single pane activity change
    mTwoPane = getResources().getBoolean(R.bool.has_two_panes);

    resolveIntentAction(getIntent());

    if (mSelectedTaskUri != null) {
        if (mShouldShowDetails && mShouldSwitchToDetail) {
            Intent viewTaskIntent = new Intent(Intent.ACTION_VIEW);
            viewTaskIntent.setData(mSelectedTaskUri);
            startActivity(viewTaskIntent);
            mSwitchedToDetail = true;
            mShouldSwitchToDetail = false;
            mTransientState = true;
        }
    } else {
        mShouldShowDetails = false;
    }

    setContentView(R.layout.activity_task_list);

    mAuthority = getString(R.string.org_dmfs_tasks_authority);
    mSearchHistoryHelper = new SearchHistoryHelper(this);

    if (findViewById(R.id.task_detail_container) != null) {
        // In two-pane mode, list items should be given the
        // 'activated' state when touched.

        // get list fragment
        // mTaskListFrag = (TaskListFragment) getSupportFragmentManager().findFragmentById(R.id.task_list);
        // mTaskListFrag.setListViewScrollbarPositionLeft(true);

        // mTaskListFrag.setActivateOnItemClick(true);

        /*
         * Create a detail fragment, but don't load any URL yet, we do that later when the fragment gets attached
         */
        mTaskDetailFrag = ViewTaskFragment.newInstance(mSelectedTaskUri);
        getSupportFragmentManager().beginTransaction()
                .replace(R.id.task_detail_container, mTaskDetailFrag, DETAIL_FRAGMENT_TAG).commit();
    } else {
        FragmentManager fragmentManager = getSupportFragmentManager();
        Fragment detailFragment = fragmentManager.findFragmentByTag(DETAIL_FRAGMENT_TAG);
        if (detailFragment != null) {
            fragmentManager.beginTransaction().remove(detailFragment).commit();
        }
    }

    mGroupingFactories = new AbstractGroupingFactory[] { new ByList(mAuthority), new ByDueDate(mAuthority),
            new ByStartDate(mAuthority), new ByPriority(mAuthority), new ByProgress(mAuthority),
            new BySearch(mAuthority, mSearchHistoryHelper) };

    // set up pager adapter
    try {
        mPagerAdapter = new TaskGroupPagerAdapter(getSupportFragmentManager(), mGroupingFactories, this,
                R.xml.listview_tabs);
    } catch (XmlPullParserException e) {
        // TODO Automatisch generierter Erfassungsblock
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Automatisch generierter Erfassungsblock
        e.printStackTrace();
    } catch (XmlObjectPullParserException e) {
        // TODO Automatisch generierter Erfassungsblock
        e.printStackTrace();
    }

    // Setup ViewPager
    mPagerAdapter.setTwoPaneLayout(mTwoPane);
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mPagerAdapter);

    int currentPageIndex = mPagerAdapter.getPagePosition(mCurrentPageId);

    if (currentPageIndex >= 0) {
        mCurrentPagePosition = currentPageIndex;
        mViewPager.setCurrentItem(currentPageIndex);
        if (VERSION.SDK_INT >= 14 && mCurrentPageId == R.id.task_group_search) {
            if (mSearchItem != null) {
                // that's actually quite impossible to happen
                MenuItemCompat.expandActionView(mSearchItem);
            } else {
                mAutoExpandSearchView = true;
            }
        }
    }
    updateTitle(currentPageIndex);

    // Bind the tabs to the ViewPager
    mTabs = (PagerSlidingTabStrip) findViewById(R.id.tabs);
    mTabs.setViewPager(mViewPager);

    mTabs.setOnPageChangeListener(new OnPageChangeListener() {

        @Override
        public void onPageSelected(int position) {
            mSelectedTaskUri = null;
            mCurrentPagePosition = position;

            int newPageId = mPagerAdapter.getPageId(position);

            if (newPageId == R.id.task_group_search) {
                int oldPageId = mCurrentPageId;
                mCurrentPageId = newPageId;

                // store the page position we're coming from
                mPreviousPagePosition = mPagerAdapter.getPagePosition(oldPageId);
            } else if (mCurrentPageId == R.id.task_group_search) {
                // we've been on the search page before, so commit the search and close the search view
                mSearchHistoryHelper.commitSearch();
                mHandler.post(mSearchUpdater);
                mCurrentPageId = newPageId;
                hideSearchActionView();
            }
            mCurrentPageId = newPageId;

            updateTitle(mCurrentPageId);
        }

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

        }

        @Override
        public void onPageScrollStateChanged(int state) {
            if (state == ViewPager.SCROLL_STATE_IDLE && mCurrentPageId == R.id.task_group_search) {
                // the search page is selected now, expand the search view
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        MenuItemCompat.expandActionView(mSearchItem);
                    }
                });
            }
        }
    });

    // make sure the status bar color is set properly on Android 5+ devices
    if (VERSION.SDK_INT >= 21) {
        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(getResources().getColor(R.color.colorPrimaryDarker));
    }
}

From source file:com.granita.tasks.TaskListActivity.java

@SuppressLint("NewApi")
@Override//  w  ww .  j a  va  2 s.com
public void updateColor(int color) {
    getSupportActionBar().setBackgroundDrawable(new ColorDrawable(color));
    mTabs.setBackgroundColor(color);

    if (VERSION.SDK_INT >= 21) {
        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(color);
    }
}

From source file:de.uni_koblenz_landau.apow.LoginActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Re-attach Tasks.
    TaskActivityReference.getInstance().attach(LoginTask.TASK_ID, this);
    TaskActivityReference.getInstance().attach(SetupTask.TASK_ID, this);
    TaskActivityReference.getInstance().attach(NFCTagReaderTask.TASK_ID, this);
    TaskActivityReference.getInstance().attach(LocationWebTask.TASK_ID, this);

    // Create UI references.
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = this.getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.setStatusBarColor(this.getResources().getColor(R.color.color_primary_dark));
    }//from   w w  w  . j  a  va2s. c o  m
    setContentView(R.layout.login_activity);
    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    if (mToolbar != null) {
        setSupportActionBar(mToolbar);
    }

    mSetupLocationView = (Spinner) findViewById(R.id.login_setup_locations);
    mStatusView = findViewById(R.id.login_status);
    mStatusMessageView = (TextView) findViewById(R.id.login_status_message);
    mLoginFormView = findViewById(R.id.login_login);
    mLoginPasswordView = (EditText) findViewById(R.id.login_login_password);
    mLoginPasswordView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {
            if (id == R.id.login || id == EditorInfo.IME_NULL) {
                login(textView);
                return true;
            }
            return false;
        }
    });
    mLoginNFCText = (TextView) findViewById(R.id.login_login_nfc);
    mSetupFormView = findViewById(R.id.login_setup);
    mSetupNFCText = (TextView) findViewById(R.id.login_setup_nfc);

    mSetupDatabasePasswordView = (EditText) findViewById(R.id.login_setup_database_password);
    mSetupDatabaseConfirmView = (EditText) findViewById(R.id.login_setup_database_password_confirm);
    mSetupServerUsernameView = (EditText) findViewById(R.id.login_login_server_user);
    mSetupServerPasswordView = (EditText) findViewById(R.id.login_login_server_password);

    //mFirstRun = true;
    mFirstRun = getSharedPreferences(Constants.PREFERENCE, MODE_PRIVATE).getBoolean(ARG_FIRST_RUN, true);
    mNfcAdapter = NfcAdapter.getDefaultAdapter(this);

    // Restore UI from saved instance or load data.
    if (savedInstanceState != null) {
        mNFCTag = savedInstanceState.getString(ARG_NFC);
        mNFCTextDrawable = savedInstanceState.getInt(ARG_NFC_STATE);
        mAutoSignOffDismissed = savedInstanceState.getBoolean(ARG_AUTO_SIGN_OFF_DISMISSED);
        mProgress = savedInstanceState.getBoolean(ARG_PROGRESS);
        if (mFirstRun) {
            mLocations = savedInstanceState.getParcelableArrayList(ARG_LOCATIONS);
            if (mLocations != null) {
                ArrayAdapter<ListViewItem> adapter = new ArrayAdapter<>(this,
                        android.R.layout.simple_spinner_item, mLocations);
                adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
                mSetupLocationView.setAdapter(adapter);
                mSetupLocationView.setSelection(savedInstanceState.getInt(ARG_LOCATION_SELECTION));
            }
        }
    } else {
        mProgress = false;
        mAutoSignOffDismissed = false;
        mNFCTag = "";
        mNFCTextDrawable = R.drawable.empty;
        if (mFirstRun) {
            loadLocations();
        }
    }
    mLoginNFCText.setCompoundDrawablesWithIntrinsicBounds(0, 0, mNFCTextDrawable, 0);
    mSetupNFCText.setCompoundDrawablesWithIntrinsicBounds(0, 0, mNFCTextDrawable, 0);

    if (mFirstRun) {
        mSetupFormView.setVisibility(View.VISIBLE);
        mLoginFormView.setVisibility(View.GONE);
        this.setTitle(R.string.login_setup_title);
    } else {
        mSetupFormView.setVisibility(View.GONE);
        mLoginFormView.setVisibility(View.VISIBLE);
        this.setTitle(R.string.login_login_title);
    }

    if (getIntent().getBooleanExtra(ARG_AUTO_LOGOUT, false) && !mAutoSignOffDismissed) {
        SignedOffDialog dialog = new SignedOffDialog();
        dialog.show(getSupportFragmentManager(), SIGNED_OFF_DIALOG_ID);
        mAutoSignOffDismissed = true;
    }
    showProgress(mProgress);
    setNFCState();
}

From source file:edu.mit.mobile.android.livingpostcards.CameraActivity.java

public void setFullscreen(boolean fullscreen) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        mPreviewHolder.setSystemUiVisibility(fullscreen ? View.SYSTEM_UI_FLAG_LOW_PROFILE : 0);
    }// w ww  .  j  a va  2s.  c  o  m

    if (fullscreen) {
        final Window w = getWindow();
        w.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
        w.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    } else {
        final Window w = getWindow();
        w.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
        w.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    }
}

From source file:com.coact.kochzap.CaptureActivity.java

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    Window window = getWindow();
    window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    setContentView(R.layout.capture);//w  ww .j  a v a 2 s .  c  o m

    hasSurface = false;
    inactivityTimer = new InactivityTimer(this);
    beepManager = new BeepManager(this);
    ambientLightManager = new AmbientLightManager(this);

    PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
}

From source file:com.cleverzone.zhizhi.capture.CaptureActivity.java

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    Window window = getWindow();
    window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    setContentView(R.layout.activity_capture);

    hasSurface = false;// w  w w .j a  v a2s  .  c o  m
    inactivityTimer = new InactivityTimer(this);
    beepManager = new BeepManager(this);
    //        ambientLightManager = new AmbientLightManager(this);

    //        PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
}

From source file:com.nbplus.vbroadlauncher.RadioActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (Constants.OPEN_BETA_PHONE && LauncherSettings.getInstance(this).isSmartPhone()) {
        this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    }/*  www  . ja  v  a2  s  .  c  om*/

    mSettingsContentObserver = new SettingsContentObserver(this, new Handler());
    getApplicationContext().getContentResolver().registerContentObserver(
            android.provider.Settings.System.CONTENT_URI, true, mSettingsContentObserver);

    showProgressDialog();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.setStatusBarColor(getResources().getColor(R.color.activity_radio_background));
    }

    overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
    setContentView(R.layout.activity_radio);

    Intent i = getIntent();
    mShortcutData = i.getParcelableExtra(Constants.EXTRA_NAME_SHORTCUT_DATA);
    if (mShortcutData == null) {
        Log.e(TAG, "mShortcutData is not found..");
        finishActivity();
        return;
    }

    IntentFilter filter = new IntentFilter();
    filter.addAction(MusicService.ACTION_PLAYED);
    filter.addAction(MusicService.ACTION_PAUSED);
    filter.addAction(MusicService.ACTION_STOPPED);
    filter.addAction(MusicService.ACTION_COMPLETED);
    filter.addAction(MusicService.ACTION_ERROR);
    filter.addAction(MusicService.ACTION_PLAYING_STATUS);

    LocalBroadcastManager.getInstance(this).registerReceiver(mBroadcastReceiver, filter);
    // send playing status
    Intent queryStatus = new Intent(this, MusicService.class);
    queryStatus.setAction(MusicService.ACTION_PLAYING_STATUS);
    startService(queryStatus);

    // ViewPager .
    // ??? ? ? ? .
    mViewPager = (NbplusViewPager) findViewById(R.id.viewPager);
    mIndicator = (CirclePageIndicator) findViewById(R.id.indicator);

    // close button
    ImageButton closeButton = (ImageButton) findViewById(R.id.btn_close);
    closeButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            finishActivity();
        }
    });

    mActivityLayout = (RelativeLayout) findViewById(R.id.radio_activity_background);
    int wallpaperId = LauncherSettings.getInstance(this).getWallpaperId();
    mActivityLayout.setBackgroundResource(LauncherSettings.landWallpaperResource[wallpaperId]);

    // title.
    mRadioTitle = (TextView) findViewById(R.id.radio_activity_label);

    // media controller
    mPlayToggle = (ImageButton) findViewById(R.id.ic_media_control_play);
    mPlayToggle.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (mCurrentPlayingStatus == null) {
                return;
            }
            MusicService.State state = (MusicService.State) mCurrentPlayingStatus
                    .getSerializable(MusicService.EXTRA_PLAYING_STATUS);
            Intent i = new Intent(RadioActivity.this, MusicService.class);
            if (state == MusicService.State.Playing) {
                i.setAction(MusicService.ACTION_PAUSE);
            } else if (state == MusicService.State.Paused) {
                i.setAction(MusicService.ACTION_PLAY);
            }
            startService(i);
        }
    });
    mPlayStop = (ImageButton) findViewById(R.id.ic_media_control_stop);
    mPlayStop.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (mCurrentPlayingStatus == null) {
                return;
            }
            MusicService.State state = (MusicService.State) mCurrentPlayingStatus
                    .getSerializable(MusicService.EXTRA_PLAYING_STATUS);
            if (state == MusicService.State.Playing || state == MusicService.State.Paused) {
                Intent i = new Intent(RadioActivity.this, MusicService.class);
                i.setAction(MusicService.ACTION_STOP);
                i.putExtra(MusicService.EXTRA_MUSIC_FORCE_STOP, false);
                startService(i);
            }
        }
    });

    mSoundToggle = (ImageButton) findViewById(R.id.ic_media_control_volume_btn);
    AudioManager audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
    int currentVolume = audio.getStreamVolume(AudioManager.STREAM_MUSIC);
    int maxVolume = audio.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
    if (currentVolume <= 0) {
        mSoundToggle.setBackgroundResource(R.drawable.ic_button_radio_sound_off);
    } else {
        mSoundToggle.setBackgroundResource(R.drawable.ic_button_radio_sound_on);
    }
    mSoundToggle.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            AudioManager audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE);

            if (audio.getStreamVolume(AudioManager.STREAM_MUSIC) <= 0) {
                if (mSoundTogglePreviousValue > 0) {
                    audio.setStreamVolume(AudioManager.STREAM_MUSIC, mSoundTogglePreviousValue,
                            AudioManager.FLAG_PLAY_SOUND);
                } else {
                    mSoundTogglePreviousValue = 1;
                    audio.setStreamVolume(AudioManager.STREAM_MUSIC, mSoundTogglePreviousValue,
                            AudioManager.FLAG_PLAY_SOUND);
                }
                mSoundToggle.setBackgroundResource(R.drawable.ic_button_radio_sound_on);
                mSeekbar.setProgress(mSoundTogglePreviousValue);
                mSoundTogglePreviousValue = -1;
            } else {
                mSoundTogglePreviousValue = audio.getStreamVolume(AudioManager.STREAM_MUSIC);
                audio.setStreamVolume(AudioManager.STREAM_MUSIC, 0, AudioManager.FLAG_PLAY_SOUND);
                mSoundToggle.setBackgroundResource(R.drawable.ic_button_radio_sound_off);
            }
        }
    });

    mSeekbar = (SeekBar) findViewById(R.id.ic_media_control_volume_seek);
    mSeekbar.setMax(maxVolume);
    mSeekbar.setProgress(currentVolume);
    mSeekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            if (fromUser) {
                mSoundTogglePreviousValue = -1;
                AudioManager audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
                audio.setStreamVolume(AudioManager.STREAM_MUSIC, progress, AudioManager.FLAG_PLAY_SOUND);
            }
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {

        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {

        }
    });

    getRadioChannelTask = new GetRadioChannelTask();
    if (getRadioChannelTask != null) {
        getRadioChannelTask.setBroadcastApiData(this, mHandler,
                mShortcutData.getDomain() + mShortcutData.getPath());
        mIsExecuteGetRadioChannelTask = true;
        getRadioChannelTask.execute();
    }
}

From source file:io.jawg.osmcontributor.ui.activities.MapActivity.java

@TargetApi(21)
private void changeNotificationToolbarColor(boolean isCreation) {
    Window window = getWindow();

    if (window != null) {
        if (isCreation) {
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            window.setStatusBarColor(getResources().getColor(R.color.colorCreationDark));
        } else {/*from w  ww  .j  a v  a  2  s .  co  m*/
            window.clearFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        }
    }
}

From source file:com.breadwallet.presenter.activities.MainActivity.java

private void setStatusBarColor() {
    Window window = getWindow();
    window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
    window.setStatusBarColor(getColor(R.color.status_bar));
}

From source file:com.hellofyc.base.app.activity.BaseActivity.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public void setStatusBarColorTransparent() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = getWindow();
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
                | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
        window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(Color.TRANSPARENT);
        window.setNavigationBarColor(Color.TRANSPARENT);
    }//from   w w  w .  ja  va  2  s .  c  o m
}