diff --git a/app/src/main/java/com/lukas/music/instruments/InternalInstrument.kt b/app/src/main/java/com/lukas/music/instruments/InternalInstrument.kt
index 6682cfe..d24f474 100644
--- a/app/src/main/java/com/lukas/music/instruments/InternalInstrument.kt
+++ b/app/src/main/java/com/lukas/music/instruments/InternalInstrument.kt
@@ -82,7 +82,7 @@
applyEffectAttributes(
id,
effect.type.ordinal,
- effect.influence.value,
+ if (effect.active) effect.influence.value else 0f,
effect.parameters[0].value
)
}
diff --git a/app/src/main/java/com/lukas/music/instruments/InternalInstrument.kt b/app/src/main/java/com/lukas/music/instruments/InternalInstrument.kt
index 6682cfe..d24f474 100644
--- a/app/src/main/java/com/lukas/music/instruments/InternalInstrument.kt
+++ b/app/src/main/java/com/lukas/music/instruments/InternalInstrument.kt
@@ -82,7 +82,7 @@
applyEffectAttributes(
id,
effect.type.ordinal,
- effect.influence.value,
+ if (effect.active) effect.influence.value else 0f,
effect.parameters[0].value
)
}
diff --git a/app/src/main/java/com/lukas/music/instruments/effect/Effect.kt b/app/src/main/java/com/lukas/music/instruments/effect/Effect.kt
index dc20f7c..f921b1b 100644
--- a/app/src/main/java/com/lukas/music/instruments/effect/Effect.kt
+++ b/app/src/main/java/com/lukas/music/instruments/effect/Effect.kt
@@ -18,6 +18,12 @@
}
val influence = EffectParameter(influenceDescription, instrument)
+ var active: Boolean = false
+ set(value) {
+ field = value
+ instrument.updateEffects()
+ }
+
companion object {
val influenceDescription = EffectParameterDescription(0.0f, 1.0f, 0.0f) {
"influence: ${it.percentageValue}%"
diff --git a/app/src/main/java/com/lukas/music/instruments/InternalInstrument.kt b/app/src/main/java/com/lukas/music/instruments/InternalInstrument.kt
index 6682cfe..d24f474 100644
--- a/app/src/main/java/com/lukas/music/instruments/InternalInstrument.kt
+++ b/app/src/main/java/com/lukas/music/instruments/InternalInstrument.kt
@@ -82,7 +82,7 @@
applyEffectAttributes(
id,
effect.type.ordinal,
- effect.influence.value,
+ if (effect.active) effect.influence.value else 0f,
effect.parameters[0].value
)
}
diff --git a/app/src/main/java/com/lukas/music/instruments/effect/Effect.kt b/app/src/main/java/com/lukas/music/instruments/effect/Effect.kt
index dc20f7c..f921b1b 100644
--- a/app/src/main/java/com/lukas/music/instruments/effect/Effect.kt
+++ b/app/src/main/java/com/lukas/music/instruments/effect/Effect.kt
@@ -18,6 +18,12 @@
}
val influence = EffectParameter(influenceDescription, instrument)
+ var active: Boolean = false
+ set(value) {
+ field = value
+ instrument.updateEffects()
+ }
+
companion object {
val influenceDescription = EffectParameterDescription(0.0f, 1.0f, 0.0f) {
"influence: ${it.percentageValue}%"
diff --git a/app/src/main/java/com/lukas/music/ui/fragments/EffectFragment.kt b/app/src/main/java/com/lukas/music/ui/fragments/EffectFragment.kt
index 1577609..ebf4cb1 100644
--- a/app/src/main/java/com/lukas/music/ui/fragments/EffectFragment.kt
+++ b/app/src/main/java/com/lukas/music/ui/fragments/EffectFragment.kt
@@ -15,8 +15,10 @@
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
+import com.lukas.music.R
import com.lukas.music.databinding.FragmentEffectBinding
import com.lukas.music.instruments.effect.Effect
+import com.lukas.music.util.setupToggle
import com.lukas.music.util.smartSetup
class EffectFragment(private val effect: Effect) : Fragment() {
@@ -28,6 +30,10 @@
): View? {
binding = FragmentEffectBinding.inflate(inflater)
binding.effectName.text = effect.type.toString()
+ binding.activeButton.setupToggle(effect::active, R.color.blue) {
+ binding.activeButton.text = if (it) "ON" else "OFF"
+ }
+ binding.activeButton.text = if (effect.active) "ON" else "OFF"
binding.influenceSeekBar.smartSetup(0, 100, effect.influence::percentageValue) {
binding.influenceText.text = effect.influence.description.text(effect.influence)
}
diff --git a/app/src/main/java/com/lukas/music/instruments/InternalInstrument.kt b/app/src/main/java/com/lukas/music/instruments/InternalInstrument.kt
index 6682cfe..d24f474 100644
--- a/app/src/main/java/com/lukas/music/instruments/InternalInstrument.kt
+++ b/app/src/main/java/com/lukas/music/instruments/InternalInstrument.kt
@@ -82,7 +82,7 @@
applyEffectAttributes(
id,
effect.type.ordinal,
- effect.influence.value,
+ if (effect.active) effect.influence.value else 0f,
effect.parameters[0].value
)
}
diff --git a/app/src/main/java/com/lukas/music/instruments/effect/Effect.kt b/app/src/main/java/com/lukas/music/instruments/effect/Effect.kt
index dc20f7c..f921b1b 100644
--- a/app/src/main/java/com/lukas/music/instruments/effect/Effect.kt
+++ b/app/src/main/java/com/lukas/music/instruments/effect/Effect.kt
@@ -18,6 +18,12 @@
}
val influence = EffectParameter(influenceDescription, instrument)
+ var active: Boolean = false
+ set(value) {
+ field = value
+ instrument.updateEffects()
+ }
+
companion object {
val influenceDescription = EffectParameterDescription(0.0f, 1.0f, 0.0f) {
"influence: ${it.percentageValue}%"
diff --git a/app/src/main/java/com/lukas/music/ui/fragments/EffectFragment.kt b/app/src/main/java/com/lukas/music/ui/fragments/EffectFragment.kt
index 1577609..ebf4cb1 100644
--- a/app/src/main/java/com/lukas/music/ui/fragments/EffectFragment.kt
+++ b/app/src/main/java/com/lukas/music/ui/fragments/EffectFragment.kt
@@ -15,8 +15,10 @@
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
+import com.lukas.music.R
import com.lukas.music.databinding.FragmentEffectBinding
import com.lukas.music.instruments.effect.Effect
+import com.lukas.music.util.setupToggle
import com.lukas.music.util.smartSetup
class EffectFragment(private val effect: Effect) : Fragment() {
@@ -28,6 +30,10 @@
): View? {
binding = FragmentEffectBinding.inflate(inflater)
binding.effectName.text = effect.type.toString()
+ binding.activeButton.setupToggle(effect::active, R.color.blue) {
+ binding.activeButton.text = if (it) "ON" else "OFF"
+ }
+ binding.activeButton.text = if (effect.active) "ON" else "OFF"
binding.influenceSeekBar.smartSetup(0, 100, effect.influence::percentageValue) {
binding.influenceText.text = effect.influence.description.text(effect.influence)
}
diff --git a/app/src/main/java/com/lukas/music/util/UIUtil.kt b/app/src/main/java/com/lukas/music/util/UIUtil.kt
index 9e2c520..b67d0ea 100644
--- a/app/src/main/java/com/lukas/music/util/UIUtil.kt
+++ b/app/src/main/java/com/lukas/music/util/UIUtil.kt
@@ -36,6 +36,9 @@
override fun onStopTrackingTouch(seekBar: SeekBar) {
}
})
+ if (progress == initialProgress) {
+ callback(initialProgress)
+ }
this.progress = initialProgress
}
diff --git a/app/src/main/java/com/lukas/music/instruments/InternalInstrument.kt b/app/src/main/java/com/lukas/music/instruments/InternalInstrument.kt
index 6682cfe..d24f474 100644
--- a/app/src/main/java/com/lukas/music/instruments/InternalInstrument.kt
+++ b/app/src/main/java/com/lukas/music/instruments/InternalInstrument.kt
@@ -82,7 +82,7 @@
applyEffectAttributes(
id,
effect.type.ordinal,
- effect.influence.value,
+ if (effect.active) effect.influence.value else 0f,
effect.parameters[0].value
)
}
diff --git a/app/src/main/java/com/lukas/music/instruments/effect/Effect.kt b/app/src/main/java/com/lukas/music/instruments/effect/Effect.kt
index dc20f7c..f921b1b 100644
--- a/app/src/main/java/com/lukas/music/instruments/effect/Effect.kt
+++ b/app/src/main/java/com/lukas/music/instruments/effect/Effect.kt
@@ -18,6 +18,12 @@
}
val influence = EffectParameter(influenceDescription, instrument)
+ var active: Boolean = false
+ set(value) {
+ field = value
+ instrument.updateEffects()
+ }
+
companion object {
val influenceDescription = EffectParameterDescription(0.0f, 1.0f, 0.0f) {
"influence: ${it.percentageValue}%"
diff --git a/app/src/main/java/com/lukas/music/ui/fragments/EffectFragment.kt b/app/src/main/java/com/lukas/music/ui/fragments/EffectFragment.kt
index 1577609..ebf4cb1 100644
--- a/app/src/main/java/com/lukas/music/ui/fragments/EffectFragment.kt
+++ b/app/src/main/java/com/lukas/music/ui/fragments/EffectFragment.kt
@@ -15,8 +15,10 @@
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
+import com.lukas.music.R
import com.lukas.music.databinding.FragmentEffectBinding
import com.lukas.music.instruments.effect.Effect
+import com.lukas.music.util.setupToggle
import com.lukas.music.util.smartSetup
class EffectFragment(private val effect: Effect) : Fragment() {
@@ -28,6 +30,10 @@
): View? {
binding = FragmentEffectBinding.inflate(inflater)
binding.effectName.text = effect.type.toString()
+ binding.activeButton.setupToggle(effect::active, R.color.blue) {
+ binding.activeButton.text = if (it) "ON" else "OFF"
+ }
+ binding.activeButton.text = if (effect.active) "ON" else "OFF"
binding.influenceSeekBar.smartSetup(0, 100, effect.influence::percentageValue) {
binding.influenceText.text = effect.influence.description.text(effect.influence)
}
diff --git a/app/src/main/java/com/lukas/music/util/UIUtil.kt b/app/src/main/java/com/lukas/music/util/UIUtil.kt
index 9e2c520..b67d0ea 100644
--- a/app/src/main/java/com/lukas/music/util/UIUtil.kt
+++ b/app/src/main/java/com/lukas/music/util/UIUtil.kt
@@ -36,6 +36,9 @@
override fun onStopTrackingTouch(seekBar: SeekBar) {
}
})
+ if (progress == initialProgress) {
+ callback(initialProgress)
+ }
this.progress = initialProgress
}
diff --git a/app/src/main/res/layout/fragment_effect.xml b/app/src/main/res/layout/fragment_effect.xml
index d5e0681..7f305be 100644
--- a/app/src/main/res/layout/fragment_effect.xml
+++ b/app/src/main/res/layout/fragment_effect.xml
@@ -35,11 +35,11 @@
android:id="@+id/influenceSeekBar"
android:layout_width="0dp"
android:layout_height="40dp"
- android:layout_marginTop="16dp"
+ android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@+id/effectName"
- app:layout_constraintTop_toBottomOf="@+id/effectName" />
+ app:layout_constraintTop_toBottomOf="@+id/activeButton" />
+
+