Java Code Examples for android.view.Window#setFlags()

The following examples show how to use android.view.Window#setFlags() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SignIn2Activity.java    From smart-farmer-android with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        Window window = getWindow();
        window.setFlags(
                WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
                WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    }

    setContentView(R.layout.activity_sign_in2);

    btn_login = (Button) findViewById(R.id.btn_to_login);
    btn_register = (Button) findViewById(R.id.btn_to_register);

    btn_login.setOnClickListener(this);
    btn_register.setOnClickListener(this);

}
 
Example 2
Source File: AdjustStatusbar.java    From BaseAndroidApp with Apache License 2.0 6 votes vote down vote up
@TargetApi (Build.VERSION_CODES.KITKAT)
public static void addColorAndHeight(@NonNull Activity activity) {
   if (!activity.getResources()
         .getBoolean(R.bool.should_color_status_bar)) {
      return;
   }
   View statusBar = activity.findViewById(R.id.statusBarBackground);
   if (statusBar == null) {
      return;
   }
   Window window = activity.getWindow();
   window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
         WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
   int statusBarHeight = getStatusBarHeight(activity);
   if (statusBarHeight != 0) {
      final int color = ContextCompat.getColor(activity, R.color.primary_dark);
      statusBar.getLayoutParams().height = +statusBarHeight;
      statusBar.setBackgroundColor(color);
      statusBar.setVisibility(View.VISIBLE);
   } else {
      statusBar.setVisibility(View.GONE);
   }
}
 
Example 3
Source File: StyledDialogFragment.java    From android_maplibui with GNU Lesser General Public License v3.0 6 votes vote down vote up
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState)
{
    // Idea from here
    // http://thanhcs.blogspot.ru/2014/10/android-custom-dialog-fragment.html

    Dialog dialog = new Dialog(mContext);

    Window window = dialog.getWindow();
    window.requestFeature(Window.FEATURE_NO_TITLE);
    window.setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
    window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));

    return dialog;
}
 
Example 4
Source File: SplashActivity.java    From monolog-android with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Window window = getWindow();
    window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);

    setContentView(R.layout.activity_splash);
    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            //显示广告
            runAd();
        }
    }, 500);
}
 
Example 5
Source File: BaseActivity.java    From shinny-futures-android with GNU General Public License v3.0 6 votes vote down vote up
protected void changeStatusBarColor(boolean isFirm) {
    Window window = getWindow();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
                WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        int statusBarHeight = getStatusBarHeight(this);
        View view = new View(this);
        view.setLayoutParams(new FrameLayout.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
        view.getLayoutParams().height = statusBarHeight;
        ((ViewGroup) window.getDecorView()).addView(view);
        if (isFirm) view.setBackground(getResources().getDrawable(R.color.colorPrimaryDark));
        else view.setBackground(getResources().getDrawable(R.color.login_simulation_hint));

    } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        if (isFirm)
            window.setStatusBarColor(ContextCompat.getColor(this, R.color.colorPrimaryDark));
        else
            window.setStatusBarColor(ContextCompat.getColor(this, R.color.login_simulation_hint));
    }
}
 
Example 6
Source File: MainActivity.java    From libsoftwaresync with Apache License 2.0 6 votes vote down vote up
private void createUi() {
  Window appWindow = getWindow();
  appWindow.setFlags(
      WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
  // Disable sleep / screen off.
  appWindow.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

  // Create the SurfaceView.
  surfaceView = findViewById(R.id.viewfinder_surface_view);

  // TextViews.
  statusTextView = findViewById(R.id.status_text);
  softwaresyncStatusTextView = findViewById(R.id.softwaresync_text);
  sensorExposureTextView = findViewById(R.id.sensor_exposure);
  sensorSensitivityTextView = findViewById(R.id.sensor_sensitivity);
  phaseTextView = findViewById(R.id.phase);

  // Controls.
  captureStillButton = findViewById(R.id.capture_still_button);
  phaseAlignButton = findViewById(R.id.phase_align_button);
  exposureSeekBar = findViewById(R.id.exposure_seekbar);
  sensitivitySeekBar = findViewById(R.id.sensitivity_seekbar);
  sensorExposureTextView.setText("Exposure: " + prettyExposureValue(currentSensorExposureTimeNs));
  sensorSensitivityTextView.setText("Sensitivity: " + currentSensorSensitivity);
}
 
Example 7
Source File: StatusBarColorHelper.java    From HayaiLauncher with Apache License 2.0 6 votes vote down vote up
public static void setStatusBarColor(final Resources resources, final Activity activity,
                                     final int color) {
    //There's no support for colored status bar in versions below KITKAT
    if(Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) return;

    final Window window = activity.getWindow();
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
        //LOLLIPOP+ path
        window.setStatusBarColor(color);
    } else {
        //KITKAT path
        window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
                WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);

        final int statusBarHeight = getStatusBarHeight(resources);
        final View statusBarDummy = activity.findViewById(R.id.statusBarDummyView);
        statusBarDummy.getLayoutParams().height=statusBarHeight;
        statusBarDummy.setBackgroundColor(color);
    }
}
 
Example 8
Source File: SignInActivity.java    From smart-farmer-android with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        Window window = getWindow();
        window.setFlags(
                WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
                WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    }

    setContentView(R.layout.activity_sign_in);

    mImgLoginRegisterClose = (ImageView) findViewById(R.id.img_login_register_close);
    mIndicatorLoginRegister = (ViewPagerIndicator) findViewById(R.id.indicator_login_register);
    mViewpagerLoginRegister = (ViewPager) findViewById(R.id.viewpager_login_register);

    mImgLoginRegisterClose.setOnClickListener(this);

    LoginRegisterAdapter adapter = new LoginRegisterAdapter(getSupportFragmentManager());
    mViewpagerLoginRegister.setAdapter(adapter);
    mIndicatorLoginRegister.setViewPager(mViewpagerLoginRegister, 0);
}
 
Example 9
Source File: LollipopUtils.java    From NBAPlus with Apache License 2.0 5 votes vote down vote up
public static void hideStatusbar(Activity activity) {

    //对于Lollipop的设备,只需要在style.xml中设置colorPrimaryDark即可

    //对于4.4的设备,如下即可
    Window w = activity.getWindow();

    if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) {
      w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
          WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
      return;
    }
  }
 
Example 10
Source File: Presenter.java    From react-native-navigation with MIT License 5 votes vote down vote up
private void mergeTranslucent(StatusBarOptions options) {
    Window window = activity.getWindow();
    if (options.translucent.isTrue()) {
        window.setFlags(FLAG_TRANSLUCENT_STATUS, FLAG_TRANSLUCENT_STATUS);
    } else if (options.translucent.isFalse() && StatusBarUtils.isTranslucent(window)) {
        window.clearFlags(FLAG_TRANSLUCENT_STATUS);
    }
}
 
Example 11
Source File: BaseActivity.java    From CatchPiggy with GNU General Public License v3.0 5 votes vote down vote up
private void mode2() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
//            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
//            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
            Window window = getWindow();
            // Translucent status bar
            window.setFlags(
                    WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
                    WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            // Translucent navigation bar
//            window.setFlags(
//                    WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION,
//                    WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
            window.getDecorView().setSystemUiVisibility(
                    View.SYSTEM_UI_FLAG_LAYOUT_STABLE
//                            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
//                            | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
//                            | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
//                            | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
                            | View.SYSTEM_UI_FLAG_IMMERSIVE
                            | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                window.setStatusBarColor(Color.TRANSPARENT);
                window.setNavigationBarColor(Color.TRANSPARENT);
            }
        }
    }
 
Example 12
Source File: Service.java    From Twire with GNU General Public License v3.0 5 votes vote down vote up
public static void isTranslucentActionbar(String LOG_TAG, Context context, Toolbar toolbar, Activity activity) {
    if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) {
        Log.d(LOG_TAG, "Settings translucent status bar");

        double statusBarHeight = Math.ceil(25 * context.getResources().getDisplayMetrics().density);

        Window w = activity.getWindow(); // in Activity's onCreate() for instance
        //w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
        w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        toolbar.getLayoutParams().height = (int) (context.getResources().getDimension((R.dimen.main_toolbar_height)) + statusBarHeight);
    }
}
 
Example 13
Source File: MaterialIntroActivity.java    From material-intro-screen with MIT License 4 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        Window window = getWindow();
        window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    }

    setContentView(R.layout.activity_material_intro);

    overScrollLayout = (OverScrollViewPager) findViewById(R.id.view_pager_slides);
    viewPager = overScrollLayout.getOverScrollView();
    pageIndicator = (InkPageIndicator) findViewById(R.id.indicator);
    backButton = (ImageButton) findViewById(R.id.button_back);
    nextButton = (ImageButton) findViewById(R.id.button_next);
    skipButton = (ImageButton) findViewById(R.id.button_skip);
    messageButton = (Button) findViewById(R.id.button_message);
    coordinatorLayout = (CoordinatorLayout) findViewById(R.id.coordinator_layout_slide);
    navigationView = (LinearLayout) findViewById(R.id.navigation_view);

    adapter = new SlidesAdapter(getSupportFragmentManager());

    viewPager.setAdapter(adapter);
    viewPager.setOffscreenPageLimit(2);
    pageIndicator.setViewPager(viewPager);

    nextButtonTranslationWrapper = new NextButtonTranslationWrapper(nextButton);
    initOnPageChangeListeners();

    permissionNotGrantedClickListener = new PermissionNotGrantedClickListener(this, nextButtonTranslationWrapper);
    finishScreenClickListener = new FinishScreenClickListener();

    setBackButtonVisible();

    viewPager.post(new Runnable() {
        @Override
        public void run() {
            if (adapter.getCount() == 0) {
                finish();
            } else {
                int currentItem = viewPager.getCurrentItem();
                messageButtonBehaviourOnPageSelected.pageSelected(currentItem);
                nextButtonBehaviour(currentItem, adapter.getItem(currentItem));
            }
        }
    });
}
 
Example 14
Source File: CropImmersiveManage.java    From Matisse-Kotlin with Apache License 2.0 4 votes vote down vote up
/**
 * @param baseActivity
 * @param statusBarColor     状态栏的颜色
 * @param navigationBarColor 导航栏的颜色
 */
public static void immersiveAboveAPI23(AppCompatActivity baseActivity, boolean isMarginStatusBar
        , boolean isMarginNavigationBar, int statusBarColor, int navigationBarColor, boolean isDarkStatusBarIcon) {
    try {
        Window window = baseActivity.getWindow();
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
            //4.4版本及以上 5.0版本及以下
            window.setFlags(
                    WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
                    WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            if (isMarginStatusBar && isMarginNavigationBar) {
                //5.0版本及以上
                window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
                        | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
                CropLightStatusBarUtils.setLightStatusBar(baseActivity, isMarginStatusBar
                        , isMarginNavigationBar
                        , statusBarColor == Color.TRANSPARENT
                        , isDarkStatusBarIcon);

                window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            } else if (!isMarginStatusBar && !isMarginNavigationBar) {
                window.requestFeature(Window.FEATURE_NO_TITLE);
                window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
                        | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);

                CropLightStatusBarUtils.setLightStatusBar(baseActivity, isMarginStatusBar
                        , isMarginNavigationBar
                        , statusBarColor == Color.TRANSPARENT
                        , isDarkStatusBarIcon);

                window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);


            } else if (!isMarginStatusBar && isMarginNavigationBar) {
                window.requestFeature(Window.FEATURE_NO_TITLE);
                window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
                        | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
                CropLightStatusBarUtils.setLightStatusBar(baseActivity, isMarginStatusBar
                        , isMarginNavigationBar
                        , statusBarColor == Color.TRANSPARENT
                        , isDarkStatusBarIcon);

                window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);


            } else {
                //留出来状态栏 不留出来导航栏 没找到办法。。
                return;
            }

            window.setStatusBarColor(statusBarColor);
            window.setNavigationBarColor(navigationBarColor);

        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 15
Source File: AMWindowCompat.java    From ProjectX with Apache License 2.0 4 votes vote down vote up
@Override
public void setTranslucentNavigation(Window window) {
    window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION,
            WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
}
 
Example 16
Source File: RulesActivity.java    From Infinity-For-Reddit with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    ((Infinity) getApplication()).getAppComponent().inject(this);

    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_rules);

    ButterKnife.bind(this);

    EventBus.getDefault().register(this);

    applyCustomTheme();

    if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK_FROM_POST_DETAIL, true)) {
        Slidr.attach(this);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        Window window = getWindow();

        if (isChangeStatusBarIconColor()) {
            addOnOffsetChangedListener(appBarLayout);
        }

        if (isImmersiveInterface()) {
            window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
            adjustToolbar(toolbar);

            int navBarHeight = getNavBarHeight();
            if (navBarHeight > 0) {
                recyclerView.setPadding(0, 0, 0, navBarHeight);
            }
        }
    }

    appBarLayout.setBackgroundColor(mCustomThemeWrapper.getColorPrimary());
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    mSubredditName = getIntent().getExtras().getString(EXTRA_SUBREDDIT_NAME);

    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    mAdapter = new RulesRecyclerViewAdapter(this, mCustomThemeWrapper);
    recyclerView.setAdapter(mAdapter);

    //fetchRules();

    FetchRules.fetchRules(mRetrofit, mSubredditName, new FetchRules.FetchRulesListener() {
        @Override
        public void success(ArrayList<Rule> rules) {
            progressBar.setVisibility(View.GONE);
            if (rules == null || rules.size() == 0) {
                errorTextView.setVisibility(View.VISIBLE);
                errorTextView.setText(R.string.no_rule);
                errorTextView.setOnClickListener(view -> {
                });
            }
            mAdapter.changeDataset(rules);
        }

        @Override
        public void failed() {
            displayError();
        }
    });
}
 
Example 17
Source File: CountDownActivity.java    From ripple with GNU General Public License v3.0 4 votes vote down vote up
@TargetApi(11)
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mTestRun = getIntent().getBooleanExtra(PanicActivity.EXTRA_TEST_RUN, false);

    Window window = getWindow();
    window.setBackgroundDrawable(null);
    window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_count_down);

    DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
    int scale;
    if (displayMetrics.heightPixels > displayMetrics.widthPixels) {
        scale = displayMetrics.heightPixels;
    } else {
        scale = displayMetrics.widthPixels;
    }
    mCountDownNumber = (TextView) findViewById(R.id.countDownNumber);
    mCountDownNumber.setTextSize(((float) scale) * 0.45f / getResources().getDisplayMetrics().scaledDensity);

    mTouchToCancel = (TextView) findViewById(R.id.tap_anywhere_to_cancel);
    mCancelButton = (ImageView) findViewById(R.id.cancelButton);

    mCountDownAsyncTask = new CountDownAsyncTask();

    if (savedInstanceState != null && savedInstanceState.getBoolean(KEY_COUNT_DOWN_DONE, false)) {
        showDoneScreen();
    } else {
        mCountDownAsyncTask.execute();
    }

    ConstraintLayout frameRoot = findViewById(R.id.frameRoot);
    frameRoot.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            cancel();
            return true;
        }
    });

    if (Build.VERSION.SDK_INT >= 16) {
        window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN);
    } else if (Build.VERSION.SDK_INT >= 14) {
        window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
    }

    if (Build.VERSION.SDK_INT >= 11) {
        frameRoot.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
            @Override
            public void onSystemUiVisibilityChange(int visibility) {
                /* If the nav bar comes back while the countdown is active,
                   that means the user clicked on the screen. Showing the
                   test dialog also triggers this, so filter on countdown */
                if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0 && mCountDown > 0) {
                    cancel();
                }
            }
        });
    }
}
 
Example 18
Source File: FilteredThingActivity.java    From Infinity-For-Reddit with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    ((Infinity) getApplication()).getAppComponent().inject(this);

    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_filtered_thing);

    ButterKnife.bind(this);

    EventBus.getDefault().register(this);

    applyCustomTheme();

    if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK_FROM_POST_DETAIL, true)) {
        Slidr.attach(this);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        Window window = getWindow();

        if (isChangeStatusBarIconColor()) {
            addOnOffsetChangedListener(appBarLayout);
        }

        if (isImmersiveInterface()) {
            window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
            adjustToolbar(toolbar);
        }
    }

    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    setToolbarGoToTop(toolbar);

    params = (AppBarLayout.LayoutParams) collapsingToolbarLayout.getLayoutParams();

    name = getIntent().getStringExtra(EXTRA_NAME);
    postType = getIntent().getIntExtra(EXTRA_POST_TYPE, PostDataSource.TYPE_FRONT_PAGE);
    int filter = getIntent().getIntExtra(EXTRA_FILTER, Post.TEXT_TYPE);

    if (postType == PostDataSource.TYPE_USER) {
        userWhere = getIntent().getStringExtra(EXTRA_USER_WHERE);
        if (userWhere != null && !PostDataSource.USER_WHERE_SUBMITTED.equals(userWhere) && mMenu != null) {
            mMenu.findItem(R.id.action_sort_filtered_thing_activity).setVisible(false);
        }
    }

    if (savedInstanceState != null) {
        isInLazyMode = savedInstanceState.getBoolean(IS_IN_LAZY_MODE_STATE);
        mNullAccessToken = savedInstanceState.getBoolean(NULL_ACCESS_TOKEN_STATE);
        mAccessToken = savedInstanceState.getString(ACCESS_TOKEN_STATE);

        mFragment = getSupportFragmentManager().getFragment(savedInstanceState, FRAGMENT_OUT_STATE);
        getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_filtered_posts_activity, mFragment).commit();

        if (!mNullAccessToken && mAccessToken == null) {
            getCurrentAccountAndBindView(filter);
        } else {
            bindView(filter, false);
        }
    } else {
        getCurrentAccountAndBindView(filter);
    }

    postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment();
}
 
Example 19
Source File: CropImmersiveManage.java    From PictureSelector with Apache License 2.0 4 votes vote down vote up
/**
 * @param baseActivity
 * @param statusBarColor     状态栏的颜色
 * @param navigationBarColor 导航栏的颜色
 */
public static void immersiveAboveAPI23(AppCompatActivity baseActivity, boolean isMarginStatusBar
        , boolean isMarginNavigationBar, int statusBarColor, int navigationBarColor, boolean isDarkStatusBarIcon) {
    try {
        Window window = baseActivity.getWindow();
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
            //4.4版本及以上 5.0版本及以下
            window.setFlags(
                    WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
                    WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            if (isMarginStatusBar && isMarginNavigationBar) {
                //5.0版本及以上
                window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
                        | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
                CropLightStatusBarUtils.setLightStatusBar(baseActivity, isMarginStatusBar
                        , isMarginNavigationBar
                        , statusBarColor == Color.TRANSPARENT
                        , isDarkStatusBarIcon);

                window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            } else if (!isMarginStatusBar && !isMarginNavigationBar) {
                window.requestFeature(Window.FEATURE_NO_TITLE);
                window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
                        | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);

                CropLightStatusBarUtils.setLightStatusBar(baseActivity, isMarginStatusBar
                        , isMarginNavigationBar
                        , statusBarColor == Color.TRANSPARENT
                        , isDarkStatusBarIcon);

                window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);


            } else if (!isMarginStatusBar && isMarginNavigationBar) {
                window.requestFeature(Window.FEATURE_NO_TITLE);
                window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
                        | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
                CropLightStatusBarUtils.setLightStatusBar(baseActivity, isMarginStatusBar
                        , isMarginNavigationBar
                        , statusBarColor == Color.TRANSPARENT
                        , isDarkStatusBarIcon);

                window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);


            } else {
                //留出来状态栏 不留出来导航栏 没找到办法。。
                return;
            }

            window.setStatusBarColor(statusBarColor);
            window.setNavigationBarColor(navigationBarColor);

        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 20
Source File: ImmersionBar.java    From ImmersionBar with Apache License 2.0 2 votes vote down vote up
/**
 * 隐藏状态栏
 * Hide status bar.
 *
 * @param window the window
 */
public static void hideStatusBar(@NonNull Window window) {
    window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
}