diff --git a/app/src/main/java/emu/skyline/preference/LicenseDialog.kt b/app/src/main/java/emu/skyline/preference/LicenseDialog.kt index 8b620f1d..d839e190 100644 --- a/app/src/main/java/emu/skyline/preference/LicenseDialog.kt +++ b/app/src/main/java/emu/skyline/preference/LicenseDialog.kt @@ -8,6 +8,7 @@ package emu.skyline.preference import android.graphics.Rect import android.os.Bundle import android.view.* +import com.google.android.material.bottomsheet.BottomSheetBehavior import com.google.android.material.bottomsheet.BottomSheetDialogFragment import emu.skyline.databinding.LicenseDialogBinding @@ -32,6 +33,13 @@ class LicenseDialog : BottomSheetDialogFragment() { }.root } + override fun onStart() { + super.onStart() + + val behavior = BottomSheetBehavior.from(requireView().parent as View) + behavior.addBottomSheetCallback(binding.dragIndicator.callback) + } + override fun onViewCreated(view : View, savedInstanceState : Bundle?) { super.onViewCreated(view, savedInstanceState) diff --git a/app/src/main/java/emu/skyline/views/DragIndicatorView.kt b/app/src/main/java/emu/skyline/views/DragIndicatorView.kt new file mode 100644 index 00000000..af735db0 --- /dev/null +++ b/app/src/main/java/emu/skyline/views/DragIndicatorView.kt @@ -0,0 +1,40 @@ +/* + * SPDX-License-Identifier: MPL-2.0 + * Copyright © 2022 Skyline Team and Contributors (https://github.com/skyline-emu/) + */ + +package emu.skyline.views + +import android.content.Context +import android.util.AttributeSet +import android.view.View +import android.view.ViewGroup +import androidx.transition.TransitionManager +import com.google.android.material.bottomsheet.BottomSheetBehavior +import emu.skyline.R + +class DragIndicatorView : androidx.appcompat.widget.AppCompatImageView { + val callback = DragIndicatorCallback() + + init { + setImageResource(R.drawable.drag_indicator) + } + + constructor(context : Context) : super(context) + constructor(context : Context, attrs : AttributeSet?) : super(context, attrs) + constructor(context : Context, attrs : AttributeSet?, defStyleAttr : Int) : super(context, attrs, defStyleAttr) + + inner class DragIndicatorCallback : BottomSheetBehavior.BottomSheetCallback() { + override fun onStateChanged(bottomSheet : View, newState : Int) { + // Enables animation between visibility states + TransitionManager.beginDelayedTransition(parent as ViewGroup) + + visibility = if (newState == BottomSheetBehavior.STATE_EXPANDED && bottomSheet.top == 0) + View.INVISIBLE + else + View.VISIBLE + } + + override fun onSlide(bottomSheet : View, slideOffset : Float) {} + } +} diff --git a/app/src/main/res/drawable/drag_indicator.xml b/app/src/main/res/drawable/drag_indicator.xml new file mode 100644 index 00000000..e8e5b7f2 --- /dev/null +++ b/app/src/main/res/drawable/drag_indicator.xml @@ -0,0 +1,9 @@ + + + + + + diff --git a/app/src/main/res/layout/license_dialog.xml b/app/src/main/res/layout/license_dialog.xml index 3e2311b7..da6906f6 100644 --- a/app/src/main/res/layout/license_dialog.xml +++ b/app/src/main/res/layout/license_dialog.xml @@ -8,8 +8,13 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" - android:paddingHorizontal="2.5dp" - android:paddingTop="20dp"> + android:paddingHorizontal="2.5dp"> + + diff --git a/app/src/main/res/values-night/colors.xml b/app/src/main/res/values-night/colors.xml index 9dc91579..ff41be98 100644 --- a/app/src/main/res/values-night/colors.xml +++ b/app/src/main/res/values-night/colors.xml @@ -4,4 +4,5 @@ #FF121212 #323232 @android:color/white + #1AFFFFFF diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 7e07fd22..0780555c 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -5,4 +5,5 @@ @android:color/white #F8F8F8 @android:color/black + #1E000000