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.ozonecity.gpslogger2.GpsMainActivity.java

public void SetUpToolbar() {
    try {/*from  w w w .  j a v  a  2 s . c o m*/
        Toolbar toolbar = GetToolbar();
        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayShowTitleEnabled(false);

        //Deprecated in Lollipop but required if targeting 4.x
        SpinnerAdapter spinnerAdapter = ArrayAdapter.createFromResource(getApplicationContext(),
                R.array.gps_main_views, R.layout.spinner_dropdown_item);
        getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
        getSupportActionBar().setListNavigationCallbacks(spinnerAdapter, this);
        getSupportActionBar().setSelectedNavigationItem(GetUserSelectedNavigationItem());

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            Window window = getWindow();
            window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        }
    } catch (Exception ex) {
        //http://stackoverflow.com/questions/26657348/appcompat-v7-v21-0-0-causing-crash-on-samsung-devices-with-android-v4-2-2
        tracer.error("Thanks for this, Samsung", ex);
    }

}

From source file:org.trakhound.www.trakhound.DeviceDetails.java

private void setStatusBar() {

    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

        Window window = this.getWindow();

        // clear FLAG_TRANSLUCENT_STATUS flag:
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);

        // add FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS flag to the window
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);

        // finally change the color
        window.setStatusBarColor(this.getResources().getColor(R.color.statusbar_color));
    }//  w w w .  jav a2s.  c o  m
}

From source file:com.example.haizhu.myvoiceassistant.ui.RobotChatActivity.java

private void setStatusBarTranslate() {
    getWindow().requestFeature(Window.FEATURE_NO_TITLE);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = getWindow();
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.getDecorView().setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(Color.TRANSPARENT);
    }//from w w  w.j a  v  a2s.  co m
}

From source file:org.apache.cordova.statusbar.StatusBar.java

/**
 * Executes the request and returns PluginResult.
 *
 * @param action            The action to execute.
 * @param args              JSONArry of arguments for the plugin.
 * @param callbackContext   The callback id used when calling back into JavaScript.
 * @return                  True if the action was valid, false otherwise.
 *///from w ww  .j a  v a  2  s . co m
@Override
public boolean execute(final String action, final CordovaArgs args, final CallbackContext callbackContext)
        throws JSONException {
    Log.v(TAG, "Executing action: " + action);
    final Activity activity = this.cordova.getActivity();
    final Window window = activity.getWindow();
    if ("_ready".equals(action)) {
        boolean statusBarVisible = (window.getAttributes().flags
                & WindowManager.LayoutParams.FLAG_FULLSCREEN) == 0;
        callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, statusBarVisible));
        return true;
    }

    if ("show".equals(action)) {
        this.cordova.getActivity().runOnUiThread(new Runnable() {
            @Override
            public void run() {
                window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
            }
        });
        return true;
    }

    if ("hide".equals(action)) {
        this.cordova.getActivity().runOnUiThread(new Runnable() {
            @Override
            public void run() {
                window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
            }
        });
        return true;
    }

    if ("backgroundColorByHexString".equals(action)) {
        this.cordova.getActivity().runOnUiThread(new Runnable() {
            @Override
            public void run() {
                try {
                    setStatusBarBackgroundColor(args.getString(0));
                } catch (JSONException ignore) {
                    Log.e(TAG, "Invalid hexString argument, use f.i. '#777777'");
                }
            }
        });
        return true;
    }

    return false;
}

From source file:br.com.hotforms.StatusBarManager.java

/**
 * Executes the request and returns PluginResult.
 *
 * @param action            The action to execute.
 * @param args              JSONArry of arguments for the plugin.
 * @param callbackContext   The callback id used when calling back into JavaScript.
 * @return                  True if the action was valid, false otherwise.
 *//*from   w  w w.j a  v  a  2 s  .  com*/
@Override
public boolean execute(String action, CordovaArgs args, final CallbackContext callbackContext)
        throws JSONException {
    Log.v(TAG, "Executing action: " + action);
    final Activity activity = this.cordova.getActivity();
    final Window window = activity.getWindow();

    if ("_ready".equals(action)) {
        boolean statusBarVisible = (window.getAttributes().flags
                & WindowManager.LayoutParams.FLAG_FULLSCREEN) == 0;
        callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, statusBarVisible));
    } else if ("show".equals(action)) {
        this.cordova.getActivity().runOnUiThread(new Runnable() {
            @Override
            public void run() {
                window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
            }
        });
        return true;
    } else if ("hide".equals(action)) {
        this.cordova.getActivity().runOnUiThread(new Runnable() {
            @Override
            public void run() {
                window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

                if (currentapiVersion >= android.os.Build.VERSION_CODES.LOLLIPOP) {
                    window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
                    window.clearFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
                    window.clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
                }
            }
        });
        return true;
    } else if ("setTranslucent".equals(action)) {
        if (currentapiVersion >= android.os.Build.VERSION_CODES.KITKAT) {
            this.cordova.getActivity().runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
                    if (currentapiVersion >= android.os.Build.VERSION_CODES.LOLLIPOP) {
                        window.clearFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
                        window.clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
                    }

                    window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
                }
            });
            return true;
        } else {
            return false;
        }
    } else if ("setTransparent".equals(action)) {
        if (currentapiVersion >= android.os.Build.VERSION_CODES.LOLLIPOP) {
            this.cordova.getActivity().runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

                    window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
                    window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
                    window.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
                }
            });
            return true;
        } else {
            return false;
        }
    } else if ("setColor".equals(action)) {
        if (currentapiVersion >= android.os.Build.VERSION_CODES.LOLLIPOP) {
            this.setColor(args.getInt(0), args.getInt(1), args.getInt(2));
            return true;
        } else {
            return false;
        }
    }

    return false;
}

From source file:net.nanocosmos.bintu.demo.encoder.activities.StreamActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Window window = getWindow();
    window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_streamer);

    ViewGroup.LayoutParams param = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    surface = new StreamPreview(this);
    surface.setLayoutParams(param);/*  w  ww . j a  v  a  2 s . co m*/
    MultiSurfaceTextureListenerImpl multiSurfaceTextureListener = new MultiSurfaceTextureListenerImpl();
    multiSurfaceTextureListener.addListener(this);
    surface.setSurfaceTextureListener(multiSurfaceTextureListener);

    FrameLayout frameLayout = (FrameLayout) findViewById(R.id.surfaceFrame);
    frameLayout.addView(surface);

    isDefaultOrientationLandscape = (RotationHelper
            .getDeviceDefaultOrientation(this) == android.content.res.Configuration.ORIENTATION_LANDSCAPE);

    String[] lic_exp = Configuration.NANOSTREAM_LICENSE.split(":adr:");
    if (lic_exp.length > 1) {
        lic_exp = lic_exp[1].split(":");
        if (lic_exp.length > 1) {
            lic_exp = lic_exp[0].split(",");
            if (lic_exp.length > 1) {
                String year = lic_exp[1].substring(0, 4);
                String month = lic_exp[1].substring(4, 6);
                String day = lic_exp[1].substring(6, 8);

                Toast.makeText(getApplicationContext(), "Licence expires on: " + month + "/" + day + "/" + year,
                        Toast.LENGTH_LONG).show();
            }
        }
    }

    Intent intent = getIntent();
    serverUrl = intent.getStringExtra(Constants.KEY_SERVER_URL);
    streamName = intent.getStringExtra(Constants.KEY_STREAM_NAME);
    webPlayoutUrl = intent.getStringExtra(Constants.KEY_WEB_PLAYOUT);
    videoBitrate = intent.getIntExtra(Constants.KEY_BITRATE, videoBitrate);
    streamVideo = intent.getBooleanExtra(Constants.KEY_VIDEO_ENABLED, true);
    streamAudio = intent.getBooleanExtra(Constants.KEY_AUDIO_ENABLED, true);
    logEnabled = intent.getBooleanExtra(Constants.KEY_LOG_ENABLED, true);

    if (null == webPlayoutUrl || webPlayoutUrl.isEmpty()) {
        webPlayoutUrl = "http://www.nanocosmos.net/nanostream/live.html?id=" + serverUrl + "/" + streamName;
    }

    qualityView = (LinearLayout) findViewById(R.id.qualityView);
    outputBitrate = (TextView) findViewById(R.id.outputBitrateText);
    bufferFillness = (TextView) findViewById(R.id.bufferfillnessText);
    bitrate = (TextView) findViewById(R.id.bitrateText);
    framerate = (TextView) findViewById(R.id.framerateText);

    streamToggle = (ImageButton) findViewById(R.id.btnToogleStream);

    orientation = new CustomOrientationEventListener(this, SensorManager.SENSOR_DELAY_UI);
    orientation.enable();

    mHandler = new Handler();
    sendStreamOrientationHandler = new Handler();

}

From source file:com.tealeaf.NativeShim.java

public void setStayAwake(final boolean on) {
    final Window w = context.getWindow();

    context.runOnUiThread(new Runnable() {
        @Override/*from  www  . j a  va  2s . c o m*/
        public void run() {
            if (on) {
                w.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
            } else {
                w.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
            }
        }
    });
}

From source file:com.honglang.zxing.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);

    app = (HlApp) getApplication();//from  w w w .  j a  v a 2s .c  o  m
    title = (TextView) this.findViewById(R.id.title);
    back = (Button) this.findViewById(R.id.back);
    back.setOnClickListener(this);
    //      ok = (Button) this.findViewById(R.id.ok);
    //      ok.setText("");
    //      ok.setVisibility(View.VISIBLE);
    //      ok.setOnClickListener(this);

    linear = (LinearLayout) findViewById(R.id.out);
    jf = (LinearLayout) findViewById(R.id.jf);
    jf.setOnClickListener(this);
    pc = (LinearLayout) findViewById(R.id.pc);
    pc.setOnClickListener(this);

    qsno = (TextView) findViewById(R.id.qsno);
    jfCount = (TextView) findViewById(R.id.jfCount);
    jfRecords = (TextView) findViewById(R.id.jfRecords);
    jfCode = (TextView) findViewById(R.id.jfCode);
    pcno = (TextView) findViewById(R.id.pcno);
    pcCount = (TextView) findViewById(R.id.pcCount);
    pcRecords = (TextView) findViewById(R.id.pcRecords);
    pcCode = (TextView) findViewById(R.id.pcCode);
    count = (TextView) findViewById(R.id.count);
    record = (TextView) findViewById(R.id.record);
    sure = (Button) findViewById(R.id.sure);
    sure.setOnClickListener(this);

    soundPool = new SoundPool(4, AudioManager.STREAM_SYSTEM, 5);
    soundPool.load(this, R.raw.success, 1);
    soundPool.load(this, R.raw.done, 1);
    soundPool.load(this, R.raw.both, 1);
    soundPool.load(this, R.raw.failed, 1);

    TYPE = this.getIntent().getExtras().getInt("QRTYPE");
    switch (TYPE) {
    case 0:
        title.setText("???");
        break;
    case 1:
        title.setText("???");
        break;
    case 2:
        title.setText("????");
        break;
    case 3:
        title.setText("????");
        break;
    case 4:
        title.setText("??");
        break;
    case 5:
        title.setText("???");
        break;
    case 6:
        title.setText("");
        linear.setVisibility(View.VISIBLE);
        new NewTask().execute((Void) null);
        break;
    }

    hasSurface = false;
    historyManager = new HistoryManager(this);
    historyManager.trimHistory();
    inactivityTimer = new InactivityTimer(this);
    beepManager = new BeepManager(this);
    ambientLightManager = new AmbientLightManager(this);

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

From source file:com.sentaroh.android.TaskAutomation.ActivityTaskStatus.java

private void showMainDialog(String action) {

    // common ??/*w w w  .  j av  a  2  s  .  c o  m*/
    mainDialog = new Dialog(context);
    mainDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    mainDialog.setContentView(R.layout.task_status_dlg);

    if (util.isKeyguardEffective()) {
        Window win = mainDialog.getWindow();
        win.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER
                | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
                //            WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD |
                WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
    }
    ;

    TextView title = (TextView) mainDialog.findViewById(R.id.task_status_dlg_title);
    title.setText(getString(R.string.msgs_status_dialog_title));
    setSchedulerStatus();
    historyListView = (ListView) mainDialog.findViewById(R.id.task_status_dlg_history_listview);
    statusListView = (ListView) mainDialog.findViewById(R.id.task_status_dlg_status_listview);

    historyAdapter = new AdapterTaskStatusHistoryList(this, R.layout.task_history_list_item,
            getTaskHistoryList());
    historyListView.setAdapter(historyAdapter);
    historyListView.setSelection(historyAdapter.getCount() - 1);
    historyListView.setEnabled(true);
    historyListView.setSelected(true);
    setTaskListLongClickListener();

    statusAdapter = new AdapterTaskStatusActiveList(this, R.layout.task_status_list_item, getActiveTaskList(1));
    statusListView.setAdapter(statusAdapter);
    statusListView.setSelection(statusAdapter.getCount() - 1);
    statusListView.setEnabled(true);
    statusListView.setSelected(true);

    setCancelBtnListener();

    final Button btnStatus = (Button) mainDialog.findViewById(R.id.task_status_dlg_status_btn);
    final Button btnHistory = (Button) mainDialog.findViewById(R.id.task_status_dlg_history_btn);

    final CheckBox cb_enable_scheduler = (CheckBox) mainDialog
            .findViewById(R.id.task_status_dlg_status_enable_scheduler);

    final Button btnLog = (Button) mainDialog.findViewById(R.id.task_status_dlg_log_btn);
    final Button btnClose = (Button) mainDialog.findViewById(R.id.task_status_dlg_close_btn);

    CommonDialog.setDlgBoxSizeLimit(mainDialog, true);
    //      mainDialog.setOnKeyListener(new DialogOnKeyListener(context));

    cb_enable_scheduler.setChecked(envParms.settingEnableScheduler);
    cb_enable_scheduler.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        private boolean ignoreEvent = false;

        @Override
        public void onCheckedChanged(CompoundButton arg0, final boolean isChecked) {
            if (ignoreEvent) {
                ignoreEvent = false;
                return;
            }
            NotifyEvent ntfy = new NotifyEvent(null);
            ntfy.setListener(new NotifyEventListener() {
                @Override
                public void positiveResponse(Context c, Object[] o) {
                    envParms.setSettingEnableScheduler(context, isChecked);
                    try {
                        svcServer.aidlCancelAllActiveTask();
                        svcServer.aidlResetScheduler();
                    } catch (RemoteException e) {
                        e.printStackTrace();
                    }
                    setSchedulerStatus();
                }

                @Override
                public void negativeResponse(Context c, Object[] o) {
                    ignoreEvent = true;
                    cb_enable_scheduler.setChecked(!isChecked);
                }
            });
            String msg = "";
            if (!isChecked)
                msg = context.getString(R.string.msgs_status_dialog_enable_scheduler_confirm_msg_disable);
            else
                msg = context.getString(R.string.msgs_status_dialog_enable_scheduler_confirm_msg_enable);
            CommonDialog cd = new CommonDialog(context, getSupportFragmentManager());
            cd.showCommonDialog(true, "W", "", msg, ntfy);
        }
    });

    btnStatus.setBackgroundResource(R.drawable.button_back_ground_color_selector);
    btnHistory.setBackgroundResource(R.drawable.button_back_ground_color_selector);

    if (action.equals("History")) {
        statusListView.setVisibility(ListView.GONE);
        historyListView.setVisibility(ListView.VISIBLE);
        btnStatus.setTextColor(Color.DKGRAY);
        btnHistory.setTextColor(Color.GREEN);
        btnHistory.setClickable(false);
    } else {
        statusListView.setVisibility(ListView.VISIBLE);
        historyListView.setVisibility(ListView.GONE);
        btnStatus.setTextColor(Color.GREEN);
        btnHistory.setTextColor(Color.DKGRAY);
        btnStatus.setClickable(false);
    }

    btnStatus.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            statusListView.setVisibility(ListView.VISIBLE);
            historyListView.setVisibility(ListView.GONE);
            btnStatus.setTextColor(Color.GREEN);
            btnHistory.setTextColor(Color.DKGRAY);
            btnStatus.setClickable(false);
            btnHistory.setClickable(true);
            setSchedulerStatus();
        }
    });

    btnHistory.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            statusListView.setVisibility(ListView.GONE);
            historyListView.setVisibility(ListView.VISIBLE);
            btnStatus.setTextColor(Color.DKGRAY);
            btnHistory.setTextColor(Color.GREEN);
            btnStatus.setClickable(true);
            btnHistory.setClickable(false);
            setSchedulerStatus();
        }
    });

    if (util.isLogFileExists())
        btnLog.setEnabled(true);
    else
        btnLog.setEnabled(false);
    btnLog.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            util.resetLogReceiver();
            Intent intent = new Intent();
            intent = new Intent(android.content.Intent.ACTION_VIEW);
            intent.setDataAndType(Uri.parse("file://" + util.getLogFilePath()), "text/plain");
            startActivity(intent);
            setSchedulerStatus();
        }
    });

    // Close?
    btnClose.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            mainDialog.dismiss();
            //            commonDlg.setFixedOrientation(false);
        }
    });
    mainDialog.setOnDismissListener(new OnDismissListener() {
        @Override
        public void onDismiss(DialogInterface arg0) {
            finish();
        }
    });
    // Cancel?
    mainDialog.setOnCancelListener(new Dialog.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface arg0) {
            btnClose.performClick();
        }
    });
    //      commonDlg.setFixedOrientation(true);
    mainDialog.setCancelable(true);
    mainDialog.show();

}