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:jahirfiquitiva.iconshowcase.activities.ViewerActivity.java

@SuppressWarnings("ResourceAsColor")
@Override//from w  ww  .j  a  v a2 s  . c  o m
protected void onCreate(Bundle savedInstanceState) {

    ThemeUtils.onActivityCreateSetTheme(this);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        ThemeUtils.onActivityCreateSetNavBar(this);
        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    }

    super.onCreate(savedInstanceState);

    context = this;

    usePalette = getResources().getBoolean(R.bool.use_palette_api_in_viewer);

    mPrefs = new Preferences(context);

    mPrefs.setActivityVisible(true);

    Intent intent = getIntent();
    String transitionName = intent.getStringExtra("transitionName");

    item = intent.getParcelableExtra("item");

    setContentView(R.layout.wall_viewer_activity);

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

    if (getSupportActionBar() != null) {
        getSupportActionBar().setTitle("");
        getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_back);
        getSupportActionBar().setHomeButtonEnabled(true);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setDisplayShowHomeEnabled(true);
    }

    final int iconsColor = ThemeUtils.darkTheme ? ContextCompat.getColor(context, R.color.toolbar_text_dark)
            : ContextCompat.getColor(context, R.color.toolbar_text_light);

    ToolbarColorizer.colorizeToolbar(toolbar, iconsColor);

    toHide1 = (LinearLayout) findViewById(R.id.iconsA);
    toHide2 = (LinearLayout) findViewById(R.id.iconsB);

    int tintLightLighter = ContextCompat.getColor(context, R.color.drawable_base_tint);
    int tintDark = ContextCompat.getColor(context, R.color.drawable_tint_dark);

    Drawable save = ColorUtils.getTintedIcon(context, R.drawable.ic_save,
            ThemeUtils.darkTheme ? tintDark : tintLightLighter);

    Drawable apply = ColorUtils.getTintedIcon(context, R.drawable.ic_apply_wallpaper,
            ThemeUtils.darkTheme ? tintDark : tintLightLighter);

    Drawable info = ColorUtils.getTintedIcon(context, R.drawable.ic_info,
            ThemeUtils.darkTheme ? tintDark : tintLightLighter);

    ImageView saveIV = (ImageView) findViewById(R.id.download);
    if (item.isDownloadable()) {
        saveIV.setImageDrawable(save);
        saveIV.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (!PermissionUtils.canAccessStorage(context)) {
                    PermissionUtils.setViewerActivityAction("save");
                    PermissionUtils.requestStoragePermission(context);
                } else {
                    showDialogs("save");
                }
            }
        });
    } else {
        saveIV.setVisibility(View.GONE);
    }

    ImageView applyIV = (ImageView) findViewById(R.id.apply);
    applyIV.setImageDrawable(apply);
    applyIV.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            showApplyWallpaperDialog(context, item.getWallURL());
        }
    });

    ImageView infoIV = (ImageView) findViewById(R.id.info);
    infoIV.setImageDrawable(info);
    infoIV.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ISDialogs.showWallpaperDetailsDialog(context, item.getWallName(), item.getWallAuthor(),
                    item.getWallDimensions(), item.getWallCopyright());
        }
    });

    TouchImageView mPhoto = (TouchImageView) findViewById(R.id.big_wallpaper);
    ViewCompat.setTransitionName(mPhoto, transitionName);

    layout = (RelativeLayout) findViewById(R.id.viewerLayout);

    TextView wallNameText = (TextView) findViewById(R.id.wallName);
    wallNameText.setText(item.getWallName());

    Bitmap bmp = null;
    String filename = getIntent().getStringExtra("image");
    try {
        if (filename != null) {
            FileInputStream is = context.openFileInput(filename);
            bmp = BitmapFactory.decodeStream(is);
            is.close();
        } else {
            bmp = null;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    int colorFromCachedPic = 0;

    if (bmp != null) {
        colorFromCachedPic = ColorExtractor.getFinalGeneratedIconsColorFromPalette(bmp, usePalette);
    } else {
        colorFromCachedPic = ThemeUtils.darkTheme ? tintDark : tintLightLighter;
    }

    final ProgressBar spinner = (ProgressBar) findViewById(R.id.progress);
    spinner.getIndeterminateDrawable().setColorFilter(colorFromCachedPic, PorterDuff.Mode.SRC_IN);

    ToolbarColorizer.colorizeToolbar(toolbar, colorFromCachedPic);

    Drawable d;
    if (bmp != null) {
        d = new GlideBitmapDrawable(getResources(), bmp);
    } else {
        d = new ColorDrawable(ContextCompat.getColor(context, android.R.color.transparent));
    }

    if (mPrefs.getAnimationsEnabled()) {
        Glide.with(context).load(item.getWallURL()).placeholder(d).diskCacheStrategy(DiskCacheStrategy.SOURCE)
                .fitCenter().listener(new RequestListener<String, GlideDrawable>() {
                    @Override
                    public boolean onException(Exception e, String model, Target<GlideDrawable> target,
                            boolean isFirstResource) {
                        return false;
                    }

                    @Override
                    public boolean onResourceReady(GlideDrawable resource, String model,
                            Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
                        Bitmap picture = ((GlideBitmapDrawable) resource).getBitmap();
                        ToolbarColorizer.colorizeToolbar(toolbar,
                                ColorExtractor.getFinalGeneratedIconsColorFromPalette(picture, usePalette));
                        spinner.setVisibility(View.GONE);
                        return false;
                    }
                }).into(mPhoto);
    } else {
        Glide.with(context).load(item.getWallURL()).placeholder(d).dontAnimate()
                .diskCacheStrategy(DiskCacheStrategy.SOURCE).fitCenter()
                .listener(new RequestListener<String, GlideDrawable>() {
                    @Override
                    public boolean onException(Exception e, String model, Target<GlideDrawable> target,
                            boolean isFirstResource) {
                        return false;
                    }

                    @Override
                    public boolean onResourceReady(GlideDrawable resource, String model,
                            Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
                        Bitmap picture = ((GlideBitmapDrawable) resource).getBitmap();
                        ToolbarColorizer.colorizeToolbar(toolbar,
                                ColorExtractor.getFinalGeneratedIconsColorFromPalette(picture, usePalette));
                        spinner.setVisibility(View.GONE);
                        return false;
                    }
                }).into(mPhoto);
    }
}

From source file:com.mjhram.geodata.GpsMainActivity.java

public void SetUpToolbar() {
    try {// w w  w .j  av  a  2s .co  m
        Toolbar toolbar = GetToolbar();
        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayShowTitleEnabled(false);

        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:net.oschina.app.v2.activity.zxing.CaptureActivity.java

@Override
protected void onBeforeSetContentLayout() {
    super.onBeforeSetContentLayout();
    Window window = getWindow();
    window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}

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;//w  w  w  .j av  a2 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:com.granita.tasks.TaskListActivity.java

@SuppressLint("NewApi")
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
@Override//www .j a  va 2 s.  c om
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 v  a 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();/*from w  w  w .j a v  a2 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;// ww  w. j  a va2  s.  com
}

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

public void pushHelperDhoperUrl() {
    ROOM_NAME = "" + Calendar.getInstance().getTimeInMillis();
    String URL;/*from   www.  j  a v  a2 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.phonegap.bossbolo.plugin.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 w  w .  j a  va  2  s  . c o 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));
    }

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