Merge pull request #11329 from t895/elevation-bar
Android: Use ElevationOverlay for app bar elevation color
This commit is contained in:
commit
932926a4aa
|
@ -7,6 +7,7 @@ import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import androidx.annotation.ColorInt;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.core.graphics.Insets;
|
import androidx.core.graphics.Insets;
|
||||||
|
@ -16,7 +17,9 @@ import androidx.fragment.app.Fragment;
|
||||||
import androidx.lifecycle.ViewModelProvider;
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
|
||||||
|
import com.google.android.material.color.MaterialColors;
|
||||||
import com.google.android.material.divider.MaterialDividerItemDecoration;
|
import com.google.android.material.divider.MaterialDividerItemDecoration;
|
||||||
|
import com.google.android.material.elevation.ElevationOverlayProvider;
|
||||||
|
|
||||||
import org.dolphinemu.dolphinemu.R;
|
import org.dolphinemu.dolphinemu.R;
|
||||||
import org.dolphinemu.dolphinemu.databinding.FragmentCheatListBinding;
|
import org.dolphinemu.dolphinemu.databinding.FragmentCheatListBinding;
|
||||||
|
@ -49,6 +52,13 @@ public class CheatListFragment extends Fragment
|
||||||
divider.setLastItemDecorated(false);
|
divider.setLastItemDecorated(false);
|
||||||
mBinding.cheatList.addItemDecoration(divider);
|
mBinding.cheatList.addItemDecoration(divider);
|
||||||
|
|
||||||
|
@ColorInt int color =
|
||||||
|
new ElevationOverlayProvider(mBinding.cheatsWarning.getContext()).compositeOverlay(
|
||||||
|
MaterialColors.getColor(mBinding.cheatsWarning, R.attr.colorSurface),
|
||||||
|
getResources().getDimensionPixelSize(R.dimen.elevated_app_bar));
|
||||||
|
mBinding.cheatsWarning.setBackgroundColor(color);
|
||||||
|
mBinding.gfxModsWarning.setBackgroundColor(color);
|
||||||
|
|
||||||
setInsets();
|
setInsets();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ import androidx.slidingpanelayout.widget.SlidingPaneLayout;
|
||||||
|
|
||||||
import com.google.android.material.color.MaterialColors;
|
import com.google.android.material.color.MaterialColors;
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||||
|
import com.google.android.material.elevation.ElevationOverlayProvider;
|
||||||
|
|
||||||
import org.dolphinemu.dolphinemu.R;
|
import org.dolphinemu.dolphinemu.R;
|
||||||
import org.dolphinemu.dolphinemu.databinding.ActivityCheatsBinding;
|
import org.dolphinemu.dolphinemu.databinding.ActivityCheatsBinding;
|
||||||
|
@ -112,7 +113,9 @@ public class CheatsActivity extends AppCompatActivity
|
||||||
setInsets();
|
setInsets();
|
||||||
|
|
||||||
@ColorInt int color =
|
@ColorInt int color =
|
||||||
MaterialColors.getColor(mBinding.toolbarCheats, R.attr.colorSurfaceVariant);
|
new ElevationOverlayProvider(mBinding.toolbarCheats.getContext()).compositeOverlay(
|
||||||
|
MaterialColors.getColor(mBinding.toolbarCheats, R.attr.colorSurface),
|
||||||
|
getResources().getDimensionPixelSize(R.dimen.elevated_app_bar));
|
||||||
mBinding.toolbarCheats.setBackgroundColor(color);
|
mBinding.toolbarCheats.setBackgroundColor(color);
|
||||||
ThemeHelper.setStatusBarColor(this, color);
|
ThemeHelper.setStatusBarColor(this, color);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ import androidx.preference.PreferenceManager;
|
||||||
import com.google.android.material.appbar.AppBarLayout;
|
import com.google.android.material.appbar.AppBarLayout;
|
||||||
import com.google.android.material.appbar.MaterialToolbar;
|
import com.google.android.material.appbar.MaterialToolbar;
|
||||||
import com.google.android.material.color.MaterialColors;
|
import com.google.android.material.color.MaterialColors;
|
||||||
|
import com.google.android.material.elevation.ElevationOverlayProvider;
|
||||||
|
|
||||||
import org.dolphinemu.dolphinemu.R;
|
import org.dolphinemu.dolphinemu.R;
|
||||||
import org.dolphinemu.dolphinemu.ui.main.ThemeProvider;
|
import org.dolphinemu.dolphinemu.ui.main.ThemeProvider;
|
||||||
|
@ -222,7 +223,10 @@ public class ThemeHelper
|
||||||
{
|
{
|
||||||
if (-verticalOffset >= (layout.getTotalScrollRange() / 2))
|
if (-verticalOffset >= (layout.getTotalScrollRange() / 2))
|
||||||
{
|
{
|
||||||
@ColorInt int color = MaterialColors.getColor(toolbar, R.attr.colorSurfaceVariant);
|
@ColorInt int color =
|
||||||
|
new ElevationOverlayProvider(appBarLayout.getContext()).compositeOverlay(
|
||||||
|
MaterialColors.getColor(appBarLayout, R.attr.colorSurface),
|
||||||
|
activity.getResources().getDimensionPixelSize(R.dimen.elevated_app_bar));
|
||||||
toolbar.setBackgroundColor(color);
|
toolbar.setBackgroundColor(color);
|
||||||
setStatusBarColor(activity, color);
|
setStatusBarColor(activity, color);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
android:name="org.dolphinemu.dolphinemu.features.cheats.ui.CheatsDisabledWarningFragment"
|
android:name="org.dolphinemu.dolphinemu.features.cheats.ui.CheatsDisabledWarningFragment"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="?attr/colorSurfaceVariant"
|
android:background="?attr/colorSurface"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
@ -21,7 +21,7 @@
|
||||||
android:name="org.dolphinemu.dolphinemu.features.cheats.ui.GraphicsModsDisabledWarningFragment"
|
android:name="org.dolphinemu.dolphinemu.features.cheats.ui.GraphicsModsDisabledWarningFragment"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="?attr/colorSurfaceVariant"
|
android:background="?attr/colorSurface"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/cheats_warning"
|
app:layout_constraintTop_toBottomOf="@id/cheats_warning"
|
||||||
|
|
|
@ -7,4 +7,6 @@
|
||||||
<dimen name="spacing_fab">72dp</dimen>
|
<dimen name="spacing_fab">72dp</dimen>
|
||||||
<dimen name="menu_width">256dp</dimen>
|
<dimen name="menu_width">256dp</dimen>
|
||||||
<dimen name="card_width">135dp</dimen>
|
<dimen name="card_width">135dp</dimen>
|
||||||
|
|
||||||
|
<dimen name="elevated_app_bar">3dp</dimen>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in New Issue