File tree 4 files changed +30
-18
lines changed
app-timer-list/src/main/java/xyz/aprildown/timer/app/timer/list
app-timer-one/src/main/java/xyz/aprildown/timer/app/timer/one
component-key/src/main/java/xyz/aprildown/timer/component/key
presentation/src/main/java/xyz/aprildown/timer/presentation/stream
4 files changed +30
-18
lines changed Original file line number Diff line number Diff line change @@ -41,8 +41,14 @@ internal class FolderToolbar(
41
41
cardElevation = context.dimen(R .dimen.elevation_timer_card).toFloat()
42
42
binding = ViewFolderToolbarBinding .inflate(LayoutInflater .from(context), this )
43
43
44
- fun requestFolderName (f : (String ) -> Unit ) {
45
- SimpleInputDialog (context).show(titleRes = RBase .string.folder_name) {
44
+ fun requestFolderName (
45
+ prefill : String? = null,
46
+ f : (String ) -> Unit ,
47
+ ) {
48
+ SimpleInputDialog (context).show(
49
+ titleRes = RBase .string.folder_name,
50
+ preFill = prefill,
51
+ ) {
46
52
if (it.isNotBlank()) {
47
53
f.invoke(it)
48
54
}
@@ -124,7 +130,10 @@ internal class FolderToolbar(
124
130
item {
125
131
labelRes = RBase .string.folder_rename
126
132
callback = {
127
- requestFolderName {
133
+ requestFolderName(
134
+ prefill = binding.textFolderToolbarCurrent.text.toString()
135
+ .takeIf { it.isNotBlank() },
136
+ ) {
128
137
this @FolderToolbar.callback?.onChangeCurrentFolderName(it)
129
138
}
130
139
}
Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ import xyz.aprildown.timer.presentation.one.OneViewModel
39
39
import xyz.aprildown.timer.presentation.stream.MachineContract
40
40
import xyz.aprildown.timer.presentation.stream.StreamState
41
41
import xyz.aprildown.timer.presentation.stream.TimerIndex
42
+ import xyz.aprildown.timer.presentation.stream.getLoop
42
43
import xyz.aprildown.timer.presentation.stream.getStep
43
44
import javax.inject.Inject
44
45
import javax.inject.Provider
@@ -245,7 +246,9 @@ abstract class BaseOneFragment<T : ViewBinding>(
245
246
protected fun showPickLoopDialog (maxLoop : Int , onPick : (Int ) -> Unit ) {
246
247
SimpleInputDialog (requireContext()).show(
247
248
inputType = InputType .TYPE_CLASS_NUMBER ,
248
- hint = getString(RBase .string.name_loop_loop_hint)
249
+ preFill = viewModel.timerCurrentIndex.value
250
+ ?.getLoop(viewModel.timer.value?.loop ? : 0 )?.toString(),
251
+ hint = getString(RBase .string.name_loop_loop_hint),
249
252
) { input ->
250
253
input.toIntOrNull()
251
254
?.takeIf { it in 1 .. maxLoop }
Original file line number Diff line number Diff line change @@ -14,7 +14,6 @@ import androidx.core.view.updateLayoutParams
14
14
import com.github.deweyreed.tools.anko.dp
15
15
import com.github.deweyreed.tools.helper.gone
16
16
import com.github.deweyreed.tools.helper.onImeActionClick
17
- import com.github.deweyreed.tools.helper.setTextAndSelectEnd
18
17
import com.google.android.material.dialog.MaterialAlertDialogBuilder
19
18
import xyz.aprildown.timer.app.base.R as RBase
20
19
@@ -71,7 +70,8 @@ class SimpleInputDialog(
71
70
}
72
71
73
72
if (! preFill.isNullOrBlank()) {
74
- edit.setTextAndSelectEnd(preFill)
73
+ edit.setText(preFill)
74
+ edit.post { edit.selectAll() }
75
75
}
76
76
if (hint != null ) {
77
77
edit.hint = hint
Original file line number Diff line number Diff line change @@ -73,15 +73,15 @@ fun Intent.putTimerIndex(index: TimerIndex?): Intent = apply {
73
73
}
74
74
}
75
75
76
- fun TimerIndex?.getNiceLoopString (max : Int = 1): String =
77
- " %d/%d" .format(
78
- this ?. let {
79
- when (it) {
80
- is TimerIndex .Start -> 1
81
- is TimerIndex . Step -> it.loopIndex + 1
82
- is TimerIndex .Group -> it.loopIndex + 1
83
- is TimerIndex .End -> max
84
- }
85
- } ? : 0 ,
86
- max
87
- )
76
+ fun TimerIndex?.getNiceLoopString (max : Int = 1): String {
77
+ return " %d/%d" .format(this ?.getLoop(max) ? : 0 , max)
78
+ }
79
+
80
+ fun TimerIndex.getLoop ( max : Int ): Int {
81
+ return when ( this ) {
82
+ is TimerIndex .Start -> 1
83
+ is TimerIndex .Step -> loopIndex + 1
84
+ is TimerIndex . Group -> loopIndex + 1
85
+ is TimerIndex . End -> max
86
+ }
87
+ }
You can’t perform that action at this time.
0 commit comments