some buttons inject
This commit is contained in:
@@ -81,7 +81,7 @@ public class LibVKXClient {
|
||||
lambdaplay(list, musicTrack, iLibVkxService, null);
|
||||
}
|
||||
|
||||
private static String asId(MusicTrack musicTrack) {
|
||||
public static String asId(MusicTrack musicTrack) {
|
||||
String str = musicTrack.e + "_" + musicTrack.d;
|
||||
if (musicTrack.O == null || musicTrack.O.equals("")) {
|
||||
return str;
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
package ru.vtosters.lite.hooks.ui;
|
||||
|
||||
import static bruhcollective.itaysonlab.libvkx.client.LibVKXClient.asId;
|
||||
import static bruhcollective.itaysonlab.libvkx.client.LibVKXClient.getInstance;
|
||||
import static bruhcollective.itaysonlab.libvkx.client.LibVKXClient.isVkxInstalled;
|
||||
import static bruhcollective.itaysonlab.libvkx.client.LibVKXClient.lambdaplay;
|
||||
import static ru.vtosters.lite.music.cache.CacheDatabaseDelegate.isCached;
|
||||
import static ru.vtosters.lite.music.cache.CacheDatabaseDelegate.removeTrackFromCache;
|
||||
import static ru.vtosters.lite.utils.Preferences.milkshake;
|
||||
|
||||
import com.vk.dto.music.MusicTrack;
|
||||
@@ -10,22 +16,32 @@ import com.vtosters.lite.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import bruhcollective.itaysonlab.libvkx.client.LibVKXClient;
|
||||
import bruhcollective.itaysonlab.libvkx.client.LibVKXClientImpl;
|
||||
import ru.vtosters.lite.music.MP3Downloader;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
|
||||
public class MusicBottomSheetHook {
|
||||
public static ArrayList<MusicAction> hook(ArrayList<MusicAction> actions, MusicTrack musicTrack) {
|
||||
if (LibVKXClient.isVkxInstalled())
|
||||
if (isVkxInstalled())
|
||||
actions.add(getPlayInVKXAction());
|
||||
|
||||
if (isCached(asId(musicTrack))){
|
||||
actions.add(getRemoveCacheTrackAction());
|
||||
} else {
|
||||
actions.add(addToCacheTrackAction());
|
||||
}
|
||||
|
||||
actions.add(downloadAsMp3Action());
|
||||
|
||||
return actions;
|
||||
}
|
||||
|
||||
public static ArrayList<MusicAction> hook(ArrayList<MusicAction> actions, Playlist playlist) {
|
||||
if (LibVKXClient.isVkxInstalled())
|
||||
if (isVkxInstalled())
|
||||
actions.add(getPlayInVKXAction());
|
||||
|
||||
actions.add(downloadAsMp3Action());
|
||||
|
||||
return actions;
|
||||
}
|
||||
|
||||
@@ -33,6 +49,21 @@ public class MusicBottomSheetHook {
|
||||
if (actionId == AndroidUtils.getIdentifier("play_in_vkx", "id"))
|
||||
return tryPlayInVKX(track, context, playlist);
|
||||
|
||||
if (actionId == AndroidUtils.getIdentifier("remove_from_cache", "id")) {
|
||||
removeTrackFromCache(track.D);
|
||||
AndroidUtils.sendToast("remove_from_cache");
|
||||
return true;
|
||||
} else if (actionId == AndroidUtils.getIdentifier("add_to_cache", "id")) {
|
||||
AndroidUtils.sendToast("add_to_cache");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (actionId == AndroidUtils.getIdentifier("download_mp3", "id")) {
|
||||
MP3Downloader.downloadMP3(track);
|
||||
AndroidUtils.sendToast("download_mp3");
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -40,6 +71,12 @@ public class MusicBottomSheetHook {
|
||||
if (actionId == AndroidUtils.getIdentifier("play_in_vkx", "id"))
|
||||
return tryPlayInVKX(null, null, playlist);
|
||||
|
||||
if (actionId == AndroidUtils.getIdentifier("download_mp3", "id")) {
|
||||
MP3Downloader.downloadPlaylist(playlist);
|
||||
AndroidUtils.sendToast("download_mp3");
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -52,8 +89,8 @@ public class MusicBottomSheetHook {
|
||||
trackList.add(track);
|
||||
}
|
||||
|
||||
LibVKXClientImpl.LibVKXAction action = iLibVkxService -> LibVKXClient.lambdaplay(trackList, track, iLibVkxService, context);
|
||||
return LibVKXClient.getInstance().runOnService(action);
|
||||
LibVKXClientImpl.LibVKXAction action = iLibVkxService -> lambdaplay(trackList, track, iLibVkxService, context);
|
||||
return getInstance().runOnService(action);
|
||||
}
|
||||
|
||||
private static MusicAction getPlayInVKXAction() {
|
||||
@@ -66,4 +103,37 @@ public class MusicBottomSheetHook {
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
private static MusicAction getRemoveCacheTrackAction() {
|
||||
return new MusicAction(
|
||||
AndroidUtils.getIdentifier("remove_from_cache", "id"),
|
||||
milkshake() ? R.drawable.ic_delete_outline_28 : R.drawable.ic_delete_24,
|
||||
AndroidUtils.getIdentifier("remove_from_cache", "string"),
|
||||
R.color.caption_gray,
|
||||
R.string.music_talkback_empty,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
private static MusicAction addToCacheTrackAction() {
|
||||
return new MusicAction(
|
||||
AndroidUtils.getIdentifier("add_to_cache", "id"),
|
||||
milkshake() ? R.drawable.ic_add_outline_28 : R.drawable.ic_add_24,
|
||||
AndroidUtils.getIdentifier("add_to_cache", "string"),
|
||||
R.color.caption_gray,
|
||||
R.string.music_talkback_empty,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
private static MusicAction downloadAsMp3Action() {
|
||||
return new MusicAction(
|
||||
AndroidUtils.getIdentifier("download_mp3", "id"),
|
||||
milkshake() ? R.drawable.ic_download_outline_28 : R.drawable.ic_download_24,
|
||||
AndroidUtils.getIdentifier("download_mp3", "string"),
|
||||
R.color.caption_gray,
|
||||
R.string.music_talkback_empty,
|
||||
false
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5953,6 +5953,7 @@
|
||||
|
||||
<string name="download_mp3">Скачать как mp3</string>
|
||||
<string name="remove_from_cache">Удалить из кеша</string>
|
||||
<string name="add_to_cache">Добавить в кэш</string>
|
||||
<string name="play_in_vkx">Воспроизвести в VK X</string>
|
||||
|
||||
|
||||
|
||||
@@ -3915,4 +3915,6 @@
|
||||
<item name="download_video" type="id" />
|
||||
<item name="savedmsg" type="id" />
|
||||
<item name="play_in_vkx" type="id" />
|
||||
<item name="add_to_cache" type="id" />
|
||||
<item name="download_mp3" type="id" />
|
||||
</resources>
|
||||
|
||||
@@ -6088,6 +6088,7 @@ 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="add_to_cache">Add to cache</string>
|
||||
|
||||
<string name="play_in_vkx">Play the track in VK X</string>
|
||||
|
||||
|
||||
@@ -366,6 +366,8 @@
|
||||
.line 30
|
||||
iget v2, v2, Lcom/vk/dto/music/Playlist;->O:I
|
||||
|
||||
const v2, 0x0
|
||||
|
||||
if-lez v2, :cond_7
|
||||
|
||||
new-instance v2, Lcom/vk/music/bottomsheets/a/MusicAction;
|
||||
|
||||
Reference in New Issue
Block a user