Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #11329 from t895/elevation-bar
Android: Use ElevationOverlay for app bar elevation color
  • Loading branch information
JosJuice committed Dec 10, 2022
2 parents 54e01c6 + f2c71a7 commit 932926a
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 4 deletions.
Expand Up @@ -7,6 +7,7 @@
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.graphics.Insets;
Expand All @@ -16,7 +17,9 @@
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager;

import com.google.android.material.color.MaterialColors;
import com.google.android.material.divider.MaterialDividerItemDecoration;
import com.google.android.material.elevation.ElevationOverlayProvider;

import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.databinding.FragmentCheatListBinding;
Expand Down Expand Up @@ -49,6 +52,13 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
divider.setLastItemDecorated(false);
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();
}

Expand Down
Expand Up @@ -24,6 +24,7 @@

import com.google.android.material.color.MaterialColors;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.elevation.ElevationOverlayProvider;

import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.databinding.ActivityCheatsBinding;
Expand Down Expand Up @@ -112,7 +113,9 @@ protected void onCreate(Bundle savedInstanceState)
setInsets();

@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);
ThemeHelper.setStatusBarColor(this, color);
}
Expand Down
Expand Up @@ -19,6 +19,7 @@
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.appbar.MaterialToolbar;
import com.google.android.material.color.MaterialColors;
import com.google.android.material.elevation.ElevationOverlayProvider;

import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.ui.main.ThemeProvider;
Expand Down Expand Up @@ -222,7 +223,10 @@ public static void enableScrollTint(AppCompatActivity activity, MaterialToolbar
{
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);
setStatusBarColor(activity, color);
}
Expand Down
Expand Up @@ -10,7 +10,7 @@
android:name="org.dolphinemu.dolphinemu.features.cheats.ui.CheatsDisabledWarningFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorSurfaceVariant"
android:background="?attr/colorSurface"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
Expand All @@ -21,7 +21,7 @@
android:name="org.dolphinemu.dolphinemu.features.cheats.ui.GraphicsModsDisabledWarningFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorSurfaceVariant"
android:background="?attr/colorSurface"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/cheats_warning"
Expand Down
2 changes: 2 additions & 0 deletions Source/Android/app/src/main/res/values/dimens.xml
Expand Up @@ -7,4 +7,6 @@
<dimen name="spacing_fab">72dp</dimen>
<dimen name="menu_width">256dp</dimen>
<dimen name="card_width">135dp</dimen>

<dimen name="elevated_app_bar">3dp</dimen>
</resources>

0 comments on commit 932926a

Please sign in to comment.