From 3d339460889644c859d932eb3f2e324bd5696707 Mon Sep 17 00:00:00 2001 From: Andreas Straub Date: Fri, 10 Jul 2015 02:56:44 +0200 Subject: [PATCH] Add key trust toggle to ContactDetailsActivity Can now toggle IdentityKey trust --- .../ui/ContactDetailsActivity.java | 49 ++++++++++++++---- src/main/res/drawable-hdpi/ic_action_done.png | Bin 0 -> 1320 bytes .../res/drawable-hdpi/ic_done_black_24dp.png | Bin 0 -> 177 bytes src/main/res/drawable-mdpi/ic_action_done.png | Bin 0 -> 1197 bytes .../res/drawable-mdpi/ic_done_black_24dp.png | Bin 0 -> 130 bytes .../res/drawable-xhdpi/ic_action_done.png | Bin 0 -> 1546 bytes .../res/drawable-xhdpi/ic_done_black_24dp.png | Bin 0 -> 188 bytes .../drawable-xxhdpi/ic_done_black_24dp.png | Bin 0 -> 227 bytes .../drawable-xxxhdpi/ic_done_black_24dp.png | Bin 0 -> 277 bytes src/main/res/layout/contact_key.xml | 10 ++++ src/main/res/values-v21/themes.xml | 1 + src/main/res/values/attrs.xml | 1 + src/main/res/values/themes.xml | 1 + 13 files changed, 52 insertions(+), 10 deletions(-) create mode 100644 src/main/res/drawable-hdpi/ic_action_done.png create mode 100644 src/main/res/drawable-hdpi/ic_done_black_24dp.png create mode 100644 src/main/res/drawable-mdpi/ic_action_done.png create mode 100644 src/main/res/drawable-mdpi/ic_done_black_24dp.png create mode 100644 src/main/res/drawable-xhdpi/ic_action_done.png create mode 100644 src/main/res/drawable-xhdpi/ic_done_black_24dp.png create mode 100644 src/main/res/drawable-xxhdpi/ic_done_black_24dp.png create mode 100644 src/main/res/drawable-xxxhdpi/ic_done_black_24dp.png diff --git a/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java b/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java index 4ff47f9e..ebc1ae83 100644 --- a/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java @@ -35,6 +35,7 @@ import java.util.List; import eu.siacs.conversations.R; import eu.siacs.conversations.crypto.PgpEngine; +import eu.siacs.conversations.crypto.axolotl.AxolotlService; import eu.siacs.conversations.entities.Account; import eu.siacs.conversations.entities.Contact; import eu.siacs.conversations.entities.ListItem; @@ -363,13 +364,13 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd View view = inflater.inflate(R.layout.contact_key, keys, false); TextView key = (TextView) view.findViewById(R.id.key); TextView keyType = (TextView) view.findViewById(R.id.key_type); - ImageButton remove = (ImageButton) view + ImageButton removeButton = (ImageButton) view .findViewById(R.id.button_remove); - remove.setVisibility(View.VISIBLE); + removeButton.setVisibility(View.VISIBLE); keyType.setText("OTR Fingerprint"); key.setText(CryptoHelper.prettifyFingerprint(otrFingerprint)); keys.addView(view); - remove.setOnClickListener(new OnClickListener() { + removeButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { @@ -384,19 +385,47 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd TextView key = (TextView) view.findViewById(R.id.key); TextView keyType = (TextView) view.findViewById(R.id.key_type); TextView keyTrust = (TextView) view.findViewById(R.id.key_trust); - ImageButton remove = (ImageButton) view + ImageButton removeButton = (ImageButton) view .findViewById(R.id.button_remove); - remove.setVisibility(View.VISIBLE); - keyTrust.setVisibility(View.VISIBLE); + ImageButton trustButton = (ImageButton) view + .findViewById(R.id.button_trust); + final AxolotlService axolotlService = contact.getAccount().getAxolotlService(); + final String fingerprint = identityKey.getFingerprint().replaceAll("\\s", ""); + final Jid bareJid = contactJid.toBareJid(); + AxolotlService.SQLiteAxolotlStore.Trust trust = contact.getAccount().getAxolotlService() + .getFingerprintTrust(bareJid.toString(), fingerprint); + switch (trust) { + case TRUSTED: + removeButton.setVisibility(View.VISIBLE); + //Log.d(Config.LOGTAG, AxolotlService.getLogprefix(contact.getAccount()) + "Setting remove button visible!"); + break; + case UNDECIDED: + case UNTRUSTED: + //Log.d(Config.LOGTAG, AxolotlService.getLogprefix(contact.getAccount()) + "Setting trust button visible!"); + trustButton.setVisibility(View.VISIBLE); + break; + } keyType.setText("Axolotl Fingerprint"); key.setText(CryptoHelper.prettifyFingerprint(identityKey.getFingerprint())); - keyTrust.setText(contact.getAccount().getAxolotlService().getFingerprintTrust(contact.getJid().toBareJid().toString(), identityKey.getFingerprint().replaceAll("\\s","")).toString()); + keyTrust.setText(trust.toString()); + keyTrust.setVisibility(View.VISIBLE); keys.addView(view); - remove.setOnClickListener(new OnClickListener() { - + removeButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { - //confirmToDeleteFingerprint(otrFingerprint); + axolotlService.setFingerprintTrust(bareJid.toString(), fingerprint, + AxolotlService.SQLiteAxolotlStore.Trust.UNTRUSTED); + refreshUi(); + xmppConnectionService.updateConversationUi(); + } + }); + trustButton.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + axolotlService.setFingerprintTrust(bareJid.toString(), fingerprint, + AxolotlService.SQLiteAxolotlStore.Trust.TRUSTED); + refreshUi(); + xmppConnectionService.updateConversationUi(); } }); } diff --git a/src/main/res/drawable-hdpi/ic_action_done.png b/src/main/res/drawable-hdpi/ic_action_done.png new file mode 100644 index 0000000000000000000000000000000000000000..58bf972171f199c359dcdb3bc6233ac84c7853d3 GIT binary patch literal 1320 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezpTC$r9IylHmNblJdl&R0hYC{G?O` z&)mfH)S%SFl*+=BsWuD@%qp275hW46K32*3xq68pHF_1f1wh>l3^w)^1&PVosU-?Y zsp*+{wo31J?^jaDOtDo8H}y5}EpSfF$n>ZxN)4{^3rViZPPR-@vbR&PsjvbXkegbP zs8ErclUHn2VXFi-*9yo63F|8hm3bwJ6}oxF$}kgLQj3#|G7CyF^YauyCMG83 zmzLNn0bL65LT&-v*t}wBFaZNhzap_f-%!s00+w{G(#^lGsVi#&Ct}+$imdr$-u?X(ACh=#L&{!#L3yw z&D7A`#K{n**Cju>G&eP`1g19yq1OzjUQlAlEdbi=l3J8mmYU*Ll%J~r_Ow+d7PlC? zn3-5OIXVK(v%u~ah~5<3ZZW~>7JZ;&^g&UJ6xA>xVEO?u;RzSWfhYacJYae+0w(OB zPunsW7#L@Hx;TbZ+F}XRH$BVJ_~tbB>ux&w{i&Jpl6k3-y`NvKHk21q zV1%GG?pIzqOj6l*_t-(U9qjp;vo`HwN=}ep)5vUa_N7?Rr}hN4ng+Fwoh&_BpW+wD z&uL8OV?3O|erD1ih8>LjGWVRk>cn-L{3q>ay)F~Cc;}xn`8m#J@(k z@^-_wj*fK>KI!`&dhL6Y6 literal 0 HcmV?d00001 diff --git a/src/main/res/drawable-hdpi/ic_done_black_24dp.png b/src/main/res/drawable-hdpi/ic_done_black_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..d4c06072b56dace7da1ab5fcfc5cb0a494adc5cf GIT binary patch literal 177 zcmeAS@N?(olHy`uVBq!ia0vp^Dj>|k0wldT1B8K8g{O;SNCo5DGlpDEh5{}R!&SuQ zX|-?oV07r-F(+5sYxQj19uA4F0*7@nHs;@YsQf$gW>+px@zP|&GZEd1Z}?}-I>Y|V z=y1-BV5J$-bD3R}6Ta_|*W@zZWWK6sUb;=`BCRvpTf-#$b)_C_PW(7UG2P#7{m0nI aGWJPksgEnI&wc~Cfx*+&&t;ucLK6Uc3_uP5 literal 0 HcmV?d00001 diff --git a/src/main/res/drawable-mdpi/ic_action_done.png b/src/main/res/drawable-mdpi/ic_action_done.png new file mode 100644 index 0000000000000000000000000000000000000000..cf5fab3adf243318d11ec95448c6deae3f52d9b1 GIT binary patch literal 1197 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz$r9IylHmNblJdl&R0hYC{G?O` z&)mfH)S%SFl*+=BsWuD@%qp275hW46K32*3xq68pHF_1f1wh>l3^w)^1&PVosU-?Y zsp*+{wo31J?^jaDOtDo8H}y5}EpSfF$n>ZxN)4{^3rViZPPR-@vbR&PsjvbXkegbP zs8ErclUHn2VXFi-*9yo63F|8hm3b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dJEH8vU^=Avr+i|X?`*2LY9 z7jHvHE29PrBH!kINN(*uSt$Oev6h7iu1N7t^Bcq8%eH4kerw;l_*m?|A2AK`y6?34 zP`@{J#lYB+FlJ}1sp{bG{!_iCO_Q1c_7CzZkyMzhv`>@qo7TfY@Gmt3uSG*tgxNWQc=v|JYQSD*fn7li5 z#PB$#i7UEVf00h?$hp1uLQj2zQtZFGsWX7jD_#?wJrFj3Z4#6Vd{fyGdK_MQaQVc! gtQRZb>M z)eh4Z*LH7YPT^1c;c>xMY3CR5UF8g~O~MqEfWRtq)wx@t#f5EcS$cj=DHe>A9+n8m zSQI=s(8$bw&b3_ExG+wt$|R_#_-}!m@==T1(=U4%_LXEm_Sb!xepO%dfZ-C;lZ8td zj!$Hgapx-N^Vofj<@f|98RxE|K99&g#i>rA^B#LHEf9Sw5tKPe>yY6RAwfaGi}hdF Y%FU*83Z;v716|GF>FVdQ&MBb@0A~SHegFUf literal 0 HcmV?d00001 diff --git a/src/main/res/drawable-xxxhdpi/ic_done_black_24dp.png b/src/main/res/drawable-xxxhdpi/ic_done_black_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..2f6d6386de9510fa6dd8c83cbb61a6f2e0fab9b2 GIT binary patch literal 277 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD0wg^q?%xcg?s&R5hEy=VJ?|UH<|x2&QEUS@ zUqF*g%NA{xn*DVG1~S@B-uDxXPUtYNKXnEQ>b^wD=lt6oW;%QS1o1=daUAyI8~(&3 zd|u96v#;i-{{JTZcp&}h>FMeJ8GvN{`tw#N{;ZEGUD<;p)-Lh7=#>`kZ6pLOOe=>Nw L`njxgN@xNAv*3Ko literal 0 HcmV?d00001 diff --git a/src/main/res/layout/contact_key.xml b/src/main/res/layout/contact_key.xml index 79b9af62..a43f8083 100644 --- a/src/main/res/layout/contact_key.xml +++ b/src/main/res/layout/contact_key.xml @@ -50,4 +50,14 @@ android:src="?attr/icon_remove" android:visibility="invisible" /> + \ No newline at end of file diff --git a/src/main/res/values-v21/themes.xml b/src/main/res/values-v21/themes.xml index d1679f92..78deb772 100644 --- a/src/main/res/values-v21/themes.xml +++ b/src/main/res/values-v21/themes.xml @@ -18,6 +18,7 @@ @drawable/ic_file_download_white_24dp @drawable/ic_edit_white_24dp @drawable/ic_edit_grey600_24dp + @drawable/ic_done_black_24dp @drawable/ic_group_white_24dp @drawable/ic_add_white_24dp @drawable/ic_attach_file_white_24dp diff --git a/src/main/res/values/attrs.xml b/src/main/res/values/attrs.xml index e314f752..d471e54a 100644 --- a/src/main/res/values/attrs.xml +++ b/src/main/res/values/attrs.xml @@ -14,6 +14,7 @@ + diff --git a/src/main/res/values/themes.xml b/src/main/res/values/themes.xml index 5c67203b..afdc3e80 100644 --- a/src/main/res/values/themes.xml +++ b/src/main/res/values/themes.xml @@ -18,6 +18,7 @@ @drawable/ic_action_download @drawable/ic_action_edit @drawable/ic_action_edit_dark + @drawable/ic_action_done @drawable/ic_action_group @drawable/ic_action_new