Add a hint that both parties need to scan each other's QR codes.

This commit is contained in:
akwizgran
2022-10-24 12:51:39 +01:00
parent 8c269541c3
commit 7302bf9d7a
5 changed files with 87 additions and 7 deletions

View File

@@ -20,6 +20,7 @@ import org.briarproject.briar.android.contact.add.nearby.AddContactState.QrCodeS
import org.briarproject.briar.android.fragment.BaseFragment;
import org.briarproject.briar.android.qrcode.CameraException;
import org.briarproject.briar.android.qrcode.CameraView;
import org.briarproject.briar.android.view.InfoView;
import org.briarproject.briar.android.view.QrCodeView;
import org.briarproject.nullsafety.MethodsNotNullByDefault;
import org.briarproject.nullsafety.ParametersNotNullByDefault;
@@ -57,6 +58,7 @@ public class AddNearbyContactFragment extends BaseFragment
private CameraView cameraView;
private LinearLayout cameraOverlay;
private View statusView;
private InfoView infoView;
private QrCodeView qrCodeView;
private TextView status;
@@ -91,6 +93,9 @@ public class AddNearbyContactFragment extends BaseFragment
cameraOverlay = view.findViewById(R.id.camera_overlay);
statusView = view.findViewById(R.id.status_container);
status = view.findViewById(R.id.connect_status);
infoView = view.findViewById(R.id.info_view);
TextView info = view.findViewById(R.id.info_text);
info.setText(R.string.info_both_must_scan);
qrCodeView = view.findViewById(R.id.qr_code_view);
qrCodeView.setFullscreenListener(this);
@@ -160,6 +165,7 @@ public class AddNearbyContactFragment extends BaseFragment
} else if (state instanceof KeyAgreementWaiting) {
status.setText(R.string.waiting_for_contact_to_scan);
} else if (state instanceof KeyAgreementStarted) {
infoView.setVisibility(INVISIBLE);
qrCodeView.setVisibility(INVISIBLE);
status.setText(R.string.authenticating_with_device);
} else if (state instanceof ContactExchangeStarted) {

View File

@@ -0,0 +1,33 @@
package org.briarproject.briar.android.view;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import org.briarproject.briar.R;
import org.briarproject.nullsafety.InterfaceNotNullByDefault;
import androidx.annotation.Nullable;
import androidx.cardview.widget.CardView;
import static android.content.Context.LAYOUT_INFLATER_SERVICE;
@InterfaceNotNullByDefault
public class InfoView extends CardView {
public InfoView(Context context) {
this(context, null);
}
public InfoView(Context context, @Nullable AttributeSet attrs) {
this(context, attrs, 0);
}
public InfoView(Context context, @Nullable AttributeSet attrs,
int defStyleAttr) {
super(context, attrs, defStyleAttr);
LayoutInflater inflater = (LayoutInflater)
context.getSystemService(LAYOUT_INFLATER_SERVICE);
inflater.inflate(R.layout.info_view, this, true);
}
}