mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-11-22 06:37:30 +00:00
close #517
This commit is contained in:
parent
a6b2031950
commit
8dc128563a
@ -226,7 +226,7 @@ public final class FeedAdapterV2 extends ListAdapter<Media, RecyclerView.ViewHol
|
|||||||
|
|
||||||
void onCommentsClick(final Media feedModel);
|
void onCommentsClick(final Media feedModel);
|
||||||
|
|
||||||
void onDownloadClick(final Media feedModel, final int childPosition);
|
void onDownloadClick(final Media feedModel, final int childPosition, final View popupLocation);
|
||||||
|
|
||||||
void onEmailClick(final String emailId);
|
void onEmailClick(final String emailId);
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ public class FeedItemCallbackAdapter implements FeedAdapterV2.FeedItemCallback {
|
|||||||
public void onCommentsClick(final Media media) {}
|
public void onCommentsClick(final Media media) {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDownloadClick(final Media media, final int childPosition) {}
|
public void onDownloadClick(final Media media, final int childPosition, final View popupLocation) {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEmailClick(final String emailId) {}
|
public void onEmailClick(final String emailId) {}
|
||||||
|
@ -47,7 +47,9 @@ public abstract class FeedItemViewHolder extends RecyclerView.ViewHolder {
|
|||||||
setupComments(media);
|
setupComments(media);
|
||||||
setupCaption(media);
|
setupCaption(media);
|
||||||
if (media.getType() != MediaItemType.MEDIA_TYPE_SLIDER) {
|
if (media.getType() != MediaItemType.MEDIA_TYPE_SLIDER) {
|
||||||
bottomBinding.btnDownload.setOnClickListener(v -> feedItemCallback.onDownloadClick(media, -1));
|
bottomBinding.btnDownload.setOnClickListener(v ->
|
||||||
|
feedItemCallback.onDownloadClick(media, -1, null)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
bindItem(media);
|
bindItem(media);
|
||||||
}
|
}
|
||||||
|
@ -59,11 +59,15 @@ public class FeedSliderViewHolder extends FeedItemViewHolder {
|
|||||||
final String text = (position + 1) + "/" + sliderItemLen;
|
final String text = (position + 1) + "/" + sliderItemLen;
|
||||||
binding.mediaCounter.setText(text);
|
binding.mediaCounter.setText(text);
|
||||||
setDimensions(binding.mediaList, sliderItems.get(position));
|
setDimensions(binding.mediaList, sliderItems.get(position));
|
||||||
binding.itemFeedBottom.btnDownload.setOnClickListener(v -> feedItemCallback.onDownloadClick(feedModel, position));
|
binding.itemFeedBottom.btnDownload.setOnClickListener(v ->
|
||||||
|
feedItemCallback.onDownloadClick(feedModel, position, binding.itemFeedBottom.btnDownload)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
setDimensions(binding.mediaList, sliderItems.get(0));
|
setDimensions(binding.mediaList, sliderItems.get(0));
|
||||||
binding.itemFeedBottom.btnDownload.setOnClickListener(v -> feedItemCallback.onDownloadClick(feedModel, 0));
|
binding.itemFeedBottom.btnDownload.setOnClickListener(v ->
|
||||||
|
feedItemCallback.onDownloadClick(feedModel, 0, binding.itemFeedBottom.btnDownload)
|
||||||
|
);
|
||||||
adapter.submitList(sliderItems);
|
adapter.submitList(sliderItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,10 +126,10 @@ public class CollectionPostsFragment extends Fragment implements SwipeRefreshLay
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDownloadClick(final Media feedModel, final int childPosition) {
|
public void onDownloadClick(final Media feedModel, final int childPosition, final View popupLocation) {
|
||||||
final Context context = getContext();
|
final Context context = getContext();
|
||||||
if (context == null) return;
|
if (context == null) return;
|
||||||
DownloadUtils.showDownloadDialog(context, feedModel, childPosition);
|
DownloadUtils.showDownloadDialog(context, feedModel, childPosition, popupLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -145,10 +145,10 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDownloadClick(final Media feedModel, final int childPosition) {
|
public void onDownloadClick(final Media feedModel, final int childPosition, final View popupLocation) {
|
||||||
final Context context = getContext();
|
final Context context = getContext();
|
||||||
if (context == null) return;
|
if (context == null) return;
|
||||||
DownloadUtils.showDownloadDialog(context, feedModel, childPosition);
|
DownloadUtils.showDownloadDialog(context, feedModel, childPosition, popupLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -139,10 +139,10 @@ public class LocationFragment extends Fragment implements SwipeRefreshLayout.OnR
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDownloadClick(final Media feedModel, final int childPosition) {
|
public void onDownloadClick(final Media feedModel, final int childPosition, final View popupLocation) {
|
||||||
final Context context = getContext();
|
final Context context = getContext();
|
||||||
if (context == null) return;
|
if (context == null) return;
|
||||||
DownloadUtils.showDownloadDialog(context, feedModel, childPosition);
|
DownloadUtils.showDownloadDialog(context, feedModel, childPosition, popupLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -446,7 +446,7 @@ public class PostViewV2Fragment extends Fragment implements EditTextDialogFragme
|
|||||||
|
|
||||||
private void setupDownload() {
|
private void setupDownload() {
|
||||||
bottom.download.setOnClickListener(v -> {
|
bottom.download.setOnClickListener(v -> {
|
||||||
DownloadUtils.showDownloadDialog(context, viewModel.getMedia(), sliderPosition);
|
DownloadUtils.showDownloadDialog(context, viewModel.getMedia(), sliderPosition, bottom.download);
|
||||||
});
|
});
|
||||||
TooltipCompat.setTooltipText(bottom.download, getString(R.string.action_download));
|
TooltipCompat.setTooltipText(bottom.download, getString(R.string.action_download));
|
||||||
}
|
}
|
||||||
@ -744,12 +744,6 @@ public class PostViewV2Fragment extends Fragment implements EditTextDialogFragme
|
|||||||
final Media media = viewModel.getMedia();
|
final Media media = viewModel.getMedia();
|
||||||
final User profileModel = media.getUser();
|
final User profileModel = media.getUser();
|
||||||
if (profileModel == null) return;
|
if (profileModel == null) return;
|
||||||
final boolean isPrivate = profileModel.isPrivate();
|
|
||||||
if (isPrivate) {
|
|
||||||
final Context context = getContext();
|
|
||||||
if (context == null) return;
|
|
||||||
// Toast.makeText(context, R.string.share_private_post, Toast.LENGTH_LONG).show();
|
|
||||||
}
|
|
||||||
if (viewModel.isLoggedIn()) {
|
if (viewModel.isLoggedIn()) {
|
||||||
final Context context = getContext();
|
final Context context = getContext();
|
||||||
if (context == null) return;
|
if (context == null) return;
|
||||||
@ -776,7 +770,7 @@ public class PostViewV2Fragment extends Fragment implements EditTextDialogFragme
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else if (itemId == R.id.share) {
|
} else if (itemId == R.id.share) {
|
||||||
shareLink(media, isPrivate);
|
shareLink(media, profileModel.isPrivate());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -784,7 +778,7 @@ public class PostViewV2Fragment extends Fragment implements EditTextDialogFragme
|
|||||||
popupMenu.show();
|
popupMenu.show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
shareLink(media, isPrivate);
|
shareLink(media, false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,10 +109,10 @@ public final class SavedViewerFragment extends Fragment implements SwipeRefreshL
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDownloadClick(final Media feedModel, final int childPosition) {
|
public void onDownloadClick(final Media feedModel, final int childPosition, final View popupLocation) {
|
||||||
final Context context = getContext();
|
final Context context = getContext();
|
||||||
if (context == null) return;
|
if (context == null) return;
|
||||||
DownloadUtils.showDownloadDialog(context, feedModel, childPosition);
|
DownloadUtils.showDownloadDialog(context, feedModel, childPosition, popupLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -120,10 +120,10 @@ public class TopicPostsFragment extends Fragment implements SwipeRefreshLayout.O
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDownloadClick(final Media feedModel, final int childPosition) {
|
public void onDownloadClick(final Media feedModel, final int childPosition, final View popupLocation) {
|
||||||
final Context context = getContext();
|
final Context context = getContext();
|
||||||
if (context == null) return;
|
if (context == null) return;
|
||||||
DownloadUtils.showDownloadDialog(context, feedModel, childPosition);
|
DownloadUtils.showDownloadDialog(context, feedModel, childPosition, popupLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -116,10 +116,10 @@ public class FeedFragment extends Fragment implements SwipeRefreshLayout.OnRefre
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDownloadClick(final Media feedModel, final int childPosition) {
|
public void onDownloadClick(final Media feedModel, final int childPosition, final View popupLocation) {
|
||||||
final Context context = getContext();
|
final Context context = getContext();
|
||||||
if (context == null) return;
|
if (context == null) return;
|
||||||
DownloadUtils.showDownloadDialog(context, feedModel, childPosition);
|
DownloadUtils.showDownloadDialog(context, feedModel, childPosition, popupLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -127,8 +127,8 @@ class ProfileFragment : Fragment(), OnRefreshListener, ConfirmDialogFragmentCall
|
|||||||
NavHostFragment.findNavController(this@ProfileFragment).navigate(commentsAction)
|
NavHostFragment.findNavController(this@ProfileFragment).navigate(commentsAction)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDownloadClick(media: Media?, childPosition: Int) {
|
override fun onDownloadClick(media: Media?, childPosition: Int, popupLocation: View) {
|
||||||
DownloadUtils.showDownloadDialog(context ?: return, media ?: return, childPosition)
|
DownloadUtils.showDownloadDialog(context ?: return, media ?: return, childPosition, popupLocation)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onEmailClick(emailId: String?) {
|
override fun onEmailClick(emailId: String?) {
|
||||||
|
@ -6,8 +6,12 @@ import android.content.UriPermission
|
|||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.provider.DocumentsContract
|
import android.provider.DocumentsContract
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
import android.view.MenuItem
|
||||||
|
import android.view.View
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
|
import androidx.appcompat.view.ContextThemeWrapper
|
||||||
|
import androidx.appcompat.widget.PopupMenu
|
||||||
import androidx.core.util.Pair
|
import androidx.core.util.Pair
|
||||||
import androidx.documentfile.provider.DocumentFile
|
import androidx.documentfile.provider.DocumentFile
|
||||||
import androidx.work.*
|
import androidx.work.*
|
||||||
@ -397,30 +401,28 @@ object DownloadUtils {
|
|||||||
fun showDownloadDialog(
|
fun showDownloadDialog(
|
||||||
context: Context,
|
context: Context,
|
||||||
feedModel: Media,
|
feedModel: Media,
|
||||||
childPosition: Int
|
childPosition: Int,
|
||||||
|
popupLocation: View?
|
||||||
) {
|
) {
|
||||||
if (childPosition >= 0) {
|
if (childPosition == -1 || popupLocation == null) {
|
||||||
val clickListener =
|
download(context, feedModel)
|
||||||
DialogInterface.OnClickListener { dialog: DialogInterface, which: Int ->
|
|
||||||
when (which) {
|
|
||||||
0 -> download(context, feedModel, childPosition)
|
|
||||||
1 -> download(context, feedModel)
|
|
||||||
DialogInterface.BUTTON_NEGATIVE -> dialog.dismiss()
|
|
||||||
else -> dialog.dismiss()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
val items = arrayOf(
|
|
||||||
context.getString(R.string.post_viewer_download_current),
|
|
||||||
context.getString(R.string.post_viewer_download_album)
|
|
||||||
)
|
|
||||||
AlertDialog.Builder(context)
|
|
||||||
.setTitle(R.string.post_viewer_download_dialog_title)
|
|
||||||
.setItems(items, clickListener)
|
|
||||||
.setNegativeButton(R.string.cancel, null)
|
|
||||||
.show()
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
download(context, feedModel)
|
val themeWrapper = ContextThemeWrapper(context, R.style.popupMenuStyle)
|
||||||
|
val popupMenu = PopupMenu(themeWrapper, popupLocation)
|
||||||
|
val menu = popupMenu.menu
|
||||||
|
menu.add(0, R.id.download_current, 0, R.string.post_viewer_download_current)
|
||||||
|
menu.add(0, R.id.download_all, 1, R.string.post_viewer_download_album)
|
||||||
|
popupMenu.setOnMenuItemClickListener { item: MenuItem ->
|
||||||
|
val itemId = item.itemId
|
||||||
|
if (itemId == R.id.download_current) {
|
||||||
|
download(context, feedModel, childPosition)
|
||||||
|
} else if (itemId == R.id.download_all) {
|
||||||
|
download(context, feedModel)
|
||||||
|
}
|
||||||
|
false
|
||||||
|
}
|
||||||
|
popupMenu.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
|
@ -6,4 +6,6 @@
|
|||||||
<item name="detail" type="id" />
|
<item name="detail" type="id" />
|
||||||
<item name="copy" type="id" />
|
<item name="copy" type="id" />
|
||||||
<item name="share_dm" type="id" />
|
<item name="share_dm" type="id" />
|
||||||
|
<item name="download_current" type="id" />
|
||||||
|
<item name="download_all" type="id" />
|
||||||
</resources>
|
</resources>
|
Loading…
Reference in New Issue
Block a user