implement "Play in VK X" quick action in track bottomsheet
resolves #723
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package ru.vtosters.lite.hooks.ui;
|
||||
|
||||
import com.vk.dto.music.MusicTrack;
|
||||
import com.vk.music.bottomsheets.a.MusicAction;
|
||||
import com.vtosters.lite.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import bruhcollective.itaysonlab.libvkx.client.LibVKXClient;
|
||||
import bruhcollective.itaysonlab.libvkx.client.LibVKXClientImpl;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
|
||||
public class MusicBottomSheetHook {
|
||||
public static ArrayList<MusicAction> hook(ArrayList<MusicAction> actions) {
|
||||
if (LibVKXClient.isVkxInstalled()) {
|
||||
actions.add(getPlayInVKXAction());
|
||||
}
|
||||
return actions;
|
||||
}
|
||||
|
||||
public static boolean tryPlayInVKX(MusicTrack track) {
|
||||
LibVKXClientImpl.LibVKXAction action = iLibVkxService -> LibVKXClient.lambdaplay(List.of(track), track, iLibVkxService);
|
||||
return LibVKXClient.getInstance().runOnService(action);
|
||||
}
|
||||
|
||||
private static MusicAction getPlayInVKXAction() {
|
||||
return new MusicAction(
|
||||
AndroidUtils.getIdentifier("play_in_vkx", "id"),
|
||||
R.drawable.ic_music_24,
|
||||
AndroidUtils.getIdentifier("play_in_vkx", "string"),
|
||||
R.color.caption_gray,
|
||||
R.string.music_talkback_empty,
|
||||
false
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -3914,4 +3914,5 @@
|
||||
<item name="btncopyid" type="id" />
|
||||
<item name="download_video" type="id" />
|
||||
<item name="savedmsg" type="id" />
|
||||
<item name="play_in_vkx" type="id" />
|
||||
</resources>
|
||||
|
||||
@@ -6091,6 +6091,8 @@ May look like a fake leaving the online"</string>
|
||||
<string name="download_mp3">Download as mp3</string>
|
||||
<string name="remove_from_cache">Delete from cache</string>
|
||||
|
||||
<string name="play_in_vkx">Play the track in VK X</string>
|
||||
|
||||
<string name="thanksfordonate">Thank you for supporting the project!</string>
|
||||
<string name="getdonate">Support the project with a donation and get rewards</string>
|
||||
|
||||
|
||||
+6
@@ -709,6 +709,12 @@
|
||||
|
||||
move-result p1
|
||||
|
||||
invoke-static {v0}, Lru/vtosters/lite/hooks/ui/MusicBottomSheetHook;->tryPlayInVKX(Lcom/vk/dto/music/MusicTrack;)Z
|
||||
|
||||
move-result v3
|
||||
|
||||
if-nez v3, :cond_7
|
||||
|
||||
const v3, 0x7f0a0870
|
||||
|
||||
const/4 v4, 0x0
|
||||
|
||||
+6
@@ -738,5 +738,11 @@
|
||||
|
||||
:cond_a
|
||||
:goto_3
|
||||
|
||||
# invoke static ru.vtosters.lite.hooks.ui.MusicBottomSheetHook.hook(ArrayList<MusicAction> actions)
|
||||
invoke-static {v3}, Lru/vtosters/lite/hooks/ui/MusicBottomSheetHook;->hook(Ljava/util/ArrayList;)Ljava/util/ArrayList;
|
||||
|
||||
move-result-object v3
|
||||
|
||||
return-object v3
|
||||
.end method
|
||||
|
||||
Reference in New Issue
Block a user