v2.10
This commit is contained in:
parent
3d7ba2afc6
commit
08e00b89c5
341 changed files with 7612 additions and 6811 deletions
|
@ -0,0 +1,77 @@
|
|||
package code.name.monkey.retromusic.views;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Build;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.WindowInsets;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
public class FitSystemWindowsLayout extends FrameLayout {
|
||||
private boolean mFit = false;
|
||||
|
||||
public FitSystemWindowsLayout(final Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public FitSystemWindowsLayout(final Context context, final AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public FitSystemWindowsLayout(final Context context, final AttributeSet attrs, final int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
public boolean isFit() {
|
||||
return mFit;
|
||||
}
|
||||
|
||||
public void setFit(final boolean fit) {
|
||||
if (mFit == fit) {
|
||||
return;
|
||||
}
|
||||
|
||||
mFit = fit;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
|
||||
requestApplyInsets();
|
||||
} else {
|
||||
//noinspection deprecation
|
||||
requestFitSystemWindows();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
protected boolean fitSystemWindows(final Rect insets) {
|
||||
if (mFit) {
|
||||
setPadding(
|
||||
insets.left,
|
||||
insets.top,
|
||||
insets.right,
|
||||
insets.bottom
|
||||
);
|
||||
return true;
|
||||
} else {
|
||||
setPadding(0, 0, 0, 0);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.KITKAT_WATCH)
|
||||
@Override
|
||||
public WindowInsets onApplyWindowInsets(final WindowInsets insets) {
|
||||
if (mFit) {
|
||||
setPadding(
|
||||
insets.getSystemWindowInsetLeft(),
|
||||
insets.getSystemWindowInsetTop(),
|
||||
insets.getSystemWindowInsetRight(),
|
||||
insets.getSystemWindowInsetBottom()
|
||||
);
|
||||
return insets.consumeSystemWindowInsets();
|
||||
} else {
|
||||
setPadding(0, 0, 0, 0);
|
||||
return insets;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,10 +2,11 @@ package code.name.monkey.retromusic.views;
|
|||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Dialog;
|
||||
import android.os.Build;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.Window;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
|
@ -13,13 +14,14 @@ import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
|||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import code.name.monkey.appthemehelper.ThemeStore;
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil;
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil;
|
||||
import code.name.monkey.retromusic.R;
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil;
|
||||
import code.name.monkey.retromusic.ui.activities.base.AbsBaseActivity;
|
||||
|
||||
/**
|
||||
* Created by yu on 2016/11/10.
|
||||
|
@ -27,12 +29,12 @@ import code.name.monkey.retromusic.util.PreferenceUtil;
|
|||
@SuppressLint("RestrictedApi")
|
||||
public class RoundedBottomSheetDialogFragment extends BottomSheetDialogFragment {
|
||||
|
||||
@Override
|
||||
/* @Override
|
||||
public int getTheme() {
|
||||
//noinspection ConstantConditions
|
||||
if (PreferenceUtil.getInstance(getContext()).getGeneralTheme() == R.style.Theme_RetroMusic_Light) {
|
||||
if (PreferenceUtil.getInstance().getGeneralTheme() == R.style.Theme_RetroMusic_Light) {
|
||||
return R.style.BottomSheetDialogTheme;
|
||||
} else if (PreferenceUtil.getInstance(getContext()).getGeneralTheme() == R.style.Theme_RetroMusic_Color) {
|
||||
} else if (PreferenceUtil.getInstance().getGeneralTheme() == R.style.Theme_RetroMusic_Color) {
|
||||
int color = ThemeStore.primaryColor(getContext());
|
||||
if (ColorUtil.isColorLight(color)) {
|
||||
return R.style.BottomSheetDialogTheme;
|
||||
|
@ -42,40 +44,40 @@ public class RoundedBottomSheetDialogFragment extends BottomSheetDialogFragment
|
|||
} else {
|
||||
return R.style.BottomSheetDialogTheme;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
view.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
@Override
|
||||
public void onGlobalLayout() {
|
||||
BottomSheetDialog dialog = (BottomSheetDialog) getDialog();
|
||||
FrameLayout bottomSheet = (FrameLayout) dialog.findViewById(R.id.design_bottom_sheet);
|
||||
view.getViewTreeObserver().addOnGlobalLayoutListener(() -> {
|
||||
BottomSheetDialog dialog = (BottomSheetDialog) getDialog();
|
||||
FrameLayout bottomSheet = dialog.findViewById(R.id.design_bottom_sheet);
|
||||
|
||||
if (bottomSheet != null) {
|
||||
BottomSheetBehavior behavior = BottomSheetBehavior.from(bottomSheet);
|
||||
behavior.setState(BottomSheetBehavior.STATE_EXPANDED);
|
||||
//behavior.setPeekHeight(0);
|
||||
}
|
||||
});
|
||||
view.setBackground(ContextCompat.getDrawable(view.getContext(), R.drawable.bg_bottom_sheet_dialog_fragment));
|
||||
view.setBackgroundTintList(ColorStateList.valueOf(ThemeStore.primaryColor(view.getContext())));
|
||||
((AbsBaseActivity) Objects.requireNonNull(getActivity())).setNavigationbarColorAuto();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
//noinspection ConstantConditions
|
||||
return new BottomSheetDialog(getContext(), getTheme());
|
||||
return new BottomSheetDialog(getContext());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
if (getDialog() != null && getDialog().getWindow() != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
if (getDialog() != null && getDialog().getWindow() != null) {
|
||||
Window window = getDialog().getWindow();
|
||||
window.findViewById(com.google.android.material.R.id.container).setFitsSystemWindows(false);
|
||||
// dark navigation bar icons
|
||||
View decorView = window.getDecorView();
|
||||
if (!ATHUtil.isWindowBackgroundDark(getContext()))
|
||||
decorView.setSystemUiVisibility(decorView.getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
|
||||
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
window.setNavigationBarColor(ThemeStore.primaryColor(getContext()));
|
||||
window.findViewById(com.google.android.material.R.id.container).setFitsSystemWindows(true);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue