From 9c57d6028dfad63b95c805e629d89b0eb806e6e6 Mon Sep 17 00:00:00 2001 From: Charles Lombardo Date: Tue, 20 Dec 2022 16:39:17 -0500 Subject: [PATCH] Android: Elevate ingame menu fragment with color Whenever the app is not using the default theme, the ingame menu fragment will be treated as an elevated component like an alert dialog. --- .../dolphinemu/fragments/MenuFragment.java | 14 ++++++++++++++ .../src/main/res/layout/fragment_ingame_menu.xml | 1 + 2 files changed, 15 insertions(+) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/MenuFragment.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/MenuFragment.java index fdd67507f1..16da69db43 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/MenuFragment.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/MenuFragment.java @@ -11,6 +11,7 @@ import android.view.ViewGroup; import android.widget.Button; import android.widget.LinearLayout; +import androidx.annotation.ColorInt; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.core.graphics.Insets; @@ -18,12 +19,17 @@ import androidx.core.view.ViewCompat; import androidx.core.view.WindowInsetsCompat; import androidx.fragment.app.Fragment; +import com.google.android.material.color.MaterialColors; +import com.google.android.material.elevation.ElevationOverlayProvider; + import org.dolphinemu.dolphinemu.NativeLibrary; import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.activities.EmulationActivity; import org.dolphinemu.dolphinemu.databinding.FragmentIngameMenuBinding; import org.dolphinemu.dolphinemu.features.settings.model.BooleanSetting; +import org.dolphinemu.dolphinemu.features.settings.model.IntSetting; import org.dolphinemu.dolphinemu.utils.InsetsHelper; +import org.dolphinemu.dolphinemu.utils.ThemeHelper; public final class MenuFragment extends Fragment implements View.OnClickListener { @@ -85,6 +91,14 @@ public final class MenuFragment extends Fragment implements View.OnClickListener @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { + if (IntSetting.MAIN_INTERFACE_THEME.getIntGlobal() != ThemeHelper.DEFAULT) + { + @ColorInt int color = new ElevationOverlayProvider(view.getContext()).compositeOverlay( + MaterialColors.getColor(view, R.attr.colorSurface), + view.getElevation()); + view.setBackgroundColor(color); + } + setInsets(); updatePauseUnpauseVisibility(); diff --git a/Source/Android/app/src/main/res/layout/fragment_ingame_menu.xml b/Source/Android/app/src/main/res/layout/fragment_ingame_menu.xml index 69ed1ddd35..8507372b92 100644 --- a/Source/Android/app/src/main/res/layout/fragment_ingame_menu.xml +++ b/Source/Android/app/src/main/res/layout/fragment_ingame_menu.xml @@ -6,6 +6,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:background="?attr/colorSurface" + android:elevation="3dp" tools:layout_width="250dp">