Add fullscreen button to QR code view.

This commit is contained in:
akwizgran
2018-03-20 11:14:27 +00:00
parent 4d502576c9
commit 2c4d5680a6
6 changed files with 123 additions and 62 deletions

View File

@@ -14,6 +14,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AlphaAnimation;
import android.widget.ImageView;
import android.widget.LinearLayout.LayoutParams;
import android.widget.TextView;
import android.widget.Toast;
@@ -52,6 +53,7 @@ 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.Toast.LENGTH_LONG;
import static java.util.logging.Level.INFO;
import static java.util.logging.Level.WARNING;
@@ -83,6 +85,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;
@@ -127,6 +130,25 @@ 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);
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
@@ -274,6 +296,7 @@ public class ShowQrCodeFragment extends BaseEventFragment
new AsyncTask<Void, Void, Bitmap>() {
@Override
@Nullable
protected Bitmap doInBackground(Void... params) {
byte[] payloadBytes = payloadEncoder.encode(payload);
if (LOG.isLoggable(INFO)) {