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.agiro.scanner.android.CaptureActivity.java

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    Log.d(TAG, "onCreate");

    Window window = getWindow();
    window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    setContentView(R.layout.capture);//from  w w  w .  j a  v  a2  s .  c om

    this.eraseButton = (Button) this.findViewById(R.id.erase);
    this.eraseButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            reference = null;
            amount = null;
            account = null;
            debug = null;
            populateList(reference, amount, account, debug);
            onContentChanged();
        }
    });

    this.sendButton = (Button) this.findViewById(R.id.send);
    this.sendButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
        }
    });

    this.scanButton = (Button) this.findViewById(R.id.scan);
    this.scanButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            handler.sendEmptyMessage(R.id.restart_preview);
        }
    });

    SimpleAdapter adapter = new SimpleAdapter(this, list, R.layout.result_list_item,
            new String[] { "data_type", "data" }, new int[] { R.id.data_type, R.id.data });
    populateList(reference, amount, account, debug);
    setListAdapter(adapter);

    CameraManager.init(getApplication());
    viewfinderView = (ViewfinderView) findViewById(R.id.viewfinder_view);
    handler = null;
    hasSurface = false;
    //    inactivityTimer = new InactivityTimer(this);
}

From source file:com.jun.elephant.ui.user.info.UserInfoActivity.java

@Override
public void initView() {
    setToolbar(mToolBar, "");

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = getWindow();
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(Color.TRANSPARENT);
    }//from   ww  w . j a va  2  s.  c o m

    mToolBar.inflateMenu(R.menu.menu_user_info);
    alphaView(mPageTitleTv, 200, 4);

    mAppBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
        @Override
        public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
            float f = ((float) Math.abs(verticalOffset)) / (float) (mAppBarLayout.getTotalScrollRange());

            appBarScrollChange(f);
        }
    });

}

From source file:com.apptentive.android.sdk.ViewActivity.java

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

    try {/* www  .  java 2 s .co  m*/
        requestWindowFeature(Window.FEATURE_NO_TITLE);

        String activityContentTypeString = getIntent().getStringExtra(ActivityContent.KEY);
        String parseStringExtra = getIntent().getStringExtra("com.parse.Data");

        if (activityContentTypeString != null) {
            Log.v("Started ViewActivity normally for %s.", activityContent);
            activeContentType = ActivityContent.Type.parse(activityContentTypeString);

            try {
                switch (activeContentType) {
                case ABOUT:
                    break;
                case MESSAGE_CENTER:
                    break;
                case INTERACTION:
                    String interactionString = getIntent().getExtras().getCharSequence(Interaction.KEY_NAME)
                            .toString();
                    Interaction interaction = Interaction.Factory.parseInteraction(interactionString);
                    switch (interaction.getType()) {
                    case UpgradeMessage:
                        activityContent = new UpgradeMessageInteractionView(
                                (UpgradeMessageInteraction) interaction);
                        break;
                    case EnjoymentDialog:
                        activityContent = new EnjoymentDialogInteractionView(
                                (EnjoymentDialogInteraction) interaction);
                        break;
                    case RatingDialog:
                        activityContent = new RatingDialogInteractionView(
                                (RatingDialogInteraction) interaction);
                        break;
                    case AppStoreRating:
                        activityContent = new AppStoreRatingInteractionView(
                                (AppStoreRatingInteraction) interaction);
                        break;
                    case FeedbackDialog:
                        activityContent = new FeedbackDialogInteractionView(
                                (FeedbackDialogInteraction) interaction);
                        break;
                    case Survey:
                        activityContent = new SurveyInteractionView((SurveyInteraction) interaction);
                        break;
                    case MessageCenter:
                        // For now, we use the old method.
                        getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
                        finish();
                        Apptentive.showMessageCenter(this);
                        return;
                    case TextModal:
                        activityContent = new TextModalInteractionView((TextModalInteraction) interaction);
                        break;
                    case NavigateToLink:
                        activityContent = new NavigateToLinkInteractionView(
                                (NavigateToLinkInteraction) interaction);
                        break;
                    default:
                        break;
                    }
                    if (activityContent == null) {
                        finish();
                    } else {
                        activityContent.onCreate(this, savedInstanceState);
                    }
                    break;
                default:
                    Log.w("No Activity specified. Finishing...");
                    finish();
                    break;
                }
            } catch (Exception e) {
                Log.e("Error starting ViewActivity.", e);
                MetricModule.sendError(this, e, null, null);
            }
        } else
        // If no content was sent to this Activity, then it may have been started from a Parse push notification.
        if (parseStringExtra != null) {
            Log.i("Started ViewActivity from Parse push.");

            // Save off the callback Activity if one was passed in.
            pushCallbackActivityName = ApptentiveInternal.getPushCallbackActivityName();

            // If the callback is null and we got here, then the developer forgot to set it.
            if (pushCallbackActivityName != null) {
                returnToPushCallbackActivity = true;
                JSONObject parseJson = new JSONObject(parseStringExtra);
                String apptentiveStringData = parseJson.optString(Apptentive.APPTENTIVE_PUSH_EXTRA_KEY);
                JSONObject apptentiveJson = new JSONObject(apptentiveStringData);
                ApptentiveInternal.PushAction action = ApptentiveInternal.PushAction
                        .parse(apptentiveJson.getString(ApptentiveInternal.PUSH_ACTION));
                switch (action) {
                case pmc:
                    activeContentType = ActivityContent.Type.MESSAGE_CENTER;
                    break;
                default:
                    break;
                }
            } else {
                Log.a("Push callback Activity was not set. Make sure to call Apptentive.setPushCallback()");
                if (GlobalInfo.isAppDebuggable) {
                    Toast.makeText(this,
                            "Push callback Activity was not set. Make sure to call Apptentive.setPushCallback()",
                            Toast.LENGTH_LONG).show();
                }
                finish();
            }
        } else {
            Log.e("Started ViewActivity in a bad way.");
        }
    } catch (Exception e) {
        Log.e("Error creating ViewActivity.", e);
        MetricModule.sendError(this, e, null, null);
    }
    if (activeContentType == null) {
        finish();
    }
    Window window = getWindow();
    window.setFormat(PixelFormat.RGBA_8888);
    window.addFlags(WindowManager.LayoutParams.FLAG_DITHER);
}

From source file:tw.jwzhuang.ipcamviewer.devices.CaptureActivity.java

@Override
public void onCreate(Bundle icicle) {
    MyApplication.getInstance().addActivity(CaptureActivity.this);
    super.onCreate(icicle);
    setContentView(R.layout.scan);/*from  www  . ja va 2  s  .c  o  m*/
    Window window = getWindow();
    window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    hasSurface = false;
    inactivityTimer = new InactivityTimer(this);

}

From source file:com.amsterdam.marktbureau.makkelijkemarkt.MainActivity.java

/**
 * Set the activity layout and add a fragment to the container
 * @param savedInstanceState activity state bundle
 *//*from   www  .ja v  a 2s .co  m*/
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // set the used layout
    setContentView(R.layout.main_activity);

    // bind the elements to the view
    ButterKnife.bind(this);

    // setup a toolbar as supportactionbar
    setSupportActionBar(mToolbar);
    if (getSupportActionBar() != null) {
        getSupportActionBar().setDisplayShowTitleEnabled(false);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);

        // set the title texview
        mToolbarTitle.setText(R.string.login);

        // set the statusbar sransparency
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            Window w = getWindow();
            w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
                    WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            w.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
        }

        // hide the toolbar
        mToolbar.setVisibility(View.GONE);
    }

    // load accounts and add mainfragment, not on rotate
    if (savedInstanceState == null) {

        // create a mainfragment and add it to the framelayout container
        mMainFragment = new MainFragment();
        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
        transaction.add(R.id.container, mMainFragment, MAIN_FRAGMENT_TAG);
        transaction.commit();
    } else {

        // re-use existing instance of main fragment
        mMainFragment = (MainFragment) getSupportFragmentManager().findFragmentByTag(MAIN_FRAGMENT_TAG);
    }
}

From source file:jp.co.tweetmap.MainActivity.java

/**
 * Set status bar color as tool bar./*  www . jav  a  2 s.  co m*/
 */
protected void setStatusBar() {
    // Set status bar color if the SDK version Lollipop more
    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.statusbar_background));
    }
}

From source file:com.github.michaelins.lightstatusbar.LightStatusBar.java

private void setStatusBarBackgroundColor(final String colorPref) {
    if (colorPref != null && !colorPref.isEmpty()) {
        final Window window = cordova.getActivity().getWindow();
        // Method and constants not available on all SDKs but we want to
        // be able to compile this code with any SDK
        window.clearFlags(0x04000000); // SDK 19:
        // WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.addFlags(0x80000000); // SDK 21:
        // WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        try {//from   w  ww.j a  v  a2 s .  c o m
            // Using reflection makes sure any 5.0+ device will work
            // without having to compile with SDK level 21
            window.getClass().getDeclaredMethod("setStatusBarColor", int.class).invoke(window,
                    Color.parseColor(colorPref));
        } catch (IllegalArgumentException ignore) {
            LOG.e(TAG, "Invalid hexString argument, use f.i. '#999999'");
        } catch (Exception ignore) {
            // this should not happen, only in case Android removes this
            // method in a version > 21
            LOG.w(TAG, "Method window.setStatusBarColor not found for SDK level " + Build.VERSION.SDK_INT);
        }
    }
}

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

private void setStatusBarColor(int mode) {
    if (mode == 0) {
        Window window = getWindow();
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(getColor(R.color.intro_status_bar));
    } else {/*  w ww  .  j  ava2s.c o  m*/
        Window window = getWindow();
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(getColor(R.color.warning_status_bar));
    }
}

From source file:com.gmartinsribeiro.qrcodereader.BarcodeCaptureActivity.java

/**
 * Initializes the UI and creates the detector pipeline.
 *//*from  w w  w  . j  a v a2 s . c om*/
@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.barcode_capture);

    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(mToolbar);

    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(getResources().getColor(R.color.blue700));
    }

    mPreview = (CameraSourcePreview) findViewById(R.id.preview);
    mGraphicOverlay = (GraphicOverlay<BarcodeGraphic>) findViewById(R.id.graphicOverlay);

    // read parameters from the intent used to launch the activity.
    boolean autoFocus = getIntent().getBooleanExtra(AutoFocus, false);
    boolean useFlash = getIntent().getBooleanExtra(UseFlash, false);

    // Check for the camera permission before accessing the camera.  If the
    // permission is not granted yet, request permission.
    int rc = ActivityCompat.checkSelfPermission(this, Manifest.permission.CAMERA);
    if (rc == PackageManager.PERMISSION_GRANTED) {
        createCameraSource(autoFocus, useFlash);
    } else {
        requestCameraPermission();
    }

    gestureDetector = new GestureDetector(this, new CaptureGestureListener());
    scaleGestureDetector = new ScaleGestureDetector(this, new ScaleListener());

    Snackbar.make(mGraphicOverlay, "Pinch/Stretch to zoom", Snackbar.LENGTH_LONG).show();
}

From source file:no.digipost.android.gui.metadata.ExternalLinkWebview.java

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ((DigipostApplication) getApplication()).getTracker(DigipostApplication.TrackerName.APP_TRACKER);
    setContentView(R.layout.activity_externallink_webview);
    Bundle bundle = getIntent().getExtras();
    fileUrl = bundle.getString("url", "https://www.digipost.no");

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);/*from  w w  w  .j  av  a  2 s .  co m*/
    actionBar = getSupportActionBar();
    if (actionBar != null) {
        setActionBarTitle(fileUrl);
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setBackgroundDrawable(new ColorDrawable(0xff2E2E2E));

        if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            Window window = this.getWindow();
            window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            window.setStatusBarColor(
                    ContextCompat.getColor(this, R.color.metadata_externalbrowser_top_background));
        }
    }

    progressSpinner = (ProgressBar) findViewById(R.id.externallink_spinner);
    webView = (WebView) findViewById(R.id.externallink_webview);
    WebSettings settings = webView.getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
    settings.setDomStorageEnabled(true);
    settings.setLoadWithOverviewMode(true);
    settings.setUseWideViewPort(true);
    settings.setSupportZoom(true);
    settings.setBuiltInZoomControls(true);
    settings.setDisplayZoomControls(false);
    settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
    webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
    webView.setScrollbarFadingEnabled(true);
    enableCookies(webView);
    webView.setWebViewClient(new WebViewClient() {

        @Override
        public void onPageFinished(WebView view, String url) {
            super.onPageFinished(view, url);
            if (firstLoad) {
                progressSpinner.setVisibility(View.GONE);
                webView.setVisibility(View.VISIBLE);
                firstLoad = false;
            }
            setActionBarTitle(view.getUrl());
        }
    });

    webView.setDownloadListener(new DownloadListener() {
        @Override
        public void onDownloadStart(final String url, final String userAgent, final String content,
                final String mimeType, final long contentLength) {
            fileName = URLUtil.guessFileName(url, content, mimeType);
            fileUrl = url;
            onComplete = new BroadcastReceiver() {
                @Override
                public void onReceive(Context context, Intent intent) {
                    String action = intent.getAction();
                    if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(action)) {
                        showDownloadSuccessDialog(context);
                    }
                }
            };

            registerReceiver(onComplete, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
            if (!mimeType.equals("text/html")) {
                if (FileUtilities.isStorageWriteAllowed(getApplicationContext())) {
                    showDownloadDialog(userAgent, content, mimeType, contentLength);
                } else {
                    showMissingPermissionsDialog();
                }
            }
        }
    });

    if (FileUtilities.isStorageWriteAllowed(this)) {
        webView.loadUrl(fileUrl);
    } else {
        showPermissionsDialog();
    }
}