diff --git a/briar-android/src/main/java/org/briarproject/briar/android/contact/add/nearby/AddNearbyContactFragment.java b/briar-android/src/main/java/org/briarproject/briar/android/contact/add/nearby/AddNearbyContactFragment.java index 81b386d017f7b1606a685aea627ea093087dd43a..c6fb17258cb9fed9f1bce0c4a45d8a2529106b42 100644 --- a/briar-android/src/main/java/org/briarproject/briar/android/contact/add/nearby/AddNearbyContactFragment.java +++ b/briar-android/src/main/java/org/briarproject/briar/android/contact/add/nearby/AddNearbyContactFragment.java @@ -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) { diff --git a/briar-android/src/main/java/org/briarproject/briar/android/view/InfoView.java b/briar-android/src/main/java/org/briarproject/briar/android/view/InfoView.java new file mode 100644 index 0000000000000000000000000000000000000000..e50ec759fa4b5b0613ca07814575686b53e969fa --- /dev/null +++ b/briar-android/src/main/java/org/briarproject/briar/android/view/InfoView.java @@ -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); + } +} 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 33728c9f553ddcb8636542a62dba26a1acd6b3c9..7ba8b54ec60f3de0129bfd6b5be5dffa3d0014a6 100644 --- a/briar-android/src/main/res/layout/fragment_keyagreement_qr.xml +++ b/briar-android/src/main/res/layout/fragment_keyagreement_qr.xml @@ -1,5 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <FrameLayout 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" android:layout_width="match_parent" android:layout_height="match_parent" @@ -17,30 +18,48 @@ android:baselineAligned="false" android:orientation="vertical"> - <LinearLayout + <androidx.constraintlayout.widget.ConstraintLayout android:id="@+id/status_container" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" - android:gravity="center" - android:orientation="vertical" - android:padding="@dimen/margin_medium" + android:padding="@dimen/margin_large" android:visibility="invisible" tools:visibility="visible"> <ProgressBar + android:id="@+id/connect_progress" style="?android:attr/progressBarStyleLarge" android:layout_width="wrap_content" - android:layout_height="wrap_content" /> + android:layout_height="wrap_content" + app:layout_constraintBottom_toTopOf="@+id/connect_status" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintVertical_chainStyle="packed" /> <TextView android:id="@+id/connect_status" android:layout_width="match_parent" android:layout_height="wrap_content" + android:layout_marginTop="@dimen/margin_large" android:gravity="center" - android:paddingTop="@dimen/margin_large" + app:layout_constraintBottom_toTopOf="@+id/info_view" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/connect_progress" tools:text="@string/waiting_for_contact_to_scan" /> - </LinearLayout> + + <org.briarproject.briar.android.view.InfoView + android:id="@+id/info_view" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="@dimen/margin_large" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" /> + + </androidx.constraintlayout.widget.ConstraintLayout> <org.briarproject.briar.android.view.QrCodeView android:id="@+id/qr_code_view" diff --git a/briar-android/src/main/res/layout/info_view.xml b/briar-android/src/main/res/layout/info_view.xml new file mode 100644 index 0000000000000000000000000000000000000000..32c0c87705f84d7363ca1752710650eb7281eb55 --- /dev/null +++ b/briar-android/src/main/res/layout/info_view.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8"?> +<merge 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" + android:layout_width="match_parent" + android:layout_height="wrap_content" + tools:parentTag="androidx.cardview.widget.CardView"> + + <TextView + android:id="@+id/info_text" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_margin="@dimen/margin_medium" + android:contentDescription="@string/info" + android:drawablePadding="@dimen/margin_medium" + app:drawableLeftCompat="@drawable/ic_info_dark" + app:drawableStartCompat="@drawable/ic_info_dark" + tools:text="Did you know that if you took all the veins out of your body and laid them out end to end, you would die?" /> + +</merge> \ No newline at end of file diff --git a/briar-android/src/main/res/values/strings.xml b/briar-android/src/main/res/values/strings.xml index 93f3730871865248daf60f1e0d1d4fcdfceafb5e..83a90004c0d5675239ba144a6b2b32e2461b1aa4 100644 --- a/briar-android/src/main/res/values/strings.xml +++ b/briar-android/src/main/res/values/strings.xml @@ -167,6 +167,7 @@ <string name="error_start_activity">Unavailable on your system</string> <string name="status_heading">Status:</string> <string name="error">Error</string> + <string name="info">Information</string> <!-- Contacts and Private Conversations--> <string name="no_contacts">No contacts to show</string> @@ -257,6 +258,7 @@ <string name="authenticating_with_device">Authenticating with device\u2026</string> <string name="connection_error_title">Could not connect to your contact</string> <string name="connection_error_feedback">If this problem persists, please <a href="feedback">send feedback</a> to help us improve the app.</string> + <string name="info_both_must_scan">You must both scan each other\'s QR codes</string> <!-- Adding Contacts Remotely -->