feat: Custom Artwork Api

This commit is contained in:
xtaodada 2022-09-25 18:39:15 +08:00
parent 1b67eb76ef
commit c611508c92
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659
5 changed files with 14 additions and 0 deletions

View File

@ -31,6 +31,7 @@ import android.util.Base64;
import androidx.collection.LongSparseArray;
import xyz.nextalone.nagram.NaConfig;
import xyz.nextalone.nagram.helper.MessageHelper;
import xyz.nextalone.nagram.ui.syntaxhighlight.SyntaxHighlight;
@ -69,6 +70,7 @@ import java.util.Collections;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicReference;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -6239,6 +6241,10 @@ public class MessageObject {
return null;
}
try {
String custom_api = NaConfig.INSTANCE.getCustomArtworkApi().String();
if (!Objects.equals(custom_api, "")) {
return custom_api + URLEncoder.encode(performer + " - " + title, "UTF-8");
}
return "athumb://itunes.apple.com/search?term=" + URLEncoder.encode(performer + " - " + title, "UTF-8") + "&entity=song&limit=4" + (small ? "&s=1" : "");
} catch (Exception ignore) {

View File

@ -96,6 +96,7 @@ public class NekoExperimentalSettingsActivity extends BaseFragment {
private final AbstractConfigCell forceCopyRow = cellGroup.appendCell(new ConfigCellTextCheck(NaConfig.INSTANCE.getForceCopy()));
private final AbstractConfigCell audioEnhanceRow = cellGroup.appendCell(new ConfigCellTextCheck(NaConfig.INSTANCE.getNoiseSuppressAndVoiceEnhance()));
private final AbstractConfigCell showRPCErrorRow = cellGroup.appendCell(new ConfigCellTextCheck(NaConfig.INSTANCE.getShowRPCError()));
private final AbstractConfigCell customArtworkApiRow = cellGroup.appendCell(new ConfigCellTextInput(null, NaConfig.INSTANCE.getCustomArtworkApi(), "", null));
private final AbstractConfigCell divider1 = cellGroup.appendCell(new ConfigCellDivider());
private UndoView tooltip;

View File

@ -263,6 +263,11 @@ object NaConfig {
ConfigItem.configTypeBool,
false
)
val customArtworkApi = addConfig(
"CustomArtworkApi",
ConfigItem.configTypeString,
""
)
private fun addConfig(
k: String,

View File

@ -60,4 +60,5 @@
<string name="SendWithoutMarkdown">禁用 Markdown</string>
<string name="SaveWithoutMarkdown">禁用 Markdown</string>
<string name="SendAsEmoji">禁用小游戏</string>
<string name="CustomArtworkApi">自定义音乐封面 API</string>
</resources>

View File

@ -61,4 +61,5 @@
<string name="SendWithoutMarkdown">Send without markdown</string>
<string name="SaveWithoutMarkdown">Save without markdown</string>
<string name="SendAsEmoji">Send as emoji</string>
<string name="CustomArtworkApi">Custom Artwork Api</string>
</resources>