From 7c9d6630d0271134a75d72ef1912cb7b140eec14 Mon Sep 17 00:00:00 2001 From: Vineet Garg Date: Sat, 15 Aug 2015 18:44:49 +0530 Subject: [PATCH] Show encryption info in device activity too --- src/org/kde/kdeconnect/Device.java | 2 +- .../UserInterface/DeviceActivity.java | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/org/kde/kdeconnect/Device.java b/src/org/kde/kdeconnect/Device.java index e08ddc30..4f2095bc 100644 --- a/src/org/kde/kdeconnect/Device.java +++ b/src/org/kde/kdeconnect/Device.java @@ -506,7 +506,7 @@ public class Device implements BaseLink.PackageReceiver { if (np.getType().equals(NetworkPackage.PACKAGE_TYPE_PAIR)) { Log.i("KDE/Device", "Pair package"); - Log.e("KDE/Device", "Pairing Handler Count " + pairingHandlers.size()); + for (BasePairingHandler ph: pairingHandlers.values()) { try { ph.packageReceived(np); diff --git a/src/org/kde/kdeconnect/UserInterface/DeviceActivity.java b/src/org/kde/kdeconnect/UserInterface/DeviceActivity.java index 88aa95c7..6aad5b8b 100644 --- a/src/org/kde/kdeconnect/UserInterface/DeviceActivity.java +++ b/src/org/kde/kdeconnect/UserInterface/DeviceActivity.java @@ -21,6 +21,9 @@ package org.kde.kdeconnect.UserInterface; import android.app.Activity; +import android.app.AlertDialog; +import android.content.Context; +import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; import android.support.v7.app.ActionBar; @@ -35,6 +38,7 @@ import android.widget.TextView; import org.kde.kdeconnect.BackgroundService; import org.kde.kdeconnect.Device; +import org.kde.kdeconnect.Helpers.SecurityHelpers.SslHelper; import org.kde.kdeconnect.Plugins.Plugin; import org.kde.kdeconnect.UserInterface.List.ButtonItem; import org.kde.kdeconnect.UserInterface.List.CustomItem; @@ -185,6 +189,28 @@ public class DeviceActivity extends ActionBarActivity { return true; } }); + menu.add(R.string.encryption_info_title).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { + @Override + public boolean onMenuItemClick(MenuItem menuItem) { + Context context = DeviceActivity.this; + AlertDialog.Builder builder = new AlertDialog.Builder(context); + builder.setTitle(context.getResources().getString(R.string.encryption_info_title)); + builder.setPositiveButton(context.getResources().getString(R.string.ok), new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + dialog.dismiss(); + } + }); + + if (device.certificate == null) { + builder.setMessage(R.string.encryption_info_msg_no_ssl); + } else { + builder.setMessage(context.getResources().getString(R.string.my_device_fingerprint) + " " + SslHelper.getCertificateHash(SslHelper.certificate) + "\n\n" + + context.getResources().getString(R.string.remote_device_fingerprint) + " " + SslHelper.getCertificateHash(device.certificate)); + } + builder.create().show(); + return true; + } + }); menu.add(R.string.device_menu_unpair).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) {