Skip to content
Snippets Groups Projects
Verified Commit 2c4d5680 authored by akwizgran's avatar akwizgran
Browse files

Add fullscreen button to QR code view.

parent 4d502576
No related branches found
No related tags found
No related merge requests found
...@@ -14,6 +14,7 @@ import android.view.View; ...@@ -14,6 +14,7 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.animation.AlphaAnimation; import android.view.animation.AlphaAnimation;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout.LayoutParams;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
...@@ -52,6 +53,7 @@ import javax.inject.Provider; ...@@ -52,6 +53,7 @@ import javax.inject.Provider;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_NOSENSOR; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_NOSENSOR;
import static android.view.View.INVISIBLE; import static android.view.View.INVISIBLE;
import static android.view.View.VISIBLE; import static android.view.View.VISIBLE;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.widget.Toast.LENGTH_LONG; import static android.widget.Toast.LENGTH_LONG;
import static java.util.logging.Level.INFO; import static java.util.logging.Level.INFO;
import static java.util.logging.Level.WARNING; import static java.util.logging.Level.WARNING;
...@@ -83,6 +85,7 @@ public class ShowQrCodeFragment extends BaseEventFragment ...@@ -83,6 +85,7 @@ public class ShowQrCodeFragment extends BaseEventFragment
private ImageView qrCode; private ImageView qrCode;
private TextView mainProgressTitle; private TextView mainProgressTitle;
private ViewGroup mainProgressContainer; private ViewGroup mainProgressContainer;
private boolean fullscreen = false;
private boolean gotRemotePayload; private boolean gotRemotePayload;
private volatile boolean gotLocalPayload; private volatile boolean gotLocalPayload;
...@@ -127,6 +130,25 @@ public class ShowQrCodeFragment extends BaseEventFragment ...@@ -127,6 +130,25 @@ public class ShowQrCodeFragment extends BaseEventFragment
qrCode = view.findViewById(R.id.qr_code); qrCode = view.findViewById(R.id.qr_code);
mainProgressTitle = view.findViewById(R.id.title_progress_bar); mainProgressTitle = view.findViewById(R.id.title_progress_bar);
mainProgressContainer = view.findViewById(R.id.container_progress); 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);
if (fullscreen) {
// Shrink the QR code container
qrCodeContainer.setLayoutParams(
new LayoutParams(MATCH_PARENT, 0, 1f));
fullscreenButton.setBackgroundResource(
R.drawable.ic_fullscreen_black_48dp);
} else {
// Grow the QR code container
qrCodeContainer.setLayoutParams(
new LayoutParams(MATCH_PARENT, MATCH_PARENT, 1f));
fullscreenButton.setBackgroundResource(
R.drawable.ic_fullscreen_exit_black_48dp);
}
view.findViewById(R.id.camera_overlay).invalidate();
fullscreen = !fullscreen;
});
} }
@Override @Override
...@@ -274,6 +296,7 @@ public class ShowQrCodeFragment extends BaseEventFragment ...@@ -274,6 +296,7 @@ public class ShowQrCodeFragment extends BaseEventFragment
new AsyncTask<Void, Void, Bitmap>() { new AsyncTask<Void, Void, Bitmap>() {
@Override @Override
@Nullable
protected Bitmap doInBackground(Void... params) { protected Bitmap doInBackground(Void... params) {
byte[] payloadBytes = payloadEncoder.encode(payload); byte[] payloadBytes = payloadEncoder.encode(payload);
if (LOG.isLoggable(INFO)) { if (LOG.isLoggable(INFO)) {
......
<vector android:height="48dp" android:viewportHeight="24.0"
android:viewportWidth="24.0" android:width="48dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M7,14L5,14v5h5v-2L7,17v-3zM5,10h2L7,7h3L10,5L5,5v5zM17,17h-3v2h5v-5h-2v3zM14,5v2h3v3h2L19,5h-5z"/>
</vector>
<vector android:height="48dp" android:viewportHeight="24.0"
android:viewportWidth="24.0" android:width="48dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M5,16h3v3h2v-5L5,14v2zM8,8L5,8v2h5L10,5L8,5v3zM14,19h2v-3h3v-2h-5v5zM16,8L16,5h-2v5h5L19,8h-3z"/>
</vector>
...@@ -15,39 +15,36 @@ ...@@ -15,39 +15,36 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="horizontal" android:orientation="horizontal"
android:weightSum="2"> android:weightSum="2"
android:baselineAligned="false">
<FrameLayout <LinearLayout
android:id="@+id/status_container"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1"> android:layout_weight="1"
android:background="@android:color/background_light"
android:gravity="center"
android:orientation="vertical"
android:padding="@dimen/margin_medium"
android:visibility="invisible">
<LinearLayout <ProgressBar
android:id="@+id/status_container" style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/connect_status"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:background="@android:color/background_light"
android:gravity="center" android:gravity="center"
android:orientation="vertical" android:paddingTop="@dimen/margin_large"
android:padding="@dimen/margin_medium" tools:text="Connection failed"/>
android:visibility="invisible"> </LinearLayout>
<ProgressBar
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/connect_status"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingTop="@dimen/margin_large"
tools:text="Connection failed"/>
</LinearLayout>
</FrameLayout>
<FrameLayout <FrameLayout
android:id="@+id/qr_code_container"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="1"
...@@ -59,12 +56,30 @@ ...@@ -59,12 +56,30 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center"/> android:layout_gravity="center"/>
<ImageView <RelativeLayout
android:id="@+id/qr_code"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent">
android:scaleType="fitCenter"
android:layout_gravity="center"/> <ImageView
android:id="@+id/qr_code"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:contentDescription="@string/qr_code"
android:scaleType="fitCenter"/>
<ImageView
android:id="@+id/fullscreen_button"
android:background="@drawable/ic_fullscreen_black_48dp"
android:alpha="0.54"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/margin_small"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:contentDescription="@string/show_qr_code_fullscreen"/>
</RelativeLayout>
</FrameLayout> </FrameLayout>
</LinearLayout> </LinearLayout>
...@@ -92,5 +107,4 @@ ...@@ -92,5 +107,4 @@
android:paddingTop="@dimen/margin_large" android:paddingTop="@dimen/margin_large"
tools:text="@string/waiting_for_contact_to_scan"/> tools:text="@string/waiting_for_contact_to_scan"/>
</RelativeLayout> </RelativeLayout>
</FrameLayout> </FrameLayout>
...@@ -15,39 +15,36 @@ ...@@ -15,39 +15,36 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
android:weightSum="2"> android:weightSum="2"
android:baselineAligned="false">
<FrameLayout <LinearLayout
android:id="@+id/status_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_weight="1"> android:layout_weight="1"
android:background="@android:color/background_light"
android:gravity="center"
android:orientation="vertical"
android:padding="@dimen/margin_medium"
android:visibility="invisible">
<LinearLayout <ProgressBar
android:id="@+id/status_container" style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/connect_status"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:background="@android:color/background_light"
android:gravity="center" android:gravity="center"
android:orientation="vertical" android:paddingTop="@dimen/margin_large"
android:padding="@dimen/margin_medium" tools:text="Connection failed"/>
android:visibility="invisible"> </LinearLayout>
<ProgressBar
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/connect_status"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingTop="@dimen/margin_large"
tools:text="Connection failed"/>
</LinearLayout>
</FrameLayout>
<FrameLayout <FrameLayout
android:id="@+id/qr_code_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_weight="1" android:layout_weight="1"
...@@ -59,12 +56,30 @@ ...@@ -59,12 +56,30 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center"/> android:layout_gravity="center"/>
<ImageView <RelativeLayout
android:id="@+id/qr_code"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent">
android:scaleType="fitCenter"
android:layout_gravity="center"/> <ImageView
android:id="@+id/qr_code"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:contentDescription="@string/qr_code"
android:scaleType="fitCenter"/>
<ImageView
android:id="@+id/fullscreen_button"
android:background="@drawable/ic_fullscreen_black_48dp"
android:alpha="0.54"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/margin_small"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:contentDescription="@string/show_qr_code_fullscreen"/>
</RelativeLayout>
</FrameLayout> </FrameLayout>
</LinearLayout> </LinearLayout>
...@@ -92,5 +107,4 @@ ...@@ -92,5 +107,4 @@
android:paddingTop="@dimen/margin_large" android:paddingTop="@dimen/margin_large"
tools:text="@string/waiting_for_contact_to_scan"/> tools:text="@string/waiting_for_contact_to_scan"/>
</RelativeLayout> </RelativeLayout>
</FrameLayout> </FrameLayout>
...@@ -410,5 +410,7 @@ ...@@ -410,5 +410,7 @@
<string name="permission_camera_request_body">To scan the QR code, Briar needs access to the camera.</string> <string name="permission_camera_request_body">To scan the QR code, Briar needs access to the camera.</string>
<string name="permission_camera_denied_body">You have denied access to the camera, but adding contacts requires using the camera.\n\nPlease consider granting access.</string> <string name="permission_camera_denied_body">You have denied access to the camera, but adding contacts requires using the camera.\n\nPlease consider granting access.</string>
<string name="permission_camera_denied_toast">Camera permission was not granted</string> <string name="permission_camera_denied_toast">Camera permission was not granted</string>
<string name="qr_code">QR code</string>
<string name="show_qr_code_fullscreen">Show QR code fullscreen</string>
</resources> </resources>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment