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:com.grarak.kerneladiutor.FileBrowserActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    fileBrowserActivity = this;
    boolean dark = Utils.getBoolean("darktheme", false, this);
    if (dark)/*from ww w.  j  a v  a  2 s  .co m*/
        super.setTheme(R.style.AppThemeDark);
    setContentView(R.layout.activity_filebrowser);

    setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
    ActionBar actionBar;
    if ((actionBar = getSupportActionBar()) != null)
        actionBar.setDisplayHomeAsUpEnabled(true);

    String fileType = getIntent().getExtras().getString(FILE_TYPE_ARG);
    String externalStorage = Utils.getExternalStorage();

    LinkedHashMap<String, Fragment> fragments = new LinkedHashMap<>();
    internalStorage = StorageFragment.newInstance(Environment.getExternalStorageDirectory().getPath(),
            fileType);
    fragments.put(getString(R.string.internal_storage), internalStorage);
    if (externalStorage != null) {
        this.externalStorage = StorageFragment.newInstance(externalStorage, fileType);
        fragments.put(getString(R.string.external_storage), this.externalStorage);
    }

    mViewPager = (ViewPager) findViewById(R.id.view_pager);
    mViewPager.setAdapter(new Adapter(getSupportFragmentManager(), fragments));
    if (dark)
        mViewPager.setBackgroundColor(getResources().getColor(R.color.card_background_dark));

    final SlidingTabLayout mSlidingTabLayout = (SlidingTabLayout) findViewById(R.id.sliding_tabs);
    mSlidingTabLayout.setCustomTabView(R.layout.tab_indicator, android.R.id.text1);
    for (int i = 0; i < fragments.keySet().toArray().length; i++)
        mSlidingTabLayout.setContentDescription(i, (String) fragments.keySet().toArray()[i]);
    mSlidingTabLayout.setSelectedIndicatorColors(
            getResources().getColor(fragments.size() > 1 ? R.color.white : R.color.color_primary));
    mSlidingTabLayout.setDistributeEvenly(true);
    mSlidingTabLayout.setViewPager(mViewPager);

    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.color_primary_dark));
    }
}

From source file:com.bilibili.magicasakurademo.MainActivity.java

@Override
protected void onPostCreate(@Nullable Bundle savedInstanceState) {
    super.onPostCreate(savedInstanceState);
    if (Build.VERSION.SDK_INT >= 21) {
        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.setStatusBarColor(ThemeUtils.getColorById(this, R.color.theme_color_primary_dark));
        ActivityManager.TaskDescription description = new ActivityManager.TaskDescription(null, null,
                ThemeUtils.getThemeAttrColor(this, android.R.attr.colorPrimary));
        setTaskDescription(description);
    }/*from ww w. ja va  2  s  . c om*/
}

From source file:com.lambdal.railgun.PInfo.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Set the activity
    PInfo.activity = this;
    int packageCount = PInfo.getPackages().size();

    // Hide the status bar.
    Window w = getWindow();
    w.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    w.clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);

    setContentView(R.layout.activity_main);
    // Set up the action bar.
    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    actionBar.hide();//  w  w w . java 2 s.  com
    // getActionBar().setBackgroundDrawable(new
    // ColorDrawable(Color.argb(128, 0, 0, 0)));
    // Create the adapter that will return a fragment for each of the three
    // primary sections of the app.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
    mSectionsPagerAdapter.pageCount = packageCount;

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    // When swiping between different sections, select the corresponding
    // tab. We can also use ActionBar.Tab#select() to do this if we have
    // a reference to the Tab.
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
        }
    });

    mViewPager.setOnClickListener(new ViewPager.OnClickListener() {
        @Override
        public void onClick(View view) {
            // When swiping between pages, select the
            // corresponding tab.
            int currentAppIndex = DummySectionFragment.currentAppIndex;
            ArrayList<PInfo> appList = PInfo.getInstalledApps(false);
            PInfo app = appList.get(currentSelectedTabIndex.intValue());
            // Open the app:
            Intent launchIntent = getPackageManager().getLaunchIntentForPackage(app.pname);
            try {
                startActivity(launchIntent);
            } catch (Exception e) {
                Log.v("We ran into an exception when launching intent: " + app.pname, e.toString());
            }
            Log.v("We have a tap event which happened at index: ",
                    app.toString() + " " + currentSelectedTabIndex.toString());
        }
    });

    for (int i = 0; i < PInfo.getPackages().size(); i++) {
        actionBar
                .addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }
}

From source file:com.melvin.share.zxing.activity.CaptureActivity.java

@Override
protected void initView() {
    Window window = getWindow();
    window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    setContentView(R.layout.activity_capture);
    initWindow();/*from  ww w .j av a 2s. com*/
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    initToolbar(toolbar);
    scanPreview = (SurfaceView) findViewById(R.id.capture_preview);
    scanContainer = (RelativeLayout) findViewById(R.id.capture_container);
    scanCropView = (RelativeLayout) findViewById(R.id.capture_crop_view);
    scanLine = (ImageView) findViewById(R.id.capture_scan_line);

    inactivityTimer = new InactivityTimer(this);
    beepManager = new BeepManager(this);

    TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f,
            Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f,
            Animation.RELATIVE_TO_PARENT, 0.9f);
    animation.setDuration(4500);
    animation.setRepeatCount(-1);
    animation.setRepeatMode(Animation.RESTART);
    scanLine.startAnimation(animation);
}

From source file:nz.ac.otago.psyanlab.common.designer.program.stage.StageActivity.java

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

    Window window = getWindow();
    window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    window.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
    window.clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
    requestWindowFeature(Window.FEATURE_NO_TITLE);

    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        if (extras.containsKey(Args.EXPERIMENT_PROPS)) {
            mProps = extras.getParcelableArrayList(Args.EXPERIMENT_PROPS);
        }/*from   w  ww.j a v a  2 s  .  c o  m*/

        mOrientation = extras.getInt(Args.STAGE_ORIENTATION,
                getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE
                        ? Scene.ORIENTATION_LANDSCAPE
                        : Scene.ORIENTATION_PORTRAIT);

        mSpecifiedWidth = extras.getInt(Args.STAGE_WIDTH, -1);
        mSpecifiedHeight = extras.getInt(Args.STAGE_HEIGHT, -1);
    } else {
        mProps = new ArrayList<PropIdPair>();
    }

    refreshStage();

    mPropAdapter = new PropAdapter(this, mProps);

    View view = getLayoutInflater().inflate(R.layout.activity_stage, null);
    mStage = (StageView) view.findViewById(R.id.stage);
    mStage.setNativeWidth(mSpecifiedWidth);
    mStage.setNativeHeight(mSpecifiedHeight);
    mStage.setAdapter(mPropAdapter);
    mStage.setOnItemClickListener(mPropClickListener);
    mStage.setOnStageClickListener(2, mSelectClickListener);
    mStage.setOnStageClickListener(1, mAddClickListener);
    mStage.setOnStageClickListener(3, mAddClickListener);
    mStage.forceMultiTouchWhenEmpty(3);
    mStage.setOnStageClickListener(4, mPropertiesClickListener);
    mStage.exemptMultiTouchFromEmptyCondition(4);
    setContentView(view);
}

From source file:edu.tjhsst.ion.gcmFrame.MainActivity.java

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

    this.setContentView(R.layout.activity_main);

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

    }//  w  ww  .  j a  v  a  2  s .  co  m
    // requestWindowFeature(Window.FEATURE_NO_TITLE);

    mRegistrationBroadcastReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
            boolean sentToken = sharedPreferences.getBoolean(QuickstartPreferences.SENT_TOKEN_TO_SERVER, false);
            if (sentToken) {
                Log.i(TAG, "Google token sent");

            } else {
                Toast.makeText(getApplicationContext(), getString(R.string.token_error_message),
                        Toast.LENGTH_LONG).show();
            }
        }

    };

    if (checkPlayServices()) {
        // Start IntentService to register this application with GCM.
        Intent intent = new Intent(this, RegistrationIntentService.class);
        startService(intent);
    }

    ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(
            Context.CONNECTIVITY_SERVICE);
    if (connectivityManager != null) {
        NetworkInfo ni = connectivityManager.getActiveNetworkInfo();
        if (ni != null) {
            NetworkInfo.State state = ni.getState();
            if (state == null || state != NetworkInfo.State.CONNECTED) {
                // record the fact that there is no connection
                isConnected = false;
            }
        }
    }

    SharedPreferences sharedPreferences = PreferenceManager
            .getDefaultSharedPreferences(getApplicationContext());
    boolean sentToken = sharedPreferences.getBoolean(QuickstartPreferences.ION_SETUP, false);

    webView = (WebView) findViewById(R.id.webview);

    webView.setInitialScale(1);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setLoadWithOverviewMode(true);

    webView.getSettings().setUseWideViewPort(true);
    webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
    webView.setScrollbarFadingEnabled(false);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        WebView.setWebContentsDebuggingEnabled(true);
    }
    StringBuilder uaString = new StringBuilder(webView.getSettings().getUserAgentString());
    uaString.append(" - IonAndroid: gcmFrame (");
    if (sentToken) {
        uaString.append("appRegistered:True");
    } else {
        uaString.append("appRegistered:False");
    }
    uaString.append(" osVersion:").append(System.getProperty("os.version"));
    uaString.append(" apiLevel:").append(android.os.Build.VERSION.SDK_INT);
    uaString.append(" Device:").append(android.os.Build.DEVICE);
    uaString.append(" Model:").append(android.os.Build.MODEL);
    uaString.append(" Product:").append(android.os.Build.PRODUCT);
    uaString.append(")");
    webView.getSettings().setUserAgentString(uaString.toString());

    webView.setNetworkAvailable(isConnected);

    webView.addJavascriptInterface(new WebAppInterface(this), "IonAndroidInterface");

    webView.loadUrl(MainActivity.ION_HOST);

    webView.setWebViewClient(new WebViewClient() {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            Log.d(TAG, "Loading " + url);
            if (!isConnected) {
                String html = getHtml("offline.html");
                html = html.replaceAll("\\[url\\]", url);
                view.loadData(html, "text/html", "utf-8");
                return true;
            } else if (url.contains(ION_HOST)) {
                // keep in WebView
                webView.loadUrl(url);
                return true;
            } else {
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse(url));
                startActivity(intent);
                return true;
            }
        }

        @Override
        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
            // if (errorCode == ERROR_TIMEOUT)
            view.stopLoading(); // may not be needed
            String html = getHtml("timeout.html");
            html = html.replaceAll("\\[url\\]", failingUrl);
            html = html.replaceAll("\\[desc\\]", description);
            view.loadData(html, "text/html", "utf-8");
        }
    });

}

From source file:com.derrick.movies.MovieDetailsActivity.java

public void setStatusBarColor(int color) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(color);
    }//w w w.j  a  v a  2s.  com
}

From source file:io.karim.materialtabs.sample.TabsActivity.java

private void applyParametersFromIntentExtras() {
    Intent intent = getIntent();/*  w  w  w.  j a v  a  2s .  c o m*/
    if (intent != null) {
        Bundle extras = intent.getExtras();
        if (extras != null) {
            Resources resources = getResources();

            int showToolbar = extras.getBoolean(TabsSettingsFragment.SHOW_TOOLBAR) ? View.VISIBLE : View.GONE;
            int indicatorColor = resources.getColor(extras.getInt(TabsSettingsFragment.INDICATOR_COLOR));
            int underlineColor = resources.getColor(extras.getInt(TabsSettingsFragment.UNDERLINE_COLOR));
            int indicatorHeightDp = extras.getInt(TabsSettingsFragment.INDICATOR_HEIGHT);
            int underlineHeightDp = extras.getInt(TabsSettingsFragment.UNDERLINE_HEIGHT);
            int tabPaddingDp = extras.getInt(TabsSettingsFragment.TAB_PADDING);

            mToolbar.setVisibility(showToolbar);

            mMaterialTabs.setIndicatorColor(indicatorColor);
            mMaterialTabs.setUnderlineColor(underlineColor);
            mMaterialTabs.setIndicatorHeight(Utils.dpToPx(resources, indicatorHeightDp));
            mMaterialTabs.setUnderlineHeight(Utils.dpToPx(resources, underlineHeightDp));
            mMaterialTabs.setTabPaddingLeftRight(Utils.dpToPx(resources, tabPaddingDp));

            boolean paddingMiddle = extras.getBoolean(TabsSettingsFragment.PADDING_MIDDLE);
            boolean sameWeightTabs = extras.getBoolean(TabsSettingsFragment.SAME_WEIGHT_TABS);
            boolean textAllCaps = extras.getBoolean(TabsSettingsFragment.TEXT_ALL_CAPS);

            mMaterialTabs.setPaddingMiddle(paddingMiddle);
            mMaterialTabs.setSameWeightTabs(sameWeightTabs);
            mMaterialTabs.setAllCaps(textAllCaps);

            int toolbarColor = resources.getColor(extras.getInt(TabsSettingsFragment.TOOLBAR_BACKGROUND));
            int tabBackgroundColor = resources.getColor(extras.getInt(TabsSettingsFragment.TAB_BACKGROUND));
            mToolbar.setBackgroundColor(toolbarColor);
            mMaterialTabs.setBackgroundColor(tabBackgroundColor);

            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(Color.argb(Color.alpha(toolbarColor), Color.red(toolbarColor) / 2,
                        Color.green(toolbarColor) / 2, Color.blue(toolbarColor) / 2));
            }

            int textColorSelected = resources.getColor(extras.getInt(TabsSettingsFragment.TEXT_COLOR_SELECTED));
            int textColorUnselected = resources
                    .getColor(extras.getInt(TabsSettingsFragment.TEXT_COLOR_UNSELECTED));
            int tabStyleSelected = extras.getInt(TabsSettingsFragment.TEXT_STYLE_SELECTED);
            int tabStyleUnselected = extras.getInt(TabsSettingsFragment.TEXT_STYLE_UNSELECTED);

            mMaterialTabs.setTextColorSelected(textColorSelected);
            mMaterialTabs.setTextColorUnselected(textColorUnselected);

            mMaterialTabs.setTabTypefaceSelectedStyle(tabStyleSelected);
            mMaterialTabs.setTabTypefaceUnselectedStyle(tabStyleUnselected);

            int rippleDuration = extras.getInt(RippleSettingsFragment.RIPPLE_DURATION);
            float rippleAlphaFloat = extras.getFloat(RippleSettingsFragment.RIPPLE_ALPHA_FLOAT);
            int rippleColor = resources.getColor(extras.getInt(RippleSettingsFragment.RIPPLE_COLOR));
            boolean rippleDelayClick = extras.getBoolean(RippleSettingsFragment.RIPPLE_DELAY_CLICK);
            float rippleDiameterDp = extras.getFloat(RippleSettingsFragment.RIPPLE_DIAMETER);
            int rippleFadeDuration = extras.getInt(RippleSettingsFragment.RIPPLE_FADE_DURATION);
            int rippleHighlightColor = resources
                    .getColor(extras.getInt(RippleSettingsFragment.RIPPLE_HIGHLIGHT_COLOR));
            boolean rippleOverlay = extras.getBoolean(RippleSettingsFragment.RIPPLE_OVERLAY);
            boolean ripplePersistent = extras.getBoolean(RippleSettingsFragment.RIPPLE_PERSISTENT);
            int rippleRoundedCornusRadiusDp = extras
                    .getInt(RippleSettingsFragment.RIPPLE_ROUNDED_CORNERS_RADIUS);

            mMaterialTabs.setRippleDuration(rippleDuration);
            mMaterialTabs.setRippleAlphaFloat(rippleAlphaFloat);
            mMaterialTabs.setRippleColor(rippleColor);
            mMaterialTabs.setRippleDelayClick(rippleDelayClick);
            mMaterialTabs.setRippleDiameterDp(rippleDiameterDp);
            mMaterialTabs.setRippleFadeDuration(rippleFadeDuration);
            mMaterialTabs.setRippleHighlightColor(rippleHighlightColor);
            mMaterialTabs.setRippleInAdapter(false);
            mMaterialTabs.setRippleOverlay(rippleOverlay);
            mMaterialTabs.setRipplePersistent(ripplePersistent);
            mMaterialTabs.setRippleRoundedCornersDp(rippleRoundedCornusRadiusDp);

            mExportableString = createExportableText(showToolbar, indicatorColor, underlineColor,
                    indicatorHeightDp, underlineHeightDp, tabPaddingDp, paddingMiddle, sameWeightTabs,
                    textAllCaps, toolbarColor, tabBackgroundColor, textColorSelected, textColorUnselected,
                    tabStyleSelected, tabStyleUnselected, rippleDuration, rippleAlphaFloat, rippleColor,
                    rippleDelayClick, rippleDiameterDp, rippleFadeDuration, rippleHighlightColor, rippleOverlay,
                    ripplePersistent, rippleRoundedCornusRadiusDp);
        }
    }
}

From source file:org.kaaproject.kaa.demo.smarthousedemo.BaseDeviceActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Window window = getWindow();
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    setContentView(R.layout.activity_device);
}

From source file:com.welcu.android.zxingfragmentlib.BarCodeScannerFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstance) {
    View view = inflater.inflate(R.layout.capture, container, false);

    Window window = getActivity().getWindow();
    window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    return view;/* ww  w  .j a va2  s.  co m*/
}