diff --git a/briar-android/src/main/java/org/briarproject/briar/android/keyagreement/ShowQrCodeFragment.java b/briar-android/src/main/java/org/briarproject/briar/android/keyagreement/ShowQrCodeFragment.java index 1088d78af..aaeafd0e4 100644 --- a/briar-android/src/main/java/org/briarproject/briar/android/keyagreement/ShowQrCodeFragment.java +++ b/briar-android/src/main/java/org/briarproject/briar/android/keyagreement/ShowQrCodeFragment.java @@ -14,6 +14,8 @@ import android.view.View; import android.view.ViewGroup; import android.view.animation.AlphaAnimation; import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.LinearLayout.LayoutParams; import android.widget.TextView; import android.widget.Toast; @@ -52,6 +54,8 @@ import javax.inject.Provider; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_NOSENSOR; import static android.view.View.INVISIBLE; import static android.view.View.VISIBLE; +import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; +import static android.widget.LinearLayout.HORIZONTAL; import static android.widget.Toast.LENGTH_LONG; import static java.util.logging.Level.INFO; import static java.util.logging.Level.WARNING; @@ -84,6 +88,7 @@ public class ShowQrCodeFragment extends BaseEventFragment private ImageView qrCode; private TextView mainProgressTitle; private ViewGroup mainProgressContainer; + private boolean fullscreen = false; private boolean gotRemotePayload; private volatile boolean gotLocalPayload; @@ -128,6 +133,34 @@ public class ShowQrCodeFragment extends BaseEventFragment qrCode = view.findViewById(R.id.qr_code); mainProgressTitle = view.findViewById(R.id.title_progress_bar); mainProgressContainer = view.findViewById(R.id.container_progress); + ImageView fullscreenButton = view.findViewById(R.id.fullscreen_button); + fullscreenButton.setOnClickListener(v -> { + View qrCodeContainer = view.findViewById(R.id.qr_code_container); + LinearLayout cameraOverlay = view.findViewById(R.id.camera_overlay); + LayoutParams statusParams, qrCodeParams; + if (fullscreen) { + // Shrink the QR code container to fill half its parent + if (cameraOverlay.getOrientation() == HORIZONTAL) { + statusParams = new LayoutParams(0, MATCH_PARENT, 1f); + qrCodeParams = new LayoutParams(0, MATCH_PARENT, 1f); + } else { + statusParams = new LayoutParams(MATCH_PARENT, 0, 1f); + qrCodeParams = new LayoutParams(MATCH_PARENT, 0, 1f); + } + fullscreenButton.setImageResource( + R.drawable.ic_fullscreen_black_48dp); + } else { + // Grow the QR code container to fill its parent + statusParams = new LayoutParams(0, 0, 0f); + qrCodeParams = new LayoutParams(MATCH_PARENT, MATCH_PARENT, 1f); + fullscreenButton.setImageResource( + R.drawable.ic_fullscreen_exit_black_48dp); + } + statusView.setLayoutParams(statusParams); + qrCodeContainer.setLayoutParams(qrCodeParams); + cameraOverlay.invalidate(); + fullscreen = !fullscreen; + }); } @Override @@ -284,6 +317,7 @@ public class ShowQrCodeFragment extends BaseEventFragment new AsyncTask() { @Override + @Nullable protected Bitmap doInBackground(Void... params) { byte[] payloadBytes = payloadEncoder.encode(payload); if (LOG.isLoggable(INFO)) { diff --git a/briar-android/src/main/res/drawable/ic_fullscreen_black_48dp.xml b/briar-android/src/main/res/drawable/ic_fullscreen_black_48dp.xml new file mode 100644 index 000000000..affab0d46 --- /dev/null +++ b/briar-android/src/main/res/drawable/ic_fullscreen_black_48dp.xml @@ -0,0 +1,4 @@ + + + diff --git a/briar-android/src/main/res/drawable/ic_fullscreen_exit_black_48dp.xml b/briar-android/src/main/res/drawable/ic_fullscreen_exit_black_48dp.xml new file mode 100644 index 000000000..5b62d104c --- /dev/null +++ b/briar-android/src/main/res/drawable/ic_fullscreen_exit_black_48dp.xml @@ -0,0 +1,4 @@ + + + diff --git a/briar-android/src/main/res/layout-land/fragment_keyagreement_qr.xml b/briar-android/src/main/res/layout-land/fragment_keyagreement_qr.xml index e9a174c77..9d378e5ba 100644 --- a/briar-android/src/main/res/layout-land/fragment_keyagreement_qr.xml +++ b/briar-android/src/main/res/layout-land/fragment_keyagreement_qr.xml @@ -15,39 +15,35 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" - android:weightSum="2"> + android:baselineAligned="false"> - + android:layout_weight="1" + android:background="@android:color/background_light" + android:gravity="center" + android:orientation="vertical" + android:padding="@dimen/margin_medium" + android:visibility="invisible"> - + + - - - - - - + android:paddingTop="@dimen/margin_large" + tools:text="Connection failed"/> + - + android:layout_height="match_parent"> + + + + + @@ -92,5 +107,4 @@ android:paddingTop="@dimen/margin_large" tools:text="@string/waiting_for_contact_to_scan"/> - diff --git a/briar-android/src/main/res/layout/fragment_keyagreement_qr.xml b/briar-android/src/main/res/layout/fragment_keyagreement_qr.xml index 1aaf28183..be534ca22 100644 --- a/briar-android/src/main/res/layout/fragment_keyagreement_qr.xml +++ b/briar-android/src/main/res/layout/fragment_keyagreement_qr.xml @@ -15,39 +15,35 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" - android:weightSum="2"> + android:baselineAligned="false"> - + android:layout_weight="1" + android:background="@android:color/background_light" + android:gravity="center" + android:orientation="vertical" + android:padding="@dimen/margin_medium" + android:visibility="invisible"> - + + - - - - - - + android:paddingTop="@dimen/margin_large" + tools:text="Connection failed"/> + - + android:layout_height="match_parent"> + + + + + @@ -92,5 +107,4 @@ android:paddingTop="@dimen/margin_large" tools:text="@string/waiting_for_contact_to_scan"/> - diff --git a/briar-android/src/main/res/values/strings.xml b/briar-android/src/main/res/values/strings.xml index 1a1ffc0b6..01630d889 100644 --- a/briar-android/src/main/res/values/strings.xml +++ b/briar-android/src/main/res/values/strings.xml @@ -414,5 +414,7 @@ To scan the QR code, Briar needs access to the camera. You have denied access to the camera, but adding contacts requires using the camera.\n\nPlease consider granting access. Camera permission was not granted + QR code + Show QR code fullscreen