Skip to content

Commit

Permalink
update 2.3.2-beta02
Browse files Browse the repository at this point in the history
  • Loading branch information
geyifeng committed Nov 7, 2018
1 parent 4eee371 commit 3614c10
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 33 deletions.
11 changes: 3 additions & 8 deletions README.md
Expand Up @@ -9,7 +9,7 @@
- 2.3.1+版本 (由于之前账户密码忘记,所以只能重新更改依赖路径)
```groovy
implementation 'com.gyf.immersionbar:immersionbar:2.3.2-beta01'
implementation 'com.gyf.immersionbar:immersionbar:2.3.2-beta02'
```
- 2.3.0以下版本
```groovy
Expand All @@ -18,7 +18,7 @@

>eclipse
[immersionbar-2.3.2-beta01.jar](https://github.com/gyf-dev/ImmersionBar/blob/master/jar/immersionbar-2.3.2-beta01.jar)
[immersionbar-2.3.2-beta02.jar](https://github.com/gyf-dev/ImmersionBar/blob/master/jar/immersionbar-2.3.2-beta02.jar)

## 版本说明
### [点我](https://github.com/gyf-dev/ImmersionBar/wiki)
Expand Down Expand Up @@ -313,12 +313,7 @@
<img width="300" src="https://github.com/gyf-dev/Screenshots/blob/master/ImmersionBar/whiteStatusBar.png"/>

## 关于结合今日头条屏幕适配
- 有些小伙伴使用fitsSystemWindows(true)方法之后之后,状态栏与标题栏之间仍然会有白色空隙,如果还是想使用fitsSystemWindows方法,请使用两个参数的fitsSystemWindows方法,
第二个参数指定为状态栏颜色就好了,比如

```java
fitsSystemWindows(true,R.color.colorPrimary)
```
- 有些小伙伴使用之后,状态栏与标题栏之间仍然会有白色空隙,请升级为2.3.2-beta02以上版本

## 状态栏和导航栏其它方法

Expand Down
6 changes: 3 additions & 3 deletions barlibrary/build.gradle
Expand Up @@ -38,11 +38,11 @@ dependencies {
}

task makeJar(type: Copy) {
delete 'build/libs/immersionbar-2.3.1.jar'
delete 'build/libs/immersionbar-2.3.2-beta02.jar'
from('build/intermediates/bundles/release/')
into('build/libs/')
include('classes.jar')
rename('classes.jar', 'immersionbar-2.3.2-beta01.jar')
rename('classes.jar', 'immersionbar-2.3.2-beta02.jar')
}

makeJar.dependsOn(build)
Expand All @@ -51,7 +51,7 @@ publish {
userOrg = 'geyifeng'
groupId = 'com.gyf.immersionbar'
artifactId = 'immersionbar'
publishVersion = '2.3.2-beta01'
publishVersion = '2.3.2-beta02'
desc = 'Android bar management'
website = 'https://github.com/gyf-dev/ImmersionBar'
}
37 changes: 22 additions & 15 deletions barlibrary/src/main/java/com/gyf/barlibrary/BarConfig.java
Expand Up @@ -7,13 +7,15 @@
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Build;
import android.provider.Settings;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import android.view.Display;
import android.view.WindowManager;

/**
* Created by geyifeng on 2017/5/11.
* @author geyifeng
* @date 2017/5/11
*/

class BarConfig {
Expand All @@ -22,6 +24,7 @@ class BarConfig {
private static final String NAV_BAR_HEIGHT_RES_NAME = "navigation_bar_height";
private static final String NAV_BAR_HEIGHT_LANDSCAPE_RES_NAME = "navigation_bar_height_landscape";
private static final String NAV_BAR_WIDTH_RES_NAME = "navigation_bar_width";
private static final String MIUI_FORCE_FSG_NAV_BAR = "force_fsg_nav_bar";

private final int mStatusBarHeight;
private final int mActionBarHeight;
Expand All @@ -36,7 +39,7 @@ public BarConfig(Activity activity) {
Resources res = activity.getResources();
mInPortrait = (res.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT);
mSmallestWidthDp = getSmallestWidthDp(activity);
mStatusBarHeight = getInternalDimensionSize(res, STATUS_BAR_HEIGHT_RES_NAME);
mStatusBarHeight = getInternalDimensionSize(STATUS_BAR_HEIGHT_RES_NAME);
mActionBarHeight = getActionBarHeight(activity);
mNavigationBarHeight = getNavigationBarHeight(activity);
mNavigationBarWidth = getNavigationBarWidth(activity);
Expand All @@ -56,7 +59,6 @@ private int getActionBarHeight(Context context) {

@TargetApi(14)
private int getNavigationBarHeight(Context context) {
Resources res = context.getResources();
int result = 0;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
if (hasNavBar((Activity) context)) {
Expand All @@ -66,26 +68,32 @@ private int getNavigationBarHeight(Context context) {
} else {
key = NAV_BAR_HEIGHT_LANDSCAPE_RES_NAME;
}
return getInternalDimensionSize(res, key);
return getInternalDimensionSize(key);
}
}
return result;
}

@TargetApi(14)
private int getNavigationBarWidth(Context context) {
Resources res = context.getResources();
int result = 0;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
if (hasNavBar((Activity) context)) {
return getInternalDimensionSize(res, NAV_BAR_WIDTH_RES_NAME);
return getInternalDimensionSize(NAV_BAR_WIDTH_RES_NAME);
}
}
return result;
}

@TargetApi(14)
private static boolean hasNavBar(Activity activity) {
private boolean hasNavBar(Activity activity) {
//判断小米手机是否开启了全面屏,开启了,直接返回false
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
if (Settings.Global.getInt(activity.getContentResolver(), MIUI_FORCE_FSG_NAV_BAR, 0) != 0) {
return false;
}
}
//其他手机根据屏幕真实高度与显示高度是否相同来判断
WindowManager windowManager = activity.getWindowManager();
Display d = windowManager.getDefaultDisplay();

Expand All @@ -106,15 +114,14 @@ private static boolean hasNavBar(Activity activity) {
return (realWidth - displayWidth) > 0 || (realHeight - displayHeight) > 0;
}

private int getInternalDimensionSize(Resources res, String key) {
private int getInternalDimensionSize(String key) {
int result = 0;
try {
Class clazz = Class.forName("com.android.internal.R$dimen");
Object object = clazz.newInstance();
int resourceId = Integer.parseInt(clazz.getField(key).get(object).toString());
if (resourceId > 0)
result = res.getDimensionPixelSize(resourceId);
} catch (Exception e) {
int resourceId = Resources.getSystem().getIdentifier(key, "dimen", "android");
if (resourceId > 0) {
result = Resources.getSystem().getDimensionPixelSize(resourceId);
}
} catch (Resources.NotFoundException e) {
e.printStackTrace();
}
return result;
Expand Down Expand Up @@ -168,7 +175,7 @@ public int getActionBarHeight() {
*
* @return True if this device uses soft key navigation, False otherwise.
*/
public boolean hasNavigtionBar() {
public boolean hasNavigationBar() {
return mHasNavigationBar;
}

Expand Down
12 changes: 6 additions & 6 deletions barlibrary/src/main/java/com/gyf/barlibrary/ImmersionBar.java
Expand Up @@ -1498,7 +1498,7 @@ private int initBarAboveLOLLIPOP(int uiFlags) {
uiFlags |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION; //Activity全屏显示,但导航栏不会被隐藏覆盖,导航栏依然可见,Activity底部布局部分会被导航栏遮住。
}
mWindow.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
if (mConfig.hasNavigtionBar()) { //判断是否存在导航栏
if (mConfig.hasNavigationBar()) { //判断是否存在导航栏
mWindow.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
}
mWindow.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); //需要设置这个才能设置状态栏颜色
Expand All @@ -1520,7 +1520,7 @@ private int initBarAboveLOLLIPOP(int uiFlags) {
private void initBarBelowLOLLIPOP() {
mWindow.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);//透明状态栏
setupStatusBarView(); //创建一个假的状态栏
if (mConfig.hasNavigtionBar()) { //判断是否存在导航栏,是否禁止设置导航栏
if (mConfig.hasNavigationBar()) { //判断是否存在导航栏,是否禁止设置导航栏
if (mBarParams.navigationBarEnable && mBarParams.navigationBarWithKitkatEnable)
mWindow.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);//透明导航栏,设置这个,如果有导航栏,底部布局会被导航栏遮住
else
Expand Down Expand Up @@ -1613,7 +1613,7 @@ private void solveNavigation() {

}
// 解决android4.4有导航栏的情况下,activity底部被导航栏遮挡的问题
if (mConfig.hasNavigtionBar() && !mBarParams.fullScreenTemp && !mBarParams.fullScreen) {
if (mConfig.hasNavigationBar() && !mBarParams.fullScreenTemp && !mBarParams.fullScreen) {
if (mConfig.isNavigationAtBottom()) { //判断导航栏是否在底部
if (!mBarParams.isSupportActionBar) { //判断是否支持actionBar
if (mBarParams.navigationBarEnable && mBarParams.navigationBarWithKitkatEnable) {
Expand Down Expand Up @@ -1679,7 +1679,7 @@ private void solveNavigation() {
* Register emui 3 x.
*/
private void registerEMUI3_x() {
if ((OSUtils.isEMUI3_1() || OSUtils.isEMUI3_0()) && mConfig.hasNavigtionBar()
if ((OSUtils.isEMUI3_1() || OSUtils.isEMUI3_0()) && mConfig.hasNavigationBar()
&& mBarParams.navigationBarEnable && mBarParams.navigationBarWithKitkatEnable) {
if (mBarParams.navigationStatusObserver == null && mBarParams.navigationBarView != null) {
mBarParams.navigationStatusObserver = new ContentObserver(new Handler()) {
Expand Down Expand Up @@ -1719,7 +1719,7 @@ public void onChange(boolean selfChange) {
* Un register emui 3 x.
*/
private void unRegisterEMUI3_x() {
if ((OSUtils.isEMUI3_1() || OSUtils.isEMUI3_0()) && mConfig.hasNavigtionBar()
if ((OSUtils.isEMUI3_1() || OSUtils.isEMUI3_0()) && mConfig.hasNavigationBar()
&& mBarParams.navigationBarEnable && mBarParams.navigationBarWithKitkatEnable) {
if (mActivity != null && mActivity.getContentResolver() != null &&
mBarParams.navigationStatusObserver != null && mBarParams.navigationBarView != null)
Expand Down Expand Up @@ -2022,7 +2022,7 @@ public static void setFitsSystemWindows(Activity activity) {
@TargetApi(14)
public static boolean hasNavigationBar(Activity activity) {
BarConfig config = new BarConfig(activity);
return config.hasNavigtionBar();
return config.hasNavigationBar();
}

/**
Expand Down
Binary file added jar/immersionbar-2.3.2-beta02.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion sample/build.gradle
Expand Up @@ -8,7 +8,7 @@ android {
minSdkVersion 18
targetSdkVersion 27
versionCode 1
versionName "2.3.2-beta01"
versionName "2.3.2-beta02"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand Down

0 comments on commit 3614c10

Please sign in to comment.