1
0
mirror of https://github.com/etesync/android synced 2024-12-23 15:18:14 +00:00

Fingerprint: Improve how the fingerprint dialog looks like.

This commit is contained in:
Tom Hacohen 2017-04-21 09:56:55 +01:00
parent fc52194d39
commit 3c1cad8960
5 changed files with 46 additions and 8 deletions

View File

@ -119,7 +119,7 @@ public class Crypto {
public static String getPrettyKeyFingerprint(byte[] pubkey) {
byte[] fingerprint = Crypto.AsymmetricCryptoManager.getKeyFingerprint(pubkey);
String fingerprintString = Hex.toHexString(fingerprint).toLowerCase();
return fingerprintString.replaceAll("(.{4})", "$1 ");
return fingerprintString.replaceAll("(.{4})", "$1 ").trim();
}
}

View File

@ -170,10 +170,13 @@ public class AccountActivity extends AppCompatActivity implements Toolbar.OnMenu
.show();
break;
case R.id.show_fingerprint:
View view = getLayoutInflater().inflate(R.layout.fingerprint_alertdialog, null);
view.findViewById(R.id.body).setVisibility(View.GONE);
((TextView) view.findViewById(R.id.fingerprint)).setText(getFormattedFingerprint());
AlertDialog dialog = new AlertDialog.Builder(AccountActivity.this)
.setIcon(R.drawable.ic_fingerprint_dark)
.setTitle(R.string.show_fingperprint_title)
.setMessage(getFormattedFingerprint())
.setView(view)
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {

View File

@ -9,6 +9,9 @@ import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import com.etesync.syncadapter.AccountSettings;
import com.etesync.syncadapter.Constants;
@ -90,18 +93,20 @@ public class AddMemberFragment extends DialogFragment {
protected void onPostExecute(AddResult result) {
if (result.throwable == null) {
String fingerprint = Crypto.AsymmetricCryptoManager.getPrettyKeyFingerprint(memberPubKey);
View view = LayoutInflater.from(getContext()).inflate(R.layout.fingerprint_alertdialog, null);
((TextView) view.findViewById(R.id.body)).setText(getString(R.string.trust_fingerprint_body, memberEmail));
((TextView) view.findViewById(R.id.fingerprint)).setText(fingerprint);
new AlertDialog.Builder(getActivity())
.setIcon(R.drawable.ic_info_dark)
.setIcon(R.drawable.ic_fingerprint_dark)
.setTitle(R.string.trust_fingerprint_title)
.setMessage(fingerprint)
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
.setView(view)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
new MemberAddSecond().execute();
}
})
.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}

View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical"
android:padding="18dp">
<TextView
android:id="@+id/body"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="12dp"
android:text="@string/trust_fingerprint_body"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/fingerprint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="monospace"
android:gravity="center"
android:textAlignment="center"
android:textAppearance="?android:attr/textAppearanceSmall"
tools:text="aaaa 1111 bbbb cccc dddd eeee\n1111" />
</LinearLayout>

View File

@ -117,7 +117,8 @@
<string name="collection_members_add">Add member</string>
<string name="collection_members_add_error">Error adding member</string>
<string name="collection_members_adding">Adding member</string>
<string name="trust_fingerprint_title">Trust fingerprint?</string>
<string name="trust_fingerprint_title">Verify security fingerprint</string>
<string name="trust_fingerprint_body">Verify %s\'s security fingerprint to ensure the encryption is secure.</string>
<string name="collection_members_removing">Removing member</string>
<string name="collection_members_remove_error">Error removing member</string>
<string name="collection_members_remove_title">Remove member</string>