Removed use of theme engine for colorPrimary
This commit is contained in:
parent
8d8149839a
commit
3f50a118f7
32 changed files with 102 additions and 205 deletions
|
@ -1,101 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Hemanth Savarala.
|
||||
*
|
||||
* Licensed under the GNU General Public License v3
|
||||
*
|
||||
* This is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
package code.name.monkey.retromusic.views;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.StyleRes;
|
||||
import androidx.appcompat.app.AppCompatDialogFragment;
|
||||
import code.name.monkey.appthemehelper.ThemeStore;
|
||||
import code.name.monkey.appthemehelper.util.VersionUtils;
|
||||
import code.name.monkey.retromusic.R;
|
||||
import code.name.monkey.retromusic.activities.base.AbsBaseActivity;
|
||||
import code.name.monkey.retromusic.util.RetroUtil;
|
||||
|
||||
/**
|
||||
* Created by yu on 2016/11/10.
|
||||
*/
|
||||
@SuppressLint("RestrictedApi")
|
||||
public class RoundedBottomSheetDialogFragment extends AppCompatDialogFragment {
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
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);
|
||||
bottomSheet.setBackground(RetroUtil.getTintedDrawable(getContext(), R.drawable.bg_bottom_sheet_dialog_fragment, ThemeStore.Companion.primaryColor(getContext())));
|
||||
}
|
||||
});
|
||||
if (getActivity() != null) {
|
||||
if (VersionUtils.INSTANCE.hasNougat()) {
|
||||
((AbsBaseActivity) getActivity()).setNavigationbarColor(ThemeStore.Companion.primaryColor(getContext()));
|
||||
} else {
|
||||
((AbsBaseActivity) getActivity()).setNavigationbarColorAuto();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(@NonNull Bundle savedInstanceState) {
|
||||
//noinspection ConstantConditions
|
||||
return new CustomWidthBottomSheetDialog(getContext(), getTheme());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
if (getDialog() != null && getDialog().getWindow() != null) {
|
||||
Window window = getDialog().getWindow();
|
||||
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
window.setNavigationBarColor(ThemeStore.Companion.primaryColor(getContext()));
|
||||
window.findViewById(com.google.android.material.R.id.container).setFitsSystemWindows(true);
|
||||
}
|
||||
}
|
||||
|
||||
static class CustomWidthBottomSheetDialog extends BottomSheetDialog {
|
||||
CustomWidthBottomSheetDialog(@NonNull Context context, @StyleRes int theme) {
|
||||
super(context, theme);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
int width = getContext().getResources().getDimensionPixelSize(R.dimen.bottom_sheet_width);
|
||||
Objects.requireNonNull(getWindow()).setLayout(width > 0 ? width : ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue