Example usage for android.view Window clearFlags

List of usage examples for android.view Window clearFlags

Introduction

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

Prototype

public void clearFlags(int flags) 

Source Link

Document

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

Usage

From source file:com.quaap.audiometer.MainActivity.java

public void stopit() {
    if (mMicLevelReader.isRunning()) {
        mMicLevelReader.stop();/*from  w w  w  .  j a v  a2s  .  co  m*/
        Window w = this.getWindow();
        w.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        try {
            mRecorderThread.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
    mMeterView.setMeterBars(0);

}

From source file:com.igniva.filemanager.activities.Preferences.java

@Override
public void onCreate(Bundle savedInstanceState) {
    SharedPreferences Sp = PreferenceManager.getDefaultSharedPreferences(this);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.prefsfrag);/*from  w  w w .  ja v a 2s .c  om*/
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    if (Build.VERSION.SDK_INT >= 21) {
        ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription("Filemanager",
                ((BitmapDrawable) getResources().getDrawable(R.mipmap.ic_launcher)).getBitmap(),
                Color.parseColor(MainActivity.currentTab == 1 ? skinTwo : skin));
        setTaskDescription(taskDescription);
    }
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayOptions(android.support.v7.app.ActionBar.DISPLAY_HOME_AS_UP
            | android.support.v7.app.ActionBar.DISPLAY_SHOW_TITLE);
    getSupportActionBar().setBackgroundDrawable(
            new ColorDrawable(Color.parseColor(MainActivity.currentTab == 1 ? skinTwo : skin)));
    int sdk = Build.VERSION.SDK_INT;

    if (sdk == 20 || sdk == 19) {
        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setStatusBarTintColor(Color.parseColor(MainActivity.currentTab == 1 ? skinTwo : skin));

        FrameLayout.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) findViewById(R.id.preferences)
                .getLayoutParams();
        SystemBarTintManager.SystemBarConfig config = tintManager.getConfig();
        p.setMargins(0, config.getStatusBarHeight(), 0, 0);
    } else if (Build.VERSION.SDK_INT >= 21) {
        boolean colourednavigation = Sp.getBoolean("colorednavigation", true);
        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.setStatusBarColor(
                (PreferenceUtils.getStatusColor(MainActivity.currentTab == 1 ? skinTwo : skin)));
        if (colourednavigation)
            window.setNavigationBarColor(
                    (PreferenceUtils.getStatusColor(MainActivity.currentTab == 1 ? skinTwo : skin)));

    }
    selectItem(0);
}

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 {// www .  j a  va 2  s .com
            // 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:org.arshad.nimbleme.WritingActivity.java

@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override//ww  w.  ja v  a 2s .  co m
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_writing);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitle("");
    setSupportActionBar(toolbar);

    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.status_bar_color));

    mdToolbar = (ExpandableLinearLayout) findViewById(R.id.action_other_operate);

    mdEditor = (ExpandableLinearLayout) findViewById(R.id.md_editor_container);
    mdEditor.setVisibility(View.VISIBLE);
    mdEditor.expand();

    mdPreview = (ExpandableLinearLayout) findViewById(R.id.md_preview_container);
    mdPreview.setVisibility(View.GONE);

    mMdEditText = (EditText) findViewById(R.id.post_description_editText);

    mMarkdownView = (MarkdownPreviewView) findViewById(R.id.markdownView);

    mTabIconView = (TabIconView) findViewById(R.id.tabIconView);

    mPerformEdit = new PerformEdit(mMdEditText);
    mPerformEditable = new PerformEditable(mMdEditText);

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar,
            R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    MarkdownUtils.newInstance().initTab(mTabIconView, this);

}

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

public void releaseCpuLock() {
    Log.e(TAG, "Releasing cpu wake lock");

    if (mCpuWakeLock != null) {
        mCpuWakeLock.release();/*from  w  w w.j a v  a 2  s.  c  om*/
        mCpuWakeLock = null;
    }
    Window wind = this.getWindow();
    if ((mDefaultWindowFlags & WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD) != 0) {
        wind.clearFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
    }
    if ((mDefaultWindowFlags & WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED) != 0) {
        wind.clearFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
    }
    if ((mDefaultWindowFlags & WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON) != 0) {
        wind.clearFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
    }
}

From source file:com.amaze.carbonfilemanager.activities.PreferencesActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    SharedPreferences Sp = PreferenceManager.getDefaultSharedPreferences(this);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.prefsfrag);/*from   w w w .j  a  va2 s.  c om*/
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    if (SDK_INT >= 21) {
        ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription("Amaze",
                ((BitmapDrawable) getResources().getDrawable(R.mipmap.ic_launcher)).getBitmap(),
                getColorPreference().getColor(ColorUsage.getPrimary(MainActivity.currentTab)));
        setTaskDescription(taskDescription);
    }
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayOptions(android.support.v7.app.ActionBar.DISPLAY_HOME_AS_UP
            | android.support.v7.app.ActionBar.DISPLAY_SHOW_TITLE);
    getSupportActionBar().setBackgroundDrawable(
            getColorPreference().getDrawable(ColorUsage.getPrimary(MainActivity.currentTab)));

    if (SDK_INT == 20 || SDK_INT == 19) {
        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setStatusBarTintColor(
                getColorPreference().getColor(ColorUsage.getPrimary(MainActivity.currentTab)));

        FrameLayout.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) findViewById(R.id.preferences)
                .getLayoutParams();
        SystemBarTintManager.SystemBarConfig config = tintManager.getConfig();
        p.setMargins(0, config.getStatusBarHeight(), 0, 0);
    } else if (SDK_INT >= 21) {
        boolean colourednavigation = Sp.getBoolean("colorednavigation", true);
        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.setStatusBarColor(PreferenceUtils.getStatusColor(
                getColorPreference().getColorAsString(ColorUsage.getPrimary(MainActivity.currentTab))));
        if (colourednavigation)
            window.setNavigationBarColor(PreferenceUtils.getStatusColor(
                    getColorPreference().getColorAsString(ColorUsage.getPrimary(MainActivity.currentTab))));

    }
    if (savedInstanceState != null) {
        selectedItem = savedInstanceState.getInt(KEY_CURRENT_FRAG_OPEN, 0);
    }
    selectItem(selectedItem);
}

From source file:com.amaze.carbonfilemanager.activities.DbViewer.java

@Override
public void onCreate(Bundle savedInstanceState) {
    this.checkStorage = false;
    super.onCreate(savedInstanceState);

    if (getAppTheme().equals(AppTheme.DARK)) {
        setTheme(R.style.appCompatDark);
        getWindow().getDecorView().setBackgroundColor(Utils.getColor(this, R.color.holo_dark_background));
    }//ww w .  j av  a2s.c  om
    setContentView(R.layout.activity_db_viewer);
    toolbar = (android.support.v7.widget.Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    if (SDK_INT >= 21) {
        ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription("Amaze",
                ((BitmapDrawable) ContextCompat.getDrawable(this, R.mipmap.ic_launcher)).getBitmap(),
                getColorPreference().getColor(ColorUsage.getPrimary(MainActivity.currentTab)));
        setTaskDescription(taskDescription);
    }
    getSupportActionBar().setBackgroundDrawable(
            getColorPreference().getDrawable(ColorUsage.getPrimary(MainActivity.currentTab)));
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    if (SDK_INT == 20 || SDK_INT == 19) {
        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setStatusBarTintColor(
                getColorPreference().getColor(ColorUsage.getPrimary(MainActivity.currentTab)));
        FrameLayout.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) findViewById(R.id.parentdb)
                .getLayoutParams();
        SystemBarTintManager.SystemBarConfig config = tintManager.getConfig();
        p.setMargins(0, config.getStatusBarHeight(), 0, 0);
    } else if (SDK_INT >= 21) {
        boolean colourednavigation = sharedPref.getBoolean("colorednavigation", true);
        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.setStatusBarColor(PreferenceUtils.getStatusColor(
                getColorPreference().getColorAsString(ColorUsage.getPrimary(MainActivity.currentTab))));
        if (colourednavigation)
            window.setNavigationBarColor(PreferenceUtils.getStatusColor(
                    getColorPreference().getColorAsString(ColorUsage.getPrimary(MainActivity.currentTab))));

    }

    path = getIntent().getStringExtra("path");
    pathFile = new File(path);
    listView = (ListView) findViewById(R.id.listView);

    load(pathFile);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
            DbViewerFragment fragment = new DbViewerFragment();
            Bundle bundle = new Bundle();
            bundle.putString("table", arrayList.get(position));
            fragment.setArguments(bundle);
            fragmentTransaction.add(R.id.content_frame, fragment);
            fragmentTransaction.addToBackStack(null);
            fragmentTransaction.commit();
        }
    });

}

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  ava2  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.filemanager.free.activities.DbViewer.java

@Override
public void onCreate(Bundle savedInstanceState) {
    this.checkStorage = false;
    super.onCreate(savedInstanceState);

    if (theme1 == 1) {
        setTheme(R.style.appCompatDark);
        getWindow().getDecorView()//ww  w .  j  a  v  a 2  s  .  c o m
                .setBackgroundColor(ContextCompat.getColor(getBaseContext(), R.color.holo_dark_background));
    }
    setContentView(R.layout.activity_db_viewer);
    toolbar = (android.support.v7.widget.Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    skin = PreferenceUtils.getPrimaryColorString(Sp);
    if (Build.VERSION.SDK_INT >= 21) {
        ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription("File Manager",
                ((BitmapDrawable) ContextCompat.getDrawable(this, R.mipmap.ic_launcher)).getBitmap(),
                Color.parseColor(skin));
        ((Activity) this).setTaskDescription(taskDescription);
    }
    skinStatusBar = PreferenceUtils.getStatusColor(skin);
    assert (getSupportActionBar()) != null;
    getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor(skin)));
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    if (Build.VERSION.SDK_INT == 20 || Build.VERSION.SDK_INT == 19) {
        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setStatusBarTintColor(Color.parseColor(skin));
        FrameLayout.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) findViewById(R.id.parentdb)
                .getLayoutParams();
        SystemBarTintManager.SystemBarConfig config = tintManager.getConfig();
        p.setMargins(0, config.getStatusBarHeight(), 0, 0);
    } else if (Build.VERSION.SDK_INT >= 21) {
        boolean colourednavigation = Sp.getBoolean("colorednavigation", true);
        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.setStatusBarColor((PreferenceUtils.getStatusColor(skin)));
        if (colourednavigation)
            window.setNavigationBarColor((PreferenceUtils.getStatusColor(skin)));

    }

    String path = getIntent().getStringExtra("path");
    pathFile = new File(path);
    listView = (ListView) findViewById(R.id.listView);

    load(pathFile);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
            DbViewerFragment fragment = new DbViewerFragment();
            Bundle bundle = new Bundle();
            bundle.putString("table", arrayList.get(position));
            fragment.setArguments(bundle);
            fragmentTransaction.add(R.id.content_frame, fragment);
            fragmentTransaction.addToBackStack(null);
            fragmentTransaction.commit();
        }
    });

}

From source file:com.mech.tech.meet.activities.scenario.MainActivity.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override//from  w w w .ja v a 2s .  c  om
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    int currentapiVersion = android.os.Build.VERSION.SDK_INT;
    if (currentapiVersion >= 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.material_wala_deep_blue));
    }

    Calendar cal = Calendar.getInstance();
    cal.add(Calendar.SECOND, 10);

    Intent intent = new Intent(this, MyNotificationService.class);
    PendingIntent pintent = PendingIntent.getService(this, 0, intent, 0);
    AlarmManager alarm = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
    alarm.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), 36000 * 1000 * 2, pintent);

    startService(new Intent(getBaseContext(), MyNotificationService.class));

    mNavigationDrawerFragment = (NavigationDrawerFragment) getSupportFragmentManager()
            .findFragmentById(R.id.navigation_drawer);
    mTitle = getTitle();

    // Set up the drawer.
    mNavigationDrawerFragment.setUp(R.id.navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout));
}