diff options
| author | JosJuice <josjuice@gmail.com> | 2022-10-23 21:20:06 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-23 21:20:06 +0200 |
| commit | d442f3f2e0699564157f45f1cee8fe9e7dde7b65 (patch) | |
| tree | 59a61944ccf50547da9ff7e027ca8273eccd6902 /Source/Android/app/src | |
| parent | 9654d9a72b26601fbda964a8971045cb9b52380b (diff) | |
| parent | 90d27be1d6246ecde3412464c2af2988b2b11bb6 (diff) | |
Merge pull request #11079 from t895/system-windows
Android: Do not fit system windows
Diffstat (limited to 'Source/Android/app/src')
27 files changed, 551 insertions, 159 deletions
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/ConvertActivity.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/ConvertActivity.java index bd05f751ed..2ba35c4d26 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/ConvertActivity.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/ConvertActivity.java @@ -5,8 +5,11 @@ package org.dolphinemu.dolphinemu.activities; import android.content.Context; import android.content.Intent; import android.os.Bundle; +import android.view.View; import androidx.appcompat.app.AppCompatActivity; +import androidx.core.view.WindowCompat; +import androidx.core.widget.NestedScrollView; import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.appbar.CollapsingToolbarLayout; @@ -14,6 +17,7 @@ import com.google.android.material.appbar.MaterialToolbar; import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.fragments.ConvertFragment; +import org.dolphinemu.dolphinemu.utils.InsetsHelper; import org.dolphinemu.dolphinemu.utils.ThemeHelper; public class ConvertActivity extends AppCompatActivity @@ -36,6 +40,8 @@ public class ConvertActivity extends AppCompatActivity setContentView(R.layout.activity_convert); + WindowCompat.setDecorFitsSystemWindows(getWindow(), false); + String path = getIntent().getStringExtra(ARG_GAME_PATH); ConvertFragment fragment = (ConvertFragment) getSupportFragmentManager() @@ -53,7 +59,10 @@ public class ConvertActivity extends AppCompatActivity getSupportActionBar().setDisplayHomeAsUpEnabled(true); AppBarLayout appBarLayout = findViewById(R.id.appbar_convert); - ThemeHelper.enableScrollTint(tb, appBarLayout, this); + NestedScrollView scrollView = findViewById(R.id.scroll_view_convert); + View workaroundView = findViewById(R.id.workaround_view); + InsetsHelper.setUpAppBarWithScrollView(this, appBarLayout, scrollView, workaroundView); + ThemeHelper.enableScrollTint(this, tb, appBarLayout); } @Override diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/UserDataActivity.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/UserDataActivity.java index 02ee1bcc82..9f6a211cd9 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/UserDataActivity.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/UserDataActivity.java @@ -15,7 +15,8 @@ import android.widget.TextView; import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; -import androidx.appcompat.widget.Toolbar; +import androidx.core.view.WindowCompat; +import androidx.core.widget.NestedScrollView; import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.appbar.MaterialToolbar; @@ -23,6 +24,7 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder; import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.utils.DirectoryInitialization; +import org.dolphinemu.dolphinemu.utils.InsetsHelper; import org.dolphinemu.dolphinemu.utils.Log; import org.dolphinemu.dolphinemu.utils.ThemeHelper; import org.dolphinemu.dolphinemu.utils.ThreadUtil; @@ -61,6 +63,8 @@ public class UserDataActivity extends AppCompatActivity setContentView(R.layout.activity_user_data); + WindowCompat.setDecorFitsSystemWindows(getWindow(), false); + TextView textType = findViewById(R.id.text_type); TextView textPath = findViewById(R.id.text_path); TextView textAndroid11 = findViewById(R.id.text_android_11); @@ -92,7 +96,10 @@ public class UserDataActivity extends AppCompatActivity getSupportActionBar().setDisplayHomeAsUpEnabled(true); AppBarLayout appBarLayout = findViewById(R.id.appbar_user_data); - ThemeHelper.enableScrollTint(tb, appBarLayout, this); + NestedScrollView scrollView = findViewById(R.id.scroll_view_user_data); + View workaroundView = findViewById(R.id.workaround_view); + InsetsHelper.setUpAppBarWithScrollView(this, appBarLayout, scrollView, workaroundView); + ThemeHelper.enableScrollTint(this, tb, appBarLayout); } @Override diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameAdapter.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameAdapter.java index 9d45036e11..25d683cbac 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameAdapter.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameAdapter.java @@ -150,9 +150,7 @@ public final class GameAdapter extends RecyclerView.Adapter<GameViewHolder> impl @Override public boolean onLongClick(View view) { - FragmentActivity activity = (FragmentActivity) view.getContext(); GameViewHolder holder = (GameViewHolder) view.getTag(); - String gameId = holder.gameFile.getGameId(); GamePropertiesDialog fragment = GamePropertiesDialog.newInstance(holder.gameFile); ((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction() @@ -160,25 +158,4 @@ public final class GameAdapter extends RecyclerView.Adapter<GameViewHolder> impl return true; } - - public static class SpacesItemDecoration extends RecyclerView.ItemDecoration - { - private int space; - - public SpacesItemDecoration(int space) - { - this.space = space; - } - - @Override - public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, - @NonNull RecyclerView parent, - @NonNull RecyclerView.State state) - { - outRect.left = space; - outRect.right = space; - outRect.bottom = space; - outRect.top = space; - } - } } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/ui/CheatListFragment.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/ui/CheatListFragment.java index a2cf37dba8..60c20590d9 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/ui/CheatListFragment.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/ui/CheatListFragment.java @@ -18,6 +18,7 @@ import com.google.android.material.divider.MaterialDividerItemDecoration; import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.features.cheats.model.CheatsViewModel; +import org.dolphinemu.dolphinemu.utils.InsetsHelper; public class CheatListFragment extends Fragment { @@ -44,5 +45,7 @@ public class CheatListFragment extends Fragment new MaterialDividerItemDecoration(requireActivity(), LinearLayoutManager.VERTICAL); divider.setLastItemDecorated(false); recyclerView.addItemDecoration(divider); + + InsetsHelper.setUpList(getContext(), recyclerView); } } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/ui/CheatsActivity.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/ui/CheatsActivity.java index c89aea45dc..189db827be 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/ui/CheatsActivity.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/cheats/ui/CheatsActivity.java @@ -10,14 +10,18 @@ import android.view.MenuInflater; import android.view.View; import android.view.ViewGroup; +import androidx.annotation.ColorInt; import androidx.annotation.NonNull; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; -import androidx.appcompat.widget.Toolbar; import androidx.core.view.ViewCompat; +import androidx.core.view.WindowCompat; import androidx.lifecycle.ViewModelProvider; import androidx.slidingpanelayout.widget.SlidingPaneLayout; +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.dialog.MaterialAlertDialogBuilder; import org.dolphinemu.dolphinemu.R; @@ -27,6 +31,7 @@ import org.dolphinemu.dolphinemu.features.cheats.model.GeckoCheat; import org.dolphinemu.dolphinemu.features.settings.model.Settings; import org.dolphinemu.dolphinemu.ui.TwoPaneOnBackPressedCallback; import org.dolphinemu.dolphinemu.ui.main.MainPresenter; +import org.dolphinemu.dolphinemu.utils.InsetsHelper; import org.dolphinemu.dolphinemu.utils.ThemeHelper; public class CheatsActivity extends AppCompatActivity @@ -83,6 +88,8 @@ public class CheatsActivity extends AppCompatActivity setContentView(R.layout.activity_cheats); + WindowCompat.setDecorFitsSystemWindows(getWindow(), false); + mSlidingPaneLayout = findViewById(R.id.sliding_pane_layout); mCheatList = findViewById(R.id.cheat_list); mCheatDetails = findViewById(R.id.cheat_details); @@ -100,9 +107,18 @@ public class CheatsActivity extends AppCompatActivity mViewModel.getOpenDetailsViewEvent().observe(this, this::openDetailsView); - Toolbar tb = findViewById(R.id.toolbar_cheats); + MaterialToolbar tb = findViewById(R.id.toolbar_cheats); setSupportActionBar(tb); getSupportActionBar().setDisplayHomeAsUpEnabled(true); + + View workaroundView = findViewById(R.id.workaround_view); + AppBarLayout appBarLayout = findViewById(R.id.appbar_cheats); + InsetsHelper.setUpCheatsLayout(this, appBarLayout, mSlidingPaneLayout, mCheatDetails, + workaroundView); + + @ColorInt int color = MaterialColors.getColor(tb, R.attr.colorSurfaceVariant); + tb.setBackgroundColor(color); + ThemeHelper.setStatusBarColor(this, color); } @Override diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/riivolution/ui/RiivolutionBootActivity.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/riivolution/ui/RiivolutionBootActivity.java index 721d8e42e3..4186de21b8 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/riivolution/ui/RiivolutionBootActivity.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/riivolution/ui/RiivolutionBootActivity.java @@ -5,10 +5,13 @@ package org.dolphinemu.dolphinemu.features.riivolution.ui; import android.content.Context; import android.content.Intent; import android.os.Bundle; +import android.view.View; import android.widget.Button; import android.widget.TextView; import androidx.appcompat.app.AppCompatActivity; +import androidx.core.view.WindowCompat; +import androidx.core.widget.NestedScrollView; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -21,6 +24,7 @@ import org.dolphinemu.dolphinemu.activities.EmulationActivity; import org.dolphinemu.dolphinemu.features.riivolution.model.RiivolutionPatches; import org.dolphinemu.dolphinemu.features.settings.model.StringSetting; import org.dolphinemu.dolphinemu.utils.DirectoryInitialization; +import org.dolphinemu.dolphinemu.utils.InsetsHelper; import org.dolphinemu.dolphinemu.utils.ThemeHelper; public class RiivolutionBootActivity extends AppCompatActivity @@ -52,6 +56,8 @@ public class RiivolutionBootActivity extends AppCompatActivity setContentView(R.layout.activity_riivolution_boot); + WindowCompat.setDecorFitsSystemWindows(getWindow(), false); + Intent intent = getIntent(); String path = getIntent().getStringExtra(ARG_GAME_PATH); @@ -89,7 +95,10 @@ public class RiivolutionBootActivity extends AppCompatActivity getSupportActionBar().setDisplayHomeAsUpEnabled(true); AppBarLayout appBarLayout = findViewById(R.id.appbar_riivolution); - ThemeHelper.enableScrollTint(tb, appBarLayout, this); + NestedScrollView scrollView = findViewById(R.id.scroll_view_riivolution); + View workaroundView = findViewById(R.id.workaround_view); + InsetsHelper.setUpAppBarWithScrollView(this, appBarLayout, scrollView, workaroundView); + ThemeHelper.enableScrollTint(this, tb, appBarLayout); } @Override diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivity.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivity.java index f21764689c..45a48a1cfa 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivity.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivity.java @@ -9,11 +9,15 @@ import android.os.Bundle; import android.provider.Settings; import android.view.Menu; import android.view.MenuInflater; +import android.view.View; +import android.widget.FrameLayout; import android.widget.Toast; import androidx.annotation.NonNull; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; +import androidx.core.view.ViewCompat; +import androidx.core.view.WindowCompat; import androidx.fragment.app.FragmentTransaction; import androidx.lifecycle.ViewModelProvider; @@ -26,6 +30,7 @@ import org.dolphinemu.dolphinemu.NativeLibrary; import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.ui.main.MainPresenter; import org.dolphinemu.dolphinemu.utils.FileBrowserHelper; +import org.dolphinemu.dolphinemu.utils.InsetsHelper; import org.dolphinemu.dolphinemu.utils.ThemeHelper; import java.util.Set; @@ -78,6 +83,8 @@ public final class SettingsActivity extends AppCompatActivity implements Setting setContentView(R.layout.activity_settings); + WindowCompat.setDecorFitsSystemWindows(getWindow(), false); + Intent launcher = getIntent(); String gameID = launcher.getStringExtra(ARG_GAME_ID); if (gameID == null) @@ -95,7 +102,15 @@ public final class SettingsActivity extends AppCompatActivity implements Setting getSupportActionBar().setDisplayHomeAsUpEnabled(true); AppBarLayout appBarLayout = findViewById(R.id.appbar_settings); - ThemeHelper.enableScrollTint(tb, appBarLayout, this); + FrameLayout frameLayout = findViewById(R.id.frame_content_settings); + + // TODO: Remove this when CollapsingToolbarLayouts are fixed by Google + // https://github.com/material-components/material-components-android/issues/1310 + ViewCompat.setOnApplyWindowInsetsListener(mToolbarLayout, null); + + View workaroundView = findViewById(R.id.workaround_view); + InsetsHelper.setUpSettingsLayout(this, appBarLayout, frameLayout, workaroundView); + ThemeHelper.enableScrollTint(this, tb, appBarLayout); } @Override @@ -162,8 +177,8 @@ public final class SettingsActivity extends AppCompatActivity implements Setting transaction.addToBackStack(null); } - transaction.replace(R.id.frame_content, SettingsFragment.newInstance(menuTag, gameID, extras), - FRAGMENT_TAG); + transaction.replace(R.id.frame_content_settings, + SettingsFragment.newInstance(menuTag, gameID, extras), FRAGMENT_TAG); transaction.commit(); } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragment.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragment.java index 89587ea535..025c98e56c 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragment.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragment.java @@ -19,6 +19,8 @@ import com.google.android.material.divider.MaterialDividerItemDecoration; import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.features.settings.model.Settings; import org.dolphinemu.dolphinemu.features.settings.model.view.SettingsItem; +import org.dolphinemu.dolphinemu.utils.InsetsHelper; +import org.dolphinemu.dolphinemu.utils.Log; import java.util.ArrayList; import java.util.HashMap; @@ -143,6 +145,8 @@ public final class SettingsFragment extends Fragment implements SettingsFragment divider.setLastItemDecorated(false); recyclerView.addItemDecoration(divider); + InsetsHelper.setUpList(getContext(), recyclerView); + SettingsActivityView activity = (SettingsActivityView) getActivity(); mPresenter.onViewCreated(menuTag, activity.getSettings()); } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/MainActivity.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/MainActivity.java index 8fa685128b..96dc44d83b 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/MainActivity.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/MainActivity.java @@ -9,15 +9,18 @@ import android.os.Bundle; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; +import android.view.View; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import androidx.core.splashscreen.SplashScreen; +import androidx.core.view.WindowCompat; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; import androidx.viewpager.widget.ViewPager; +import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.floatingactionbutton.FloatingActionButton; import com.google.android.material.tabs.TabLayout; @@ -35,6 +38,7 @@ import org.dolphinemu.dolphinemu.utils.Action1; import org.dolphinemu.dolphinemu.utils.AfterDirectoryInitializationRunner; import org.dolphinemu.dolphinemu.utils.DirectoryInitialization; import org.dolphinemu.dolphinemu.utils.FileBrowserHelper; +import org.dolphinemu.dolphinemu.utils.InsetsHelper; import org.dolphinemu.dolphinemu.utils.PermissionsHandler; import org.dolphinemu.dolphinemu.utils.StartupHandler; import org.dolphinemu.dolphinemu.utils.ThemeHelper; @@ -50,6 +54,7 @@ public final class MainActivity extends AppCompatActivity private ViewPager mViewPager; private Toolbar mToolbar; private TabLayout mTabLayout; + private AppBarLayout mAppBarLayout; private FloatingActionButton mFab; private int mThemeId; @@ -70,6 +75,11 @@ public final class MainActivity extends AppCompatActivity findViews(); + View workaroundView = findViewById(R.id.workaround_view); + WindowCompat.setDecorFitsSystemWindows(getWindow(), false); + InsetsHelper.setUpMainLayout(this, mAppBarLayout, mFab, mViewPager, workaroundView); + ThemeHelper.enableStatusBarScrollTint(this, mAppBarLayout); + setSupportActionBar(mToolbar); // Set up the FAB. @@ -147,6 +157,7 @@ public final class MainActivity extends AppCompatActivity // TODO: Replace with a ButterKnife injection. private void findViews() { + mAppBarLayout = findViewById(R.id.appbar_main); mToolbar = findViewById(R.id.toolbar_main); mViewPager = findViewById(R.id.pager_platforms); mTabLayout = findViewById(R.id.tabs_platforms); diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/platform/PlatformGamesFragment.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/platform/PlatformGamesFragment.java index 84b921aa8f..62063caaeb 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/platform/PlatformGamesFragment.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/platform/PlatformGamesFragment.java @@ -19,6 +19,7 @@ import com.google.android.material.color.MaterialColors; import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.adapters.GameAdapter; import org.dolphinemu.dolphinemu.services.GameFileCacheManager; +import org.dolphinemu.dolphinemu.utils.InsetsHelper; public final class PlatformGamesFragment extends Fragment implements PlatformGamesView { @@ -74,7 +75,7 @@ public final class PlatformGamesFragment extends Fragment implements PlatformGam mRecyclerView.setLayoutManager(layoutManager); mRecyclerView.setAdapter(mAdapter); - mRecyclerView.addItemDecoration(new GameAdapter.SpacesItemDecoration(8)); + InsetsHelper.setUpList(getContext(), mRecyclerView); setRefreshing(GameFileCacheManager.isLoadingOrRescanning()); diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/InsetsHelper.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/InsetsHelper.java new file mode 100644 index 0000000000..575756b99c --- /dev/null +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/InsetsHelper.java @@ -0,0 +1,181 @@ +package org.dolphinemu.dolphinemu.utils; + +import android.content.Context; +import android.content.res.Resources; +import android.util.DisplayMetrics; +import android.view.View; +import android.view.ViewGroup; +import android.widget.FrameLayout; + +import androidx.appcompat.app.AppCompatActivity; +import androidx.core.graphics.Insets; +import androidx.core.view.ViewCompat; +import androidx.core.view.WindowInsetsCompat; +import androidx.core.widget.NestedScrollView; +import androidx.recyclerview.widget.RecyclerView; +import androidx.slidingpanelayout.widget.SlidingPaneLayout; +import androidx.viewpager.widget.ViewPager; + +import com.google.android.material.appbar.AppBarLayout; +import com.google.android.material.color.MaterialColors; +import com.google.android.material.floatingactionbutton.FloatingActionButton; + +import org.dolphinemu.dolphinemu.R; + +public class InsetsHelper +{ + public static final int FAB_INSET = 16; + public static final int EXTRA_NAV_INSET = 32; + + public static final int THREE_BUTTON_NAVIGATION = 0; + public static final int TWO_BUTTON_NAVIGATION = 1; + public static final int GESTURE_NAVIGATION = 2; + + public static int dpToPx(Context context, int dp) + { + return (int) (dp * ((float) context.getResources().getDisplayMetrics().densityDpi / + DisplayMetrics.DENSITY_DEFAULT) + 0.5f); + } + + public static void setUpAppBarWithScrollView(AppCompatActivity activity, + AppBarLayout appBarLayout, NestedScrollView nestedScrollView, View workaroundView) + { + ViewCompat.setOnApplyWindowInsetsListener(appBarLayout, (v, windowInsets) -> + { + Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()); + + insetAppBar(insets, appBarLayout); + + nestedScrollView.setPadding(insets.left, 0, insets.right, insets.bottom); + + applyWorkaround(insets.bottom, workaroundView); + + ThemeHelper.setNavigationBarColor(activity, + MaterialColors.getColor(appBarLayout, R.attr.colorSurface)); + + return windowInsets; + }); + } + + public static void setUpList(Context context, RecyclerView recyclerView) + { + ViewCompat.setOnApplyWindowInsetsListener(recyclerView, (v, windowInsets) -> + { + Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()); + v.setPadding(0, 0, 0, insets.bottom + dpToPx(context, EXTRA_NAV_INSET)); + + return windowInsets; + }); + } + + public static void setUpMainLayout(AppCompatActivity activity, AppBarLayout appBarLayout, + FloatingActionButton fab, ViewPager viewPager, View workaroundView) + { + ViewCompat.setOnApplyWindowInsetsListener(appBarLayout, (v, windowInsets) -> + { + Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()); + + insetAppBar(insets, appBarLayout); + + ViewGroup.MarginLayoutParams mlpFab = (ViewGroup.MarginLayoutParams) fab.getLayoutParams(); + int fabPadding = + InsetsHelper.dpToPx(activity.getApplicationContext(), FAB_INSET); + mlpFab.leftMargin = insets.left + fabPadding; + mlpFab.bottomMargin = insets.bottom + fabPadding; + mlpFab.rightMargin = insets.right + fabPadding; + fab.setLayoutParams(mlpFab); + + viewPager.setPadding(insets.left, 0, insets.right, 0); + + applyWorkaround(insets.bottom, workaroundView); + + ThemeHelper.setNavigationBarColor(activity, + MaterialColors.getColor(appBarLayout, R.attr.colorSurface)); + + return windowInsets; + }); + } + + public static void setUpSettingsLayout(AppCompatActivity activity, + AppBarLayout appBarLayout, FrameLayout frameLayout, View workaroundView) + { + ViewCompat.setOnApplyWindowInsetsListener(appBarLayout, (v, windowInsets) -> + { + Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()); + + insetAppBar(insets, appBarLayout); + + frameLayout.setPadding(insets.left, 0, insets.right, 0); + + applyWorkaround(insets.bottom, workaroundView); + + ThemeHelper.setNavigationBarColor(activity, + MaterialColors.getColor(appBarLayout, R.attr.colorSurface)); + + return windowInsets; + }); + } + + public static void setUpCheatsLayout(AppCompatActivity activity, AppBarLayout appBarLayout, + SlidingPaneLayout slidingPaneLayout, View cheatDetails, View workaroundView) + { + ViewCompat.setOnApplyWindowInsetsListener(appBarLayout, (v, windowInsets) -> + { + Insets barInsets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()); + Insets keyboardInsets = windowInsets.getInsets(WindowInsetsCompat.Type.ime()); + + insetAppBar(barInsets, appBarLayout); + + slidingPaneLayout.setPadding(barInsets.left, barInsets.top, barInsets.right, 0); + + if (keyboardInsets.bottom > 0) + { + cheatDetails.setPadding(0, 0, 0, keyboardInsets.bottom); + } + else + { + cheatDetails.setPadding(0, 0, 0, barInsets.bottom); + } + + applyWorkaround(barInsets.bottom, workaroundView); + + ThemeHelper.setNavigationBarColor(activity, + MaterialColors.getColor(appBarLayout, R.attr.colorSurface)); + + return windowInsets; + }); + } + + private static void insetAppBar(Insets insets, AppBarLayout appBarLayout) + { + ViewGroup.MarginLayoutParams mlpAppBar = + (ViewGroup.MarginLayoutParams) appBarLayout.getLayoutParams(); + mlpAppBar.leftMargin = insets.left; + mlpAppBar.topMargin = insets.top; + mlpAppBar.rightMargin = insets.right; + appBarLayout.setLayoutParams(mlpAppBar); + } + + // Workaround for a bug on Android 13 that allows users to interact with UI behind the + // navigation bar https://issuetracker.google.com/issues/248761842 + private static void applyWorkaround(int bottomInset, View workaroundView) + { + if (bottomInset > 0) + { + ViewGroup.LayoutParams lpWorkaround = workaroundView.getLayoutParams(); + lpWorkaround.height = bottomInset; + workaroundView.setLayoutParams(lpWorkaround); + } + } + + public static int getSystemGestureType(Context context) + { + Resources resources = context.getResources(); + int resourceId = resources.getIdentifier("config_navBarInteractionMode", "integer", "android"); + if (resourceId != 0) + { + return resources.getInteger(resourceId); + } + return 0; + } +} diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/ThemeHelper.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/ThemeHelper.java index ab66878383..5d9a1a9c5b 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/ThemeHelper.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/ThemeHelper.java @@ -3,10 +3,15 @@ package org.dolphinemu.dolphinemu.utils; import android.app.Activity; import android.content.SharedPreferences; import android.content.res.Configuration; +import android.graphics.Color; import android.os.Build; import android.preference.PreferenceManager; import androidx.annotation.ColorInt; +import androidx.annotation.NonNull; +import androidx.annotation.RequiresApi; +import androidx.appcompat.app.AppCompatActivity; +import androidx.core.content.ContextCompat; import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.appbar.MaterialToolbar; @@ -25,7 +30,9 @@ public class ThemeHelper public static final int GREEN = 3; public static final int PINK = 4; - public static void setTheme(Activity activity) + public static final float NAV_BAR_ALPHA = 0.9f; + + public static void setTheme(@NonNull AppCompatActivity activity) { // We have to use shared preferences in addition to Dolphin's settings to guarantee that the // requested theme id is ready before the onCreate method of any given Activity. @@ -35,43 +42,22 @@ public class ThemeHelper { case DEFAULT: activity.setTheme(R.style.Theme_Dolphin_Main); - activity.getWindow() - .setStatusBarColor(activity.getResources().getColor(R.color.dolphin_surface)); break; case MONET: activity.setTheme(R.style.Theme_Dolphin_Main_MaterialYou); - int currentNightMode = activity.getResources().getConfiguration().uiMode & - Configuration.UI_MODE_NIGHT_MASK; - switch (currentNightMode) - { - case Configuration.UI_MODE_NIGHT_NO: - activity.getWindow().setStatusBarColor( - activity.getResources().getColor(R.color.m3_sys_color_dynamic_light_surface)); - break; - case Configuration.UI_MODE_NIGHT_YES: - activity.getWindow().setStatusBarColor( - activity.getResources().getColor(R.color.m3_sys_color_dynamic_dark_surface)); - break; - } break; case MATERIAL_DEFAULT: activity.setTheme(R.style.Theme_Dolphin_Main_Material); - activity.getWindow() - .setStatusBarColor(activity.getResources().getColor(R.color.dolphin_surface)); break; case GREEN: activity.setTheme(R.style.Theme_Dolphin_Main_Green); - activity.getWindow() - .setStatusBarColor(activity.getResources().getColor(R.color.green_surface)); break; case PINK: activity.setTheme(R.style.Theme_Dolphin_Main_Pink); - activity.getWindow() - .setStatusBarColor(activity.getResources().getColor(R.color.pink_surface)); break; } @@ -79,19 +65,19 @@ public class ThemeHelper // black status bar since their icons do not adapt based on background color if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { - activity.getWindow() - .setStatusBarColor(activity.getResources().getColor(android.R.color.black)); + activity.getWindow().setStatusBarColor( + ContextCompat.getColor(activity.getApplicationContext(), android.R.color.black)); } } - public static void saveTheme(Activity activity, int themeValue) + public static void saveTheme(@NonNull Activity activity, int themeValue) { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity.getApplicationContext()); preferences.edit().putInt(CURRENT_THEME, themeValue).apply(); } - public static void deleteThemeKey(Activity activity) + public static void deleteThemeKey(@NonNull Activity activity) { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity.getApplicationContext()); @@ -100,7 +86,7 @@ public class ThemeHelper activity.recreate(); } - public static void setCorrectTheme(Activity activity) + public static void setCorrectTheme(AppCompatActivity activity) { int currentTheme = ((ThemeProvider) activity).getThemeId(); setTheme(activity); @@ -111,12 +97,12 @@ public class ThemeHelper } } - private static void setStatusBarColor(@ColorInt int color, Activity activity) + public static void setStatusBarColor(AppCompatActivity activity, @ColorInt int color) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { - activity.getWindow() - .setStatusBarColor(activity.getResources().getColor(android.R.color.black)); + activity.getWindow().setStatusBarColor( + ContextCompat.getColor(activity.getApplicationContext(), android.R.color.black)); } else { @@ -124,8 +110,42 @@ public class ThemeHelper } } - public static void enableScrollTint(MaterialToolbar toolbar, AppBarLayout appBarLayout, - Activity activity) + public static void setNavigationBarColor(Activity activity, @ColorInt int color) + { + int gestureType = InsetsHelper.getSystemGestureType(activity.getApplicationContext()); + int orientation = activity.getResources().getConfiguration().orientation; + + // Use black if the Android version is too low to support changing button colors + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O_MR1) + { + activity.getWindow().setNavigationBarColor( + ContextCompat.getColor(activity.getApplicationContext(), android.R.color.black)); + } + // Use a solid color when the navigation bar is on the left/right edge of the screen + else if ((gestureType == InsetsHelper.THREE_BUTTON_NAVIGATION || + gestureType == InsetsHelper.TWO_BUTTON_NAVIGATION) && + orientation == Configuration.ORIENTATION_LANDSCAPE) + { + activity.getWindow().setNavigationBarColor(color); + } + // Use semi-transparent color when in portrait mode with three/two button navigation to + // partially see list items behind the navigation bar + else if (gestureType == InsetsHelper.THREE_BUTTON_NAVIGATION || + gestureType == InsetsHelper.TWO_BUTTON_NAVIGATION) + { + activity.getWindow().setNavigationBarColor(getColorWithOpacity(color, NAV_BAR_ALPHA)); + } + // Use transparent color when using gesture navigation + else + { + activity.getWindow().setNavigationBarColor( + ContextCompat.getColor(activity.getApplicationContext(), + android.R.color.transparent)); + } + } + + public static void enableScrollTint(AppCompatActivity activity, MaterialToolbar toolbar, + @NonNull AppBarLayout appBarLayout) { appBarLayout.addOnOffsetChangedListener((layout, verticalOffset) -> { @@ -133,14 +153,42 @@ public class ThemeHelper { @ColorInt int color = MaterialColors.getColor(toolbar, R.attr.colorSurfaceVariant); toolbar.setBackgroundColor(color); - setStatusBarColor(color, activity); + setStatusBarColor(activity, color); } else { - @ColorInt int color = MaterialColors.getColor(toolbar, R.attr.colorSurface); - toolbar.setBackgroundColor(color); - setStatusBarColor(color, activity); + @ColorInt int statusBarColor = ContextCompat.getColor(activity.getApplicationContext(), + android.R.color.transparent); + @ColorInt int appBarColor = MaterialColors.getColor(toolbar, R.attr.colorSurface); + toolbar.setBackgroundColor(appBarColor); + setStatusBarColor(activity, statusBarColor); } }); } + + public static void enableStatusBarScrollTint(AppCompatActivity activity, + @NonNull AppBarLayout appBarLayout) + { + appBarLayout.addOnOffsetChangedListener((layout, verticalOffset) -> + { + if (-verticalOffset > 0) + { + @ColorInt int color = MaterialColors.getColor(appBarLayout, R.attr.colorSurface); + setStatusBarColor(activity, color); + } + else + { + @ColorInt int statusBarColor = ContextCompat.getColor(activity.getApplicationContext(), + android.R.color.transparent); + setStatusBarColor(activity, statusBarColor); + } + }); + } + + @RequiresApi(api = Build.VERSION_CODES.O_MR1) @ColorInt + private static int getColorWithOpacity(@ColorInt int color, float alphaFactor) + { + return Color.argb(Math.round(alphaFactor * Color.alpha(color)), Color.red(color), + Color.green(color), Color.blue(color)); + } } diff --git a/Source/Android/app/src/main/res/layout-land/activity_user_data.xml b/Source/Android/app/src/main/res/layout-land/activity_user_data.xml index 24863dcd5f..52f6b173fd 100644 --- a/Source/Android/app/src/main/res/layout-land/activity_user_data.xml +++ b/Source/Android/app/src/main/res/layout-land/activity_user_data.xml @@ -4,7 +4,8 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" - android:layout_height="match_parent"> + android:layout_height="match_parent" + android:background="?attr/colorSurface"> <com.google.android.material.appbar.AppBarLayout android:id="@+id/appbar_user_data" @@ -18,6 +19,7 @@ android:id="@+id/toolbar_user_data_layout" android:layout_width="match_parent" android:layout_height="?attr/collapsingToolbarLayoutMediumSize" + app:contentScrim="@android:color/transparent" app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"> <com.google.android.material.appbar.MaterialToolbar @@ -33,8 +35,10 @@ </com.google.android.material.appbar.AppBarLayout> <androidx.core.widget.NestedScrollView + android:id="@+id/scroll_view_user_data" android:layout_width="match_parent" android:layout_height="match_parent" + android:clipToPadding="false" app:layout_behavior="@string/appbar_scrolling_view_behavior"> <androidx.constraintlayout.widget.ConstraintLayout @@ -140,4 +144,12 @@ </androidx.core.widget.NestedScrollView> + <View + android:id="@+id/workaround_view" + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_gravity="bottom" + android:clickable="true" + android:background="@android:color/transparent" /> + </androidx.coordinatorlayout.widget.CoordinatorLayout> diff --git a/Source/Android/app/src/main/res/layout-w680dp-land/activity_convert.xml b/Source/Android/app/src/main/res/layout-w680dp-land/activity_convert.xml index 1c00d679a6..78dfcbd0cf 100644 --- a/Source/Android/app/src/main/res/layout-w680dp-land/activity_convert.xml +++ b/Source/Android/app/src/main/res/layout-w680dp-land/activity_convert.xml @@ -3,7 +3,8 @@ xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" - android:layout_height="match_parent"> + android:layout_height="match_parent" + android:background="?attr/colorSurface"> <com.google.android.material.appbar.AppBarLayout android:id="@+id/appbar_convert" @@ -17,6 +18,7 @@ android:id="@+id/toolbar_convert_layout" android:layout_width="match_parent" android:layout_height="?attr/collapsingToolbarLayoutMediumSize" + app:contentScrim="@android:color/transparent" app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"> <com.google.android.material.appbar.MaterialToolbar @@ -32,8 +34,10 @@ </com.google.android.material.appbar.AppBarLayout> <androidx.core.widget.NestedScrollView + android:id="@+id/scroll_view_convert" android:layout_width="match_parent" android:layout_height="match_parent" + android:clipToPadding="false" app:layout_behavior="@string/appbar_scrolling_view_behavior"> <androidx.constraintlayout.widget.ConstraintLayout @@ -79,4 +83,12 @@ </androidx.core.widget.NestedScrollView> + <View + android:id="@+id/workaround_view" + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_gravity="bottom" + android:clickable="true" + android:background="@android:color/transparent" /> + </androidx.coordinatorlayout.widget.CoordinatorLayout> diff --git a/Source/Android/app/src/main/res/layout/activity_cheats.xml b/Source/Android/app/src/main/res/layout/activity_cheats.xml index 581f8bddbe..151c8edf67 100644 --- a/Source/Android/app/src/main/res/layout/activity_cheats.xml +++ b/Source/Android/app/src/main/res/layout/activity_cheats.xml @@ -3,20 +3,22 @@ xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/coordinator_main" android:layout_width="match_parent" - android:layout_height="match_parent"> + android:layout_height="match_parent" + android:background="?attr/colorSurface"> <com.google.android.material.appbar.AppBarLayout android:id="@+id/appbar_cheats" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentTop="true" + app:liftOnScroll="false" app:elevation="0dp"> <com.google.android.material.appbar.MaterialToolbar android:id="@+id/toolbar_cheats" android:layout_width="match_parent" android:layout_height="wrap_content" - android:background="?attr/colorSurface"/> + android:background="?attr/colorSurface" /> </com.google.android.material.appbar.AppBarLayout> @@ -24,7 +26,7 @@ android:id="@+id/sliding_pane_layout" android:layout_width="match_parent" android:layout_height="match_parent" - android:layout_marginTop="56dp"> + android:layout_marginTop="64dp"> <androidx.fragment.app.FragmentContainerView android:id="@+id/cheat_list" @@ -40,4 +42,12 @@ </androidx.slidingpanelayout.widget.SlidingPaneLayout> + <View + android:id="@+id/workaround_view" + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_gravity="bottom" + android:clickable="true" + android:background="@android:color/transparent" /> + </androidx.coordinatorlayout.widget.CoordinatorLayout> diff --git a/Source/Android/app/src/main/res/layout/activity_convert.xml b/Source/Android/app/src/main/res/layout/activity_convert.xml index f2e07bf56f..f2072d0037 100644 --- a/Source/Android/app/src/main/res/layout/activity_convert.xml +++ b/Source/Android/app/src/main/res/layout/activity_convert.xml @@ -3,7 +3,8 @@ xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" - android:layout_height="match_parent"> + android:layout_height="match_parent" + android:background="?attr/colorSurface"> <com.google.android.material.appbar.AppBarLayout android:id="@+id/appbar_convert" @@ -17,6 +18,7 @@ android:id="@+id/toolbar_convert_layout" android:layout_width="match_parent" android:layout_height="?attr/collapsingToolbarLayoutMediumSize" + app:contentScrim="@android:color/transparent" app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"> <com.google.android.material.appbar.MaterialToolbar @@ -32,8 +34,10 @@ </com.google.android.material.appbar.AppBarLayout> <androidx.core.widget.NestedScrollView + android:id="@+id/scroll_view_convert" android:layout_width="match_parent" android:layout_height="match_parent" + android:clipToPadding="false" app:layout_behavior="@string/appbar_scrolling_view_behavior"> <androidx.constraintlayout.widget.ConstraintLayout @@ -77,4 +81,12 @@ </androidx.core.widget.NestedScrollView> + <View + android:id="@+id/workaround_view" + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_gravity="bottom" + android:clickable="true" + android:background="@android:color/transparent" /> + </androidx.coordinatorlayout.widget.CoordinatorLayout> diff --git a/Source/Android/app/src/main/res/layout/activity_main.xml b/Source/Android/app/src/main/res/layout/activity_main.xml index c183cd1717..645825062a 100644 --- a/Source/Android/app/src/main/res/layout/activity_main.xml +++ b/Source/Android/app/src/main/res/layout/activity_main.xml @@ -4,12 +4,14 @@ xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/coordinator_main" android:layout_width="match_parent" - android:layout_height="match_parent"> + android:layout_height="match_parent" + android:background="?attr/colorSurface"> <com.google.android.material.appbar.AppBarLayout android:id="@+id/appbar_main" android:layout_width="match_parent" android:layout_height="wrap_content" + app:liftOnScroll="false" app:elevation="0dp"> <com.google.android.material.appbar.MaterialToolbar @@ -40,11 +42,18 @@ android:background="?attr/colorSurface" app:layout_behavior="@string/appbar_scrolling_view_behavior" /> + <View + android:id="@+id/workaround_view" + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_gravity="bottom" + android:clickable="true" + android:background="@android:color/transparent" /> + <com.google.android.material.floatingactionbutton.FloatingActionButton android:id="@+id/button_add_directory" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_margin="16dp" android:src="@drawable/ic_add" app:layout_anchor="@+id/pager_platforms" app:layout_anchorGravity="bottom|right|end" /> diff --git a/Source/Android/app/src/main/res/layout/activity_riivolution_boot.xml b/Source/Android/app/src/main/res/layout/activity_riivolution_boot.xml index 1ab3315646..7203dd15ed 100644 --- a/Source/Android/app/src/main/res/layout/activity_riivolution_boot.xml +++ b/Source/Android/app/src/main/res/layout/activity_riivolution_boot.xml @@ -4,7 +4,8 @@ xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" - android:layout_height="match_parent"> + android:layout_height="match_parent" + android:background="?attr/colorSurface"> <com.google.android.material.appbar.AppBarLayout android:id="@+id/appbar_riivolution" @@ -18,6 +19,7 @@ android:id="@+id/toolbar_riivolution_layout" android:layout_width="match_parent" android:layout_height="?attr/collapsingToolbarLayoutMediumSize" + app:contentScrim="@android:color/transparent" app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"> <com.google.android.material.appbar.MaterialToolbar @@ -33,8 +35,10 @@ </com.google.android.material.appbar.AppBarLayout> <androidx.core.widget.NestedScrollView + android:id="@+id/scroll_view_riivolution" android:layout_width="match_parent" android:layout_height="match_parent" + android:clipToPadding="false" app:layout_behavior="@string/appbar_scrolling_view_behavior"> <androidx.constraintlayout.widget.ConstraintLayout @@ -94,4 +98,12 @@ </androidx.core.widget.NestedScrollView> + <View + android:id="@+id/workaround_view" + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_gravity="bottom" + android:clickable="true" + android:background="@android:color/transparent" /> + </androidx.coordinatorlayout.widget.CoordinatorLayout> diff --git a/Source/Android/app/src/main/res/layout/activity_settings.xml b/Source/Android/app/src/main/res/layout/activity_settings.xml index d38c9618d1..561755a5f6 100644 --- a/Source/Android/app/src/main/res/layout/activity_settings.xml +++ b/Source/Android/app/src/main/res/layout/activity_settings.xml @@ -4,7 +4,8 @@ xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/coordinator_main" android:layout_width="match_parent" - android:layout_height="match_parent"> + android:layout_height="match_parent" + android:background="?attr/colorSurface"> <com.google.android.material.appbar.AppBarLayout android:id="@+id/appbar_settings" @@ -18,6 +19,7 @@ android:id="@+id/toolbar_settings_layout" android:layout_width="match_parent" android:layout_height="?attr/collapsingToolbarLayoutMediumSize" + app:contentScrim="@android:color/transparent" app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"> <com.google.android.material.appbar.MaterialToolbar @@ -32,9 +34,17 @@ </com.google.android.material.appbar.AppBarLayout> <FrameLayout - android:id="@+id/frame_content" + android:id="@+id/frame_content_settings" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior"/> + <View + android:id="@+id/workaround_view" + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_gravity="bottom" + android:clickable="true" + android:background="@android:color/transparent" /> + </androidx.coordinatorlayout.widget.CoordinatorLayout> diff --git a/Source/Android/app/src/main/res/layout/activity_user_data.xml b/Source/Android/app/src/main/res/layout/activity_user_data.xml index a9df023fce..849e4668cb 100644 --- a/Source/Android/app/src/main/res/layout/activity_user_data.xml +++ b/Source/Android/app/src/main/res/layout/activity_user_data.xml @@ -4,7 +4,8 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" - android:layout_height="match_parent"> + android:layout_height="match_parent" + android:background="?attr/colorSurface"> <com.google.android.material.appbar.AppBarLayout android:id="@+id/appbar_user_data" @@ -18,6 +19,7 @@ android:id="@+id/toolbar_user_data_layout" android:layout_width="match_parent" android:layout_height="?attr/collapsingToolbarLayoutMediumSize" + app:contentScrim="@android:color/transparent" app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"> <com.google.android.material.appbar.MaterialToolbar @@ -33,8 +35,10 @@ </com.google.android.material.appbar.AppBarLayout> <androidx.core.widget.NestedScrollView + android:id="@+id/scroll_view_user_data" android:layout_width="match_parent" android:layout_height="match_parent" + android:clipToPadding="false" app:layout_behavior="@string/appbar_scrolling_view_behavior"> <androidx.constraintlayout.widget.ConstraintLayout @@ -117,4 +121,12 @@ </androidx.core.widget.NestedScrollView> + <View + android:id="@+id/workaround_view" + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_gravity="bottom" + android:clickable="true" + android:background="@android:color/transparent" /> + </androidx.coordinatorlayout.widget.CoordinatorLayout> diff --git a/Source/Android/app/src/main/res/layout/card_game.xml b/Source/Android/app/src/main/res/layout/card_game.xml index 2e7eb280d3..47e2c7a559 100644 --- a/Source/Android/app/src/main/res/layout/card_game.xml +++ b/Source/Android/app/src/main/res/layout/card_game.xml @@ -1,5 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" +<androidx.constraintlayout.widget.ConstraintLayout + xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" @@ -8,37 +9,38 @@ android:clickable="true" android:clipToPadding="false" android:focusable="true" - android:orientation="vertical" android:paddingStart="4dp" android:paddingTop="8dp" android:paddingEnd="4dp" + android:paddingBottom="8dp" android:transitionName="card_game"> <androidx.cardview.widget.CardView android:id="@+id/card_game_art" android:layout_width="115dp" android:layout_height="161dp" - android:layout_gravity="center" - android:layout_marginBottom="8dp" - app:cardCornerRadius="4dp"> + app:cardCornerRadius="4dp" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent"> <ImageView android:id="@+id/image_game_screen" android:layout_width="match_parent" android:layout_height="match_parent" - android:layout_weight="1"/> + android:layout_weight="1" /> <TextView android:id="@+id/text_game_title_inner" style="@android:style/TextAppearance.Material.Subhead" android:layout_width="match_parent" android:layout_height="match_parent" - android:paddingTop="8dp" - android:paddingLeft="2dp" - android:paddingRight="2dp" android:ellipsize="end" android:gravity="center|top" android:maxLines="2" + android:paddingLeft="2dp" + android:paddingRight="2dp" + android:paddingTop="8dp" android:visibility="visible" tools:text="The Legend of Zelda: The Wind Waker" /> @@ -47,26 +49,28 @@ <TextView android:id="@+id/text_game_title" style="@android:style/TextAppearance.Material.Subhead" - android:layout_width="wrap_content" + android:layout_width="115dp" android:layout_height="wrap_content" - android:layout_gravity="start" android:ellipsize="end" android:maxLines="2" - tools:layout_width="140dp" + android:paddingTop="8dp" + app:layout_constraintEnd_toEndOf="@+id/card_game_art" + app:layout_constraintStart_toStartOf="@+id/card_game_art" + app:layout_constraintTop_toBottomOf="@+id/card_game_art" tools:text="The Legend of Zelda: The Wind Waker" /> <TextView android:id="@+id/text_game_caption" style="@android:style/TextAppearance.Material.Caption" - android:layout_width="wrap_content" + android:layout_width="115dp" android:layout_height="wrap_content" - android:layout_gravity="start" - android:layout_marginTop="8dp" - android:layout_marginBottom="8dp" android:ellipsize="end" android:lines="1" android:maxLines="1" - tools:layout_width="140dp" + android:paddingTop="8dp" + app:layout_constraintEnd_toEndOf="@+id/card_game_art" + app:layout_constraintStart_toStartOf="@+id/card_game_art" + app:layout_constraintTop_toBottomOf="@+id/text_game_title" tools:text="Nintendo" /> -</LinearLayout> +</androidx.constraintlayout.widget.ConstraintLayout> diff --git a/Source/Android/app/src/main/res/layout/fragment_cheat_details.xml b/Source/Android/app/src/main/res/layout/fragment_cheat_details.xml index 208bd9b450..5b85c3b5ab 100644 --- a/Source/Android/app/src/main/res/layout/fragment_cheat_details.xml +++ b/Source/Android/app/src/main/res/layout/fragment_cheat_details.xml @@ -14,7 +14,7 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="parent" - app:layout_constraintBottom_toTopOf="@id/barrier"> + app:layout_constraintBottom_toTopOf="@id/button_layout"> <androidx.constraintlayout.widget.ConstraintLayout android:layout_width="match_parent" @@ -119,55 +119,62 @@ </ScrollView> - <androidx.constraintlayout.widget.Barrier - android:id="@+id/barrier" - android:layout_width="wrap_content" + <androidx.constraintlayout.widget.ConstraintLayout + android:id="@+id/button_layout" + android:layout_width="match_parent" android:layout_height="wrap_content" - app:barrierDirection="top" - app:constraint_referenced_ids="button_delete,button_edit,button_cancel,button_ok" /> + android:background="@android:color/transparent" + app:layout_constraintBottom_toBottomOf="parent"> - <Button - android:id="@+id/button_delete" - android:layout_width="0dp" - android:layout_height="wrap_content" - android:layout_margin="@dimen/spacing_large" - android:text="@string/cheats_delete" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintEnd_toStartOf="@id/button_edit" - app:layout_constraintTop_toBottomOf="@id/barrier" - app:layout_constraintBottom_toBottomOf="parent" /> - - <Button - android:id="@+id/button_edit" - android:layout_width="0dp" - android:layout_height="wrap_content" - android:layout_margin="@dimen/spacing_large" - android:text="@string/cheats_edit" - app:layout_constraintStart_toEndOf="@id/button_delete" - app:layout_constraintEnd_toStartOf="@id/button_cancel" - app:layout_constraintTop_toBottomOf="@id/barrier" - app:layout_constraintBottom_toBottomOf="parent" /> - - <Button - android:id="@+id/button_cancel" - android:layout_width="0dp" - android:layout_height="wrap_content" - android:layout_margin="@dimen/spacing_large" - android:text="@string/cancel" - app:layout_constraintStart_toEndOf="@id/button_edit" - app:layout_constraintEnd_toStartOf="@id/button_ok" - app:layout_constraintTop_toBottomOf="@id/barrier" - app:layout_constraintBottom_toBottomOf="parent" /> - - <Button - android:id="@+id/button_ok" - android:layout_width="0dp" - android:layout_height="wrap_content" - android:layout_margin="@dimen/spacing_large" - android:text="@string/ok" - app:layout_constraintStart_toEndOf="@id/button_cancel" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintTop_toBottomOf="@id/barrier" - app:layout_constraintBottom_toBottomOf="parent" /> + <com.google.android.material.divider.MaterialDivider + android:layout_width="match_parent" + android:layout_height="0dp" + app:layout_constraintTop_toTopOf="parent" /> + + <Button + android:id="@+id/button_delete" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_margin="@dimen/spacing_large" + android:text="@string/cheats_delete" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toStartOf="@id/button_edit" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" /> + + <Button + android:id="@+id/button_edit" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_margin="@dimen/spacing_large" + android:text="@string/cheats_edit" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toStartOf="@id/button_cancel" + app:layout_constraintStart_toEndOf="@id/button_delete" + app:layout_constraintTop_toTopOf="parent" /> + + <Button + android:id="@+id/button_cancel" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_margin="@dimen/spacing_large" + android:text="@string/cancel" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toStartOf="@id/button_ok" + app:layout_constraintStart_toEndOf="@id/button_edit" + app:layout_constraintTop_toTopOf="parent" /> + + <Button + android:id="@+id/button_ok" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_margin="@dimen/spacing_large" + android:text="@string/ok" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toEndOf="@id/button_cancel" + app:layout_constraintTop_toTopOf="parent" /> + + </androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout> diff --git a/Source/Android/app/src/main/res/layout/fragment_cheat_list.xml b/Source/Android/app/src/main/res/layout/fragment_cheat_list.xml index ad8ec880af..c82f4104ff 100644 --- a/Source/Android/app/src/main/res/layout/fragment_cheat_list.xml +++ b/Source/Android/app/src/main/res/layout/fragment_cheat_list.xml @@ -10,6 +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" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="parent" @@ -20,6 +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" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toBottomOf="@id/cheats_warning" @@ -29,6 +31,7 @@ android:id="@+id/cheat_list" android:layout_width="match_parent" android:layout_height="0dp" + android:clipToPadding="false" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toBottomOf="@id/gfx_mods_warning" diff --git a/Source/Android/app/src/main/res/layout/fragment_grid.xml b/Source/Android/app/src/main/res/layout/fragment_grid.xml index 5c44cbcb5e..62be5a20ea 100644 --- a/Source/Android/app/src/main/res/layout/fragment_grid.xml +++ b/Source/Android/app/src/main/res/layout/fragment_grid.xml @@ -6,8 +6,8 @@ <androidx.swiperefreshlayout.widget.SwipeRefreshLayout android:id="@+id/swipe_refresh" - android:layout_width="match_parent" - android:layout_height="match_parent" + android:layout_width="wrap_content" + android:layout_height="wrap_content" android:layout_marginLeft="@dimen/activity_horizontal_margin" android:layout_marginRight="@dimen/activity_horizontal_margin"> @@ -15,10 +15,8 @@ android:id="@+id/grid_games" android:layout_width="match_parent" android:layout_height="match_parent" - tools:listitem="@layout/card_game" android:clipToPadding="false" - android:paddingTop="8dp" - android:paddingBottom="8dp"/> + tools:listitem="@layout/card_game" /> </androidx.swiperefreshlayout.widget.SwipeRefreshLayout> diff --git a/Source/Android/app/src/main/res/layout/fragment_settings.xml b/Source/Android/app/src/main/res/layout/fragment_settings.xml index 1fef71b426..d7b48d8f2b 100644 --- a/Source/Android/app/src/main/res/layout/fragment_settings.xml +++ b/Source/Android/app/src/main/res/layout/fragment_settings.xml @@ -1,12 +1,14 @@ <?xml version="1.0" encoding="utf-8"?> -<org.dolphinemu.dolphinemu.features.settings.ui.SettingsFrameLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="match_parent"> +<org.dolphinemu.dolphinemu.features.settings.ui.SettingsFrameLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent"> <androidx.recyclerview.widget.RecyclerView android:id="@+id/list_settings" - android:background="?android:attr/colorBackground" + android:background="?attr/colorSurface" android:layout_width="match_parent" - android:layout_height="match_parent"/> + android:layout_height="match_parent" + android:clipToPadding="false" /> </org.dolphinemu.dolphinemu.features.settings.ui.SettingsFrameLayout> diff --git a/Source/Android/app/src/main/res/values-v27/themes.xml b/Source/Android/app/src/main/res/values-v27/themes.xml index 06e1668481..ec8f103c8d 100644 --- a/Source/Android/app/src/main/res/values-v27/themes.xml +++ b/Source/Android/app/src/main/res/values-v27/themes.xml @@ -1,7 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <resources> <style name="Theme.V27.Dolphin" parent="Theme.Dolphin"> - <item name="android:navigationBarColor">@android:color/transparent</item> <item name="android:windowLightNavigationBar">@bool/lightSystemBars</item> </style> diff --git a/Source/Android/app/src/main/res/values-v29/themes.xml b/Source/Android/app/src/main/res/values-v29/themes.xml new file mode 100644 index 0000000000..232c5aeefa --- /dev/null +++ b/Source/Android/app/src/main/res/values-v29/themes.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <style name="Theme.V29.Dolphin" parent="Theme.V27.Dolphin"> + <item name="android:enforceStatusBarContrast">false</item> + <item name="android:enforceNavigationBarContrast">false</item> + </style> + + <style name="Theme.Dolphin.Main" parent="Theme.V29.Dolphin" /> +</resources> |
