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 63478fee0b..bd05f751ed 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 @@ -8,6 +8,7 @@ import android.os.Bundle; import androidx.appcompat.app.AppCompatActivity; +import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.appbar.CollapsingToolbarLayout; import com.google.android.material.appbar.MaterialToolbar; @@ -50,6 +51,9 @@ public class ConvertActivity extends AppCompatActivity ctb.setTitle(getString(R.string.convert_convert)); setSupportActionBar(tb); getSupportActionBar().setDisplayHomeAsUpEnabled(true); + + AppBarLayout appBarLayout = findViewById(R.id.appbar_convert); + ThemeHelper.enableScrollTint(tb, appBarLayout, this); } @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 fddbad7e28..02ee1bcc82 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 @@ -17,6 +17,8 @@ import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; +import com.google.android.material.appbar.AppBarLayout; +import com.google.android.material.appbar.MaterialToolbar; import com.google.android.material.dialog.MaterialAlertDialogBuilder; import org.dolphinemu.dolphinemu.R; @@ -85,9 +87,12 @@ public class UserDataActivity extends AppCompatActivity buttonExportUserData.setOnClickListener(view -> exportUserData()); - Toolbar tb = findViewById(R.id.toolbar_user_data); + MaterialToolbar tb = findViewById(R.id.toolbar_user_data); setSupportActionBar(tb); getSupportActionBar().setDisplayHomeAsUpEnabled(true); + + AppBarLayout appBarLayout = findViewById(R.id.appbar_user_data); + ThemeHelper.enableScrollTint(tb, appBarLayout, this); } @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 70487da0b9..721d8e42e3 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 @@ -12,6 +12,7 @@ import androidx.appcompat.app.AppCompatActivity; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; +import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.appbar.CollapsingToolbarLayout; import com.google.android.material.appbar.MaterialToolbar; @@ -86,6 +87,9 @@ public class RiivolutionBootActivity extends AppCompatActivity ctb.setTitle(getString(R.string.riivolution_riivolution)); setSupportActionBar(tb); getSupportActionBar().setDisplayHomeAsUpEnabled(true); + + AppBarLayout appBarLayout = findViewById(R.id.appbar_riivolution); + ThemeHelper.enableScrollTint(tb, appBarLayout, this); } @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 1139688418..f21764689c 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 @@ -14,11 +14,12 @@ import android.widget.Toast; import androidx.annotation.NonNull; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; -import androidx.appcompat.widget.Toolbar; import androidx.fragment.app.FragmentTransaction; import androidx.lifecycle.ViewModelProvider; +import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.appbar.CollapsingToolbarLayout; +import com.google.android.material.appbar.MaterialToolbar; import com.google.android.material.dialog.MaterialAlertDialogBuilder; import org.dolphinemu.dolphinemu.NativeLibrary; @@ -88,10 +89,13 @@ public final class SettingsActivity extends AppCompatActivity implements Setting mPresenter = new SettingsActivityPresenter(this, getSettings()); mPresenter.onCreate(savedInstanceState, menuTag, gameID, revision, isWii, this); - Toolbar tb = findViewById(R.id.toolbar_settings); + MaterialToolbar tb = findViewById(R.id.toolbar_settings); mToolbarLayout = findViewById(R.id.toolbar_settings_layout); setSupportActionBar(tb); getSupportActionBar().setDisplayHomeAsUpEnabled(true); + + AppBarLayout appBarLayout = findViewById(R.id.appbar_settings); + ThemeHelper.enableScrollTint(tb, appBarLayout, this); } @Override 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 5cc4f5b4ec..ab66878383 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 @@ -6,6 +6,12 @@ import android.content.res.Configuration; import android.os.Build; import android.preference.PreferenceManager; +import androidx.annotation.ColorInt; + +import com.google.android.material.appbar.AppBarLayout; +import com.google.android.material.appbar.MaterialToolbar; +import com.google.android.material.color.MaterialColors; + import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.ui.main.ThemeProvider; @@ -104,4 +110,37 @@ public class ThemeHelper activity.recreate(); } } + + private static void setStatusBarColor(@ColorInt int color, Activity activity) + { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) + { + activity.getWindow() + .setStatusBarColor(activity.getResources().getColor(android.R.color.black)); + } + else + { + activity.getWindow().setStatusBarColor(color); + } + } + + public static void enableScrollTint(MaterialToolbar toolbar, AppBarLayout appBarLayout, + Activity activity) + { + appBarLayout.addOnOffsetChangedListener((layout, verticalOffset) -> + { + if (-verticalOffset >= (layout.getTotalScrollRange() / 2)) + { + @ColorInt int color = MaterialColors.getColor(toolbar, R.attr.colorSurfaceVariant); + toolbar.setBackgroundColor(color); + setStatusBarColor(color, activity); + } + else + { + @ColorInt int color = MaterialColors.getColor(toolbar, R.attr.colorSurface); + toolbar.setBackgroundColor(color); + setStatusBarColor(color, activity); + } + }); + } } 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 0bdfb7059b..581f8bddbe 100644 --- a/Source/Android/app/src/main/res/layout/activity_cheats.xml +++ b/Source/Android/app/src/main/res/layout/activity_cheats.xml @@ -1,6 +1,6 @@ - @@ -9,7 +9,8 @@ android:id="@+id/appbar_cheats" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_alignParentTop="true"> + android:layout_alignParentTop="true" + app:elevation="0dp"> + android:layout_height="wrap_content" + app:elevation="0dp"> + android:layout_alignParentTop="true" + app:elevation="0dp">