mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-17 05:09:53 +01:00
Add buttons to switch between showing link and code
This commit is contained in:
@@ -2,7 +2,6 @@ package org.briarproject.briar.android.contact;
|
|||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.ActionBar;
|
import android.support.v7.app.ActionBar;
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
|
||||||
import org.briarproject.briar.R;
|
import org.briarproject.briar.R;
|
||||||
@@ -15,9 +14,6 @@ import javax.annotation.Nullable;
|
|||||||
public class ContactLinkOutputActivity extends BriarActivity implements
|
public class ContactLinkOutputActivity extends BriarActivity implements
|
||||||
BaseFragmentListener {
|
BaseFragmentListener {
|
||||||
|
|
||||||
private Menu menu;
|
|
||||||
private boolean showQrCode = true;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void injectActivity(ActivityComponent component) {
|
public void injectActivity(ActivityComponent component) {
|
||||||
component.inject(this);
|
component.inject(this);
|
||||||
@@ -35,40 +31,27 @@ public class ContactLinkOutputActivity extends BriarActivity implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (state == null) {
|
if (state == null) {
|
||||||
showInitialFragment(new ContactQrCodeOutputFragment());
|
showInitialFragment(new ContactLinkOutputFragment());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
|
||||||
// MenuInflater inflater = getMenuInflater();
|
|
||||||
// inflater.inflate(R.menu.contact_output_actions, menu);
|
|
||||||
// menu.findItem(R.id.action_switch)
|
|
||||||
// .setTitle(showQrCode ? R.string.show_link : R.string.show_code);
|
|
||||||
return super.onCreateOptionsMenu(menu);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case android.R.id.home:
|
case android.R.id.home:
|
||||||
onBackPressed();
|
onBackPressed();
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_switch:
|
|
||||||
switchFragment();
|
|
||||||
return true;
|
|
||||||
default:
|
default:
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void switchFragment() {
|
void showLink() {
|
||||||
if (showQrCode) {
|
showInitialFragment(new ContactLinkOutputFragment());
|
||||||
showInitialFragment(new ContactLinkOutputFragment());
|
}
|
||||||
} else {
|
|
||||||
showInitialFragment(new ContactQrCodeOutputFragment());
|
void showCode() {
|
||||||
}
|
showInitialFragment(new ContactQrCodeOutputFragment());
|
||||||
showQrCode = !showQrCode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,6 +63,10 @@ public class ContactLinkOutputFragment extends BaseFragment {
|
|||||||
i.setType("text/plain");
|
i.setType("text/plain");
|
||||||
startActivity(i);
|
startActivity(i);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Button showCodeButton = v.findViewById(R.id.showCodeButton);
|
||||||
|
showCodeButton.setOnClickListener(
|
||||||
|
view -> ((ContactLinkOutputActivity) getActivity()).showCode());
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import android.util.DisplayMetrics;
|
|||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Button;
|
||||||
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||||
import org.briarproject.briar.R;
|
import org.briarproject.briar.R;
|
||||||
@@ -45,6 +46,10 @@ public class ContactQrCodeOutputFragment extends BaseFragment
|
|||||||
qrCodeView.setQrCode(qrCode);
|
qrCodeView.setQrCode(qrCode);
|
||||||
qrCodeView.setFullscreenListener(this);
|
qrCodeView.setFullscreenListener(this);
|
||||||
|
|
||||||
|
Button showLinkButton = v.findViewById(R.id.showLinkButton);
|
||||||
|
showLinkButton.setOnClickListener(
|
||||||
|
view -> ((ContactLinkOutputActivity) getActivity()).showLink());
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,9 @@ public class QrCodeView extends FrameLayout {
|
|||||||
listener.setFullscreen(fullscreen);
|
listener.setFullscreen(fullscreen);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// TODO remove
|
||||||
|
fullscreenButton.setVisibility(INVISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@UiThread
|
@UiThread
|
||||||
|
|||||||
@@ -59,4 +59,31 @@
|
|||||||
app:layout_constraintStart_toEndOf="@id/copyButton"
|
app:layout_constraintStart_toEndOf="@id/copyButton"
|
||||||
app:layout_constraintTop_toTopOf="@id/copyButton"/>
|
app:layout_constraintTop_toTopOf="@id/copyButton"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textView2"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginEnd="8dp"
|
||||||
|
android:layout_marginStart="8dp"
|
||||||
|
android:text="or"
|
||||||
|
android:textSize="18sp"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/copyButton"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/showCodeButton"
|
||||||
|
style="@style/BriarButton"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginEnd="8dp"
|
||||||
|
android:layout_marginStart="8dp"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:drawableLeft="@drawable/ic_qr_code"
|
||||||
|
android:drawablePadding="8dp"
|
||||||
|
android:text="Show QR Code"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/textView2"/>
|
||||||
|
|
||||||
</android.support.constraint.ConstraintLayout>
|
</android.support.constraint.ConstraintLayout>
|
||||||
|
|||||||
@@ -9,30 +9,67 @@
|
|||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/linkIntro"
|
android:id="@+id/linkIntro"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="0dp"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="@dimen/margin_large"
|
android:layout_margin="@dimen/margin_large"
|
||||||
android:text="@string/send_code_instructions"
|
android:text="@string/send_code_instructions"
|
||||||
android:textIsSelectable="true"
|
android:textIsSelectable="true"
|
||||||
android:textSize="18sp"
|
android:textSize="18sp"
|
||||||
app:layout_constraintBottom_toTopOf="@id/qrCodeView"
|
app:layout_constraintBottom_toTopOf="@+id/qrCodeView"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="0.5"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintVertical_bias="0.0"
|
||||||
|
app:layout_constraintVertical_chainStyle="packed"
|
||||||
app:layout_constraintVertical_weight="1"
|
app:layout_constraintVertical_weight="1"
|
||||||
tools:visibility="visible"/>
|
tools:visibility="visible"/>
|
||||||
|
|
||||||
<org.briarproject.briar.android.view.QrCodeView
|
<org.briarproject.briar.android.view.QrCodeView
|
||||||
android:id="@+id/qrCodeView"
|
android:id="@+id/qrCodeView"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="0dp"
|
android:layout_height="wrap_content"
|
||||||
android:background="@android:color/white"
|
android:background="@android:color/white"
|
||||||
android:textIsSelectable="true"
|
android:textIsSelectable="true"
|
||||||
android:textSize="18sp"
|
android:textSize="18sp"
|
||||||
android:typeface="monospace"
|
android:typeface="monospace"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toTopOf="@+id/textView2"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="0.5"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/linkIntro"
|
app:layout_constraintTop_toBottomOf="@+id/linkIntro"
|
||||||
app:layout_constraintVertical_weight="1"/>
|
app:layout_constraintVertical_weight="1"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textView2"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginEnd="8dp"
|
||||||
|
android:layout_marginStart="8dp"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:text="or"
|
||||||
|
android:textSize="18sp"
|
||||||
|
app:layout_constraintBottom_toTopOf="@+id/showLinkButton"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/qrCodeView"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/showLinkButton"
|
||||||
|
style="@style/BriarButton"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="8dp"
|
||||||
|
android:layout_marginEnd="8dp"
|
||||||
|
android:layout_marginStart="8dp"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:drawableLeft="@drawable/ic_link"
|
||||||
|
android:drawablePadding="8dp"
|
||||||
|
android:text="Show Link"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="0.5"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/textView2"
|
||||||
|
app:layout_constraintVertical_bias="1.0"/>
|
||||||
|
|
||||||
</android.support.constraint.ConstraintLayout>
|
</android.support.constraint.ConstraintLayout>
|
||||||
|
|||||||
@@ -153,9 +153,9 @@
|
|||||||
|
|
||||||
<string name="add_contact_nearby_title">Add Contact Nearby</string>
|
<string name="add_contact_nearby_title">Add Contact Nearby</string>
|
||||||
<string name="open_link_title">Open Link</string>
|
<string name="open_link_title">Open Link</string>
|
||||||
<string name="open_code_title">Open QR Code</string>
|
<string name="open_code_title">Open Invite</string>
|
||||||
<string name="send_link_title">Send My Link</string>
|
<string name="send_link_title">Send My Link</string>
|
||||||
<string name="send_code_title">Send My QR Code</string>
|
<string name="send_code_title">Send My Invite</string>
|
||||||
<string name="show_link">Show Link</string>
|
<string name="show_link">Show Link</string>
|
||||||
<string name="show_code">Show QR code</string>
|
<string name="show_code">Show QR code</string>
|
||||||
<string name="contact_name_hint">Contact name</string>
|
<string name="contact_name_hint">Contact name</string>
|
||||||
@@ -165,7 +165,7 @@
|
|||||||
<string name="share_button">Share</string>
|
<string name="share_button">Share</string>
|
||||||
<string name="copy_button">Copy</string>
|
<string name="copy_button">Copy</string>
|
||||||
<string name="send_link_instructions">Send this link to your contact:</string>
|
<string name="send_link_instructions">Send this link to your contact:</string>
|
||||||
<string name="send_code_instructions">Let your contact scan this QR code with Briar:</string>
|
<string name="send_code_instructions">Let your contact scan this QR code:</string>
|
||||||
<string name="link_clip_label">Briar link</string>
|
<string name="link_clip_label">Briar link</string>
|
||||||
<string name="link_copied_toast">Link copied</string>
|
<string name="link_copied_toast">Link copied</string>
|
||||||
<string name="pending_contact_requests_snackbar">"There are pending contact requests"</string>
|
<string name="pending_contact_requests_snackbar">"There are pending contact requests"</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user