Example usage for android.view Window setStatusBarColor

List of usage examples for android.view Window setStatusBarColor

Introduction

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

Prototype

public abstract void setStatusBarColor(@ColorInt int color);

Source Link

Document

Sets the color of the status bar to color .

Usage

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 w w. j av 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.granita.tasks.TaskListActivity.java

@SuppressLint("NewApi")
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
@Override//  w  ww .  j  av a 2  s .com
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());
    //custom start

    Tracker t = ((com.granita.tasks.Tasks) getApplication())
            .getTracker(com.granita.tasks.Tasks.TrackerName.APP_TRACKER);
    t.setScreenName("Tasks: List activity");
    t.send(new HitBuilders.AppViewBuilder().build());

    //check if sync for icloud calendar exists
    String packageName = "com.granita.caldavsync";
    Intent intent = this.getPackageManager().getLaunchIntentForPackage(packageName);
    if (intent == null) {
        /* bring user to the market or let them choose an app? */
        intent = new Intent(this, installicloud.class);
        startActivity(intent);
    }

    try {

        //Start premium features
        String base64EncodedPublicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvczcgR9FJqJ/LK94t4VcmdfVizoy66QWJRxF+o0ZZbFeMi1jQ6kBcYb1kogQnLLBeS+Q0DtRjsxap9Z6B8yP5rcZxIs51yF2LKy9+nmcLeJF0wPU2cvIjZLf7dD7Umh/LMi88VHSLExwkDMb2vBpcROz7DwjhgF5fzXHWh986ZxWmJiMiYLX1cg5toWaOPYgxcSELyCsfkvfmtX8ctJ+QcovWXevSBJsOQCLNkmKdBd5biExy96WicjVUZ/e31/CCjb8xYcMJnMaBGXEBDdtJFMFAczpdrB+Zyw6gEr1ZUH1U7trsbTrC2TvOa1MTcwXHE2JwqjU2eke4FLYIcAdbwIDAQAB";
        mHelper = new IabHelper(this, base64EncodedPublicKey);

        mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
            public void onIabSetupFinished(IabResult result) {
                if (!result.isSuccess()) {
                    Log.d(TAG, "In-app Billing setup failed: " + result);
                } else {
                    mHelper.queryInventoryAsync(mGotInventoryListener);
                    Log.d(TAG, "In-app Billing is set up OK");
                }
            }
        });

        //End premium features
    } catch (Exception e) {

    }
    //custom end

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

    //custom start
    mAuthority = getString(R.string.org_dmfs_tasks_authority);
    //custom end
    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:esolz.connexstudent.apprtc.ConnectActivity.java

public void permissionChk() {
    if (ActivityCompat.checkSelfPermission(this,
            Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED
            || ActivityCompat.checkSelfPermission(this,
                    Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED
            || ActivityCompat.checkSelfPermission(this,
                    Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED
            || ActivityCompat.checkSelfPermission(this,
                    Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED
            || ActivityCompat.checkSelfPermission(this,
                    Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
        // TODO: Consider calling
        if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.READ_EXTERNAL_STORAGE)
                && ActivityCompat.shouldShowRequestPermissionRationale(this,
                        Manifest.permission.WRITE_EXTERNAL_STORAGE)
                && ActivityCompat.shouldShowRequestPermissionRationale(this,
                        Manifest.permission.MODIFY_AUDIO_SETTINGS)
                && ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.RECORD_AUDIO)
                && ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.CAMERA)) {
            ActivityCompat.requestPermissions(this,
                    new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE,
                            Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.CAMERA,
                            Manifest.permission.MODIFY_AUDIO_SETTINGS, Manifest.permission.RECORD_AUDIO },
                    MY_PERMISSIONS_REQUEST_READ_CONTACTS);
        } else {//  w w  w  .  j a va  2  s . c  o m
            // No explanation needed, we can request the permission.
            ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE,
                    Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.MODIFY_AUDIO_SETTINGS,
                    Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO },
                    MY_PERMISSIONS_REQUEST_READ_CONTACTS);
        }
        return;
    } else {
        if (getIntent().getAction().equals(ACTION_APP)) {
            RECEIVER_ID = getIntent().getStringExtra("RECEIVER_ID");
            pushHelperDhoperUrl();
        } else {
            //                Intent i = new Intent(getApplicationContext(), RingToneService.class);
            //                i.setAction(RingToneService.ACTION_START);
            //                startService(i);

            OPONENT_ID = getIntent().getStringExtra("OPONENT_ID");

            threadmanager.postDelayed(callRejectionThred, 15000);

            findViewById(R.id.notifoicatio).setVisibility(View.VISIBLE);
            PROFILE_IMAGE = cDB.getUserImage(getIntent().getStringExtra("PHONE"));
            Picasso.with(getApplicationContext()).load(PROFILE_IMAGE).fit().centerCrop()
                    .into((ImageView) findViewById(R.id.dialer_bg));

            ((AvenirRoman) findViewById(R.id.caller_name))
                    .setText(getIntent().getStringExtra("CALLER_NAME") + "\nincoming...");

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                Window window = getWindow();
                window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
                window.setStatusBarColor(Color.BLACK);
            }
        }
    }
}

From source file:esolz.connexstudent.apprtc.ConnectActivity.java

@Override
public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
    switch (requestCode) {
    case MY_PERMISSIONS_REQUEST_READ_CONTACTS: {
        if (grantResults.length > 1 && grantResults[0] == PackageManager.PERMISSION_GRANTED
                && grantResults[1] == PackageManager.PERMISSION_GRANTED
                && grantResults[2] == PackageManager.PERMISSION_GRANTED
                && grantResults[3] == PackageManager.PERMISSION_GRANTED
                && grantResults[4] == PackageManager.PERMISSION_GRANTED) {

            if (getIntent().getAction().equals(ACTION_APP)) {
                RECEIVER_ID = getIntent().getStringExtra("RECEIVER_ID");
                pushHelperDhoperUrl();// w ww.ja va 2  s  . com
            } else {

                //                        Intent i = new Intent(getApplicationContext(), RingToneService.class);
                //                        i.setAction(RingToneService.ACTION_START);
                //                        startService(i);

                //                        ROOM_NAME = getIntent().getStringExtra("ROOM_NAME");
                //                        connectToRoom(0);

                OPONENT_ID = getIntent().getStringExtra("OPONENT_ID");

                threadmanager.postDelayed(callRejectionThred, 20000);

                findViewById(R.id.notifoicatio).setVisibility(View.VISIBLE);
                PROFILE_IMAGE = cDB.getUserImage(getIntent().getStringExtra("PHONE"));
                Picasso.with(getApplicationContext()).load(PROFILE_IMAGE).fit().centerCrop()
                        .into((ImageView) findViewById(R.id.dialer_bg));

                ((AvenirRoman) findViewById(R.id.caller_name))
                        .setText(getIntent().getStringExtra("CALLER_NAME") + "\n\n" + "incoming...");
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                    Window window = getWindow();
                    window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
                    window.setStatusBarColor(Color.BLACK);
                }

            }
        } else {
            android.support.v7.app.AlertDialog.Builder alertDialogBuilder = new android.support.v7.app.AlertDialog.Builder(
                    ConnectActivity.this);
            alertDialogBuilder.setMessage(
                    "With out these permissions, we cant move into meeting room. Would you like to continue?");
            alertDialogBuilder.setPositiveButton("Retry", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface arg0, int arg1) {
                    permissionChk();
                }
            });
            alertDialogBuilder.setNegativeButton("DISCARD", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    finish();
                }
            });
            android.support.v7.app.AlertDialog alertDialog = alertDialogBuilder.create();
            alertDialog.show();
        }
        return;
    }
    }
}

From source file:com.elitise.appv2.Peripheral.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    Window wd = this.getWindow();
    wd.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    wd.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
    wd.setStatusBarColor(Color.parseColor("#000000"));
    return true;//from  ww  w  .ja  v a2s .com
}

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 www . ja  v  a 2s . c o m*/
}

From source file:esolz.connexstudent.apprtc.ConnectActivity.java

public void pushHelperDhoperUrl() {
    ROOM_NAME = "" + Calendar.getInstance().getTimeInMillis();
    String URL;//from   ww w .  j a v  a 2 s . c om
    if (getIntent().getStringExtra("MODE").equalsIgnoreCase("voice")) {
        URL = ConnexConstante.DOMAIN_URL + "push_send?roomId=" + ROOM_NAME + "&sender_id="
                + ConnexApplication.getInstance().getUserID() + "&receiver_id=" + RECEIVER_ID
                + "&mod=voice&pem_mod=prod";
    } else {
        URL = ConnexConstante.DOMAIN_URL + "push_send?roomId=" + ROOM_NAME + "&sender_id="
                + ConnexApplication.getInstance().getUserID() + "&receiver_id=" + RECEIVER_ID
                + "&mod=video&pem_mod=prod";
    }
    Log.i(TAG, URL);
    JsonObjectRequest jsonObjReq = new JsonObjectRequest(Request.Method.GET, URL,
            new Response.Listener<JSONObject>() {
                @Override
                public void onResponse(JSONObject response) {
                    Log.i(TAG, response.toString());
                    try {
                        if (response.getBoolean("response")) {
                            Log.i(TAG, ROOM_NAME);
                            //                                connectToRoom(0);
                            //==========opening dialong screen

                            findViewById(R.id.notifoicatio).setVisibility(View.VISIBLE);

                            PROFILE_IMAGE = cDB.getUserImageFromID(RECEIVER_ID);

                            Picasso.with(getApplicationContext()).load(PROFILE_IMAGE).fit().centerCrop()
                                    .into((ImageView) findViewById(R.id.dialer_bg));

                            ((AvenirRoman) findViewById(R.id.caller_name))
                                    .setText("Calling \n\n" + cDB.getUserNameFromID(RECEIVER_ID) + "...");

                            findViewById(R.id.rcv_call).setVisibility(View.GONE);
                            findViewById(R.id.message_withreject).setVisibility(View.GONE);
                            ((AvenirLight) findViewById(R.id.rejection_call_text)).setText("End Call");

                            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                                Window window = getWindow();
                                window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
                                window.setStatusBarColor(Color.BLACK);
                            }

                            //======Dialed Call by You

                            SimpleDateFormat frmatr = new SimpleDateFormat("dd MMM,yyyy-HH:mm");

                            cDB.insertInLogTable(cDB.getUserPhoneFromID(RECEIVER_ID),
                                    cDB.getUserNameFromID(RECEIVER_ID), PROFILE_IMAGE, "called",
                                    frmatr.format(new Date(Calendar.getInstance().getTimeInMillis())));

                            //==================================

                            mPlayer.start();

                            new Handler().postDelayed(new Runnable() {
                                @Override
                                public void run() {
                                    try {
                                        if (mPlayer.isPlaying()) {
                                            mPlayer.stop();
                                            mPlayer.release();
                                        }
                                        finish();
                                    } catch (Exception e) {
                                        e.printStackTrace();
                                    }

                                }
                            }, 19000);

                        } else {
                            Toast.makeText(ConnectActivity.this, "Failed to create Meeting, Try Again!",
                                    Toast.LENGTH_SHORT).show();
                            onBackPressed();
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                        Toast.makeText(ConnectActivity.this, "Failed to create Meeting, Try Again!",
                                Toast.LENGTH_SHORT).show();
                        onBackPressed();
                    }
                }
            }, new Response.ErrorListener() {

                @Override
                public void onErrorResponse(VolleyError error) {
                    Log.i(TAG, "Error: " + error.getMessage());
                    Toast.makeText(ConnectActivity.this, "Failed to create Meeting, Try Again!",
                            Toast.LENGTH_SHORT).show();
                    onBackPressed();
                }
            });
    ConnexApplication.getInstance().addToRequestQueue(jsonObjReq);
}

From source file:com.develop.autorus.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    Fabric.with(this, new Crashlytics());
    super.onCreate(savedInstanceState);
    SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);

    AnalyticsApplication application = (AnalyticsApplication) getApplication();
    mTracker = application.getDefaultTracker();
    mTracker.setScreenName("Main activity");
    mTracker.send(new HitBuilders.ScreenViewBuilder().build());

    if (pref.getBoolean("notificationIsActive", true)) {
        Intent checkIntent = new Intent(getApplicationContext(), MonitoringWork.class);
        Boolean alrarmIsActive = false;
        if (PendingIntent.getService(getApplicationContext(), 0, checkIntent,
                PendingIntent.FLAG_NO_CREATE) != null)
            alrarmIsActive = true;//from   w  ww. jav  a 2  s .  c o  m
        am = (AlarmManager) getSystemService(ALARM_SERVICE);

        if (!alrarmIsActive) {
            Intent serviceIntent = new Intent(getApplicationContext(), MonitoringWork.class);
            PendingIntent pIntent = PendingIntent.getService(getApplicationContext(), 0, serviceIntent, 0);

            int period = pref.getInt("numberOfActiveMonitors", 0) * 180000;

            if (period != 0)
                am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + period,
                        period, pIntent);
        }
    }

    /*ForEasyDelete
            
    //Danger! Auchtung! ?, !!!
    String base64EncodedPublicKey =
        "<your license key here>";//?   . !!! ? ,    
    // github ?  .         ?!!!
            
    mHelper = new IabHelper(this, base64EncodedPublicKey);
            
    mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
    public void onIabSetupFinished(IabResult result) {
        if (!result.isSuccess()) {
            Log.d(TAG, "In-app Billing setup failed: " +
                    result);
        } else {
            Log.d(TAG, "In-app Billing is set up OK");
        }
    }
    });
    */

    //Service inapp
    Intent intent = new Intent("com.android.vending.billing.InAppBillingService.BIND");
    intent.setPackage("com.android.vending");
    blnBind = bindService(intent, mServiceConn, Context.BIND_AUTO_CREATE);

    String themeName = pref.getString("theme", "1");

    if (themeName.equals("1")) {
        setTheme(R.style.AppTheme);
        if (android.os.Build.VERSION.SDK_INT >= 21) {
            Window statusBar = getWindow();
            statusBar.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            statusBar.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            statusBar.setStatusBarColor(getResources().getColor(R.color.myPrimaryDarkColor));
        }
    } else if (themeName.equals("2")) {
        setTheme(R.style.AppTheme2);
        if (android.os.Build.VERSION.SDK_INT >= 21) {
            Window statusBar = getWindow();
            statusBar.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            statusBar.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            statusBar.setStatusBarColor(getResources().getColor(R.color.myPrimaryDarkColor2));
        }
    }
    ThemeManager.init(this, 2, 0, null);

    if (isFirstLaunch) {
        SQLiteDatabase db = new DbHelper(this).getWritableDatabase();
        Cursor cursorMonitors = db.query("monitors", null, null, null, null, null, null);
        Boolean monitorsExist = cursorMonitors != null && cursorMonitors.getCount() > 0;
        db.close();

        if (getSupportFragmentManager().findFragmentByTag("MAIN") == null) {
            FragmentTransaction fTrans = getSupportFragmentManager().beginTransaction();
            if (monitorsExist)
                mainFragment = SearchAndMonitorsFragment.newInstance(0);
            else
                mainFragment = SearchAndMonitorsFragment.newInstance(1);
            fTrans.add(R.id.container, mainFragment, "MAIN").commit();
        } else {
            mainFragment = (SearchAndMonitorsFragment) getSupportFragmentManager().findFragmentByTag("MAIN");
            if (getSupportFragmentManager().findFragmentByTag("Second") != null) {
                FragmentTransaction fTrans = getSupportFragmentManager().beginTransaction();
                fTrans.remove(getSupportFragmentManager().findFragmentByTag("Second")).commit();
            }
            pref.edit().remove("NumberOfCallingFragment");
        }
    }

    backToast = Toast.makeText(this, "?   ? ", Toast.LENGTH_SHORT);
    setContentView(R.layout.main_activity);
    mToolbar = (Toolbar) findViewById(R.id.toolbar_actionbar);
    mSnackBar = (SnackBar) findViewById(R.id.main_sn);
    setSupportActionBar(mToolbar);

    addMonitorButton = (Button) findViewById(R.id.toolbar_add_monitor_button);

    mNavigationDrawerFragment = (NavigationDrawerFragment) getSupportFragmentManager()
            .findFragmentById(R.id.fragment_drawer);
    mNavigationDrawerFragment.setup(R.id.fragment_drawer, (DrawerLayout) findViewById(R.id.drawer), mToolbar);

    Thread threadAvito = new Thread(new Runnable() {
        @TargetApi(Build.VERSION_CODES.HONEYCOMB)
        public void run() {
            Document doc;
            SharedPreferences sPref;
            try {
                String packageName = getApplicationContext().getPackageName();
                doc = Jsoup.connect("https://play.google.com/store/apps/details?id=" + packageName).userAgent(
                        "Mozilla/5.0 (Windows; U; WindowsNT 5.1; ru-RU; rv1.8.1.6) Gecko/20070725 Firefox/2.0.0.6")
                        .timeout(12000).get();
                //"")

                PackageManager packageManager;
                PackageInfo packageInfo;
                packageManager = getPackageManager();

                packageInfo = packageManager.getPackageInfo(getPackageName(), 0);
                Element mainElems = doc.select(
                        "#body-content > div > div > div.main-content > div.details-wrapper.apps-secondary-color > div > div.details-section-contents > div:nth-child(4) > div.content")
                        .first();

                if (!packageInfo.versionName.equals(mainElems.text())) {
                    sPref = getPreferences(MODE_PRIVATE);
                    SharedPreferences.Editor ed = sPref.edit();
                    ed.putBoolean(SAVED_TEXT_WITH_VERSION, false);
                    ed.commit();
                } else {
                    sPref = getPreferences(MODE_PRIVATE);
                    SharedPreferences.Editor ed = sPref.edit();
                    ed.putBoolean(SAVED_TEXT_WITH_VERSION, true);
                    ed.commit();

                }
                //SharedPreferences sPrefRemind;
                //sPrefRemind = getPreferences(MODE_PRIVATE);
                //sPrefRemind.edit().putBoolean(DO_NOT_REMIND, false).commit();
            } catch (HttpStatusException e) {
                return;
            } catch (IOException e) {
                return;
            } catch (PackageManager.NameNotFoundException e) {

                e.printStackTrace();
            }
        }
    });

    SharedPreferences sPrefVersion;
    sPrefVersion = getPreferences(MODE_PRIVATE);
    Boolean isNewVersion;
    isNewVersion = sPrefVersion.getBoolean(SAVED_TEXT_WITH_VERSION, true);

    threadAvito.start();
    boolean remind = true;
    if (!isNewVersion) {
        Log.d("affa", "isNewVersion= " + isNewVersion);
        SharedPreferences sPref12;
        sPref12 = getPreferences(MODE_PRIVATE);
        String isNewVersion12;

        PackageManager packageManager;
        PackageInfo packageInfo;
        packageManager = getPackageManager();

        try {
            packageInfo = packageManager.getPackageInfo(getPackageName(), 0);
            isNewVersion12 = sPref12.getString("OldVersionName", packageInfo.versionName);

            if (!isNewVersion12.equals(packageInfo.versionName)) {
                SharedPreferences sPref;
                sPref = getPreferences(MODE_PRIVATE);
                SharedPreferences.Editor ed = sPref.edit();
                ed.putBoolean(SAVED_TEXT_WITH_VERSION, false);
                ed.commit();

                SharedPreferences sPrefRemind;
                sPrefRemind = getPreferences(MODE_PRIVATE);
                sPrefRemind.edit().putBoolean(DO_NOT_REMIND, false).commit();
            } else
                remind = false;

            SharedPreferences sPrefRemind;
            sPrefRemind = getPreferences(MODE_PRIVATE);
            sPrefRemind.edit().putString("OldVersionName", packageInfo.versionName).commit();
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }

        SharedPreferences sPrefRemind;
        sPrefRemind = getPreferences(MODE_PRIVATE);
        Boolean dontRemind;
        dontRemind = sPrefRemind.getBoolean(DO_NOT_REMIND, false);
        Log.d("affa", "dontRemind= " + dontRemind.toString());
        Log.d("affa", "remind= " + remind);
        Log.d("affa", "44444444444444444444444= ");
        if ((!dontRemind) && (!remind)) {
            Log.d("affa", "5555555555555555555555555= ");
            SimpleDialog.Builder builder = new SimpleDialog.Builder(R.style.SimpleDialogLight) {
                @Override
                public void onPositiveActionClicked(DialogFragment fragment) {
                    super.onPositiveActionClicked(fragment);
                    String packageName = getApplicationContext().getPackageName();
                    Intent intent = new Intent(Intent.ACTION_VIEW,
                            Uri.parse("https://play.google.com/store/apps/details?id=" + packageName));
                    startActivity(intent);
                }

                @Override
                public void onNegativeActionClicked(DialogFragment fragment) {
                    super.onNegativeActionClicked(fragment);
                }

                @Override
                public void onNeutralActionClicked(DialogFragment fragment) {
                    super.onNegativeActionClicked(fragment);
                    SharedPreferences sPrefRemind;
                    sPrefRemind = getPreferences(MODE_PRIVATE);
                    sPrefRemind.edit().putBoolean(DO_NOT_REMIND, true).commit();
                }
            };

            builder.message(
                    "  ??   ? ? ?")
                    .title(" !").positiveAction("")
                    .negativeAction("").neutralAction("? ");
            DialogFragment fragment = DialogFragment.newInstance(builder);
            fragment.show(getSupportFragmentManager(), null);
        }
    }
}

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));
    }//from w  w  w .j av  a 2 s.  c o m
}

From source file:com.zoffcc.applications.zanavi.ZANaviMainIntroActivityStatic.java

/**
 * Making notification bar transparent/*from   w  ww  . j av  a2s .  c  o  m*/
 */
@SuppressLint("NewApi")
private void changeStatusBarColor() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(Color.TRANSPARENT);
    }
}