Video author refactor, info title tweak, donation upd, build upd

This commit is contained in:
Yuriy Liskov
2022-06-20 15:44:06 +03:00
parent 6d434f83c4
commit 8b3d228454
10 changed files with 33 additions and 35 deletions

View File

@@ -126,21 +126,13 @@ To enable global voice search, an additional app must be installed alongside Sma
If you want to support my developments you are welcome to buy me a cup of coffee :)
<!--
> [BountySource (**PayPal**, **VISA**)](https://salt.bountysource.com/checkout/amount?team=smarttube)
> [QIWI (RU, Visa)](https://qiwi.com/n/GUESS025)
> [DonatePay (RU, **PayPal**, Visa)](https://new.donatepay.ru/@459197)
-->
> [**Patreon**](https://www.patreon.com/smarttube)
> [**Patreon (Visa, Mastercard, PayPal)**](https://www.patreon.com/smarttube)
> **PayPal**: firsthash at gmail.com
> **BTC**: 1JAT5VVWarVBkpVbNDn8UA8HXNdrukuBSx
> **LTC**: ltc1qgc24eq9jl9cq78qnd5jpqhemkajg9vudwyd8pw
> **ETH**: 0xe455E21a085ae195a097cd4F456051A9916A5064
> **ETC**: 0x209eCd33Fa61fA92167595eB3Aea92EE1905c815
> **XMR**: 48QsMjqfkeW54vkgKyRnjodtYxdmLk6HXfTWPSZoaFPEDpoHDwFUciGCe1QC9VAeGrgGw4PKNAksX9RW7myFqYJQDN5cHGT
> **BNB**: bnb1amjr7fauftxxyhe4f95280vklctj243k9u55fq
> **DOGE**: DBnqJwJs2GJBxrCDsi5bXwSmjnz8uGdUpB
> **eUSDT**: 0xe455e21a085ae195a097cd4f456051a9916a5064
## Support
@@ -161,8 +153,9 @@ The international group is in **English only**. But don't worry if your English
SmartTubeNext is developed single-handedly by Yurii; there is no larger team or company behind this. This is an open source, hobby project. Several others have helped with translations, some of which can be seen on [Github](https://github.com/yuliskov/SmartTubeNext/graphs/contributors), some have sent their translations directly to Yurii. There are also helpful people in the support chat.
## Build
To build, install and run a debug version, run this from the root of the project:
NOTE: OpenJDK 14 or older (!) is required. Newer JDK could cause the app crash!
To build, install and run a debug version, run this commands:
```
git clone https://github.com/yuliskov/SmartTubeNext.git

View File

@@ -232,7 +232,7 @@ public final class Video implements Parcelable {
return secondTitle != null ? secondTitle : metadataSecondTitle;
}
public String extractAuthor() {
public String getAuthor() {
if (author != null) {
return author;
}
@@ -240,15 +240,15 @@ public final class Video implements Parcelable {
return extractAuthor(secondTitle != null ? secondTitle : metadataSecondTitle);
}
private static String extractAuthor(String info) {
private static String extractAuthor(String secondTitle) {
String result = null;
if (info != null) {
info = info.replace(TERTIARY_TEXT_DELIM + " LIVE", ""); // remove special marks
String[] split = info.split(TERTIARY_TEXT_DELIM);
if (secondTitle != null) {
secondTitle = secondTitle.replace(TERTIARY_TEXT_DELIM + " LIVE", ""); // remove special marks
String[] split = secondTitle.split(TERTIARY_TEXT_DELIM);
if (split.length <= 1) {
result = info;
result = secondTitle;
} else {
// First part may be a special label (4K, Stream, New etc)
// Two cases to detect label: 1) Description is long (4 items); 2) First item of info is too short (2 letters)
@@ -264,7 +264,7 @@ public final class Video implements Parcelable {
if (group != null && group.getVideos() != null) {
for (Video video : group.getVideos()) {
if (Helpers.equals(video.extractAuthor(), author)) {
if (Helpers.equals(video.getAuthor(), author)) {
result.add(video);
}
}

View File

@@ -352,7 +352,9 @@ public class PlayerUIManager extends PlayerEventListenerHelper implements Metada
return;
}
String description = getController().getVideo().description;
Video video = getController().getVideo();
String description = video.description;
if (description == null || description.isEmpty()) {
MessageHelpers.showMessage(getActivity(), R.string.description_not_found);
@@ -363,7 +365,7 @@ public class PlayerUIManager extends PlayerEventListenerHelper implements Metada
dialogPresenter.clear();
String title = getController().getVideo().title;
String title = String.format("%s - %s", video.getTitle(), video.getAuthor());
dialogPresenter.appendLongTextCategory(title, UiOptionItem.from(description, null));

View File

@@ -124,8 +124,8 @@ public abstract class BaseMenuPresenter extends BasePresenter<Void> {
// Trying to properly format channel playlists, mixes etc
boolean isChannelPlaylistItem = video.getGroupTitle() != null && video.belongsToSameAuthorGroup() && video.belongsToSamePlaylistGroup();
boolean isUserPlaylistItem = video.getGroupTitle() != null && video.belongsToSamePlaylistGroup();
String title = isChannelPlaylistItem ? video.extractAuthor() : isUserPlaylistItem ? null : video.title;
String subtitle = isChannelPlaylistItem || isUserPlaylistItem ? video.getGroupTitle() : video.extractAuthor();
String title = isChannelPlaylistItem ? video.getAuthor() : isUserPlaylistItem ? null : video.title;
String subtitle = isChannelPlaylistItem || isUserPlaylistItem ? video.getGroupTitle() : video.getAuthor();
section.title = title != null && subtitle != null ? String.format("%s - %s", title, subtitle) : String.format("%s", title != null ? title : subtitle);
section.cardImageUrl = video.cardImageUrl;
@@ -144,8 +144,8 @@ public abstract class BaseMenuPresenter extends BasePresenter<Void> {
// Trying to properly format channel playlists, mixes etc
boolean hasChannel = video.hasChannel() && !video.isChannel();
boolean isUserPlaylistItem = video.getGroupTitle() != null && video.belongsToSamePlaylistGroup();
String title = hasChannel ? video.extractAuthor() : isUserPlaylistItem ? null : video.title;
String subtitle = isUserPlaylistItem ? video.getGroupTitle() : hasChannel || video.isChannel() ? null : video.extractAuthor();
String title = hasChannel ? video.getAuthor() : isUserPlaylistItem ? null : video.title;
String subtitle = isUserPlaylistItem ? video.getGroupTitle() : hasChannel || video.isChannel() ? null : video.getAuthor();
section.title = title != null && subtitle != null ? String.format("%s - %s", title, subtitle) : String.format("%s", title != null ? title : subtitle);
section.cardImageUrl = video.cardImageUrl;

View File

@@ -581,7 +581,7 @@ public class VideoMenuPresenter extends BaseMenuPresenter {
closeDialog();
MessageHelpers.showMessage(getContext(), String.format("%s: %s",
mVideo.extractAuthor(),
mVideo.getAuthor(),
getContext().getString(containsVideo ? R.string.removed_from_playback_queue : R.string.added_to_playback_queue))
);
}));
@@ -712,7 +712,7 @@ public class VideoMenuPresenter extends BaseMenuPresenter {
}
MessageHelpers.showMessage(getContext(),
video.extractAuthor() + ": " + getContext().getString(!video.isSubscribed ? R.string.unsubscribed_from_channel : R.string.subscribed_to_channel));
video.getAuthor() + ": " + getContext().getString(!video.isSubscribed ? R.string.unsubscribed_from_channel : R.string.subscribed_to_channel));
}
private void updateEnabledMenuItems() {

View File

@@ -543,7 +543,7 @@ public class AppDialogUtil {
for (Video video : playlist.getAll()) {
String title = video.getTitle();
String author = video.extractAuthor();
String author = video.getAuthor();
options.add(0, UiOptionItem.from( // Add to start (recent videos on top)
String.format("%s - %s", title != null ? title : "...", author != null ? author : "..."),
optionItem -> {

View File

@@ -1,12 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="donations">
<!-- <item>Donation Alerts (VISA, PayPal)|https://www.donationalerts.com/r/firsthash</item> -->
<!-- <item>BountySource (PayPal, VISA)|https://salt.bountysource.com/checkout/amount?team=smarttube</item> -->
<item>Patreon (Visa, Mastercard, PayPal)|https://www.patreon.com/smarttube</item>
<!-- <item>BountySource (Visa, Mastercard, PayPal)|https://salt.bountysource.com/checkout/amount?team=smarttube</item> -->
<item>PayPal (email)|firsthash@gmail.com</item>
<item>PayPal (link)|https://www.paypal.com/donate/?business=2WLCM95RRVWZ6</item>
<item>Patreon|https://www.patreon.com/smarttube</item>
<!-- Still doesn't work (20.06.2022) -->
<!--<item>PayPal (link)|https://www.paypal.com/donate/?business=2WLCM95RRVWZ6</item>-->
<!--<item>QIWI (RU, Visa)|https://qiwi.com/n/GUESS025</item>-->
<!-- <item>Donation Alerts (VISA, PayPal)|https://www.donationalerts.com/r/firsthash</item> -->
<!--<item>DonatePay (RU, PayPal, Visa)|https://new.donatepay.ru/@459197</item>-->
<!-- <item>PrivatBank (UA)|https://privatbank.ua/ru/sendmoney?payment=9e46a6ef78</item> -->
<item>BTC|1JAT5VVWarVBkpVbNDn8UA8HXNdrukuBSx</item>
@@ -14,6 +15,8 @@
<item>ETH|0xe455E21a085ae195a097cd4F456051A9916A5064</item>
<item>ETC|0x209eCd33Fa61fA92167595eB3Aea92EE1905c815</item>
<item>XMR|48QsMjqfkeW54vkgKyRnjodtYxdmLk6HXfTWPSZoaFPEDpoHDwFUciGCe1QC9VAeGrgGw4PKNAksX9RW7myFqYJQDN5cHGT</item>
<!--<item>BNB|bnb1amjr7fauftxxyhe4f95280vklctj243k9u55fq</item>-->
<!--<item>DOGE|DBnqJwJs2GJBxrCDsi5bXwSmjnz8uGdUpB</item>-->
<!--<item>eUSDT|0xe455e21a085ae195a097cd4f456051a9916a5064</item>-->
</string-array>
</resources>

View File

@@ -145,8 +145,8 @@ public class VideoGroupObjectAdapter extends ObjectAdapter {
}
public void removeAuthor(VideoGroup group) {
String author = group.getVideos().get(0).extractAuthor(); // assume same author
List<Video> result = Helpers.filter(mVideoItems, video -> Helpers.equals(author, video.extractAuthor()));
String author = group.getVideos().get(0).getAuthor(); // assume same author
List<Video> result = Helpers.filter(mVideoItems, video -> Helpers.equals(author, video.getAuthor()));
if (result != null) {
remove(VideoGroup.from(result));
}

View File

@@ -469,7 +469,7 @@ public class PlaybackFragment extends SeekModePlaybackFragment implements Playba
metadataBuilder.putString(MediaMetadataCompat.METADATA_KEY_TITLE, getVideo().title);
metadataBuilder.putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_TITLE, getVideo().title);
metadataBuilder.putString(MediaMetadataCompat.METADATA_KEY_ARTIST, getVideo().extractAuthor());
metadataBuilder.putString(MediaMetadataCompat.METADATA_KEY_ARTIST, getVideo().getAuthor());
metadataBuilder.putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_SUBTITLE, getVideo().secondTitle);
metadataBuilder.putString(MediaMetadataCompat.METADATA_KEY_ALBUM_ART_URI, getVideo().cardImageUrl);
metadataBuilder.putLong(MediaMetadataCompat.METADATA_KEY_DURATION, getLengthMs());

View File

@@ -212,7 +212,7 @@ public class NavigateTitleView extends TitleView {
if (newVisibility == View.VISIBLE) {
Video video = PlaybackPresenter.instance(getContext()).getVideo();
mPipTitle.setText(video != null ? String.format("%s - %s", video.title, video.extractAuthor()) : "");
mPipTitle.setText(video != null ? String.format("%s - %s", video.title, video.getAuthor()) : "");
}
}
}