From b284c7dd3f1b8b7c57c3a1dd90ad7d83acf3aae0 Mon Sep 17 00:00:00 2001 From: str4d Date: Tue, 26 Aug 2014 05:57:56 +0000 Subject: [PATCH] View identity: - Show fingerprint (en) - Generate QR code from identity key --- app/build.gradle | 3 ++ .../android/config/ViewIdentityFragment.java | 22 ++++++++++ .../res/layout/fragment_view_identity.xml | 43 ++++++++++++++++++- 3 files changed, 66 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index fb0d72a..6ed1036 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -37,16 +37,19 @@ dependencies { compile ('com.mcxiaoke.viewpagerindicator:library:2.4.1') { exclude group: 'com.android.support', module: 'support-v4' } + compile 'com.google.zxing:android-integration:3.1.0' } dependencyVerification { verify = [ + 'net.i2p.android:client:29815aa778f19bbf2c9d003e30289cca214481bb0fb17afe8adb77641aa7875f', 'com.android.support:support-v4:3f40fa7b3a4ead01ce15dce9453b061646e7fe2e7c51cb75ca01ee1e77037f3f', 'com.android.support:appcompat-v7:9df7637c5219202ddbbbf0924c2d5a9e6d64379166795a89d8f75d1e3f3372df', 'com.github.chrisbanes.actionbarpulltorefresh:extra-abc:a94f35b8b701d2cf761bb6b731d0921f73fb552a69a9c1d1379a19c2a9418ec6', 'com.github.chrisbanes.actionbarpulltorefresh:library:ea06f4e8cf7ae959cbe37028acf2631a6950714d2112e16531e4528daf69b6db', 'com.github.castorflex.smoothprogressbar:library:eb35b46d99a7f56d3d173cafe5f0f31beaaba0ce606258f81b07b0607ee3c32f', 'com.mcxiaoke.viewpagerindicator:library:470bbd2bec1ede64ad21efd6f02676807d22f1b526c4ac6a5b41a428c6e47e67', + 'com.google.zxing:android-integration:89e56aadf1164bd71e57949163c53abf90af368b51669c0d4a47a163335f95c4', ] } diff --git a/app/src/main/java/i2p/bote/android/config/ViewIdentityFragment.java b/app/src/main/java/i2p/bote/android/config/ViewIdentityFragment.java index 34301fc..484a4c4 100644 --- a/app/src/main/java/i2p/bote/android/config/ViewIdentityFragment.java +++ b/app/src/main/java/i2p/bote/android/config/ViewIdentityFragment.java @@ -27,9 +27,12 @@ import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; +import android.widget.Button; import android.widget.ImageView; import android.widget.TextView; +import com.google.zxing.integration.android.IntentIntegrator; + public class ViewIdentityFragment extends Fragment { public static final String IDENTITY_KEY = "identity_key"; @@ -39,9 +42,12 @@ public class ViewIdentityFragment extends Fragment { ImageView mIdentityPicture; TextView mNameField; TextView mDescField; + TextView mFingerprintField; TextView mCryptoField; TextView mKeyField; + Button mGenQRCode; + public static ViewIdentityFragment newInstance(String key) { ViewIdentityFragment f = new ViewIdentityFragment(); Bundle args = new Bundle(); @@ -70,8 +76,10 @@ public class ViewIdentityFragment extends Fragment { mIdentityPicture = (ImageView) view.findViewById(R.id.identity_picture); mNameField = (TextView) view.findViewById(R.id.public_name); mDescField = (TextView) view.findViewById(R.id.description); + mFingerprintField = (TextView) view.findViewById(R.id.fingerprint); mCryptoField = (TextView) view.findViewById(R.id.crypto_impl); mKeyField = (TextView) view.findViewById(R.id.key); + mGenQRCode = (Button) view.findViewById(R.id.generate_qr); if (mKey != null) { try { @@ -100,8 +108,22 @@ public class ViewIdentityFragment extends Fragment { mNameField.setText(mIdentity.getPublicName()); mDescField.setText(mIdentity.getDescription()); + try { + mFingerprintField.setText(BoteHelper.getFingerprint(mIdentity, "en")); + } catch (GeneralSecurityException e) { + // Could not get fingerprint + mFingerprintField.setText(e.getLocalizedMessage()); + } mCryptoField.setText(mIdentity.getCryptoImpl().getName()); mKeyField.setText(mKey); + + mGenQRCode.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + IntentIntegrator i = new IntentIntegrator(getActivity()); + i.shareText("bote:" + mKey); + } + }); } } diff --git a/app/src/main/res/layout/fragment_view_identity.xml b/app/src/main/res/layout/fragment_view_identity.xml index 101fd05..b911845 100644 --- a/app/src/main/res/layout/fragment_view_identity.xml +++ b/app/src/main/res/layout/fragment_view_identity.xml @@ -35,12 +35,22 @@ android:ems="10" android:text="@string/description" /> + + @@ -52,4 +62,33 @@ android:layout_marginTop="5dp" android:text="Key" /> + + + + +