Skip to content
This repository has been archived by the owner on Jan 14, 2025. It is now read-only.

Commit

Permalink
Fixed fitSystemWindow
Browse files Browse the repository at this point in the history
- fixed #1
  • Loading branch information
danimahardhika authored May 7, 2017
1 parent 1d63c51 commit 1edeb50
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions library/src/main/java/com/danimahardhika/cafebar/CafeBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import android.graphics.Point;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.support.annotation.BoolRes;
import android.support.annotation.DrawableRes;
import android.support.annotation.IntRange;
Expand Down Expand Up @@ -393,7 +394,7 @@ public static class Builder {
private boolean mFitSystemWindow = false;
private boolean mFloating = false;
private boolean mAdjustCustomView = false;
private boolean mFilterIconColor = true;
private boolean mTintIcon = true;
private boolean mSwipeToDismiss = true;

private Typeface mContentTypeface;
Expand Down Expand Up @@ -490,21 +491,21 @@ public Builder icon(@DrawableRes int res) {
return this;
}

public Builder icon(@Nullable Drawable icon, boolean filterIconColor) {
public Builder icon(@Nullable Drawable icon, boolean tintIcon) {
mIcon = icon;
mFilterIconColor = filterIconColor;
mTintIcon = tintIcon;
return this;
}

public Builder icon(@Nullable Bitmap icon, boolean filterIconColor) {
public Builder icon(@Nullable Bitmap icon, boolean tintIcon) {
mIcon = CafeBarUtil.toDrawable(mContext, icon);
mFilterIconColor = filterIconColor;
mTintIcon = tintIcon;
return this;
}

public Builder icon(@DrawableRes int res, boolean filterIconColor) {
public Builder icon(@DrawableRes int res, boolean tintIcon) {
mIcon = CafeBarUtil.getDrawable(mContext, res);
mFilterIconColor = filterIconColor;
mTintIcon = tintIcon;
return this;
}

Expand Down Expand Up @@ -570,13 +571,19 @@ public Builder fitSystemWindow(boolean fitSystemWindow) {
}

public Builder fitSystemWindow() {
Window window = ((Activity) mContext).getWindow();
Activity activity = (Activity) mContext;
Window window = activity.getWindow();
WindowManager.LayoutParams params = window.getAttributes();
int navigationBarHeight = CafeBarUtil.getNavigationBarHeight(mContext);

boolean isInMultiWindowMode = false;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
isInMultiWindowMode = activity.isInMultiWindowMode();
}

if ((params.flags & WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION) ==
WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION) {
mFitSystemWindow = navigationBarHeight > 0;
mFitSystemWindow = navigationBarHeight > 0 && !isInMultiWindowMode;
}
return this;
}
Expand Down Expand Up @@ -790,7 +797,7 @@ Drawable icon() {
}

boolean filterIconColor() {
return mFilterIconColor;
return mTintIcon;
}

@NonNull
Expand Down

0 comments on commit 1edeb50

Please sign in to comment.