Fixes text story preview sizing on pixel 2.
This commit is contained in:
parent
ef6e846512
commit
65bf0aad79
5 changed files with 55 additions and 2 deletions
|
@ -42,6 +42,9 @@ import org.thoughtcrime.securesms.mediasend.v2.MediaAnimations;
|
|||
import org.thoughtcrime.securesms.mediasend.v2.MediaCountIndicatorButton;
|
||||
import org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader.DecryptableUri;
|
||||
import org.thoughtcrime.securesms.mms.GlideApp;
|
||||
import org.thoughtcrime.securesms.stories.Stories;
|
||||
import org.thoughtcrime.securesms.stories.viewer.page.StoryDisplay;
|
||||
import org.thoughtcrime.securesms.util.FeatureFlags;
|
||||
import org.thoughtcrime.securesms.util.ServiceUtil;
|
||||
import org.thoughtcrime.securesms.util.Stopwatch;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
|
@ -275,6 +278,20 @@ public class Camera1Fragment extends LoggingFragment implements CameraFragment,
|
|||
|
||||
View galleryButton = requireView().findViewById(R.id.camera_gallery_button);
|
||||
View countButton = requireView().findViewById(R.id.camera_review_button);
|
||||
View toggleSpacer = requireView().findViewById(R.id.toggle_spacer);
|
||||
|
||||
if (toggleSpacer != null) {
|
||||
if (Stories.isFeatureEnabled() && FeatureFlags.storiesTextPosts()) {
|
||||
StoryDisplay storyDisplay = StoryDisplay.Companion.getStoryDisplay(getResources().getDisplayMetrics().widthPixels, getResources().getDisplayMetrics().heightPixels);
|
||||
if (storyDisplay == StoryDisplay.SMALL) {
|
||||
toggleSpacer.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
toggleSpacer.setVisibility(View.GONE);
|
||||
}
|
||||
} else {
|
||||
toggleSpacer.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
captureButton.setOnClickListener(v -> {
|
||||
captureButton.setEnabled(false);
|
||||
|
|
|
@ -46,6 +46,9 @@ import org.thoughtcrime.securesms.mediasend.v2.MediaAnimations;
|
|||
import org.thoughtcrime.securesms.mediasend.v2.MediaCountIndicatorButton;
|
||||
import org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader.DecryptableUri;
|
||||
import org.thoughtcrime.securesms.mms.MediaConstraints;
|
||||
import org.thoughtcrime.securesms.stories.Stories;
|
||||
import org.thoughtcrime.securesms.stories.viewer.page.StoryDisplay;
|
||||
import org.thoughtcrime.securesms.util.FeatureFlags;
|
||||
import org.thoughtcrime.securesms.util.MemoryFileDescriptor;
|
||||
import org.thoughtcrime.securesms.util.Stopwatch;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
|
@ -252,6 +255,20 @@ public class CameraXFragment extends LoggingFragment implements CameraFragment {
|
|||
View galleryButton = requireView().findViewById(R.id.camera_gallery_button);
|
||||
View countButton = requireView().findViewById(R.id.camera_review_button);
|
||||
CameraXFlashToggleView flashButton = requireView().findViewById(R.id.camera_flash_button);
|
||||
View toggleSpacer = requireView().findViewById(R.id.toggle_spacer);
|
||||
|
||||
if (toggleSpacer != null) {
|
||||
if ( Stories.isFeatureEnabled() && FeatureFlags.storiesTextPosts()) {
|
||||
StoryDisplay storyDisplay = StoryDisplay.Companion.getStoryDisplay(getResources().getDisplayMetrics().widthPixels, getResources().getDisplayMetrics().heightPixels);
|
||||
if (storyDisplay == StoryDisplay.SMALL) {
|
||||
toggleSpacer.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
toggleSpacer.setVisibility(View.GONE);
|
||||
}
|
||||
} else {
|
||||
toggleSpacer.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
selfieFlash = requireView().findViewById(R.id.camera_selfie_flash);
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ import android.graphics.drawable.Drawable
|
|||
import android.util.AttributeSet
|
||||
import android.util.TypedValue
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.annotation.ColorInt
|
||||
import androidx.annotation.Px
|
||||
|
@ -17,6 +16,7 @@ import androidx.core.view.doOnNextLayout
|
|||
import androidx.core.view.isVisible
|
||||
import androidx.core.widget.doAfterTextChanged
|
||||
import com.airbnb.lottie.SimpleColorFilter
|
||||
import com.google.android.material.imageview.ShapeableImageView
|
||||
import org.signal.core.util.DimensionUnit
|
||||
import org.thoughtcrime.securesms.R
|
||||
import org.thoughtcrime.securesms.conversation.colors.ChatColors
|
||||
|
@ -29,6 +29,7 @@ import org.thoughtcrime.securesms.mediasend.v2.text.TextAlignment
|
|||
import org.thoughtcrime.securesms.mediasend.v2.text.TextStoryPostCreationState
|
||||
import org.thoughtcrime.securesms.mediasend.v2.text.TextStoryScale
|
||||
import org.thoughtcrime.securesms.mediasend.v2.text.TextStoryTextWatcher
|
||||
import org.thoughtcrime.securesms.stories.viewer.page.StoryDisplay
|
||||
import org.thoughtcrime.securesms.util.ViewUtil
|
||||
import org.thoughtcrime.securesms.util.concurrent.ListenableFuture
|
||||
import org.thoughtcrime.securesms.util.visible
|
||||
|
@ -45,7 +46,7 @@ class StoryTextPostView @JvmOverloads constructor(
|
|||
}
|
||||
|
||||
private var textAlignment: TextAlignment? = null
|
||||
private val backgroundView: ImageView = findViewById(R.id.text_story_post_background)
|
||||
private val backgroundView: ShapeableImageView = findViewById(R.id.text_story_post_background)
|
||||
private val textView: TextView = findViewById(R.id.text_story_post_text)
|
||||
private val linkPreviewView: StoryLinkPreviewView = findViewById(R.id.text_story_post_link_preview)
|
||||
|
||||
|
@ -66,6 +67,19 @@ class StoryTextPostView @JvmOverloads constructor(
|
|||
adjustTextTranslationX(this)
|
||||
}
|
||||
}
|
||||
|
||||
val displaySize = StoryDisplay.getStoryDisplay(
|
||||
resources.displayMetrics.widthPixels.toFloat(),
|
||||
resources.displayMetrics.heightPixels.toFloat()
|
||||
)
|
||||
|
||||
when (displaySize) {
|
||||
StoryDisplay.SMALL ->
|
||||
backgroundView.shapeAppearanceModel = backgroundView.shapeAppearanceModel
|
||||
.toBuilder()
|
||||
.setAllCornerSizes(0f)
|
||||
.build()
|
||||
}
|
||||
}
|
||||
|
||||
fun showCloseButton() {
|
||||
|
|
|
@ -341,16 +341,19 @@ class StoryViewerPageFragment :
|
|||
|
||||
when (StoryDisplay.getStoryDisplay(resources.displayMetrics.widthPixels.toFloat(), resources.displayMetrics.heightPixels.toFloat())) {
|
||||
StoryDisplay.LARGE -> {
|
||||
constraintSet.setDimensionRatio(cardWrapper.id, "9:16")
|
||||
constraintSet.connect(viewsAndReplies.id, ConstraintSet.TOP, cardWrapper.id, ConstraintSet.BOTTOM)
|
||||
constraintSet.connect(viewsAndReplies.id, ConstraintSet.BOTTOM, ConstraintSet.PARENT_ID, ConstraintSet.BOTTOM)
|
||||
card.radius = DimensionUnit.DP.toPixels(18f)
|
||||
}
|
||||
StoryDisplay.MEDIUM -> {
|
||||
constraintSet.setDimensionRatio(cardWrapper.id, "9:16")
|
||||
constraintSet.clear(viewsAndReplies.id, ConstraintSet.TOP)
|
||||
constraintSet.connect(viewsAndReplies.id, ConstraintSet.BOTTOM, cardWrapper.id, ConstraintSet.BOTTOM)
|
||||
card.radius = DimensionUnit.DP.toPixels(18f)
|
||||
}
|
||||
StoryDisplay.SMALL -> {
|
||||
constraintSet.setDimensionRatio(cardWrapper.id, null)
|
||||
constraintSet.clear(viewsAndReplies.id, ConstraintSet.TOP)
|
||||
constraintSet.connect(viewsAndReplies.id, ConstraintSet.BOTTOM, cardWrapper.id, ConstraintSet.BOTTOM)
|
||||
card.radius = DimensionUnit.DP.toPixels(0f)
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
android:id="@+id/story_content_card_touch_interceptor"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintVertical_bias="0"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintDimensionRatio="9:16"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
|
Loading…
Add table
Reference in a new issue