From 39a289e7f105f5186cfc0626a1ecbd707bdce97a Mon Sep 17 00:00:00 2001 From: Clayton Hickey Date: Wed, 16 Sep 2020 14:18:06 -0400 Subject: [PATCH] Add ability to download & delete your own videos and move unpublish button to description --- .../ui/findcontent/FileViewFragment.java | 60 +++++++++++-------- .../main/res/drawable-anydpi/ic_unpublish.xml | 11 ++++ .../main/res/layout/fragment_file_view.xml | 47 +++++++++------ app/src/main/res/values/strings.xml | 1 + 4 files changed, 76 insertions(+), 43 deletions(-) create mode 100644 app/src/main/res/drawable-anydpi/ic_unpublish.xml diff --git a/app/src/main/java/io/lbry/browser/ui/findcontent/FileViewFragment.java b/app/src/main/java/io/lbry/browser/ui/findcontent/FileViewFragment.java index b5c28c7b..7eab0ebe 100644 --- a/app/src/main/java/io/lbry/browser/ui/findcontent/FileViewFragment.java +++ b/app/src/main/java/io/lbry/browser/ui/findcontent/FileViewFragment.java @@ -1010,30 +1010,39 @@ public class FileViewFragment extends BaseFragment implements } if (claim != null) { - boolean isOwnClaim = Lbry.ownClaims.contains(claim); - if (isOwnClaim) { - AlertDialog.Builder builder = new AlertDialog.Builder(getContext()). - setTitle(R.string.delete_content). - setMessage(R.string.confirm_delete_content_message) - .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - deleteCurrentClaim(); - } - }).setNegativeButton(R.string.no, null); - builder.show(); - } else { - AlertDialog.Builder builder = new AlertDialog.Builder(getContext()). - setTitle(R.string.delete_file). - setMessage(R.string.confirm_delete_file_message) - .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - deleteClaimFile(); - } - }).setNegativeButton(R.string.no, null); - builder.show(); - } + AlertDialog.Builder builder = new AlertDialog.Builder(getContext()). + setTitle(R.string.delete_file). + setMessage(R.string.confirm_delete_file_message) + .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + deleteClaimFile(); + } + }).setNegativeButton(R.string.no, null); + builder.show(); + } + } + }); + + root.findViewById(R.id.file_view_action_unpublish).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if (!Lbry.SDK_READY) { + Snackbar.make(root.findViewById(R.id.file_view_claim_display_area), R.string.sdk_initializing_functionality, Snackbar.LENGTH_LONG).show(); + return; + } + + if (claim != null) { + AlertDialog.Builder builder = new AlertDialog.Builder(getContext()). + setTitle(R.string.delete_content). + setMessage(R.string.confirm_delete_content_message) + .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + deleteCurrentClaim(); + } + }).setNegativeButton(R.string.no, null); + builder.show(); } } }); @@ -2773,10 +2782,9 @@ public class FileViewFragment extends BaseFragment implements boolean isOwnClaim = Lbry.ownClaims.contains(claim); View root = getView(); if (root != null) { - Helper.setViewVisibility(root.findViewById(R.id.file_view_action_download), isOwnClaim ? View.GONE : View.VISIBLE); Helper.setViewVisibility(root.findViewById(R.id.file_view_action_report), isOwnClaim ? View.GONE : View.VISIBLE); Helper.setViewVisibility(root.findViewById(R.id.file_view_action_edit), isOwnClaim ? View.VISIBLE : View.GONE); - Helper.setViewVisibility(root.findViewById(R.id.file_view_action_delete), isOwnClaim ? View.VISIBLE : View.GONE); + Helper.setViewVisibility(root.findViewById(R.id.file_view_action_unpublish), isOwnClaim ? View.VISIBLE : View.GONE); } } } diff --git a/app/src/main/res/drawable-anydpi/ic_unpublish.xml b/app/src/main/res/drawable-anydpi/ic_unpublish.xml new file mode 100644 index 00000000..802a3e6f --- /dev/null +++ b/app/src/main/res/drawable-anydpi/ic_unpublish.xml @@ -0,0 +1,11 @@ + + + diff --git a/app/src/main/res/layout/fragment_file_view.xml b/app/src/main/res/layout/fragment_file_view.xml index 2bc6e115..1139d78c 100644 --- a/app/src/main/res/layout/fragment_file_view.xml +++ b/app/src/main/res/layout/fragment_file_view.xml @@ -2,6 +2,7 @@ @@ -578,52 +579,63 @@ + + android:textSize="12sp" /> + + android:layout_marginEnd="16dp" + android:layout_weight="10" + android:orientation="horizontal" + android:paddingTop="36dp"> + + android:textFontWeight="600" + android:textSize="12sp" /> + + android:layout_height="wrap_content" + android:layout_marginStart="8dp" + android:layout_weight="8" /> +