mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 03:09:04 +01:00
replace peer by contact, improve link sharing, and icon tinting
This commit is contained in:
@@ -8,6 +8,7 @@ import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.design.widget.TextInputEditText;
|
||||
import android.support.design.widget.TextInputLayout;
|
||||
import android.support.v4.app.ShareCompat.IntentBuilder;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -24,8 +25,6 @@ import java.util.regex.Matcher;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static android.content.Context.CLIPBOARD_SERVICE;
|
||||
import static android.content.Intent.ACTION_SEND;
|
||||
import static android.content.Intent.EXTRA_TEXT;
|
||||
import static android.os.Build.VERSION.SDK_INT;
|
||||
import static android.support.v4.graphics.drawable.DrawableCompat.setTint;
|
||||
import static android.support.v4.graphics.drawable.DrawableCompat.wrap;
|
||||
@@ -34,7 +33,6 @@ import static java.util.Objects.requireNonNull;
|
||||
import static org.briarproject.briar.android.contact.ContactLinkExchangeActivity.LINK_REGEX;
|
||||
import static org.briarproject.briar.android.contact.ContactLinkExchangeActivity.OUR_LINK;
|
||||
import static org.briarproject.briar.android.util.UiUtils.resolveColorAttribute;
|
||||
import static org.briarproject.briar.android.util.UiUtils.setError;
|
||||
|
||||
public class ContactLinkExchangeFragment extends BaseFragment {
|
||||
|
||||
@@ -87,8 +85,7 @@ public class ContactLinkExchangeFragment extends BaseFragment {
|
||||
contactNameLayout = v.findViewById(R.id.contactNameLayout);
|
||||
contactNameInput = v.findViewById(R.id.contactNameInput);
|
||||
if (SDK_INT < 23) {
|
||||
Drawable drawable =
|
||||
wrap(contactNameInput.getCompoundDrawables()[0]);
|
||||
Drawable drawable = wrap(contactNameInput.getCompoundDrawables()[0]);
|
||||
setTint(drawable, color);
|
||||
contactNameInput.setCompoundDrawables(drawable, null, null, null);
|
||||
}
|
||||
@@ -131,10 +128,10 @@ public class ContactLinkExchangeFragment extends BaseFragment {
|
||||
|
||||
Button shareButton = v.findViewById(R.id.shareButton);
|
||||
shareButton.setOnClickListener(view -> {
|
||||
Intent i = new Intent(ACTION_SEND);
|
||||
i.putExtra(EXTRA_TEXT, OUR_LINK);
|
||||
i.setType("text/plain");
|
||||
startActivity(i);
|
||||
IntentBuilder.from(getActivity())
|
||||
.setText(OUR_LINK)
|
||||
.setType("text/plain")
|
||||
.startChooser();
|
||||
});
|
||||
|
||||
Button showCodeButton = v.findViewById(R.id.showCodeButton);
|
||||
@@ -154,22 +151,24 @@ public class ContactLinkExchangeFragment extends BaseFragment {
|
||||
private boolean isInputError() {
|
||||
boolean briarLink = isBriarLink(linkInput.getText());
|
||||
if (!briarLink) {
|
||||
linkInputLayout.setError("Invalid link");
|
||||
linkInputLayout.setError(getString(R.string.invalid_link));
|
||||
linkInput.requestFocus();
|
||||
return true;
|
||||
} else linkInputLayout.setError(null);
|
||||
String link = getLink();
|
||||
boolean isOurLink = link != null && OUR_LINK.equals("briar://" + link);
|
||||
if (isOurLink) {
|
||||
linkInputLayout.setError("Add your peer's link, not your own.");
|
||||
linkInputLayout.setError(getString(R.string.own_link_error));
|
||||
linkInput.requestFocus();
|
||||
return true;
|
||||
} else linkInputLayout.setError(null);
|
||||
boolean validContactName = contactNameInput.getText() != null &&
|
||||
contactNameInput.getText().length() > 0;
|
||||
if (!validContactName) {
|
||||
contactNameLayout.setError("Nickname is missing");
|
||||
contactNameLayout.setError(getString(R.string.nickname_missing));
|
||||
contactNameInput.requestFocus();
|
||||
return true;
|
||||
} else contactNameLayout.setError(null);
|
||||
setError(linkInputLayout, null, false);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,11 +38,11 @@ public class PendingRequestsViewHolder extends ViewHolder {
|
||||
long diff = item.getAddAt() - System.currentTimeMillis();
|
||||
Log.e("TEST", "diff: " + diff);
|
||||
if (diff < SECONDS.toMillis(10)) {
|
||||
status.setText("Adding contact…");
|
||||
status.setText(R.string.adding_contact);
|
||||
} else if (diff < SECONDS.toMillis(20)) {
|
||||
status.setText("Connecting…");
|
||||
status.setText(R.string.connecting);
|
||||
} else if (diff < SECONDS.toMillis(30)) {
|
||||
status.setText("Waiting for peer to come online…");
|
||||
status.setText(R.string.waiting_for_contact_to_come_online);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,6 @@
|
||||
android:viewportHeight="24.0"
|
||||
android:viewportWidth="24.0">
|
||||
<path
|
||||
android:fillColor="#FFFFFFFF"
|
||||
android:fillColor="#FFFFFF"
|
||||
android:pathData="M3.9,12c0,-1.71 1.39,-3.1 3.1,-3.1h4L11,7L7,7c-2.76,0 -5,2.24 -5,5s2.24,5 5,5h4v-1.9L7,15.1c-1.71,0 -3.1,-1.39 -3.1,-3.1zM8,13h8v-2L8,11v2zM17,7h-4v1.9h4c1.71,0 3.1,1.39 3.1,3.1s-1.39,3.1 -3.1,3.1h-4L13,17h4c2.76,0 5,-2.24 5,-5s-2.24,-5 -5,-5z"/>
|
||||
</vector>
|
||||
|
||||
9
briar-android/src/main/res/drawable/ic_link_menu.xml
Normal file
9
briar-android/src/main/res/drawable/ic_link_menu.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportHeight="24.0"
|
||||
android:viewportWidth="24.0">
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:pathData="M3.9,12c0,-1.71 1.39,-3.1 3.1,-3.1h4L11,7L7,7c-2.76,0 -5,2.24 -5,5s2.24,5 5,5h4v-1.9L7,15.1c-1.71,0 -3.1,-1.39 -3.1,-3.1zM8,13h8v-2L8,11v2zM17,7h-4v1.9h4c1.71,0 3.1,1.39 3.1,3.1s-1.39,3.1 -3.1,3.1h-4L13,17h4c2.76,0 5,-2.24 5,-5s-2.24,-5 -5,-5z"/>
|
||||
</vector>
|
||||
@@ -98,12 +98,28 @@
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="left|start"
|
||||
android:text="@string/send_link_instructions"
|
||||
android:text="@string/send_link_title"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintBottom_toTopOf="@+id/yourLink"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0"
|
||||
app:layout_constraintVertical_chainStyle="packed"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/yourLink"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:gravity="left|start"
|
||||
android:text="@string/your_link"
|
||||
android:textSize="18sp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/linkView"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/linkIntro"
|
||||
app:layout_constraintVertical_bias="0"
|
||||
app:layout_constraintVertical_chainStyle="packed"/>
|
||||
|
||||
@@ -121,9 +137,8 @@
|
||||
app:layout_constraintBottom_toTopOf="@+id/copyButton"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/linkIntro"
|
||||
tools:text="briar://scnsdflamslkfjgluoblmksdfbwevlewajfdlkjewwhqliafskfjhskdjhvoieiv"
|
||||
/>
|
||||
app:layout_constraintTop_toBottomOf="@+id/yourLink"
|
||||
tools:text="briar://scnsdflamslkfjgluoblmksdfbwevlewajfdlkjewwhqliafskfjhskdjhvoieiv"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/copyButton"
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/margin_large"
|
||||
android:text="@string/send_link_instructions"
|
||||
android:text="@string/your_link"
|
||||
android:textIsSelectable="true"
|
||||
android:textSize="18sp"
|
||||
app:layout_constraintBottom_toTopOf="@id/linkView"
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="Waiting for peer to come online…"
|
||||
android:text="@string/waiting_for_contact_to_come_online"
|
||||
app:layout_constrainedWidth="true"
|
||||
app:layout_constraintBottom_toTopOf="@+id/divider"
|
||||
app:layout_constraintEnd_toStartOf="@+id/time"
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
<item
|
||||
android:id="@+id/action_add_contact_remotely"
|
||||
android:icon="@drawable/ic_link"
|
||||
android:icon="@drawable/ic_link_menu"
|
||||
android:orderInCategory="2"
|
||||
android:title="@string/add_contact_remotely_title"
|
||||
app:showAsAction="never"/>
|
||||
|
||||
@@ -164,17 +164,20 @@
|
||||
<string name="connection_error_explanation">Please check that you\'re both connected to the same Wi-Fi network.</string>
|
||||
<string name="connection_error_feedback">If this problem persists, please <a href="feedback">send feedback</a> to help us improve the app.</string>
|
||||
|
||||
|
||||
<!-- Adding Contacts Remotely PROTOTYPE -->
|
||||
<string name="add_contact_nearby_title">Add contact nearby</string>
|
||||
<string name="add_contact_remotely_title">Add contact remotely</string>
|
||||
<string name="contact_name_hint">Give peer a nickname</string>
|
||||
<string name="contact_link_hint">Enter peer\'s link</string>
|
||||
<string name="contact_name_hint">Give contact a nickname</string>
|
||||
<string name="contact_link_hint">Enter contact\'s link</string>
|
||||
<string name="paste_button">Paste</string>
|
||||
<string name="scan_qr_code_button">QR Code</string>
|
||||
<string name="add_contact_button">Add peer as contact</string>
|
||||
<string name="add_contact_button">Add contact</string>
|
||||
<string name="copy_button">Copy</string>
|
||||
<string name="share_button">Share</string>
|
||||
<string name="show_qr_code_button">QR Code</string>
|
||||
<string name="send_link_instructions">Exchange links with your peer!\n\nYour link:</string>
|
||||
<string name="send_link_title">Exchange links with your contact</string>
|
||||
<string name="your_link">Your link:</string>
|
||||
<string name="link_clip_label">Briar link</string>
|
||||
<string name="link_copied_toast">Link copied</string>
|
||||
<string name="pending_contact_requests_snackbar">"There are pending contact requests"</string>
|
||||
@@ -183,6 +186,13 @@
|
||||
<string name="scan_qr_code_title">Scan QR Code</string>
|
||||
<string name="show_qr_code_title">Your QR Code</string>
|
||||
<string name="camera_error_toast">Camera Error</string>
|
||||
<string name="waiting_for_contact_to_come_online">Waiting for contact to come online…</string>
|
||||
<string name="connecting">Connecting…</string>
|
||||
<string name="adding_contact">Adding contact…</string>
|
||||
<string name="own_link_error">Enter your contact\'s link</string>
|
||||
<string name="nickname_missing">Nickname is missing</string>
|
||||
<string name="invalid_link">Invalid link</string>
|
||||
|
||||
|
||||
<!-- Introductions -->
|
||||
<string name="introduction_onboarding_title">Introduce your contacts</string>
|
||||
|
||||
Reference in New Issue
Block a user