Skip to content

Commit 59a0f34

Browse files
committed
test
1 parent d1348b2 commit 59a0f34

12 files changed

Lines changed: 156 additions & 23 deletions

File tree

android/app/src/main/AndroidManifest.xml

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,83 @@
3131
<action android:name="android.intent.action.MAIN" />
3232
<category android:name="android.intent.category.LAUNCHER" />
3333
</intent-filter>
34-
<intent-filter android:label="@string/app_name">
34+
<intent-filter>
3535
<action android:name="android.intent.action.VIEW" />
3636
<category android:name="android.intent.category.DEFAULT" />
3737
<category android:name="android.intent.category.BROWSABLE" />
3838
<data android:scheme="lxmusic" android:host="*" />
3939
</intent-filter>
40+
<intent-filter android:priority="80">
41+
<action android:name="android.intent.action.VIEW" />
42+
<category android:name="android.intent.category.DEFAULT"/>
43+
<category android:name="android.intent.category.OPENABLE"/>
44+
45+
<data android:scheme="file"/>
46+
<data android:scheme="content" />
47+
<data android:mimeType="audio/*" />
48+
<data android:mimeType="vnd.android.cursor.dir/audio"/>
49+
<data android:mimeType="application/ogg"/>
50+
<data android:mimeType="application/x-ogg"/>
51+
</intent-filter>
52+
<intent-filter>
53+
<action android:name="android.intent.action.MAIN" />
54+
<category android:name="android.intent.category.APP_MUSIC" />
55+
</intent-filter>
56+
<intent-filter>
57+
<action android:name="com.cyanogenmod.eleven.AUDIO_PLAYER"/>
58+
<category android:name="android.intent.category.DEFAULT"/>
59+
</intent-filter>
60+
61+
<intent-filter android:priority="80">
62+
<!-- <action android:name="android.intent.action.PICK"/> -->
63+
<action android:name="android.intent.action.VIEW" />
64+
<category android:name="android.intent.category.DEFAULT"/>
65+
<category android:name="android.intent.category.OPENABLE"/>
66+
67+
<data android:scheme="file"/>
68+
<data android:scheme="content" />
69+
<data android:host="*"/>
70+
<data android:mimeType="application/javascript"/>
71+
<data android:mimeType="application/octet-stream"/>
72+
<!-- https://stackoverflow.com/a/66402243 -->
73+
<data android:pathPattern=".*\\.js" />
74+
<data android:pathPattern=".*\\..*\\.js" />
75+
<data android:pathPattern=".*\\..*\\..*\\.js" />
76+
<data android:pathSuffix=".js" />
77+
</intent-filter>
78+
79+
<intent-filter android:priority="80">
80+
<!-- <action android:name="android.intent.action.PICK"/> -->
81+
<action android:name="android.intent.action.VIEW" />
82+
<category android:name="android.intent.category.DEFAULT"/>
83+
<category android:name="android.intent.category.OPENABLE"/>
84+
85+
<data android:scheme="file"/>
86+
<data android:scheme="content" />
87+
<data android:host="*"/>
88+
<data android:mimeType="application/json"/>
89+
<data android:mimeType="application/octet-stream"/>
90+
<data android:pathPattern=".*\\.json" />
91+
<data android:pathPattern=".*\\..*\\.json" />
92+
<data android:pathPattern=".*\\..*\\..*\\.json" />
93+
<data android:pathSuffix=".json" />
94+
</intent-filter>
95+
96+
<intent-filter android:priority="80">
97+
<!-- <action android:name="android.intent.action.PICK"/> -->
98+
<action android:name="android.intent.action.VIEW" />
99+
<category android:name="android.intent.category.DEFAULT"/>
100+
<category android:name="android.intent.category.OPENABLE"/>
101+
102+
<data android:scheme="file"/>
103+
<data android:scheme="content" />
104+
<data android:host="*"/>
105+
<data android:mimeType="application/octet-stream"/>
106+
<data android:pathPattern=".*\\.lxmc" />
107+
<data android:pathPattern=".*\\..*\\.lxmc" />
108+
<data android:pathPattern=".*\\..*\\..*\\.lxmc" />
109+
<data android:pathSuffix=".lxmc" />
110+
</intent-filter>
40111
</activity>
41112

42113
<!-- Define a FileProvider for API24+ -->

publish/changeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
- 新增蓝牙歌词支持,可以通过「设置 → 播放设置 → 显示蓝牙歌词」启用(#615
88
- 新增繁体中文语言(#659, @3gf8jv4dv
9+
- 将 LX Music 设置为“音乐应用”分类,允许将 LX Music 设置为系统默认音乐播放器
10+
- 添加在程序外使用LX Music打开歌曲文件、`js``json``lxmc`文件的支持
911

1012
### 优化
1113

src/core/init/deeplink/index.ts

Lines changed: 53 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { errorDialog } from './utils'
33
import { handleMusicAction } from './musicAction'
44
import { handlePlayerAction, type PlayerAction } from './playerAction'
55
import { handleSonglistAction } from './songlistAction'
6+
import { extname, stat } from '@/utils/fs'
7+
import { handleFileMusicAction, handleFileJSAction, handleFileLXMCAction } from './fileAction'
68

79

810
const handleLinkAction = async(link: string) => {
@@ -38,14 +40,59 @@ const handleLinkAction = async(link: string) => {
3840
// default: throw new Error('Unknown type: ' + type)
3941
}
4042
}
43+
44+
const handleFileAction = async(link: string) => {
45+
const file = await stat(link)
46+
// console.log(file)
47+
switch (extname(file.name)) {
48+
case 'json':
49+
case 'lxmc':
50+
await handleFileLXMCAction(file)
51+
break
52+
case 'js':
53+
await handleFileJSAction(file)
54+
break
55+
case 'ogg':
56+
case 'flac':
57+
case 'wav':
58+
case 'mp3':
59+
await handleFileMusicAction(file)
60+
break
61+
default:
62+
if (!file.mimeType?.startsWith('audio/')) throw new Error('Unknown file type')
63+
await handleFileMusicAction(file)
64+
break
65+
}
66+
}
67+
68+
// const handleHttpAction = async(link: string) => {
69+
// }
70+
71+
4172
const runLinkAction = async(link: string) => {
42-
if (!link.startsWith('lxmusic://')) return
43-
try {
44-
await handleLinkAction(link)
45-
} catch (err: any) {
46-
errorDialog(err.message)
47-
// focusWindow()
73+
if (link.startsWith('lxmusic://')) {
74+
try {
75+
await handleLinkAction(link)
76+
} catch (err: any) {
77+
errorDialog(err.message)
78+
// focusWindow()
79+
}
80+
} else if (link.startsWith('file://') || link.startsWith('content://')) {
81+
try {
82+
await handleFileAction(link)
83+
} catch (err: any) {
84+
errorDialog(err.message)
85+
// focusWindow()
86+
}
4887
}
88+
// else if (/^https?:\/\//.test(link)) {
89+
// try {
90+
// await handleHttpAction(link)
91+
// } catch (err: any) {
92+
// errorDialog(err.message)
93+
// // focusWindow()
94+
// }
95+
// }
4996
}
5097

5198
export const initDeeplink = async() => {

src/lang/en-us.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
"date_format_minute": "{num} minutes ago",
3838
"date_format_second": "{num} seconds ago",
3939
"deep_link__handle_error_tip": "Call failed: {message}",
40+
"deep_link_file_js_confirm_tip": "Are you sure you want to import this ({name}) custom source file?",
41+
"deep_link_file_lxmc_confirm_tip": "Are you sure you want to import this ({name}) list file?",
4042
"delete": "Remove",
4143
"dialog_cancel": "No",
4244
"dialog_confirm": "OK",
@@ -49,8 +51,6 @@
4951
"ignoring_battery_optimization_check_tip": "LX Music is \"Restricted\" or \"Optimized\" in \"App battery usage\", which may cause LX Music to be prevented by the system when playing music in the background. Do you need to set LX Music to \"Unrestricted\"?",
5052
"ignoring_battery_optimization_check_title": "Background Running Permission Reminder",
5153
"input_error": "Don't type indiscriminately 😡",
52-
"list_name_default": "Default",
53-
"list_name_love": "Loved",
5454
"list_add_btn_title": "Add the song(s) to \"{name}\"",
5555
"list_add_tip_exists": "This song already exists in the list, don't click me again~😡",
5656
"list_add_title_first_add": "Add",
@@ -84,6 +84,9 @@
8484
"list_multi_add_title_first_add": "Add the selected",
8585
"list_multi_add_title_first_move": "Move the selected",
8686
"list_multi_add_title_last": "songs to ...",
87+
"list_name_default": "Default",
88+
"list_name_love": "Loved",
89+
"list_name_temp": "Temp List",
8790
"list_remove": "Remove",
8891
"list_remove_music_multi_tip": "Do you really want to remove the selected {num} songs?",
8992
"list_remove_tip": "Do you really want to remove \"{name}\"?",
@@ -96,7 +99,6 @@
9699
"list_select_local_file_desc": "Choose local song folder",
97100
"list_select_local_file_empty_tip": "No songs found in current folder",
98101
"list_select_local_file_result_failed_tip": "Found {total} song(s), successfully added {success} song(s), failed to add {failed} song(s). View the error log for details.",
99-
100102
"list_select_local_file_result_tip": "Found {Total} song(s), all added!",
101103
"list_select_local_file_temp_add_tip": "Found {total} matching files, quickly added to the current list, will now start the file metadata reading process. Please do not exit the app!",
102104
"list_select_range": "Range",
@@ -115,7 +117,6 @@
115117
"list_sort_modal_by_up": "Ascending",
116118
"list_sync": "Update",
117119
"list_sync_confirm_tip": "This will replace the songs in \"{name}\" with the songs in the online list, are you sure you want to update?",
118-
"list_name_temp": "Temp List",
119120
"list_update_error": "Failed to update \"{name}\"",
120121
"list_update_success": "Successfully updated \"{name}\"",
121122
"list_updating": "Updating",
@@ -303,11 +304,11 @@
303304
"setting_list_click_action": "Automatically switch to current list when clicking a song in the list (Only valid for \"Playlists\" and \"Charts\" page)",
304305
"setting_list_show interval": "Show song length",
305306
"setting_list_show_album_name": "Show song album name",
306-
"setting_lyric_desktop_permission_tip": "To use this feature, you need to grant LX Music the permission to display hover windows in the system permission settings.\n\nDo you go to the relevant page to grant this permission?",
307307
"setting_lyric_desktop": "Desktop Lyric",
308308
"setting_lyric_desktop_enable": "Show lyric window",
309309
"setting_lyric_desktop_lock": "Lock lyric window",
310310
"setting_lyric_desktop_maxlineNum": "Maximum Number of Lines",
311+
"setting_lyric_desktop_permission_tip": "To use this feature, you need to grant LX Music the permission to display hover windows in the system permission settings.\n\nDo you go to the relevant page to grant this permission?",
311312
"setting_lyric_desktop_single_line": "Do not wrap lyrics",
312313
"setting_lyric_desktop_text_opacity": "Lyric Font Transparency",
313314
"setting_lyric_desktop_text_size": "Lyric Font Size",

src/lang/zh-cn.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
"date_format_minute": "{num} 分钟前",
3838
"date_format_second": "{num} 秒前",
3939
"deep_link__handle_error_tip": "调用失败:{message}",
40+
"deep_link_file_js_confirm_tip": "确认要导入这个({name})自定义源文件吗?",
41+
"deep_link_file_lxmc_confirm_tip": "确认要导入这个({name})列表文件吗?",
4042
"delete": "移除",
4143
"dialog_cancel": "我不",
4244
"dialog_confirm": "好的",
@@ -49,8 +51,6 @@
4951
"ignoring_battery_optimization_check_tip": "LX Music 没有在「忽略电池优化」的白名单中,这可能会导致在后台播放音乐时被系统暂停。是否将 LX Music 加入该白名单中?",
5052
"ignoring_battery_optimization_check_title": "后台运行权限设置提醒",
5153
"input_error": "不要乱输好吧😡",
52-
"list_name_default": "试听列表",
53-
"list_name_love": "我的收藏",
5454
"list_add_btn_title": "把该歌曲添加到「{name}」",
5555
"list_add_tip_exists": "列表已经存在这首歌啦,不要再点我啦~😡",
5656
"list_add_title_first_add": "添加",
@@ -84,6 +84,9 @@
8484
"list_multi_add_title_first_add": "添加已选的",
8585
"list_multi_add_title_first_move": "移动已选的",
8686
"list_multi_add_title_last": "首歌曲到...",
87+
"list_name_default": "试听列表",
88+
"list_name_love": "我的收藏",
89+
"list_name_temp": "临时列表",
8790
"list_remove": "移除",
8891
"list_remove_music_multi_tip": "你真的想要移除所选的 {num} 首歌曲吗?",
8992
"list_remove_tip": "你真的想要移除「{name}」吗?",
@@ -114,7 +117,6 @@
114117
"list_sort_modal_by_up": "升序",
115118
"list_sync": "更新",
116119
"list_sync_confirm_tip": "这将会把「{name}」内的歌曲替换成在线列表的歌曲,你确认要更新吗?",
117-
"list_name_temp": "临时列表",
118120
"list_update_error": "「{name}」更新失败",
119121
"list_update_success": "「{name}」更新成功",
120122
"list_updating": "更新中",
@@ -302,11 +304,11 @@
302304
"setting_list_click_action": "点击列表里的歌曲时自动切换到当前列表播放(仅对歌单、排行榜有效)",
303305
"setting_list_show interval": "显示歌曲时长",
304306
"setting_list_show_album_name": "显示歌曲专辑名",
305-
"setting_lyric_desktop_permission_tip": "桌面歌词功能需要在系统权限设置中授予 LX Music 显示悬浮窗口的权限才能使用,是否去相关界面授予该权限?",
306307
"setting_lyric_desktop": "桌面歌词",
307308
"setting_lyric_desktop_enable": "显示歌词",
308309
"setting_lyric_desktop_lock": "锁定歌词",
309310
"setting_lyric_desktop_maxlineNum": "最大行数",
311+
"setting_lyric_desktop_permission_tip": "桌面歌词功能需要在系统权限设置中授予 LX Music 显示悬浮窗口的权限才能使用,是否去相关界面授予该权限?",
310312
"setting_lyric_desktop_single_line": "使用单行歌词",
311313
"setting_lyric_desktop_text_opacity": "歌词字体透明度",
312314
"setting_lyric_desktop_text_size": "歌词字体大小",

src/lang/zh-tw.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
"date_format_minute": "{num} 分鐘前",
3838
"date_format_second": "{num} 秒前",
3939
"deep_link__handle_error_tip": "呼叫失敗:{message}",
40+
"deep_link_file_js_confirm_tip": "確認要匯入這個({name})自訂原始檔嗎?",
41+
"deep_link_file_lxmc_confirm_tip": "確認要匯入這個({name})清單檔案嗎?",
4042
"delete": "移除",
4143
"dialog_cancel": "我不",
4244
"dialog_confirm": "好的",

src/screens/Home/Views/Mylist/MyList/listAction.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export const handleSync = (listInfo: LX.List.UserListInfo) => {
9292
})
9393
}
9494

95-
const buildLocalMusicInfoByFilePath = (file: FileType): LX.Music.MusicInfoLocal => {
95+
export const buildLocalMusicInfoByFilePath = (file: FileType): LX.Music.MusicInfoLocal => {
9696
const index = file.name.lastIndexOf('.')
9797
return {
9898
id: file.path,
@@ -109,7 +109,7 @@ const buildLocalMusicInfoByFilePath = (file: FileType): LX.Music.MusicInfoLocal
109109
},
110110
}
111111
}
112-
const buildLocalMusicInfo = (filePath: string, metadata: MusicMetadataFull): LX.Music.MusicInfoLocal => {
112+
export const buildLocalMusicInfo = (filePath: string, metadata: MusicMetadataFull): LX.Music.MusicInfoLocal => {
113113
return {
114114
id: filePath,
115115
name: metadata.name,

src/store/player/action.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export default {
8181
global.state_event.playPlayedListChanged({ ...state.playedList })
8282
},
8383
addTempPlayList(list: LX.Player.TempPlayListItem[]) {
84-
const topList: Array<{ listId: string, musicInfo: LX.Music.MusicInfo | LX.Download.ListItem }> = []
84+
const topList: Array<{ listId: string | null, musicInfo: LX.Music.MusicInfo | LX.Download.ListItem }> = []
8585
const bottomList = list.filter(({ isTop, ...musicInfo }) => {
8686
if (isTop) {
8787
topList.push(musicInfo)

src/types/player.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ declare global {
5757
/**
5858
* 播放列表id
5959
*/
60-
listId: string
60+
listId: string | null
6161
/**
6262
* 歌曲信息
6363
*/

src/utils/fs.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ export type {
1515

1616
// export const externalDirectoryPath = RNFS.ExternalDirectoryPath
1717

18+
export const extname = (name: string) => name.lastIndexOf('.') > 0 ? name.substring(name.lastIndexOf('.') + 1) : ''
19+
1820
export const temporaryDirectoryPath = Dirs.CacheDir
1921
export const externalStorageDirectoryPath = Dirs.SDCardDir
2022
export const privateStorageDirectoryPath = Dirs.DocumentDir

0 commit comments

Comments
 (0)