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..76f87e409cc2c7793e8775838760028dc633ae95 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,8 @@ 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); + infoView.setText(R.string.info_both_must_scan); qrCodeView = view.findViewById(R.id.qr_code_view); qrCodeView.setFullscreenListener(this); @@ -160,6 +164,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/contact/add/remote/LinkExchangeFragment.java b/briar-android/src/main/java/org/briarproject/briar/android/contact/add/remote/LinkExchangeFragment.java index 42097e32ad86582a5ce3c19ca08d77d62216f723..6e797e23ece28fff53f13231eccdbf906fc05ef8 100644 --- a/briar-android/src/main/java/org/briarproject/briar/android/contact/add/remote/LinkExchangeFragment.java +++ b/briar-android/src/main/java/org/briarproject/briar/android/contact/add/remote/LinkExchangeFragment.java @@ -16,6 +16,7 @@ import com.google.android.material.textfield.TextInputLayout; import org.briarproject.briar.R; import org.briarproject.briar.android.activity.ActivityComponent; import org.briarproject.briar.android.fragment.BaseFragment; +import org.briarproject.briar.android.view.InfoView; import org.briarproject.nullsafety.MethodsNotNullByDefault; import org.briarproject.nullsafety.ParametersNotNullByDefault; @@ -122,6 +123,9 @@ public class LinkExchangeFragment extends BaseFragment { .startChooser()); shareButton.setEnabled(true); + InfoView infoText = v.findViewById(R.id.infoView); + infoText.setText(R.string.info_both_must_enter_links); + Button continueButton = v.findViewById(R.id.addButton); continueButton.setOnClickListener(view -> onContinueButtonClicked()); continueButton.setEnabled(true); 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..cc33df6a2bdc0be60ae60073ba1321c013bb9477 --- /dev/null +++ b/briar-android/src/main/java/org/briarproject/briar/android/view/InfoView.java @@ -0,0 +1,40 @@ +package org.briarproject.briar.android.view; + +import android.content.Context; +import android.util.AttributeSet; +import android.view.LayoutInflater; +import android.widget.TextView; + +import org.briarproject.briar.R; +import org.briarproject.nullsafety.InterfaceNotNullByDefault; + +import androidx.annotation.Nullable; +import androidx.annotation.StringRes; +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); + } + + public void setText(@StringRes int resId) { + TextView infoText = findViewById(R.id.info_text); + infoText.setText(resId); + } +} 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/fragment_link_exchange.xml b/briar-android/src/main/res/layout/fragment_link_exchange.xml index 4ebd1a64c6af89f1f0537985ab6a1368d68d7e0b..9b8bab8e6c4393f9ea0c724fee76d44d7e9d4c83 100644 --- a/briar-android/src/main/res/layout/fragment_link_exchange.xml +++ b/briar-android/src/main/res/layout/fragment_link_exchange.xml @@ -30,8 +30,7 @@ app:layout_constraintBottom_toTopOf="@+id/stepOneText" app:layout_constraintEnd_toStartOf="@+id/guideline" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toTopOf="parent" - app:layout_constraintVertical_bias="0.0" /> + app:layout_constraintTop_toTopOf="parent" /> <TextView android:id="@+id/stepOneText" @@ -64,7 +63,6 @@ app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="@+id/guideline" app:layout_constraintTop_toTopOf="@+id/stepOne" - app:layout_constraintVertical_bias="0.0" app:layout_constraintVertical_chainStyle="packed" /> <TextView @@ -162,7 +160,6 @@ app:drawableStartCompat="@drawable/social_share_blue" app:layout_constraintBottom_toBottomOf="@id/copyButton" app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintHorizontal_bias="1.0" app:layout_constraintStart_toEndOf="@id/copyButton" app:layout_constraintTop_toTopOf="@id/copyButton" /> @@ -226,8 +223,18 @@ app:layout_constraintHorizontal_bias="1.0" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/linkInputLayout" + app:layout_constraintBottom_toTopOf="@+id/infoView" app:layout_constraintVertical_bias="0.0" /> + <org.briarproject.briar.android.view.InfoView + android:id="@+id/infoView" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="16dp" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/pasteButton" /> + </androidx.constraintlayout.widget.ConstraintLayout> </ScrollView> 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..c7cf40f7b6cdce0e42e6b1057d07d793a7968fca --- /dev/null +++ b/briar-android/src/main/res/layout/info_view.xml @@ -0,0 +1,22 @@ +<?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" + android:drawableTint="?attr/colorControlNormal" + android:gravity="center_vertical" + 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..dcb578ad2c48575d60d78c58de15c5c7cab1e009 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 --> @@ -316,6 +318,7 @@ <string name="different_person_button">Different Person</string> <string name="duplicate_link_dialog_text_3">%1$s and %2$s sent you the same link.\n\nOne of them may be trying to discover who your contacts are.\n\nDon\'t tell them you received the same link from someone else.</string> <string name="pending_contact_updated_toast">Pending contact updated</string> + <string name="info_both_must_enter_links">You must both add each other\'s links</string> <!-- Peer trust levels -->