From 9a4b48d1ec964bdce2a3c5f8242a01c0fa4a70e0 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 3 Oct 2014 15:55:06 +0200 Subject: [PATCH] let's own otr-fingerprint copy to clipboard. --- art/ic_action_copy.svg | 108 ++++++++++++++++++ art/render.rb | 2 +- res/drawable-hdpi/ic_action_copy.png | Bin 0 -> 717 bytes res/drawable-mdpi/ic_action_copy.png | Bin 0 -> 585 bytes res/drawable-xhdpi/ic_action_copy.png | Bin 0 -> 763 bytes res/drawable-xxhdpi/ic_action_copy.png | Bin 0 -> 1040 bytes res/layout/activity_edit_account.xml | 36 ++++-- res/values-de/strings.xml | 1 + res/values/strings.xml | 3 +- .../conversations/ui/EditAccountActivity.java | 35 +++++- 10 files changed, 175 insertions(+), 10 deletions(-) create mode 100644 art/ic_action_copy.svg create mode 100644 res/drawable-hdpi/ic_action_copy.png create mode 100644 res/drawable-mdpi/ic_action_copy.png create mode 100644 res/drawable-xhdpi/ic_action_copy.png create mode 100644 res/drawable-xxhdpi/ic_action_copy.png diff --git a/art/ic_action_copy.svg b/art/ic_action_copy.svg new file mode 100644 index 00000000..485fd2ed --- /dev/null +++ b/art/ic_action_copy.svg @@ -0,0 +1,108 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + diff --git a/art/render.rb b/art/render.rb index 5464b9f5..a78a2f47 100755 --- a/art/render.rb +++ b/art/render.rb @@ -1,6 +1,6 @@ #!/bin/env ruby resolutions={'mdpi'=> 1, 'hdpi' => 1.5, 'xhdpi' => 2, 'xxhdpi' => 3} -images = { 'conversations.svg' => ['ic_launcher',48], 'conversations_baloon.svg' => ['ic_activity', 32], 'conversations_mono.svg' => ['ic_notification',24], 'ic_received_indicator.svg' => ['ic_received_indicator',12] } +images = { 'conversations.svg' => ['ic_launcher', 48], 'conversations_baloon.svg' => ['ic_activity', 32], 'conversations_mono.svg' => ['ic_notification', 24], 'ic_received_indicator.svg' => ['ic_received_indicator', 12], 'ic_action_copy.svg' => ['ic_action_copy', 32] } images.each do |source, result| resolutions.each do |name, factor| size = factor * result[1] diff --git a/res/drawable-hdpi/ic_action_copy.png b/res/drawable-hdpi/ic_action_copy.png new file mode 100644 index 0000000000000000000000000000000000000000..b47bb69c9a0e8e02bb84b3dedb65032133644af9 GIT binary patch literal 717 zcmV;;0y6!HP)5uNYqY61Hu(rr4j6Gtppnz8w>vi z{{X>%!P-KsBwC0~EW}0-1hI&}io`+<92hLba1p;27s9db?#;X%lWg*VE%x5LdEePL z^WM9?GfDKBecLUdE4>e3e_NxO%>fs-NXsP8BrSOiTLS=&1B32*!n_7j0;qBTu&|uz ztOG@>Ni=|az{iq-rf|D*@2<^h0aTy%NYXE_b1!B#U-`(DJ`kUQ&1p8XL%_jc|0dp7 zKQOan4Yq5O4>39elX-d>xag9X%fiM5?1Ft@S^#Y`up@}pKojqP$4S2GxDK4DYv@t~ zlZ+&-Mpbz+v)@f^(G=QoM2on0HQ=5BGaCTc3N)-rx?9i>$g2SupOa<^G&JV7hpbfy zNsGX(EPq~lzYp|&C(bP5!@z7eIh(9V`tC7|*1(^Zwprjt&|eczfEOOav>5m;vS@gV*qqKmkMI3;>@Q zzjo=uw`hmVRp=+M7!}Z!J@!1Nr`u8Dp`=&QPQ`ELYFKA{oG4{f z(kZiuKLK}2M08=#74g8#PX8Arg+yvVz!l&vaKGAUW=DZ@NxGIKt#}MecH*X`^dxY# zz+WAYfRq5lzpF!207KxpXHW-Uy@ss;NSX(#zn(PN4uPlMfwSoS7n-co=vgznndGaE z6HN_S0UX)5wwyhkLLY#&EFl4wCvU9pf4BJy>Ar`R4$qilor})W2JVIN^C3yL;g7DycX`@s^^hv+vA&Gb`InQqLxu z9hi>Yl=P8*2X}3IqY40c2~0H*eL)7z@kOdp7l4}MKCs&p;4@(0PalAwf$d+CW`O6F z0PEpI(p)TV3LrQTrpR01LnS~;C%_iu`*-YfwA6v1b71oc`Bs6I5`ZoZZD04zF6q&L z>;f=%E<6mf0L*7{4Q-#6K;^n1rX^rG6ZZ%3wHJV-cJkOD+yTCo1n&h9I69JJdjyQe z36OL^(jxG>BFD&fr(?NU5c|@3;8g{{F!iv@fzSny9I(9y>{S3H)l~`q+b*Tr0ZD7X zo5J{qwhw9na=HY*7q-31HAp!C@iA}=92Wv)l`6$iNh;nY*&gKD;dC|&kkJD0sTLrmiT|8x(!b|7 X<#>CHpqGh)00000NkvXXu0mjf#{Bw0 literal 0 HcmV?d00001 diff --git a/res/drawable-xhdpi/ic_action_copy.png b/res/drawable-xhdpi/ic_action_copy.png new file mode 100644 index 0000000000000000000000000000000000000000..a45423f69d697ce56daf0d502647afcdee3fbd7a GIT binary patch literal 763 zcmVWzXo!E%&rOh_pE%uB)!pOF{J_N&51Zz7`o0J?7iWMCJBC?V){t+f5 zzdOuxPpMvD*=e3%09*wqRSA045bm`|kq98UR$?6uV=rK^9h?BY>;(oN0Y#Fah-@OS zU=xz-8pBdaFn6@vY7L_zKw{de$Js+(5iYcbsqJuc6VV$Yxs$L?QDTokFK+-~>;{t} zpqG_kN)AwO*s&dMa!vA!b&^;CtP$YV4mUXmU>2ZMDV!sTy3Cmp0pT~Eat)5{a90`Y z0E6w|BA}O1kdg#LQeKODx5K|le)gECR4MFzT-@d>RS0>v!xOKGO1&2EWjj2mTcEdC zuECcg@4nJ za3z8;64!{5;QX|b^2DN4hVt@qz0ADq;^f4FRK5J7^x5xhq!<{Odp%to zLn`LHox3+H)KTDgy|Akei|7%PEXAbM02aX`FQk7+?Q2}n|B(Ael;(|&UKXXSY~c+a ze;8C*x?NNhvW`9K5ZLkkNlJNoy8pXBs}7ue$Mb#v=FQgCb}pfue`b6xOSs0#I0ud_ z=Uk3($zwXs_4AUIe8|_@mwuaB81fj^y)2BF?lB%^Ju$awNr(7jh4Kx4Dn$nheAuF0 z8jRHvzxFTg(LPkiRA04jHqW*g#$R))c=w!nvtRA|w;g##Gjx;_qC?Gje(QI2oX^S9 zJaFR&&zmnX=8`_sf-kIib!XMD3y0s$nDnIah!K;Txqv0poU>c3&90T4Iyv2)&w}+% z>4w)QnIC*#!aYrTW8hN;eVt+l4ub{_R|{dm2R=air>$Nvg`hdyo*-=`6e@&L%vFWICHyS>WI-5kagUJ$H(!UNo9CT#~ns7?q8ea!$Q6W>L!OtZ@eS3Ve(D8_ElxY#SZf~ z2X;v~tX|ro`{!NPkFd)TlPw)Wr#C)r+GpbZhIvkBP>b=jqdNo=7osevO{FhTL5(w~s6C(ih=% z3!Ts4FZ5SR^d!@YSLF}t9OKg_?XbQDiYOquCKntlF!Ay|VB)n~8ko%#^R;Y&nIWsC zFp~uwDF@pXW~6VZKJJp;Y8D()`Y4^}pkqUVIZ)YWaTBEtOhtO}8o=Dk;OXk;vd$@? F2>^cBxyk?l literal 0 HcmV?d00001 diff --git a/res/layout/activity_edit_account.xml b/res/layout/activity_edit_account.xml index 04f63795..0f4bae97 100644 --- a/res/layout/activity_edit_account.xml +++ b/res/layout/activity_edit_account.xml @@ -180,13 +180,35 @@ android:textSize="?attr/TextSizeHeadline" android:textStyle="bold" /> - + android:layout_height="match_parent" + android:layout_marginTop="8dp"> + + + + + + + @@ -226,4 +248,4 @@ android:textColor="@color/secondarytext" /> - \ No newline at end of file + diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml index 0c230ec6..6f21a71f 100644 --- a/res/values-de/strings.xml +++ b/res/values-de/strings.xml @@ -261,5 +261,6 @@ Sonstiges Konferenz-Name Konferenz-Thema statt Raum-JID als Name verwenden + OTR Fingerabdruck in die Zwischenablage kopiert! diff --git a/res/values/strings.xml b/res/values/strings.xml index 8d976dce..b6e5e15c 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -261,5 +261,6 @@ Other Conference name Use room’s subject instead of JID to identify conferences + OTR fingerprint copied to clipboard! - \ No newline at end of file + diff --git a/src/eu/siacs/conversations/ui/EditAccountActivity.java b/src/eu/siacs/conversations/ui/EditAccountActivity.java index bc946115..9aa8a9b4 100644 --- a/src/eu/siacs/conversations/ui/EditAccountActivity.java +++ b/src/eu/siacs/conversations/ui/EditAccountActivity.java @@ -1,6 +1,8 @@ package eu.siacs.conversations.ui; import android.app.PendingIntent; +import android.content.ClipData; +import android.content.ClipboardManager; import android.content.Intent; import android.os.Bundle; import android.view.View; @@ -10,9 +12,11 @@ import android.widget.Button; import android.widget.CheckBox; import android.widget.CompoundButton; import android.widget.EditText; +import android.widget.ImageButton; import android.widget.LinearLayout; import android.widget.CompoundButton.OnCheckedChangeListener; import android.widget.TextView; +import android.widget.Toast; import eu.siacs.conversations.R; import eu.siacs.conversations.entities.Account; import eu.siacs.conversations.services.XmppConnectionService.OnAccountUpdate; @@ -38,6 +42,7 @@ public class EditAccountActivity extends XmppActivity { private TextView mSessionEst; private TextView mOtrFingerprint; private TextView mOtrFingerprintHeadline; + private ImageButton mOtrFingerprintToClipboardButton; private String jidToEdit; private Account mAccount; @@ -228,6 +233,7 @@ public class EditAccountActivity extends XmppActivity { this.mServerInfoPep = (TextView) findViewById(R.id.server_info_pep); this.mOtrFingerprint = (TextView) findViewById(R.id.otr_fingerprint); this.mOtrFingerprintHeadline = (TextView) findViewById(R.id.otr_fingerprint_headline); + this.mOtrFingerprintToClipboardButton = (ImageButton) findViewById(R.id.action_copy_to_clipboard); this.mSaveButton = (Button) findViewById(R.id.save_button); this.mCancelButton = (Button) findViewById(R.id.cancel_button); this.mSaveButton.setOnClickListener(this.mSaveButtonClickListener); @@ -324,13 +330,29 @@ public class EditAccountActivity extends XmppActivity { } else { this.mServerInfoPep.setText(R.string.server_info_unavailable); } - String fingerprint = this.mAccount + final String fingerprint = this.mAccount .getOtrFingerprint(xmppConnectionService); if (fingerprint != null) { this.mOtrFingerprintHeadline.setVisibility(View.VISIBLE); this.mOtrFingerprint.setVisibility(View.VISIBLE); this.mOtrFingerprint.setText(fingerprint); + this.mOtrFingerprintToClipboardButton.setVisibility(View.VISIBLE); + this.mOtrFingerprintToClipboardButton + .setOnClickListener(new View.OnClickListener() { + + @Override + public void onClick(View v) { + + if (OtrFingerprintToClipBoard(fingerprint)) { + Toast.makeText( + EditAccountActivity.this, + R.string.toast_message_otr_fingerprint, + Toast.LENGTH_SHORT).show(); + } + } + }); } else { + this.mOtrFingerprintToClipboardButton.setVisibility(View.GONE); this.mOtrFingerprint.setVisibility(View.GONE); this.mOtrFingerprintHeadline.setVisibility(View.GONE); } @@ -343,4 +365,15 @@ public class EditAccountActivity extends XmppActivity { this.mStats.setVisibility(View.GONE); } } + + private boolean OtrFingerprintToClipBoard(String fingerprint) { + ClipboardManager mClipBoardManager = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); + String label = getResources().getString(R.string.otr_fingerprint); + if (mClipBoardManager != null) { + ClipData mClipData = ClipData.newPlainText(label, fingerprint); + mClipBoardManager.setPrimaryClip(mClipData); + return true; + } + return false; + } }