From 64733b2504f55d14000e1b321c13fcc736043b91 Mon Sep 17 00:00:00 2001 From: Charles Lombardo Date: Fri, 2 Dec 2022 22:12:33 -0500 Subject: [PATCH] Android: Use expanding Extended FAB This adds text to the FAB when expanded and shrinks the FAB on scroll. The text will return when scrolling up as well. --- .../dolphinemu/dolphinemu/ui/main/MainActivity.java | 11 +++++++++++ .../org/dolphinemu/dolphinemu/utils/InsetsHelper.java | 4 ++-- .../Android/app/src/main/res/layout/activity_main.xml | 5 +++-- Source/Android/app/src/main/res/values/strings.xml | 1 + 4 files changed, 17 insertions(+), 4 deletions(-) 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 2a0512e3ac..0e97ee2181 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 @@ -76,6 +76,17 @@ public final class MainActivity extends AppCompatActivity // Set up the FAB. mBinding.buttonAddDirectory.setOnClickListener(view -> mPresenter.onFabClick()); + mBinding.appbarMain.addOnOffsetChangedListener((appBarLayout, verticalOffset) -> + { + if (verticalOffset == 0) + { + mBinding.buttonAddDirectory.extend(); + } + else if (appBarLayout.getTotalScrollRange() == -verticalOffset) + { + mBinding.buttonAddDirectory.shrink(); + } + }); mPresenter.onCreate(); 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 index 7b98528667..311e16b10a 100644 --- 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 @@ -20,7 +20,7 @@ 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 com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton; import org.dolphinemu.dolphinemu.R; @@ -73,7 +73,7 @@ public class InsetsHelper } public static void setUpMainLayout(AppCompatActivity activity, AppBarLayout appBarLayout, - FloatingActionButton fab, ViewPager viewPager, View workaroundView) + ExtendedFloatingActionButton fab, ViewPager viewPager, View workaroundView) { ViewCompat.setOnApplyWindowInsetsListener(appBarLayout, (v, windowInsets) -> { 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 645825062a..9ce601de0d 100644 --- a/Source/Android/app/src/main/res/layout/activity_main.xml +++ b/Source/Android/app/src/main/res/layout/activity_main.xml @@ -50,11 +50,12 @@ android:clickable="true" android:background="@android:color/transparent" /> - diff --git a/Source/Android/app/src/main/res/values/strings.xml b/Source/Android/app/src/main/res/values/strings.xml index f35b5adb60..a39b0daf5e 100644 --- a/Source/Android/app/src/main/res/values/strings.xml +++ b/Source/Android/app/src/main/res/values/strings.xml @@ -440,6 +440,7 @@ GameCube Games Wii Games WiiWare Games + Add Games Add Folder to Library Settings Refresh Library