diff --git a/briar-android/src/main/java/org/briarproject/briar/android/keyagreement/KeyAgreementFragment.java b/briar-android/src/main/java/org/briarproject/briar/android/keyagreement/KeyAgreementFragment.java index 4c4623d09d9629edfb1dfde5c5468a300212df9e..222750ece54726cd441ca3881517ccd09219d1a1 100644 --- a/briar-android/src/main/java/org/briarproject/briar/android/keyagreement/KeyAgreementFragment.java +++ b/briar-android/src/main/java/org/briarproject/briar/android/keyagreement/KeyAgreementFragment.java @@ -144,7 +144,7 @@ public class KeyAgreementFragment extends BaseEventFragment } @Override - public void toggleFullscreen(boolean fullscreen) { + public void setFullscreen(boolean fullscreen) { LinearLayout.LayoutParams statusParams, qrCodeParams; if (fullscreen) { // Grow the QR code view to fill its parent @@ -278,6 +278,11 @@ public class KeyAgreementFragment extends BaseEventFragment }); } + private void keyAgreementWaiting() { + runOnUiThreadUnlessDestroyed( + () -> status.setText(R.string.waiting_for_contact_to_scan)); + } + private void keyAgreementStarted() { runOnUiThreadUnlessDestroyed(() -> { qrCodeView.setVisibility(INVISIBLE); @@ -286,11 +291,6 @@ public class KeyAgreementFragment extends BaseEventFragment }); } - private void keyAgreementWaiting() { - runOnUiThreadUnlessDestroyed( - () -> status.setText(R.string.waiting_for_contact_to_scan)); - } - private void keyAgreementAborted(boolean remoteAborted) { runOnUiThreadUnlessDestroyed(() -> { reset(); diff --git a/briar-android/src/main/java/org/briarproject/briar/android/view/QrCodeView.java b/briar-android/src/main/java/org/briarproject/briar/android/view/QrCodeView.java index c4649cf4fd5d04138051b2a9f9ffc7b9a16b1f8e..32b6956226d5e8256beee571eb25de17739e8e95 100644 --- a/briar-android/src/main/java/org/briarproject/briar/android/view/QrCodeView.java +++ b/briar-android/src/main/java/org/briarproject/briar/android/view/QrCodeView.java @@ -15,47 +15,49 @@ import org.briarproject.briar.R; public class QrCodeView extends FrameLayout { - private final ImageView qrCodeImageView; - private boolean fullscreen = false; - private FullscreenListener listener; - - public QrCodeView(@NonNull Context context, - @Nullable AttributeSet attrs) { - super(context, attrs); - LayoutInflater inflater = (LayoutInflater) context - .getSystemService(Context.LAYOUT_INFLATER_SERVICE); - inflater.inflate(R.layout.qr_code_view, this, true); - qrCodeImageView = findViewById(R.id.qr_code); - ImageView fullscreenButton = findViewById(R.id.fullscreen_button); - fullscreenButton.setOnClickListener(v -> { - fullscreen = !fullscreen; - if (!fullscreen) - fullscreenButton.setImageResource( - R.drawable.ic_fullscreen_black_48dp); - else - fullscreenButton.setImageResource( - R.drawable.ic_fullscreen_exit_black_48dp); - if (listener != null) - listener.toggleFullscreen(fullscreen); - } - ); - } - - public void setQrCode(Bitmap qrCode) { - qrCodeImageView.setImageBitmap(qrCode); - // Simple fade-in animation - AlphaAnimation anim = new AlphaAnimation(0.0f, 1.0f); - anim.setDuration(200); - qrCodeImageView.startAnimation(anim); - } - - @UiThread - public void setFullscreenListener(FullscreenListener listener) { - this.listener = listener; - } - - public interface FullscreenListener { - void toggleFullscreen(boolean isFullscreen); - } + private final ImageView qrCodeImageView; + private boolean fullscreen = false; + private FullscreenListener listener; + + public QrCodeView(@NonNull Context context, + @Nullable AttributeSet attrs) { + super(context, attrs); + LayoutInflater inflater = (LayoutInflater) context + .getSystemService(Context.LAYOUT_INFLATER_SERVICE); + inflater.inflate(R.layout.qr_code_view, this, true); + qrCodeImageView = findViewById(R.id.qr_code); + ImageView fullscreenButton = findViewById(R.id.fullscreen_button); + fullscreenButton.setOnClickListener(v -> { + fullscreen = !fullscreen; + if (!fullscreen) { + fullscreenButton.setImageResource( + R.drawable.ic_fullscreen_black_48dp); + } else { + fullscreenButton.setImageResource( + R.drawable.ic_fullscreen_exit_black_48dp); + } + if (listener != null) + listener.setFullscreen(fullscreen); + } + ); + } + + @UiThread + public void setQrCode(Bitmap qrCode) { + qrCodeImageView.setImageBitmap(qrCode); + // Simple fade-in animation + AlphaAnimation anim = new AlphaAnimation(0.0f, 1.0f); + anim.setDuration(200); + qrCodeImageView.startAnimation(anim); + } + + @UiThread + public void setFullscreenListener(FullscreenListener listener) { + this.listener = listener; + } + + public interface FullscreenListener { + void setFullscreen(boolean fullscreen); + } } diff --git a/briar-android/src/main/res/layout/qr_code_view.xml b/briar-android/src/main/res/layout/qr_code_view.xml index eb690fe976f437cca92a1be1f0175fad8a59b244..9062428d0e6b3456b06b1e91a8e952cd3963e44d 100644 --- a/briar-android/src/main/res/layout/qr_code_view.xml +++ b/briar-android/src/main/res/layout/qr_code_view.xml @@ -3,7 +3,7 @@ xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" - tools:showIn="@layout/list_item_forum"> + tools:showIn="@layout/fragment_keyagreement_qr"> <ProgressBar style="?android:attr/progressBarStyleLarge" @@ -20,12 +20,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:contentDescription="@string/qr_code" - android:scaleType="fitCenter" - app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintLeft_toLeftOf="parent" - app:layout_constraintRight_toRightOf="parent" - app:layout_constraintTop_toTopOf="parent" - tools:src="@drawable/startup_lock"/> + android:scaleType="fitCenter"/> <ImageView android:id="@+id/fullscreen_button" @@ -39,5 +34,6 @@ app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintRight_toRightOf="parent"/> + </android.support.constraint.ConstraintLayout> </merge>