diff options
| author | 2023-03-07 21:15:14 -0500 | |
|---|---|---|
| committer | 2023-06-03 00:05:38 -0700 | |
| commit | a29c615f8d2ca9b05cee1305495f58410b56d593 (patch) | |
| tree | bc32e65f7101e4b9547d4ed4d9634bf488356446 /src/android | |
| parent | android: Convert SettingsFragmentView to Kotlin (diff) | |
| download | yuzu-a29c615f8d2ca9b05cee1305495f58410b56d593.tar.gz yuzu-a29c615f8d2ca9b05cee1305495f58410b56d593.tar.xz yuzu-a29c615f8d2ca9b05cee1305495f58410b56d593.zip | |
android: Convert SettingsFrameLayout to Kotlin
Diffstat (limited to 'src/android')
2 files changed, 43 insertions, 48 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFrameLayout.java b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFrameLayout.java deleted file mode 100644 index f753368a8..000000000 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFrameLayout.java +++ /dev/null | |||
| @@ -1,48 +0,0 @@ | |||
| 1 | package org.yuzu.yuzu_emu.features.settings.ui; | ||
| 2 | |||
| 3 | import android.content.Context; | ||
| 4 | import android.util.AttributeSet; | ||
| 5 | import android.widget.FrameLayout; | ||
| 6 | |||
| 7 | /** | ||
| 8 | * FrameLayout subclass with few Properties added to simplify animations. | ||
| 9 | * Don't remove the methods appearing as unused, in order not to break the menu animations | ||
| 10 | */ | ||
| 11 | public final class SettingsFrameLayout extends FrameLayout { | ||
| 12 | private float mVisibleness = 1.0f; | ||
| 13 | |||
| 14 | public SettingsFrameLayout(Context context) { | ||
| 15 | super(context); | ||
| 16 | } | ||
| 17 | |||
| 18 | public SettingsFrameLayout(Context context, AttributeSet attrs) { | ||
| 19 | super(context, attrs); | ||
| 20 | } | ||
| 21 | |||
| 22 | public SettingsFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) { | ||
| 23 | super(context, attrs, defStyleAttr); | ||
| 24 | } | ||
| 25 | |||
| 26 | public SettingsFrameLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { | ||
| 27 | super(context, attrs, defStyleAttr, defStyleRes); | ||
| 28 | } | ||
| 29 | |||
| 30 | public float getYFraction() { | ||
| 31 | return getY() / getHeight(); | ||
| 32 | } | ||
| 33 | |||
| 34 | public void setYFraction(float yFraction) { | ||
| 35 | final int height = getHeight(); | ||
| 36 | setY((height > 0) ? (yFraction * height) : -9999); | ||
| 37 | } | ||
| 38 | |||
| 39 | public float getVisibleness() { | ||
| 40 | return mVisibleness; | ||
| 41 | } | ||
| 42 | |||
| 43 | public void setVisibleness(float visibleness) { | ||
| 44 | setScaleX(visibleness); | ||
| 45 | setScaleY(visibleness); | ||
| 46 | setAlpha(visibleness); | ||
| 47 | } | ||
| 48 | } | ||
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFrameLayout.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFrameLayout.kt new file mode 100644 index 000000000..a5370af20 --- /dev/null +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFrameLayout.kt | |||
| @@ -0,0 +1,43 @@ | |||
| 1 | package org.yuzu.yuzu_emu.features.settings.ui | ||
| 2 | |||
| 3 | import android.content.Context | ||
| 4 | import android.util.AttributeSet | ||
| 5 | import android.widget.FrameLayout | ||
| 6 | |||
| 7 | /** | ||
| 8 | * FrameLayout subclass with few Properties added to simplify animations. | ||
| 9 | * Don't remove the methods appearing as unused, in order not to break the menu animations | ||
| 10 | */ | ||
| 11 | class SettingsFrameLayout : FrameLayout { | ||
| 12 | private val mVisibleness = 1.0f | ||
| 13 | |||
| 14 | constructor(context: Context?) : super(context!!) | ||
| 15 | constructor(context: Context?, attrs: AttributeSet?) : super(context!!, attrs) | ||
| 16 | |||
| 17 | constructor( | ||
| 18 | context: Context?, | ||
| 19 | attrs: AttributeSet?, | ||
| 20 | defStyleAttr: Int | ||
| 21 | ) : super(context!!, attrs, defStyleAttr) | ||
| 22 | |||
| 23 | constructor( | ||
| 24 | context: Context?, | ||
| 25 | attrs: AttributeSet?, | ||
| 26 | defStyleAttr: Int, | ||
| 27 | defStyleRes: Int | ||
| 28 | ) : super(context!!, attrs, defStyleAttr, defStyleRes) | ||
| 29 | |||
| 30 | var yFraction: Float | ||
| 31 | get() = y / height | ||
| 32 | set(yFraction) { | ||
| 33 | val height = height | ||
| 34 | y = (if (height > 0) yFraction * height else -9999) as Float | ||
| 35 | } | ||
| 36 | var visibleness: Float | ||
| 37 | get() = mVisibleness | ||
| 38 | set(visibleness) { | ||
| 39 | scaleX = visibleness | ||
| 40 | scaleY = visibleness | ||
| 41 | alpha = visibleness | ||
| 42 | } | ||
| 43 | } | ||