Skip to content

Commit

Permalink
update 3.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ifan-ge committed Feb 15, 2022
1 parent 4b1ee71 commit 4216677
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 20 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
![logo](https://github.com/gyf-dev/Screenshots/blob/master/ImmersionBar/readme_head.png)
# ImmersionBar -- android 4.4以上沉浸式实现
[![version](https://img.shields.io/badge/version-3.2.0-brightgreen.svg)](https://bintray.com/geyifeng/maven/immersionbar) [![author](https://img.shields.io/badge/author-gyf--dev-orange.svg)](https://github.com/gyf-dev) [![简书](https://img.shields.io/badge/%E7%AE%80%E4%B9%A6-HeLe%E5%B0%8F%E5%AD%90%E6%8B%BD-blue.svg)](https://www.jianshu.com/p/2a884e211a62) [![QQ群](https://img.shields.io/badge/QQ%E7%BE%A4-314360549-red.svg)]()
[![version](https://img.shields.io/badge/version-3.2.1-brightgreen.svg)](https://bintray.com/geyifeng/maven/immersionbar) [![author](https://img.shields.io/badge/author-gyf--dev-orange.svg)](https://github.com/gyf-dev) [![简书](https://img.shields.io/badge/%E7%AE%80%E4%B9%A6-HeLe%E5%B0%8F%E5%AD%90%E6%8B%BD-blue.svg)](https://www.jianshu.com/p/2a884e211a62) [![QQ群](https://img.shields.io/badge/QQ%E7%BE%A4-314360549-red.svg)]()

## 直接看效果图,建议下载demo体验,最下面有各个版本的效果图
<img width="300" src="https://github.com/gyf-dev/Screenshots/blob/master/ImmersionBar/Screenshot_6.0.gif"/>
Expand All @@ -9,11 +9,11 @@
> 3.1.1以上版本(mavenCentral)
```groovy
// 基础依赖包,必须要依赖
implementation 'com.geyifeng.immersionbar:immersionbar:3.2.0'
implementation 'com.geyifeng.immersionbar:immersionbar:3.2.1'
// kotlin扩展(可选)
implementation 'com.geyifeng.immersionbar:immersionbar-ktx:3.2.0'
implementation 'com.geyifeng.immersionbar:immersionbar-ktx:3.2.1'
// fragment快速实现(可选)已废弃
implementation 'com.geyifeng.immersionbar:immersionbar-components:3.2.0'
implementation 'com.geyifeng.immersionbar:immersionbar-components:3.2.1'
```
> 3.0.0版本(jcenter)
```groovy
Expand All @@ -29,13 +29,13 @@
#### [点我查看版本说明](https://github.com/gyf-dev/ImmersionBar/wiki)

## 下载demo
#### [点我下载immersionBar-3.2.0.apk](https://github.com/gyf-dev/ImmersionBar/blob/master/apk/immersionbar-3.2.0.apk)
#### [点我下载immersionBar-3.2.1.apk](https://github.com/gyf-dev/ImmersionBar/blob/master/apk/immersionbar-3.2.1.apk)

## 关于全面屏与刘海
#### 关于全面屏
在manifest加入如下配置,四选其一,或者都写

① 升级targetSdkVersion为25以上版本
① 升级targetSdkVersion为25以上版本,现在基本都是25以上了,所以以下三个必须要配置了

② 在manifest的Application节点中加入
```xml
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import java.util.function.Consumer

buildscript {
ext.kotlin_version = '1.6.10'
ext.immersionbar_version = '3.2.0'
ext.immersionbar_version = '3.2.1'
repositories {
mavenCentral()
google()
Expand Down
24 changes: 11 additions & 13 deletions immersionbar/src/main/java/com/gyf/immersionbar/ImmersionBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowInsets;
import android.view.WindowInsetsController;
import android.view.WindowManager;
import android.widget.FrameLayout;
Expand All @@ -35,9 +36,6 @@
import androidx.annotation.RequiresApi;
import androidx.core.content.ContextCompat;
import androidx.core.graphics.ColorUtils;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.core.view.WindowInsetsControllerCompat;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.Fragment;
Expand Down Expand Up @@ -380,7 +378,7 @@ void setBar() {
//android 8.0以上设置导航栏图标为暗色
uiFlags = setNavigationIconDark(uiFlags);
//适配android 11以上
setBarDarkFont();
setBarDarkFontAboveR();
} else {
//初始化5.0以下,4.4以上沉浸式
initBarBelowLOLLIPOP();
Expand All @@ -399,7 +397,7 @@ void setBar() {
}
}

private void setBarDarkFont() {
private void setBarDarkFontAboveR() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
setStatusBarDarkFontAboveR();
setNavigationIconDarkAboveR();
Expand Down Expand Up @@ -863,27 +861,27 @@ private void setNavigationIconDarkAboveR() {

private void hideBarAboveR() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
WindowInsetsControllerCompat controller = ViewCompat.getWindowInsetsController(mContentView);
WindowInsetsController controller = mContentView.getWindowInsetsController();
if (controller != null) {
switch (mBarParams.barHide) {
case FLAG_HIDE_BAR:
controller.hide(WindowInsetsCompat.Type.statusBars());
controller.hide(WindowInsetsCompat.Type.navigationBars());
controller.hide(WindowInsets.Type.statusBars());
controller.hide(WindowInsets.Type.navigationBars());
break;
case FLAG_HIDE_STATUS_BAR:
controller.hide(WindowInsetsCompat.Type.statusBars());
controller.hide(WindowInsets.Type.statusBars());
break;
case FLAG_HIDE_NAVIGATION_BAR:
controller.hide(WindowInsetsCompat.Type.navigationBars());
controller.hide(WindowInsets.Type.navigationBars());
break;
case FLAG_SHOW_BAR:
controller.show(WindowInsetsCompat.Type.statusBars());
controller.show(WindowInsetsCompat.Type.navigationBars());
controller.show(WindowInsets.Type.statusBars());
controller.show(WindowInsets.Type.navigationBars());
break;
default:
break;
}
controller.setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE);
controller.setSystemBarsBehavior(WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE);
}
}
}
Expand Down

0 comments on commit 4216677

Please sign in to comment.