mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 01:40:07 +01:00
Improve behaviour of media send flow in landscape.
This commit is contained in:
committed by
Greyson Parrelli
parent
a712622891
commit
a086305c38
@@ -123,7 +123,7 @@ public class Camera1Fragment extends LoggingFragment implements CameraFragment,
|
||||
|
||||
view.addOnLayoutChangeListener((v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> {
|
||||
// Let's assume portrait for now, so 9:16
|
||||
float aspectRatio = 9f / 16f;
|
||||
float aspectRatio = CameraFragment.getAspectRatioForOrientation(getResources().getConfiguration().orientation);
|
||||
float width = right - left;
|
||||
float height = Math.min((1f / aspectRatio) * width, bottom - top);
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.thoughtcrime.securesms.mediasend;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.res.Configuration;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
@@ -14,6 +15,8 @@ import java.io.FileDescriptor;
|
||||
|
||||
public interface CameraFragment {
|
||||
|
||||
float PORTRAIT_ASPECT_RATIO = 9 / 16f;
|
||||
|
||||
@SuppressLint("RestrictedApi")
|
||||
static Fragment newInstance() {
|
||||
if (CameraXUtil.isSupported()) {
|
||||
@@ -32,6 +35,14 @@ public interface CameraFragment {
|
||||
}
|
||||
}
|
||||
|
||||
static float getAspectRatioForOrientation(int orientation) {
|
||||
if (orientation == Configuration.ORIENTATION_PORTRAIT) {
|
||||
return PORTRAIT_ASPECT_RATIO;
|
||||
} else {
|
||||
return 1f / PORTRAIT_ASPECT_RATIO;
|
||||
}
|
||||
}
|
||||
|
||||
void presentHud(int selectedMediaCount);
|
||||
void fadeOutControls(@NonNull Runnable onEndAction);
|
||||
void fadeInControls();
|
||||
|
||||
@@ -126,7 +126,7 @@ public class CameraXFragment extends LoggingFragment implements CameraFragment {
|
||||
|
||||
view.addOnLayoutChangeListener((v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> {
|
||||
// Let's assume portrait for now, so 9:16
|
||||
float aspectRatio = 9f / 16f;
|
||||
float aspectRatio = CameraFragment.getAspectRatioForOrientation(getResources().getConfiguration().orientation);
|
||||
float width = right - left;
|
||||
float height = Math.min((1f / aspectRatio) * width, bottom - top);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user