From 495a4a974f6bbb76b5e3c881766b9f6a69f5fe52 Mon Sep 17 00:00:00 2001 From: Austin Huang Date: Fri, 6 Nov 2020 17:49:29 -0500 Subject: [PATCH] restore share button --- .../fragments/PostViewV2Fragment.java | 20 +++++++++++++++-- app/src/main/res/layout/dialog_post_view.xml | 22 +++++++++++++++++-- app/src/main/res/values/strings.xml | 1 + 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/awais/instagrabber/fragments/PostViewV2Fragment.java b/app/src/main/java/awais/instagrabber/fragments/PostViewV2Fragment.java index 2a434f9d..1cc4c2a5 100644 --- a/app/src/main/java/awais/instagrabber/fragments/PostViewV2Fragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/PostViewV2Fragment.java @@ -9,6 +9,7 @@ import android.annotation.SuppressLint; import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; +import android.content.Intent; import android.content.pm.PackageManager; import android.graphics.Color; import android.graphics.drawable.Animatable; @@ -27,6 +28,7 @@ import android.view.Window; import android.view.WindowManager; import android.widget.FrameLayout; import android.widget.ScrollView; +import android.widget.Toast; import android.widget.ViewSwitcher; import androidx.annotation.NonNull; @@ -497,7 +499,6 @@ public class PostViewV2Fragment extends SharedElementTransitionDialogFragment { } else { textRes = R.string.unliking; } - binding.like.setText(textRes); if (!feedModel.getLike()) { mediaService.like(feedModel.getPostId(), userId, csrfToken, likeCallback); } else { @@ -575,7 +576,6 @@ public class PostViewV2Fragment extends SharedElementTransitionDialogFragment { } else { textRes = R.string.removing; } - binding.save.setText(textRes); if (!feedModel.isSaved()) { mediaService.save(feedModel.getPostId(), userId, csrfToken, saveCallback); } else { @@ -734,6 +734,20 @@ public class PostViewV2Fragment extends SharedElementTransitionDialogFragment { } }); } + binding.share.setOnLongClickListener(v -> { + Utils.displayToastAboveView(context, v, getString(R.string.share)); + return true; + }); + binding.share.setOnClickListener(v -> { + final boolean isPrivate = feedModel.getProfileModel().isPrivate(); + if (isPrivate) + Toast.makeText(context, R.string.share_private_post, Toast.LENGTH_LONG).show(); + Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND); + sharingIntent.setType("text/plain"); + sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, "https://instagram.com/p/"+feedModel.getShortCode()); + startActivity(Intent.createChooser(sharingIntent, + isPrivate ? getString(R.string.share_private_post) : getString(R.string.share_public_post))); + }); } private void setupCounts() { @@ -1061,6 +1075,7 @@ public class PostViewV2Fragment extends SharedElementTransitionDialogFragment { binding.playerControlsToggle.setVisibility(View.GONE); binding.like.setVisibility(View.GONE); binding.save.setVisibility(View.GONE); + binding.share.setVisibility(View.GONE); binding.download.setVisibility(View.GONE); binding.mediaCounter.setVisibility(View.GONE); wasControlsVisible = binding.playerControls.getRoot().getVisibility() == View.VISIBLE; @@ -1087,6 +1102,7 @@ public class PostViewV2Fragment extends SharedElementTransitionDialogFragment { binding.download.setVisibility(View.VISIBLE); binding.like.setVisibility(View.VISIBLE); binding.save.setVisibility(View.VISIBLE); + binding.share.setVisibility(View.VISIBLE); if (wasControlsVisible) { showPlayerControls(); } diff --git a/app/src/main/res/layout/dialog_post_view.xml b/app/src/main/res/layout/dialog_post_view.xml index 4920eb67..e39e6b4f 100644 --- a/app/src/main/res/layout/dialog_post_view.xml +++ b/app/src/main/res/layout/dialog_post_view.xml @@ -357,12 +357,30 @@ app:iconSize="24dp" app:iconTint="@color/white" app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintEnd_toStartOf="@id/download" + app:layout_constraintEnd_toStartOf="@id/share" app:layout_constraintStart_toEndOf="@id/player_controls_toggle" app:layout_constraintTop_toBottomOf="@id/buttons_barrier" app:rippleColor="@color/grey_300" tools:visibility="visible" /> + +