Skip to content

Commit

Permalink
Add remaining android bridge functions
Browse files Browse the repository at this point in the history
  • Loading branch information
aidewoode committed Mar 21, 2024
1 parent ac91df0 commit 5c2dc9c
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/javascript/controllers/flash_bridge_controller.js
Expand Up @@ -7,6 +7,6 @@ export default class extends Controller {
}

connect () {
App.nativeBridge.showFlashMessage(this.element.textContent)
App.nativeBridge.showFlashMessage(this.element.textContent.trim())
}
}
20 changes: 20 additions & 0 deletions app/javascript/native_bridge.js
Expand Up @@ -9,6 +9,10 @@ class NativeBridge {
resourceId: Number(resourceId)
})
}

if (isAndroidApp()) {
window.NativeBridge.playAll(resourceType, Number(resourceId))
}
}

playSong (songId) {
Expand All @@ -18,6 +22,10 @@ class NativeBridge {
songId: Number(songId)
})
}

if (isAndroidApp()) {
window.NativeBridge.playSong(Number(songId))
}
}

playNext (songId) {
Expand All @@ -27,6 +35,10 @@ class NativeBridge {
songId: Number(songId)
})
}

if (isAndroidApp()) {
window.NativeBridge.playNext(Number(songId))
}
}

playLast (songId) {
Expand All @@ -36,6 +48,10 @@ class NativeBridge {
songId: Number(songId)
})
}

if (isAndroidApp()) {
window.NativeBridge.playLast(Number(songId))
}
}

search (query) {
Expand All @@ -62,6 +78,10 @@ class NativeBridge {
message
})
}

if (isAndroidApp()) {
window.NativeBridge.showFlashMessage(message)
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/views/albums/show.html.erb
Expand Up @@ -23,7 +23,7 @@
"disabled-on-native" => "true",
"turbo-frame" => "turbo-playlist",
"action" => "playlist-songs-bridge#playAll",
"playlist-songs-bridge-resource-type-param" => "albums",
"playlist-songs-bridge-resource-type-param" => "album",
"playlist-songs-bridge-resource-id-param" => @album.id
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/views/favorite_playlist/songs/index.html.erb
Expand Up @@ -22,7 +22,7 @@
"disabled-on-native" => "true",
"turbo-frame" => "turbo-playlist",
"action" => "playlist-songs-bridge#playAll",
"playlist-songs-bridge-resource-type-param" => "playlists",
"playlist-songs-bridge-resource-type-param" => "playlist",
"playlist-songs-bridge-resource-id-param" => @playlist.id
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/views/playlists/songs/index.html.erb
Expand Up @@ -24,7 +24,7 @@
"disabled-on-native" => "true",
"turbo-frame" => "turbo-playlist",
"action" => "playlist-songs-bridge#playAll",
"playlist-songs-bridge-resource-type-param" => "playlists",
"playlist-songs-bridge-resource-type-param" => "playlist",
"playlist-songs-bridge-resource-id-param" => @playlist.id
}
}
Expand Down

0 comments on commit 5c2dc9c

Please sign in to comment.