Handle special URLs from notifications. Disable auto load/play for comment notifications.
This commit is contained in:
parent
47cbc3624c
commit
d21cfd55ab
2 changed files with 34 additions and 14 deletions
|
@ -202,8 +202,11 @@ import lombok.Setter;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity implements SdkStatusListener {
|
public class MainActivity extends AppCompatActivity implements SdkStatusListener {
|
||||||
|
private static final String CHANNEL_ID_PLAYBACK = "io.lbry.browser.LBRY_PLAYBACK_CHANNEL";
|
||||||
|
private static final int PLAYBACK_NOTIFICATION_ID = 3;
|
||||||
|
private static final String SPECIAL_URL_PREFIX = "lbry://?";
|
||||||
|
public static final String SKU_SKIP = "lbryskip";
|
||||||
|
|
||||||
static final String SKU_SKIP = "lbryskip";
|
|
||||||
private Map<String, Class> specialRouteFragmentClassMap;
|
private Map<String, Class> specialRouteFragmentClassMap;
|
||||||
@Getter
|
@Getter
|
||||||
private boolean inPictureInPictureMode;
|
private boolean inPictureInPictureMode;
|
||||||
|
@ -888,6 +891,21 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
|
||||||
openFragment(FileViewFragment.class, true, NavMenuItem.ID_ITEM_FOLLOWING, params);
|
openFragment(FileViewFragment.class, true, NavMenuItem.ID_ITEM_FOLLOWING, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void openSpecialUrl(String url) {
|
||||||
|
String specialPath = url.substring(8).toLowerCase();
|
||||||
|
if (specialRouteFragmentClassMap.containsKey(specialPath)) {
|
||||||
|
Class fragmentClass = specialRouteFragmentClassMap.get(specialPath);
|
||||||
|
if (fragmentClassNavIdMap.containsKey(fragmentClass)) {
|
||||||
|
openFragment(
|
||||||
|
specialRouteFragmentClassMap.get(specialPath),
|
||||||
|
true,
|
||||||
|
fragmentClassNavIdMap.get(fragmentClass),
|
||||||
|
null
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void openSendTo(String path) {
|
public void openSendTo(String path) {
|
||||||
Map<String, Object> params = new HashMap<>();
|
Map<String, Object> params = new HashMap<>();
|
||||||
params.put("directFilePath", path);
|
params.put("directFilePath", path);
|
||||||
|
@ -1719,9 +1737,6 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
|
||||||
mediaSession.setActive(true);
|
mediaSession.setActive(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String CHANNEL_ID_PLAYBACK = "io.lbry.browser.LBRY_PLAYBACK_CHANNEL";
|
|
||||||
private static final int PLAYBACK_NOTIFICATION_ID = 3;
|
|
||||||
|
|
||||||
public void initNotificationsPage() {
|
public void initNotificationsPage() {
|
||||||
findViewById(R.id.notification_list_empty_container).setVisibility(View.VISIBLE);
|
findViewById(R.id.notification_list_empty_container).setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
@ -2687,7 +2702,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
String url = data.toString();
|
String url = data.toString();
|
||||||
// check special urls
|
// check special urls
|
||||||
if (url.startsWith("lbry://?")) {
|
if (url.startsWith(SPECIAL_URL_PREFIX)) {
|
||||||
String specialPath = url.substring(8).toLowerCase();
|
String specialPath = url.substring(8).toLowerCase();
|
||||||
if (specialRouteFragmentClassMap.containsKey(specialPath)) {
|
if (specialRouteFragmentClassMap.containsKey(specialPath)) {
|
||||||
Class fragmentClass = specialRouteFragmentClassMap.get(specialPath);
|
Class fragmentClass = specialRouteFragmentClassMap.get(specialPath);
|
||||||
|
@ -3291,15 +3306,20 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
|
||||||
notificationListAdapter.notifyDataSetChanged();
|
notificationListAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
LbryUri target = LbryUri.tryParse(notification.getTargetUrl());
|
String targetUrl = notification.getTargetUrl();
|
||||||
if (target != null) {
|
if (targetUrl.startsWith(SPECIAL_URL_PREFIX)) {
|
||||||
if (target.isChannel()) {
|
openSpecialUrl(targetUrl);
|
||||||
openChannelUrl(notification.getTargetUrl());
|
} else {
|
||||||
} else {
|
LbryUri target = LbryUri.tryParse(notification.getTargetUrl());
|
||||||
openFileUrl(notification.getTargetUrl());
|
if (target != null) {
|
||||||
|
if (target.isChannel()) {
|
||||||
|
openChannelUrl(notification.getTargetUrl());
|
||||||
|
} else {
|
||||||
|
openFileUrl(notification.getTargetUrl());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
hideNotifications();
|
|
||||||
}
|
}
|
||||||
|
hideNotifications();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1489,7 +1489,7 @@ public class FileViewFragment extends BaseFragment implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (claim.isFree()) {
|
if (claim.isFree() && Helper.isNullOrEmpty(commentHash)) {
|
||||||
if (claim.isPlayable() || (!Lbry.SDK_READY && Lbryio.isSignedIn())) {
|
if (claim.isPlayable() || (!Lbry.SDK_READY && Lbryio.isSignedIn())) {
|
||||||
if (MainActivity.nowPlayingClaim != null && MainActivity.nowPlayingClaim.getClaimId().equalsIgnoreCase(claim.getClaimId())) {
|
if (MainActivity.nowPlayingClaim != null && MainActivity.nowPlayingClaim.getClaimId().equalsIgnoreCase(claim.getClaimId())) {
|
||||||
// claim already playing
|
// claim already playing
|
||||||
|
@ -1507,7 +1507,7 @@ public class FileViewFragment extends BaseFragment implements
|
||||||
restoreMainActionButton();
|
restoreMainActionButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Lbry.SDK_READY && !claim.isPlayable() && !claim.isViewable()) {
|
if (Lbry.SDK_READY && !claim.isPlayable() && !claim.isViewable() && Helper.isNullOrEmpty(commentHash)) {
|
||||||
if (claim.getFile() == null) {
|
if (claim.getFile() == null) {
|
||||||
loadFile();
|
loadFile();
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue