Skip to content

Commit

Permalink
update 2.3.3-beta02,fix ImmersionFragment bug
Browse files Browse the repository at this point in the history
  • Loading branch information
geyifeng committed Nov 21, 2018
1 parent 2049271 commit bf5d963
Show file tree
Hide file tree
Showing 21 changed files with 49 additions and 55 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
- 2.3.1+版本 (由于之前账户密码忘记,所以只能重新更改依赖路径)
```groovy
implementation 'com.gyf.immersionbar:immersionbar:2.3.2'
implementation 'com.gyf.immersionbar:immersionbar:2.3.3-beta02'
```
- 2.3.0以下版本
```groovy
Expand All @@ -18,13 +18,13 @@

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

## 版本说明
### [点我查看版本说明](https://github.com/gyf-dev/ImmersionBar/wiki)

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

## 关于全面屏与刘海
### 关于全面屏
Expand Down
Binary file removed apk/immersionBar-2.3.2.apk
Binary file not shown.
Binary file added apk/immersionBar-2.3.3-beta02.apk
Binary file not shown.
6 changes: 3 additions & 3 deletions barlibrary/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ dependencies {
}

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

makeJar.dependsOn(build)
Expand All @@ -51,7 +51,7 @@ publish {
userOrg = 'geyifeng'
groupId = 'com.gyf.immersionbar'
artifactId = 'immersionbar'
publishVersion = '2.3.2'
publishVersion = '2.3.3-beta02'
desc = 'Android bar management'
website = 'https://github.com/gyf-dev/ImmersionBar'
}
2 changes: 1 addition & 1 deletion barlibrary/src/main/java/com/gyf/barlibrary/BarConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ private boolean hasNavBar(Activity activity) {
private int getInternalDimensionSize(Context context, String key) {
int result = 0;
try {
int resourceId = Resources.getSystem().getIdentifier(key, "dimen", "android");
int resourceId = context.getResources().getIdentifier(key, "dimen", "android");
if (resourceId > 0) {
result = Math.max(context.getResources().getDimensionPixelSize(resourceId),
Resources.getSystem().getDimensionPixelSize(resourceId));
Expand Down
34 changes: 17 additions & 17 deletions barlibrary/src/main/java/com/gyf/barlibrary/ImmersionBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public class ImmersionBar {
private static final int IMMERSION_STATUS_BAR_VIEW = R.id.immersion_status_bar_view;
private static final int IMMERSION_NAVIGATION_BAR_VIEW = R.id.immersion_navigation_bar_view;
private static final String NAVIGATIONBAR_IS_MIN = "navigationbar_is_min";
private static final String MIUI_STATUS_BAR_DARK = "EXTRA_FLAG_STATUS_BAR_DARK_MODE";
private static final String MIUI_NAVIGATION_BAR_DARK = "EXTRA_FLAG_NAVIGATION_BAR_DARK_MODE";

private static final int FLAG_FITS_DEFAULT = 0X00;
private static final int FLAG_FITS_TITLE = 0X01;
Expand Down Expand Up @@ -1642,18 +1644,18 @@ private void setBar() {
fitsWindows();
mDecorView.setSystemUiVisibility(uiFlags);
}
//修改miui状态栏字体颜色
if (OSUtils.isMIUI6Later()) {
setMIUIStatusBarDarkFont(mWindow, mBarParams.statusBarDarkFont);
//修改miui状态栏字体颜色
setMIUIBarDark(mWindow, MIUI_STATUS_BAR_DARK, mBarParams.statusBarDarkFont);
//修改miui导航栏图标为黑色
setMIUIBarDark(mWindow, MIUI_NAVIGATION_BAR_DARK, mBarParams.navigationBarDarkIcon);
}
// 修改Flyme OS状态栏字体颜色
if (OSUtils.isFlymeOS4Later()) {
if (mBarParams.flymeOSStatusBarFontColor != 0) {
FlymeOSStatusBarFontUtils.setStatusBarDarkIcon(mActivity, mBarParams.flymeOSStatusBarFontColor);
} else {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
FlymeOSStatusBarFontUtils.setStatusBarDarkIcon(mActivity, mBarParams.statusBarDarkFont);
}
FlymeOSStatusBarFontUtils.setStatusBarDarkIcon(mActivity, mBarParams.statusBarDarkFont);
}
}
}
Expand Down Expand Up @@ -1851,6 +1853,7 @@ private void fitsWindows() {
*/
private void fitsWindowsAboveLOLLIPOP() {
if (checkFitsSystemWindows(mDecorView.findViewById(android.R.id.content))) {
mIsFitsLayoutOverlap = true;
if (mBarParams.isSupportActionBar) {
setPadding(0, mBarConfig.getActionBarHeight(), 0, 0);
}
Expand All @@ -1872,6 +1875,7 @@ private void fitsWindowsAboveLOLLIPOP() {
*/
private void fitsWindowsBelowLOLLIPOP() {
if (checkFitsSystemWindows(mDecorView.findViewById(android.R.id.content))) {
mIsFitsLayoutOverlap = true;
if (mBarParams.isSupportActionBar) {
setPadding(0, mBarConfig.getActionBarHeight(), 0, 0);
}
Expand Down Expand Up @@ -1992,23 +1996,17 @@ private int setNavigationIconDark(int uiFlags) {
}
}

/**
* 设置状态栏字体图标为深色,需要MIUIV6以上
*
* @param window the window
* @param darkFont the dark font
*/
@SuppressLint("PrivateApi")
private void setMIUIStatusBarDarkFont(Window window, boolean darkFont) {
private void setMIUIBarDark(Window window, String key, boolean dark) {
if (window != null) {
Class<? extends Window> clazz = window.getClass();
try {
int darkModeFlag;
Class<?> layoutParams = Class.forName("android.view.MiuiWindowManager$LayoutParams");
Field field = layoutParams.getField("EXTRA_FLAG_STATUS_BAR_DARK_MODE");
Field field = layoutParams.getField(key);
darkModeFlag = field.getInt(layoutParams);
Method extraFlagField = clazz.getMethod("setExtraFlags", int.class, int.class);
if (darkFont) {
if (dark) {
//状态栏透明且黑色字体
extraFlagField.invoke(window, darkModeFlag, darkModeFlag);
} else {
Expand Down Expand Up @@ -2182,7 +2180,7 @@ public static boolean isSupportStatusBarDarkFont() {
* @return the boolean
*/
public static boolean isSupportNavigationIconDark() {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.O;
return OSUtils.isMIUI6Later() || Build.VERSION.SDK_INT >= Build.VERSION_CODES.O;
}

/**
Expand Down Expand Up @@ -2289,7 +2287,7 @@ public static void setFitsSystemWindows(Activity activity) {
}

/**
* 检查布局是否使用了android:fitsSystemWindows="true"属性
* 检查布局根节点是否使用了android:fitsSystemWindows="true"属性
* Check fits system windows boolean.
*
* @param view the view
Expand All @@ -2304,7 +2302,9 @@ public static boolean checkFitsSystemWindows(View view) {
for (int i = 0, count = viewGroup.getChildCount(); i < count; i++) {
View childView = viewGroup.getChildAt(i);
if (childView instanceof DrawerLayout) {
continue;
if (checkFitsSystemWindows(childView)) {
return true;
}
}
if (childView.getFitsSystemWindows()) {
return true;
Expand Down
15 changes: 3 additions & 12 deletions barlibrary/src/main/java/com/gyf/barlibrary/ImmersionProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ public void setUserVisibleHint(boolean isVisibleToUser) {
}

public void onResume() {
mIsFirstShow = true;
if (mFragment.getUserVisibleHint()) {
mVisible = true;
mImmersionOwner.onVisible();
if (mImmersionOwner.immersionBarEnabled()) {
if (mImmersionOwner.immersionBarEnabled() && !mIsFirstShow) {
mImmersionOwner.initImmersionBar();
}
}
mIsFirstShow = true;
}

public void onPause() {
Expand All @@ -80,15 +80,6 @@ public void onConfigurationChanged(Configuration newConfig) {
}

public void onHiddenChanged(boolean hidden) {
if (hidden) {
mVisible = false;
mImmersionOwner.onInvisible();
} else {
mVisible = true;
mImmersionOwner.onVisible();
if (mImmersionOwner.immersionBarEnabled()) {
mImmersionOwner.initImmersionBar();
}
}
mFragment.setUserVisibleHint(!hidden);
}
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Thu Nov 08 22:22:29 CST 2018
#Sat Nov 17 20:41:45 CST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
Expand Down
Binary file added jar/immersionbar-2.3.3-beta02.aar
Binary file not shown.
2 changes: 1 addition & 1 deletion sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ android {
minSdkVersion 18
targetSdkVersion 28
versionCode 1
versionName "2.3.2"
versionName "2.3.3-beta02"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void onAttach(Context context) {
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
mRootView = inflater.inflate(setLayoutId(), container, false);
mRootView = inflater.inflate(getLayoutId(), container, false);
return mRootView;
}

Expand All @@ -64,11 +64,11 @@ public void onDestroy() {
}

/**
* Sets layout id.
* Gets layout id.
*
* @return the layout id
*/
protected abstract int setLayoutId();
protected abstract int getLayoutId();


@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ protected int setLayoutId() {
@Override
public void initImmersionBar() {
super.initImmersionBar();
ImmersionBar.with(this).navigationBarColor(R.color.btn2).keyboardEnable(false).init();
ImmersionBar.with(this)
.navigationBarColor(R.color.btn2)
.keyboardEnable(false)
.statusBarDarkFont(true, 0.2f)
.navigationBarDarkIcon(true)
.init();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
public class CategoryOneFragment extends BaseFragment {

@Override
protected int setLayoutId() {
protected int getLayoutId() {
return R.layout.fragment_one_category;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class HomeOneFragment extends BaseFragment {
private int bannerHeight;

@Override
protected int setLayoutId() {
protected int getLayoutId() {
return R.layout.fragment_one_home;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
public class MineOneFragment extends BaseFragment {

@Override
protected int setLayoutId() {
protected int getLayoutId() {
return R.layout.fragment_one_mine;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
public class ServiceOneFragment extends BaseFragment {

@Override
protected int setLayoutId() {
protected int getLayoutId() {
return R.layout.fragment_one_service;
}

Expand All @@ -20,6 +20,7 @@ public void initImmersionBar() {
super.initImmersionBar();
ImmersionBar.with(this)
.navigationBarColor(R.color.btn13)
.navigationBarDarkIcon(true)
.keyboardEnable(false)
.init();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
public class CategoryTwoFragment extends BaseFragment {

@Override
protected int setLayoutId() {
protected int getLayoutId() {
return R.layout.fragment_two_category;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
*/

public class HomeTwoFragment extends BaseFragment {

@Override
protected int setLayoutId() {
protected int getLayoutId() {
return R.layout.fragment_two_home;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
public class MineTwoFragment extends BaseFragment {

@Override
protected int setLayoutId() {
protected int getLayoutId() {
return R.layout.fragment_two_mine;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
public class ServiceTwoFragment extends BaseFragment {
@Override
protected int setLayoutId() {
protected int getLayoutId() {
return R.layout.fragment_two_service;
}

Expand All @@ -20,6 +20,7 @@ public void initImmersionBar() {
ImmersionBar.with(this)
.statusBarDarkFont(true, 0.2f)
.navigationBarColor(R.color.btn2)
.navigationBarDarkIcon(true)
.keyboardEnable(false)
.init();
}
Expand Down
5 changes: 0 additions & 5 deletions sample/src/main/res/layout/fragment_two_home.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@
android:text="向上滑动试试"
android:textSize="20sp" />

<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>

Expand Down

0 comments on commit bf5d963

Please sign in to comment.