Better handling of file view URLs. Some issue list fixes.
This commit is contained in:
parent
f317aa2174
commit
a42442b13b
8 changed files with 75 additions and 59 deletions
|
@ -181,6 +181,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
|
|||
fragmentClassNavIdMap.put(AllContentFragment.class, NavMenuItem.ID_ITEM_ALL_CONTENT);
|
||||
|
||||
fragmentClassNavIdMap.put(ChannelManagerFragment.class, NavMenuItem.ID_ITEM_CHANNELS);
|
||||
fragmentClassNavIdMap.put(LibraryFragment.class, NavMenuItem.ID_ITEM_LIBRARY);
|
||||
|
||||
fragmentClassNavIdMap.put(WalletFragment.class, NavMenuItem.ID_ITEM_WALLET);
|
||||
fragmentClassNavIdMap.put(RewardsFragment.class, NavMenuItem.ID_ITEM_REWARDS);
|
||||
|
@ -190,11 +191,11 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
|
|||
fragmentClassNavIdMap.put(AboutFragment.class, NavMenuItem.ID_ITEM_ABOUT);
|
||||
|
||||
// Internal (sub-)pages
|
||||
fragmentClassNavIdMap.put(FileViewFragment.class, NavMenuItem.ID_ITEM_FOLLOWING);
|
||||
fragmentClassNavIdMap.put(ChannelFragment.class, NavMenuItem.ID_ITEM_FOLLOWING);
|
||||
fragmentClassNavIdMap.put(SearchFragment.class, NavMenuItem.ID_ITEM_FOLLOWING);
|
||||
}
|
||||
|
||||
|
||||
public static final int REQUEST_STORAGE_PERMISSION = 1001;
|
||||
public static final int REQUEST_SIMPLE_SIGN_IN = 2001;
|
||||
public static final int REQUEST_WALLET_SYNC_SIGN_IN = 2002;
|
||||
|
|
|
@ -438,6 +438,12 @@ public class ChannelFormFragment extends BaseFragment implements
|
|||
Snackbar.make(getView(), R.string.image_upload_failed, Snackbar.LENGTH_LONG).setBackgroundTint(
|
||||
ContextCompat.getColor(context, R.color.red)
|
||||
).show();
|
||||
if (coverFilePickerActive) {
|
||||
// cover selected
|
||||
imageCover.setImageResource(R.drawable.default_channel_cover);
|
||||
} else if (thumbnailFilePickerActive) {
|
||||
imageThumbnail.setImageDrawable(null);
|
||||
}
|
||||
coverFilePickerActive = false;
|
||||
thumbnailFilePickerActive = false;
|
||||
uploading = false;
|
||||
|
|
|
@ -257,6 +257,8 @@ public class FileViewFragment extends BaseFragment implements
|
|||
// nothing at this location
|
||||
renderNothingAtLocation();
|
||||
}
|
||||
} else {
|
||||
checkAndResetNowPlayingClaim();
|
||||
}
|
||||
|
||||
if (!Helper.isNullOrEmpty(currentUrl)) {
|
||||
|
@ -266,6 +268,11 @@ public class FileViewFragment extends BaseFragment implements
|
|||
if (claim != null) {
|
||||
Helper.saveViewHistory(currentUrl, claim);
|
||||
renderClaim();
|
||||
if (claim.getFile() == null) {
|
||||
loadFile();
|
||||
} else {
|
||||
initialFileLoadDone = true;
|
||||
}
|
||||
}
|
||||
|
||||
checkIsFileComplete();
|
||||
|
@ -305,7 +312,6 @@ public class FileViewFragment extends BaseFragment implements
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
|
@ -337,11 +343,16 @@ public class FileViewFragment extends BaseFragment implements
|
|||
}
|
||||
|
||||
private void checkAndResetNowPlayingClaim() {
|
||||
if (MainActivity.nowPlayingClaim != null && claim != null &&
|
||||
if (MainActivity.nowPlayingClaim != null
|
||||
&& claim != null &&
|
||||
!MainActivity.nowPlayingClaim.getClaimId().equalsIgnoreCase(claim.getClaimId())) {
|
||||
Context context = getContext();
|
||||
if (context instanceof MainActivity) {
|
||||
((MainActivity) context).clearNowPlayingClaim();
|
||||
MainActivity activity = (MainActivity) context;
|
||||
activity.clearNowPlayingClaim();
|
||||
if (claim != null && !claim.isPlayable()) {
|
||||
activity.stopExoplayer();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -363,30 +374,6 @@ public class FileViewFragment extends BaseFragment implements
|
|||
resetPlayer();
|
||||
}
|
||||
|
||||
private void loadClaimForCacheKey(ClaimCacheKey key, String url) {
|
||||
if (Lbry.claimCache.containsKey(key)) {
|
||||
claim = Lbry.claimCache.get(key);
|
||||
Helper.saveUrlHistory(url, claim.getTitle(), UrlSuggestion.TYPE_FILE);
|
||||
Helper.saveViewHistory(url, claim);
|
||||
checkAndResetNowPlayingClaim();
|
||||
if (claim.getFile() == null) {
|
||||
loadFile();
|
||||
} else {
|
||||
initialFileLoadDone = true;
|
||||
checkInitialFileLoadDone();
|
||||
}
|
||||
renderClaim();
|
||||
} else {
|
||||
Helper.saveUrlHistory(url, null, UrlSuggestion.TYPE_FILE);
|
||||
getView().findViewById(R.id.file_view_claim_display_area).setVisibility(View.INVISIBLE);
|
||||
Context context = getContext();
|
||||
if (context instanceof MainActivity) {
|
||||
((MainActivity) context).clearNowPlayingClaim();
|
||||
}
|
||||
resolveUrl(url);
|
||||
}
|
||||
}
|
||||
|
||||
public void onSdkReady() {
|
||||
if (loadFilePending) {
|
||||
loadFile();
|
||||
|
@ -432,27 +419,16 @@ public class FileViewFragment extends BaseFragment implements
|
|||
checkIsFileComplete();
|
||||
}
|
||||
initialFileLoadDone = true;
|
||||
checkInitialFileLoadDone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Exception error) {
|
||||
initialFileLoadDone = true;
|
||||
checkInitialFileLoadDone();
|
||||
}
|
||||
});
|
||||
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
|
||||
private void checkInitialFileLoadDone() {
|
||||
if (initialFileLoadDone) {
|
||||
restoreMainActionButton();
|
||||
}
|
||||
if (claim != null && claim.isFree() && (claim.isPlayable() || claim.isViewable())) {
|
||||
onMainActionButtonClicked();
|
||||
}
|
||||
}
|
||||
|
||||
public void openClaimUrl(String url) {
|
||||
resetViewCount();
|
||||
currentUrl = url;
|
||||
|
@ -832,7 +808,7 @@ public class FileViewFragment extends BaseFragment implements
|
|||
|
||||
private void checkStoragePermissionAndFileGet() {
|
||||
Context context = getContext();
|
||||
if (MainActivity.hasPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, context)) {
|
||||
if (!MainActivity.hasPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, context)) {
|
||||
fileGetPending = true;
|
||||
MainActivity.requestPermission(
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
|
@ -840,6 +816,8 @@ public class FileViewFragment extends BaseFragment implements
|
|||
getString(R.string.storage_permission_rationale_download),
|
||||
context,
|
||||
true);
|
||||
} else {
|
||||
fileGet(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1040,7 +1018,11 @@ public class FileViewFragment extends BaseFragment implements
|
|||
}
|
||||
} else if (claim.isViewable() && Lbry.SDK_READY) {
|
||||
onMainActionButtonClicked();
|
||||
} else if (!Lbry.SDK_READY) {
|
||||
restoreMainActionButton();
|
||||
}
|
||||
} else {
|
||||
restoreMainActionButton();
|
||||
}
|
||||
|
||||
RecyclerView relatedContentList = getView().findViewById(R.id.file_view_related_content_list);
|
||||
|
@ -1192,6 +1174,11 @@ public class FileViewFragment extends BaseFragment implements
|
|||
// not free (and the user does not own the claim yet), perform a purchase
|
||||
confirmPurchaseUrl();
|
||||
} else {
|
||||
if (!claim.isPlayable() && !Lbry.SDK_READY) {
|
||||
Snackbar.make(getView().findViewById(R.id.file_view_global_layout), R.string.sdk_initializing_functionality, Snackbar.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
|
||||
getView().findViewById(R.id.file_view_main_action_button).setVisibility(View.INVISIBLE);
|
||||
getView().findViewById(R.id.file_view_main_action_loading).setVisibility(View.VISIBLE);
|
||||
handleMainActionForClaim();
|
||||
|
@ -1237,18 +1224,15 @@ public class FileViewFragment extends BaseFragment implements
|
|||
public void onSuccess(List<LbryFile> files, boolean hasReachedEnd) {
|
||||
if (files.size() > 0) {
|
||||
claim.setFile(files.get(0));
|
||||
handleMainActionForClaim();
|
||||
checkIsFileComplete();
|
||||
} else {
|
||||
checkStoragePermissionAndFileGet();
|
||||
}
|
||||
initialFileLoadDone = true;
|
||||
checkInitialFileLoadDone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Exception error) {
|
||||
initialFileLoadDone = true;
|
||||
checkInitialFileLoadDone();
|
||||
checkStoragePermissionAndFileGet();
|
||||
}
|
||||
});
|
||||
|
@ -1470,7 +1454,7 @@ public class FileViewFragment extends BaseFragment implements
|
|||
if (claim.getName().startsWith("@")) {
|
||||
activity.openChannelUrl(claim.getPermanentUrl());
|
||||
} else {
|
||||
openClaimUrl(claim.getPermanentUrl());
|
||||
activity.openFileUrl(claim.getPermanentUrl()); //openClaimUrl(claim.getPermanentUrl());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -248,7 +248,10 @@ public class InvitesFragment extends BaseFragment implements SdkStatusListener,
|
|||
}
|
||||
|
||||
private void updateInviteLink(Claim claim) {
|
||||
String link = String.format(INVITE_LINK_FORMAT, claim.getName(), claim.getClaimId());
|
||||
LbryUri canonical = LbryUri.tryParse(claim.getCanonicalUrl());
|
||||
String link = String.format(INVITE_LINK_FORMAT,
|
||||
canonical != null ? String.format("@%s", canonical.getChannelName()) : claim.getName(),
|
||||
canonical != null ? canonical.getChannelClaimId() : claim.getClaimId());
|
||||
textInviteLink.setText(link);
|
||||
}
|
||||
private void copyInviteLink() {
|
||||
|
|
6
app/src/main/res/drawable/bg_small_icon.xml
Normal file
6
app/src/main/res/drawable/bg_small_icon.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<solid android:color="@color/smallIconBackground" />
|
||||
<corners android:radius="24dp" />
|
||||
</shape>
|
|
@ -25,15 +25,22 @@
|
|||
android:layout_height="match_parent"
|
||||
android:src="@drawable/default_channel_cover"
|
||||
android:scaleType="centerCrop" />
|
||||
<ImageView
|
||||
android:id="@+id/channel_form_cover_edit_icon"
|
||||
android:layout_width="16dp"
|
||||
android:layout_height="16dp"
|
||||
<RelativeLayout
|
||||
android:background="@drawable/bg_small_icon"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:src="@drawable/ic_edit"
|
||||
android:tint="@color/white" />
|
||||
android:layout_alignParentBottom="true">
|
||||
<ImageView
|
||||
android:id="@+id/channel_form_cover_edit_icon"
|
||||
android:layout_width="16dp"
|
||||
android:layout_height="16dp"
|
||||
android:layout_centerInParent="true"
|
||||
android:src="@drawable/ic_edit"
|
||||
android:tint="@color/white" />
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/channel_form_upload_progress"
|
||||
|
@ -92,14 +99,21 @@
|
|||
android:id="@+id/channel_form_thumbnail"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
<ImageView
|
||||
android:layout_width="16dp"
|
||||
android:layout_height="16dp"
|
||||
<RelativeLayout
|
||||
android:background="@drawable/bg_small_icon"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:src="@drawable/ic_edit"
|
||||
android:tint="@color/white" />
|
||||
android:layout_centerHorizontal="true">
|
||||
<ImageView
|
||||
android:layout_width="16dp"
|
||||
android:layout_height="16dp"
|
||||
android:layout_centerInParent="true"
|
||||
android:src="@drawable/ic_edit"
|
||||
android:tint="@color/white" />
|
||||
</RelativeLayout>
|
||||
</RelativeLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
<color name="menuItemForeground">#AAAAAA</color>
|
||||
<color name="selectedNavItem">#0E0E0E</color>
|
||||
<color name="channelCoverBackground">#CC000000</color>
|
||||
<color name="smallIconBackground">#55000000</color>
|
||||
<color name="costBackground">#F4E866</color>
|
||||
|
||||
<color name="playerControlsBackground">#33000000</color>
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
<color name="menuItemForeground">#444444</color>
|
||||
<color name="selectedNavItem">#F1F1F1</color>
|
||||
<color name="channelCoverBackground">#CC000000</color>
|
||||
<color name="smallIconBackground">#55000000</color>
|
||||
<color name="costBackground">#F4E866</color>
|
||||
|
||||
<color name="playerControlsBackground">#33000000</color>
|
||||
|
|
Loading…
Reference in a new issue