@@ -16,6 +16,7 @@ import remix.myplayer.helper.EQHelper
16
16
import remix.myplayer.helper.MusicServiceRemote.getCurrentSong
17
17
import remix.myplayer.service.Command
18
18
import remix.myplayer.theme.Theme.getBaseDialog
19
+ import remix.myplayer.ui.ViewCommon
19
20
import remix.myplayer.ui.activity.PlayerActivity
20
21
import remix.myplayer.ui.dialog.AddtoPlayListDialog
21
22
import remix.myplayer.ui.dialog.TimerDialog
@@ -43,74 +44,10 @@ class AudioPopupListener(activity: PlayerActivity, private val song: Song) :
43
44
val activity = ref.get() ? : return true
44
45
when (item.itemId) {
45
46
R .id.menu_lyric -> {
46
- val alreadyIgnore = (SPUtil
47
- .getValue(ref.get(), SPUtil .LYRIC_KEY .NAME , song.id.toString(),
48
- SPUtil .LYRIC_KEY .LYRIC_DEFAULT ) == SPUtil .LYRIC_KEY .LYRIC_IGNORE )
49
-
50
- val lyricFragment = ref.get()?.lyricFragment ? : return true
51
- getBaseDialog(ref.get())
52
- .items(
53
- getString(R .string.embedded_lyric),
54
- getString(R .string.local),
55
- getString(R .string.kugou),
56
- getString(R .string.netease),
57
- getString(R .string.qq),
58
- getString(R .string.select_lrc),
59
- getString(if (! alreadyIgnore) R .string.ignore_lrc else R .string.cancel_ignore_lrc),
60
- getString(R .string.lyric_adjust_font_size),
61
- getString(R .string.change_offset))
62
- .itemsCallback { dialog, itemView, position, text ->
63
- when (position) {
64
- 0 , 1 , 2 , 3 , 4 -> { // 0内嵌 1本地 2酷狗 3网易 4qq
65
- SPUtil .putValue(ref.get(), SPUtil .LYRIC_KEY .NAME , song.id.toString(), position + 2 )
66
- lyricFragment.updateLrc(song, true )
67
- sendLocalBroadcast(MusicUtil .makeCmdIntent(Command .CHANGE_LYRIC ))
68
- }
69
- 5 -> { // 手动选择歌词
70
- val intent = Intent (Intent .ACTION_GET_CONTENT ).apply {
71
- type = MimeTypeMap .getSingleton().getMimeTypeFromExtension(" lrc" )
72
- addCategory(Intent .CATEGORY_OPENABLE )
73
- }
74
- Util .startActivityForResultSafely(
75
- activity,
76
- intent,
77
- PlayerActivity .REQUEST_SELECT_LYRIC
78
- )
79
- }
80
- 6 -> { // 忽略或者取消忽略
81
- getBaseDialog(activity)
82
- .title(if (! alreadyIgnore) R .string.confirm_ignore_lrc else R .string.confirm_cancel_ignore_lrc)
83
- .negativeText(R .string.cancel)
84
- .positiveText(R .string.confirm)
85
- .onPositive { dialog1, which ->
86
- if (! alreadyIgnore) {// 忽略
87
- SPUtil .putValue(activity, SPUtil .LYRIC_KEY .NAME , song.id.toString(),
88
- SPUtil .LYRIC_KEY .LYRIC_IGNORE )
89
- lyricFragment.updateLrc(song)
90
- } else {// 取消忽略
91
- SPUtil .putValue(activity, SPUtil .LYRIC_KEY .NAME , song.id.toString(),
92
- SPUtil .LYRIC_KEY .LYRIC_DEFAULT )
93
- lyricFragment.updateLrc(song)
94
- }
95
- sendLocalBroadcast(MusicUtil .makeCmdIntent(Command .CHANGE_LYRIC ))
96
- }
97
- .show()
98
- }
99
- 7 -> { // 字体大小调整
100
- getBaseDialog(ref.get())
101
- .items(R .array.lyric_font_size)
102
- .itemsCallback { dialog, itemView, position, text ->
103
- lyricFragment.setLyricScalingFactor(position)
104
- }
105
- .show()
106
- }
107
- 8 -> { // 歌词时间轴调整
108
- activity.showLyricOffsetView()
109
- }
110
- }
111
-
112
- }
113
- .show()
47
+ ViewCommon .showLocalLyricTip(activity) {
48
+ onClickLyric(activity)
49
+ }
50
+ return true
114
51
}
115
52
R .id.menu_edit -> {
116
53
if (! song.isLocal()) {
@@ -204,4 +141,86 @@ class AudioPopupListener(activity: PlayerActivity, private val song: Song) :
204
141
}
205
142
return true
206
143
}
144
+
145
+ private fun onClickLyric (activity : PlayerActivity ) {
146
+ val alreadyIgnore = (SPUtil
147
+ .getValue(
148
+ ref.get(), SPUtil .LYRIC_KEY .NAME , song.id.toString(),
149
+ SPUtil .LYRIC_KEY .LYRIC_DEFAULT
150
+ ) == SPUtil .LYRIC_KEY .LYRIC_IGNORE )
151
+
152
+ val lyricFragment = ref.get()?.lyricFragment ? : return
153
+ getBaseDialog(ref.get())
154
+ .items(
155
+ getString(R .string.embedded_lyric),
156
+ getString(R .string.local),
157
+ getString(R .string.kugou),
158
+ getString(R .string.netease),
159
+ getString(R .string.qq),
160
+ getString(R .string.select_lrc),
161
+ getString(if (! alreadyIgnore) R .string.ignore_lrc else R .string.cancel_ignore_lrc),
162
+ getString(R .string.lyric_adjust_font_size),
163
+ getString(R .string.change_offset)
164
+ )
165
+ .itemsCallback { dialog, itemView, position, text ->
166
+ when (position) {
167
+ 0 , 1 , 2 , 3 , 4 -> { // 0内嵌 1本地 2酷狗 3网易 4qq
168
+ SPUtil .putValue(ref.get(), SPUtil .LYRIC_KEY .NAME , song.id.toString(), position + 2 )
169
+ lyricFragment.updateLrc(song, true )
170
+ sendLocalBroadcast(MusicUtil .makeCmdIntent(Command .CHANGE_LYRIC ))
171
+ }
172
+
173
+ 5 -> { // 手动选择歌词
174
+ val intent = Intent (Intent .ACTION_GET_CONTENT ).apply {
175
+ type = MimeTypeMap .getSingleton().getMimeTypeFromExtension(" lrc" )
176
+ addCategory(Intent .CATEGORY_OPENABLE )
177
+ }
178
+ Util .startActivityForResultSafely(
179
+ activity,
180
+ intent,
181
+ PlayerActivity .REQUEST_SELECT_LYRIC
182
+ )
183
+ }
184
+
185
+ 6 -> { // 忽略或者取消忽略
186
+ getBaseDialog(activity)
187
+ .title(if (! alreadyIgnore) R .string.confirm_ignore_lrc else R .string.confirm_cancel_ignore_lrc)
188
+ .negativeText(R .string.cancel)
189
+ .positiveText(R .string.confirm)
190
+ .onPositive { dialog1, which ->
191
+ if (! alreadyIgnore) {// 忽略
192
+ SPUtil .putValue(
193
+ activity, SPUtil .LYRIC_KEY .NAME , song.id.toString(),
194
+ SPUtil .LYRIC_KEY .LYRIC_IGNORE
195
+ )
196
+ lyricFragment.updateLrc(song)
197
+ } else {// 取消忽略
198
+ SPUtil .putValue(
199
+ activity, SPUtil .LYRIC_KEY .NAME , song.id.toString(),
200
+ SPUtil .LYRIC_KEY .LYRIC_DEFAULT
201
+ )
202
+ lyricFragment.updateLrc(song)
203
+ }
204
+ sendLocalBroadcast(MusicUtil .makeCmdIntent(Command .CHANGE_LYRIC ))
205
+ }
206
+ .show()
207
+ }
208
+
209
+ 7 -> { // 字体大小调整
210
+ getBaseDialog(ref.get())
211
+ .items(R .array.lyric_font_size)
212
+ .itemsCallback { dialog, itemView, position, text ->
213
+ lyricFragment.setLyricScalingFactor(position)
214
+ }
215
+ .show()
216
+ }
217
+
218
+ 8 -> { // 歌词时间轴调整
219
+ activity.showLyricOffsetView()
220
+ }
221
+ }
222
+
223
+ }
224
+ .show()
225
+ }
207
226
}
0 commit comments