Update to SDK 0.94.1 and allow user to view livestream content on Odysee

This commit is contained in:
Javi Rueda 2021-04-26 15:10:02 +02:00
parent a878d3bdd4
commit e4417dc51d
7 changed files with 75 additions and 27 deletions

View file

@ -132,8 +132,8 @@ dependencies {
androidTestImplementation 'androidx.test.ext:junit:1.1.2' androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
__32bitImplementation 'io.lbry:lbrysdk32:0.91.0' __32bitImplementation 'io.lbry:lbrysdk32:0.94.1'
__64bitImplementation 'io.lbry:lbrysdk64:0.91.0' __64bitImplementation 'io.lbry:lbrysdk64:0.94.1'
} }
apply plugin: 'com.google.gms.google-services' apply plugin: 'com.google.gms.google-services'

View file

@ -137,6 +137,14 @@ public class Claim {
return null; return null;
} }
public boolean hasSource() {
if (value instanceof StreamMetadata) {
StreamMetadata metadata = (StreamMetadata) value;
return metadata.getSource() != null;
}
return false;
}
public boolean isPlayable() { public boolean isPlayable() {
if (value instanceof StreamMetadata) { if (value instanceof StreamMetadata) {
StreamMetadata metadata = (StreamMetadata) value; StreamMetadata metadata = (StreamMetadata) value;

View file

@ -1617,7 +1617,7 @@ public class FileViewFragment extends BaseFragment implements
root.findViewById(R.id.file_view_open_external_button).setOnClickListener(new View.OnClickListener() { root.findViewById(R.id.file_view_open_external_button).setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
openClaimExternally(claim, claim.getMediaType()); openClaimExternally(claim, claim.getMediaType(), !claim.hasSource());
} }
}); });
@ -1675,7 +1675,10 @@ public class FileViewFragment extends BaseFragment implements
restoreMainActionButton(); restoreMainActionButton();
} }
if (Lbry.SDK_READY && !claim.isPlayable() && !claim.isViewable() && Helper.isNullOrEmpty(commentHash)) { if (Lbry.SDK_READY) {
if (!claim.hasSource()) {
showUnsupportedView();
} else if (!claim.isPlayable() && !claim.isViewable() && Helper.isNullOrEmpty(commentHash)) {
if (claim.getFile() == null) { if (claim.getFile() == null) {
loadFile(); loadFile();
} else { } else {
@ -1683,6 +1686,7 @@ public class FileViewFragment extends BaseFragment implements
showUnsupportedView(); showUnsupportedView();
} }
} }
}
checkRewardsDriver(); checkRewardsDriver();
checkOwnClaim(); checkOwnClaim();
@ -1724,6 +1728,7 @@ public class FileViewFragment extends BaseFragment implements
if (root != null) { if (root != null) {
root.findViewById(R.id.file_view_exoplayer_container).setVisibility(View.GONE); root.findViewById(R.id.file_view_exoplayer_container).setVisibility(View.GONE);
root.findViewById(R.id.file_view_unsupported_container).setVisibility(View.VISIBLE); root.findViewById(R.id.file_view_unsupported_container).setVisibility(View.VISIBLE);
if (claim.hasSource()) {
String fileNameString = ""; String fileNameString = "";
if (claim.getFile() != null && !Helper.isNullOrEmpty(claim.getFile().getDownloadPath())) { if (claim.getFile() != null && !Helper.isNullOrEmpty(claim.getFile().getDownloadPath())) {
LbryFile lbryFile = claim.getFile(); LbryFile lbryFile = claim.getFile();
@ -1731,6 +1736,11 @@ public class FileViewFragment extends BaseFragment implements
fileNameString = String.format("\"%s\" ", file.getName()); fileNameString = String.format("\"%s\" ", file.getName());
} }
((TextView) root.findViewById(R.id.file_view_unsupported_text)).setText(getString(R.string.unsupported_content_desc, fileNameString)); ((TextView) root.findViewById(R.id.file_view_unsupported_text)).setText(getString(R.string.unsupported_content_desc, fileNameString));
((MaterialButton) root.findViewById(R.id.file_view_open_external_button)).setText(getString(R.string.open));
} else {
((TextView) root.findViewById(R.id.file_view_unsupported_text)).setText(getString(R.string.unsupported_content_to_odysee_desc));
((MaterialButton) root.findViewById(R.id.file_view_open_external_button)).setText(getString(R.string.open_on_odysee_com));
}
} }
} }
@ -2182,7 +2192,7 @@ public class FileViewFragment extends BaseFragment implements
handled = true; handled = true;
} }
} else { } else {
openClaimExternally(claim, mediaType); openClaimExternally(claim, mediaType, false);
} }
} }
@ -2266,7 +2276,16 @@ public class FileViewFragment extends BaseFragment implements
" </html>"; " </html>";
} }
private void openClaimExternally(Claim claim, String mediaType) { private void openClaimExternally(Claim claim, String mediaType, boolean odyseeLink) {
if (odyseeLink) {
try {
LbryUri lbryUri = LbryUri.parse(claim.getCanonicalUrl());
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(lbryUri.toOdyseeString()));
startActivity(intent);
} catch (LbryUriException e) {
e.printStackTrace();
}
} else {
Uri fileUri = Uri.parse(claim.getFile().getDownloadPath()); Uri fileUri = Uri.parse(claim.getFile().getDownloadPath());
Intent intent = new Intent(); Intent intent = new Intent();
@ -2276,6 +2295,7 @@ public class FileViewFragment extends BaseFragment implements
Intent chooser = Intent.createChooser(intent, getString(R.string.choose_app)); Intent chooser = Intent.createChooser(intent, getString(R.string.choose_app));
startActivityForResult(chooser, 419); startActivityForResult(chooser, 419);
} }
}
public void showError(String message) { public void showError(String message) {
View root = getView(); View root = getView();

View file

@ -16,6 +16,7 @@ import static org.apache.commons.codec.CharEncoding.UTF_8;
@Data @Data
public class LbryUri { public class LbryUri {
public static final String LBRY_TV_BASE_URL = "https://lbry.tv/"; public static final String LBRY_TV_BASE_URL = "https://lbry.tv/";
public static final String ODYSEE_COM_BASE_URL = "https://odysee.com/";
public static final String PROTO_DEFAULT = "lbry://"; public static final String PROTO_DEFAULT = "lbry://";
public static final String REGEX_INVALID_URI = "[ =&#:$@%?;/\\\\\"<>%\\{\\}|^~\\[\\]`\u0000-\u0008\u000b-\u000c\u000e-\u001F\uD800-\uDFFF\uFFFE-\uFFFF]"; public static final String REGEX_INVALID_URI = "[ =&#:$@%?;/\\\\\"<>%\\{\\}|^~\\[\\]`\u0000-\u0008\u000b-\u000c\u000e-\u001F\uD800-\uDFFF\uFFFE-\uFFFF]";
public static final String REGEX_ADDRESS = "^(b)(?=[^0OIl]{32,33})[0-9A-Za-z]{32,33}$"; public static final String REGEX_ADDRESS = "^(b)(?=[^0OIl]{32,33})[0-9A-Za-z]{32,33}$";
@ -202,7 +203,7 @@ public class LbryUri {
} }
String primaryClaimName = null; String primaryClaimName = null;
if (protocol.equals(LBRY_TV_BASE_URL) && Helper.isNullOrEmpty(formattedChannelName)) { if ((protocol.equals(LBRY_TV_BASE_URL) || protocol.equals(ODYSEE_COM_BASE_URL)) && Helper.isNullOrEmpty(formattedChannelName)) {
try { try {
primaryClaimName = URLEncoder.encode(claimName, UTF_8); primaryClaimName = URLEncoder.encode(claimName, UTF_8);
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
@ -241,7 +242,7 @@ public class LbryUri {
secondaryClaimName = contentName; secondaryClaimName = contentName;
} }
if (Helper.isNullOrEmpty(secondaryClaimName)) { if (Helper.isNullOrEmpty(secondaryClaimName)) {
if (protocol.equals(LBRY_TV_BASE_URL)) { if (protocol.equals(LBRY_TV_BASE_URL) || protocol.equals(ODYSEE_COM_BASE_URL)) {
try { try {
secondaryClaimName = !Helper.isNullOrEmpty(formattedChannelName) ? URLEncoder.encode(streamName, UTF_8) : null; secondaryClaimName = !Helper.isNullOrEmpty(formattedChannelName) ? URLEncoder.encode(streamName, UTF_8) : null;
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
@ -254,7 +255,7 @@ public class LbryUri {
String secondaryClaimId = !Helper.isNullOrEmpty(secondaryClaimName) ? streamClaimId : null; String secondaryClaimId = !Helper.isNullOrEmpty(secondaryClaimName) ? streamClaimId : null;
if (!Helper.isNullOrEmpty(primaryClaimId)) { if (!Helper.isNullOrEmpty(primaryClaimId)) {
if (protocol.equals(LBRY_TV_BASE_URL)) if (protocol.equals(LBRY_TV_BASE_URL) || protocol.equals(ODYSEE_COM_BASE_URL))
sb.append(':').append(primaryClaimId); sb.append(':').append(primaryClaimId);
else else
sb.append('#').append(primaryClaimId); sb.append('#').append(primaryClaimId);
@ -269,7 +270,7 @@ public class LbryUri {
} }
if (!Helper.isNullOrEmpty(secondaryClaimId)) { if (!Helper.isNullOrEmpty(secondaryClaimId)) {
if (protocol.equals(LBRY_TV_BASE_URL)) if (protocol.equals(LBRY_TV_BASE_URL) || protocol.equals(ODYSEE_COM_BASE_URL))
sb.append(':').append(secondaryClaimId); sb.append(':').append(secondaryClaimId);
else else
sb.append('#').append(secondaryClaimId); sb.append('#').append(secondaryClaimId);
@ -289,6 +290,9 @@ public class LbryUri {
public String toTvString() { public String toTvString() {
return build(true, LBRY_TV_BASE_URL, false); return build(true, LBRY_TV_BASE_URL, false);
} }
public String toOdyseeString() {
return build(true, ODYSEE_COM_BASE_URL, false);
}
public String toVanityString() { public String toVanityString() {
return build(true, PROTO_DEFAULT, true); return build(true, PROTO_DEFAULT, true);
} }

View file

@ -57,6 +57,7 @@
<string name="delete">Delete</string> <string name="delete">Delete</string>
<string name="download">Download</string> <string name="download">Download</string>
<string name="open">Open</string> <string name="open">Open</string>
<string name="open_on_odysee_com">Open on ODYSEE.COM</string>
<string name="report">Report</string> <string name="report">Report</string>
<string name="loading_decentralized_data">Loading decentralized data…</string> <string name="loading_decentralized_data">Loading decentralized data…</string>
<string name="related_content">Related Content</string> <string name="related_content">Related Content</string>
@ -71,6 +72,7 @@
<string name="play">Play</string> <string name="play">Play</string>
<string name="unsupported_content">Unsupported Content</string> <string name="unsupported_content">Unsupported Content</string>
<string name="unsupported_content_desc">Sorry, we are unable to display this content in the app. You can find the file %1$sin your downloads folder.</string> <string name="unsupported_content_desc">Sorry, we are unable to display this content in the app. You can find the file %1$sin your downloads folder.</string>
<string name="unsupported_content_to_odysee_desc">Sorry, we are unable to display this content in the app. Click the button to open it on the Odysee website.</string>
<string name="nothing_at_this_location">There\'s nothing at this location.</string> <string name="nothing_at_this_location">There\'s nothing at this location.</string>
<string name="dmca_complaint_blocked">In response to a complaint we received under the US Digital Millennium Copyright Act, we have blocked access to this content from our applications. &lt;a href="https://lbry.com/faq/dmca"&gt;Read more&lt;/a&gt;</string> <string name="dmca_complaint_blocked">In response to a complaint we received under the US Digital Millennium Copyright Act, we have blocked access to this content from our applications. &lt;a href="https://lbry.com/faq/dmca"&gt;Read more&lt;/a&gt;</string>
<string name="dmca_complaint_channel_blocked">In response to a complaint we received under the US Digital Millennium Copyright Act, we have blocked access to this channel from our applications. &lt;a href="https://lbry.com/faq/dmca"&gt;Read more&lt;/a&gt;</string> <string name="dmca_complaint_channel_blocked">In response to a complaint we received under the US Digital Millennium Copyright Act, we have blocked access to this channel from our applications. &lt;a href="https://lbry.com/faq/dmca"&gt;Read more&lt;/a&gt;</string>

View file

@ -178,6 +178,19 @@ public class LbryUriTest {
assertEquals("https://lbry.tv/@test:1/La-Peur%2C-Nos-Attentats%2C-c%27est-VOTRE-Se%CC%81curite%CC%81%21-Les-Guignols:6", obtained.toTvString()); assertEquals("https://lbry.tv/@test:1/La-Peur%2C-Nos-Attentats%2C-c%27est-VOTRE-Se%CC%81curite%CC%81%21-Les-Guignols:6", obtained.toTvString());
} }
@Test
public void lbryToOdyseeString() {
LbryUri obtained = new LbryUri();
try {
obtained = LbryUri.parse("lbry://@lbry#3f/lbryturns4#6",false);
} catch (LbryUriException e) {
e.printStackTrace();
}
assertEquals("https://odysee.com/@lbry:3f/lbryturns4:6", obtained.toOdyseeString());
}
@NotNull @NotNull
private LbryUri sinthesizeExpected() { private LbryUri sinthesizeExpected() {
LbryUri expectedForChannel = new LbryUri(); LbryUri expectedForChannel = new LbryUri();

View file

@ -21,6 +21,7 @@ allprojects {
google() google()
jcenter() jcenter()
maven { url "https://jitpack.io" } maven { url "https://jitpack.io" }
maven { url "https://dl.bintray.com/lbryio/io.lbry" }
} }
} }