-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from pansong291/dev/fix_20241019
增加倍速调整和点击模式功能
- Loading branch information
Showing
21 changed files
with
463 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
app/src/main/kotlin/pansong291/piano/wizard/dialog/MusicPlayingSettingsDialog.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package pansong291.piano.wizard.dialog | ||
|
||
import android.content.Context | ||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import android.widget.LinearLayout | ||
import android.widget.RadioGroup | ||
import android.widget.ScrollView | ||
import com.xw.repo.BubbleSeekBar | ||
import pansong291.piano.wizard.R | ||
import pansong291.piano.wizard.dialog.actions.DialogConfirmActions | ||
import pansong291.piano.wizard.dialog.base.BaseDialog | ||
import pansong291.piano.wizard.entity.MusicPlayingSettings | ||
import pansong291.piano.wizard.entity.TapMode | ||
import pansong291.piano.wizard.utils.ViewUtil | ||
|
||
class MusicPlayingSettingsDialog(context: Context) : BaseDialog(context) { | ||
private val bsbTempoRate: BubbleSeekBar | ||
private val rgTapMode: RadioGroup | ||
private val bsbEarlyRelease: BubbleSeekBar | ||
private val bsbTapInterval: BubbleSeekBar | ||
var onOk: (() -> Unit)? = null | ||
|
||
init { | ||
setIcon(R.drawable.outline_settings_applications_32) | ||
setTitle(R.string.playing_settings) | ||
DialogConfirmActions.loadIn(this) { ok, cancel -> | ||
ok.setOnClickListener { onOk?.invoke() } | ||
} | ||
val scrollView = ScrollView(context) | ||
scrollView.layoutParams = LinearLayout.LayoutParams( | ||
ViewGroup.LayoutParams.MATCH_PARENT, | ||
ViewGroup.LayoutParams.WRAP_CONTENT | ||
) | ||
val horizontalPadding = ViewUtil.dpToPx(context, 16f).toInt() | ||
scrollView.setPadding(horizontalPadding, horizontalPadding, horizontalPadding, 0) | ||
findContentWrapper().addView(scrollView) | ||
val root = LayoutInflater.from(context) | ||
.inflate(R.layout.dialog_content_music_playing_settings, scrollView) | ||
bsbTempoRate = root.findViewById(R.id.bsb_tempo_rate) | ||
rgTapMode = root.findViewById(R.id.rg_tap_mode) | ||
bsbEarlyRelease = root.findViewById(R.id.bsb_early_release) | ||
bsbTapInterval = root.findViewById(R.id.bsb_tap_interval) | ||
|
||
// FIXME 目前存在问题 https://github.com/woxingxiao/BubbleSeekBar/issues/214 | ||
// 故未启用进度气泡,待解决后再调整 | ||
/* scrollView.setOnScrollChangeListener { _, _, _, _, _ -> | ||
bsbTempoRate.correctOffsetWhenContainerOnScrolling() | ||
bsbEarlyRelease.correctOffsetWhenContainerOnScrolling() | ||
bsbTapInterval.correctOffsetWhenContainerOnScrolling() | ||
} */ | ||
rgTapMode.setOnCheckedChangeListener { _, id -> | ||
setBubbleSeekBarEnabled(bsbEarlyRelease, id == android.R.id.button2) | ||
setBubbleSeekBarEnabled(bsbTapInterval, id == android.R.id.button3) | ||
} | ||
} | ||
|
||
fun setSettings(settings: MusicPlayingSettings) { | ||
bsbTempoRate.setProgress(settings.tempoRate) | ||
rgTapMode.check( | ||
when (settings.tapMode) { | ||
TapMode.Tap -> android.R.id.button1 | ||
TapMode.TapAndHold -> android.R.id.button2 | ||
TapMode.RepeatedlyTap -> android.R.id.button3 | ||
} | ||
) | ||
setBubbleSeekBarEnabled(bsbEarlyRelease, settings.tapMode == TapMode.TapAndHold) | ||
setBubbleSeekBarEnabled(bsbTapInterval, settings.tapMode == TapMode.RepeatedlyTap) | ||
bsbEarlyRelease.setProgress(settings.earlyRelease.toFloat()) | ||
bsbTapInterval.setProgress(settings.tapInterval.toFloat()) | ||
} | ||
|
||
fun getSettings(): MusicPlayingSettings { | ||
return MusicPlayingSettings().apply { | ||
tempoRate = bsbTempoRate.progressFloat | ||
tapMode = when (rgTapMode.checkedRadioButtonId) { | ||
android.R.id.button2 -> TapMode.TapAndHold | ||
android.R.id.button3 -> TapMode.RepeatedlyTap | ||
else -> TapMode.Tap | ||
} | ||
earlyRelease = bsbEarlyRelease.progress | ||
tapInterval = bsbTapInterval.progress | ||
} | ||
} | ||
|
||
private fun setBubbleSeekBarEnabled(bsb: BubbleSeekBar, enabled: Boolean) { | ||
bsb.isEnabled = enabled | ||
bsb.alpha = if (enabled) 1f else .2f | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
app/src/main/kotlin/pansong291/piano/wizard/entity/MusicPlayingSettings.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package pansong291.piano.wizard.entity | ||
|
||
class MusicPlayingSettings { | ||
/** | ||
* 变速 | ||
*/ | ||
var tempoRate: Float = 1f | ||
|
||
/** | ||
* 点击模式 | ||
*/ | ||
var tapMode: TapMode = TapMode.Tap | ||
|
||
/** | ||
* 提前释放 | ||
* when: [TapMode.TapAndHold] | ||
*/ | ||
var earlyRelease: Int = 100 | ||
|
||
/** | ||
* 点击间隔 | ||
* when: [TapMode.RepeatedlyTap] | ||
*/ | ||
var tapInterval: Int = 100 | ||
} | ||
|
||
enum class TapMode { | ||
/** | ||
* 点触 | ||
*/ | ||
Tap, | ||
|
||
/** | ||
* 按住 | ||
*/ | ||
TapAndHold, | ||
|
||
/** | ||
* 连点 | ||
*/ | ||
RepeatedlyTap | ||
} |
Oops, something went wrong.