mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-11-22 22:57:29 +00:00
Make buttons in PostView dialog title-less, and show the titles on long click
This commit is contained in:
parent
a83664d6d9
commit
1c6cd348f4
@ -420,6 +420,10 @@ public class PostViewV2Fragment extends SharedElementTransitionDialogFragment {
|
||||
bundle.putString("postUserId", feedModel.getProfileModel().getId());
|
||||
navController.navigate(R.id.action_global_commentsViewerFragment, bundle);
|
||||
});
|
||||
binding.comment.setOnLongClickListener(v -> {
|
||||
Utils.displayToastAboveView(context, v, getString(R.string.comment));
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
private void setupDownload() {
|
||||
@ -430,6 +434,10 @@ public class PostViewV2Fragment extends SharedElementTransitionDialogFragment {
|
||||
}
|
||||
requestPermissions(DownloadUtils.PERMS, STORAGE_PERM_REQUEST_CODE);
|
||||
});
|
||||
binding.download.setOnLongClickListener(v -> {
|
||||
Utils.displayToastAboveView(context, v, getString(R.string.action_download));
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
private void setupLike() {
|
||||
@ -496,6 +504,10 @@ public class PostViewV2Fragment extends SharedElementTransitionDialogFragment {
|
||||
mediaService.unlike(feedModel.getPostId(), userId, csrfToken, likeCallback);
|
||||
}
|
||||
});
|
||||
binding.like.setOnLongClickListener(v -> {
|
||||
Utils.displayToastAboveView(context, v, getString(R.string.like_without_count));
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
private void setLikedResources(final boolean liked) {
|
||||
@ -513,7 +525,7 @@ public class PostViewV2Fragment extends SharedElementTransitionDialogFragment {
|
||||
}
|
||||
binding.like.setIconResource(iconResource);
|
||||
binding.like.setIconTintResource(tintResource);
|
||||
binding.like.setText(textResId);
|
||||
// binding.like.setText(textResId);
|
||||
}
|
||||
|
||||
private void setupSave() {
|
||||
@ -570,6 +582,10 @@ public class PostViewV2Fragment extends SharedElementTransitionDialogFragment {
|
||||
mediaService.unsave(feedModel.getPostId(), userId, csrfToken, saveCallback);
|
||||
}
|
||||
});
|
||||
binding.save.setOnLongClickListener(v -> {
|
||||
Utils.displayToastAboveView(context, v, getString(R.string.save));
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
private void setSavedResources(final boolean saved) {
|
||||
@ -587,7 +603,7 @@ public class PostViewV2Fragment extends SharedElementTransitionDialogFragment {
|
||||
}
|
||||
binding.save.setIconResource(iconResource);
|
||||
binding.save.setIconTintResource(tintResource);
|
||||
binding.save.setText(textResId);
|
||||
// binding.save.setText(textResId);
|
||||
}
|
||||
|
||||
private void setupProfilePic() {
|
||||
@ -705,6 +721,10 @@ public class PostViewV2Fragment extends SharedElementTransitionDialogFragment {
|
||||
default:
|
||||
}
|
||||
});
|
||||
binding.captionToggle.setOnLongClickListener(v -> {
|
||||
Utils.displayToastAboveView(context, v, getString(R.string.caption));
|
||||
return true;
|
||||
});
|
||||
if (sharedProfilePicElement == null || sharedMainPostElement == null) {
|
||||
binding.getRoot().getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
@Override
|
||||
@ -724,8 +744,7 @@ public class PostViewV2Fragment extends SharedElementTransitionDialogFragment {
|
||||
final int likesCount = (int) feedModel.getLikesCount();
|
||||
final String likesString = getResources().getQuantityString(R.plurals.likes_count, likesCount, likesCount);
|
||||
binding.likesCount.setText(likesString);
|
||||
}
|
||||
catch (IllegalStateException e) {}
|
||||
} catch (IllegalStateException e) {}
|
||||
}
|
||||
|
||||
private void setupPostTypeLayout() {
|
||||
|
@ -11,6 +11,8 @@ import android.net.Uri;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.webkit.MimeTypeMap;
|
||||
import android.widget.Toast;
|
||||
|
||||
@ -178,4 +180,14 @@ public final class Utils {
|
||||
emailIntent.putExtra(Intent.EXTRA_TEXT, "");
|
||||
context.startActivity(emailIntent);
|
||||
}
|
||||
|
||||
public static void displayToastAboveView(@NonNull final Context context,
|
||||
@NonNull final View view,
|
||||
@NonNull final String text) {
|
||||
final Toast toast = Toast.makeText(context, text, Toast.LENGTH_SHORT);
|
||||
toast.setGravity(Gravity.TOP | Gravity.START,
|
||||
view.getLeft(),
|
||||
view.getTop() - view.getHeight() - 4);
|
||||
toast.show();
|
||||
}
|
||||
}
|
||||
|
@ -211,7 +211,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="8dp"
|
||||
android:textColor="@color/white"
|
||||
app:layout_constraintBottom_toTopOf="@id/caption_toggle"
|
||||
app:layout_constraintBottom_toBottomOf="@id/buttons_barrier"
|
||||
app:layout_constraintEnd_toStartOf="@id/comments_count"
|
||||
app:layout_constraintHorizontal_bias="0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
@ -225,7 +225,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="8dp"
|
||||
android:textColor="@color/white"
|
||||
app:layout_constraintBottom_toTopOf="@id/caption_toggle"
|
||||
app:layout_constraintBottom_toBottomOf="@id/buttons_barrier"
|
||||
app:layout_constraintEnd_toStartOf="@id/views_count"
|
||||
app:layout_constraintHorizontal_bias="0"
|
||||
app:layout_constraintStart_toEndOf="@id/likes_count"
|
||||
@ -239,131 +239,149 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="8dp"
|
||||
android:textColor="@color/white"
|
||||
app:layout_constraintBottom_toTopOf="@id/caption_toggle"
|
||||
app:layout_constraintBottom_toBottomOf="@id/buttons_barrier"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/comments_count"
|
||||
app:layout_constraintTop_toTopOf="@id/bottom_bg_barrier"
|
||||
tools:text="9999999999 views"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<androidx.constraintlayout.widget.Barrier
|
||||
android:id="@+id/buttons_barrier"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:barrierDirection="bottom"
|
||||
app:constraint_referenced_ids="likes_count,comments_count,views_count" />
|
||||
|
||||
<!--android:text="@string/caption"-->
|
||||
<!--app:iconGravity="top"-->
|
||||
<!--android:textAppearance="@style/TextAppearance.MaterialComponents.Caption"
|
||||
android:textColor="@color/white"-->
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/caption_toggle"
|
||||
style="@style/Widget.MaterialComponents.Button.TextButton"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/caption"
|
||||
android:textAppearance="@style/TextAppearance.MaterialComponents.Caption"
|
||||
android:textColor="@color/white"
|
||||
android:layout_height="48dp"
|
||||
android:visibility="visible"
|
||||
app:icon="@drawable/ic_notes_24"
|
||||
app:iconGravity="top"
|
||||
app:iconSize="16dp"
|
||||
app:iconGravity="textStart"
|
||||
app:iconPadding="0dp"
|
||||
app:iconSize="24dp"
|
||||
app:iconTint="@color/white"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/like"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/likes_count"
|
||||
app:layout_constraintVertical_bias="1"
|
||||
app:layout_constraintTop_toBottomOf="@id/buttons_barrier"
|
||||
app:rippleColor="@color/grey_300"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<!--android:text="@string/like_without_count"
|
||||
android:textAppearance="@style/TextAppearance.MaterialComponents.Caption"
|
||||
android:textColor="@color/white"
|
||||
app:iconGravity="top"-->
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/like"
|
||||
style="@style/Widget.MaterialComponents.Button.TextButton"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/like_without_count"
|
||||
android:textAppearance="@style/TextAppearance.MaterialComponents.Caption"
|
||||
android:textColor="@color/white"
|
||||
android:layout_height="48dp"
|
||||
android:visibility="visible"
|
||||
app:icon="@drawable/ic_not_liked"
|
||||
app:iconGravity="top"
|
||||
app:iconSize="16dp"
|
||||
app:iconGravity="textStart"
|
||||
app:iconPadding="0dp"
|
||||
app:iconSize="24dp"
|
||||
app:iconTint="@color/white"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/comment"
|
||||
app:layout_constraintStart_toEndOf="@id/caption_toggle"
|
||||
app:layout_constraintTop_toTopOf="@id/caption_toggle"
|
||||
app:layout_constraintTop_toBottomOf="@id/buttons_barrier"
|
||||
app:rippleColor="@color/grey_300"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<!--android:text="@string/comment"
|
||||
android:textAppearance="@style/TextAppearance.MaterialComponents.Caption"
|
||||
android:textColor="@color/white"
|
||||
app:iconGravity="top"-->
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/comment"
|
||||
style="@style/Widget.MaterialComponents.Button.TextButton"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/comment"
|
||||
android:textAppearance="@style/TextAppearance.MaterialComponents.Caption"
|
||||
android:textColor="@color/white"
|
||||
android:layout_height="48dp"
|
||||
android:visibility="visible"
|
||||
app:icon="@drawable/ic_outline_comments_24"
|
||||
app:iconGravity="top"
|
||||
app:iconSize="16dp"
|
||||
app:iconGravity="textStart"
|
||||
app:iconPadding="0dp"
|
||||
app:iconSize="24dp"
|
||||
app:iconTint="@color/white"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/player_controls_toggle"
|
||||
app:layout_constraintStart_toEndOf="@id/like"
|
||||
app:layout_constraintTop_toTopOf="@id/caption_toggle"
|
||||
app:layout_constraintTop_toBottomOf="@id/buttons_barrier"
|
||||
app:rippleColor="@color/grey_300"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<!--android:text="@string/controls"
|
||||
android:textAppearance="@style/TextAppearance.MaterialComponents.Caption"
|
||||
android:textColor="@color/white"
|
||||
app:iconGravity="top"-->
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/player_controls_toggle"
|
||||
style="@style/Widget.MaterialComponents.Button.TextButton"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/controls"
|
||||
android:textAppearance="@style/TextAppearance.MaterialComponents.Caption"
|
||||
android:textColor="@color/white"
|
||||
android:layout_height="48dp"
|
||||
android:visibility="gone"
|
||||
app:icon="@drawable/ic_play_circle_outline_24"
|
||||
app:iconGravity="top"
|
||||
app:iconSize="16dp"
|
||||
app:iconGravity="textStart"
|
||||
app:iconPadding="0dp"
|
||||
app:iconSize="24dp"
|
||||
app:iconTint="@color/white"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/save"
|
||||
app:layout_constraintStart_toEndOf="@id/comment"
|
||||
app:layout_constraintTop_toTopOf="@id/caption_toggle"
|
||||
app:layout_constraintTop_toBottomOf="@id/buttons_barrier"
|
||||
app:rippleColor="@color/grey_300"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<!--android:text="@string/save"
|
||||
android:textAppearance="@style/TextAppearance.MaterialComponents.Caption"
|
||||
android:textColor="@color/white"
|
||||
app:iconGravity="top"-->
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/save"
|
||||
style="@style/Widget.MaterialComponents.Button.TextButton"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/save"
|
||||
android:textAppearance="@style/TextAppearance.MaterialComponents.Caption"
|
||||
android:textColor="@color/white"
|
||||
android:layout_height="48dp"
|
||||
android:visibility="visible"
|
||||
app:icon="@drawable/ic_outline_class_24"
|
||||
app:iconGravity="top"
|
||||
app:iconSize="16dp"
|
||||
app:iconGravity="textStart"
|
||||
app:iconPadding="0dp"
|
||||
app:iconSize="24dp"
|
||||
app:iconTint="@color/white"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/download"
|
||||
app:layout_constraintStart_toEndOf="@id/player_controls_toggle"
|
||||
app:layout_constraintTop_toTopOf="@id/caption_toggle"
|
||||
app:layout_constraintTop_toBottomOf="@id/buttons_barrier"
|
||||
app:rippleColor="@color/grey_300"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<!--android:text="@string/action_download"
|
||||
android:textAppearance="@style/TextAppearance.MaterialComponents.Caption"
|
||||
android:textColor="@color/white"
|
||||
app:iconGravity="top"-->
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/download"
|
||||
style="@style/Widget.MaterialComponents.Button.TextButton"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/action_download"
|
||||
android:textAppearance="@style/TextAppearance.MaterialComponents.Caption"
|
||||
android:textColor="@color/white"
|
||||
android:layout_height="48dp"
|
||||
android:visibility="visible"
|
||||
app:icon="@drawable/ic_download"
|
||||
app:iconGravity="top"
|
||||
app:iconSize="16dp"
|
||||
app:iconGravity="textStart"
|
||||
app:iconPadding="0dp"
|
||||
app:iconSize="24dp"
|
||||
app:iconTint="@color/white"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/save"
|
||||
app:layout_constraintTop_toTopOf="@id/caption_toggle"
|
||||
app:layout_constraintTop_toBottomOf="@id/buttons_barrier"
|
||||
app:rippleColor="@color/grey_300"
|
||||
tools:visibility="visible" />
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user