diff options
author | Michael <betheg@bitcloner.org> | 2014-10-03 15:55:06 +0200 |
---|---|---|
committer | iNPUTmice <daniel@gultsch.de> | 2014-10-03 16:20:39 +0200 |
commit | 9a4b48d1ec964bdce2a3c5f8242a01c0fa4a70e0 (patch) | |
tree | a04a7f0ba2b3d0aa6f590eef73d4fd1b69482489 | |
parent | d51b41590c6d6871632a9cf88de532c4038b8bcd (diff) |
let's own otr-fingerprint copy to clipboard.
-rw-r--r-- | art/ic_action_copy.svg | 108 | ||||
-rwxr-xr-x | art/render.rb | 2 | ||||
-rw-r--r-- | res/drawable-hdpi/ic_action_copy.png | bin | 0 -> 717 bytes | |||
-rw-r--r-- | res/drawable-mdpi/ic_action_copy.png | bin | 0 -> 585 bytes | |||
-rw-r--r-- | res/drawable-xhdpi/ic_action_copy.png | bin | 0 -> 763 bytes | |||
-rw-r--r-- | res/drawable-xxhdpi/ic_action_copy.png | bin | 0 -> 1040 bytes | |||
-rw-r--r-- | res/layout/activity_edit_account.xml | 36 | ||||
-rw-r--r-- | res/values-de/strings.xml | 1 | ||||
-rw-r--r-- | res/values/strings.xml | 3 | ||||
-rw-r--r-- | src/eu/siacs/conversations/ui/EditAccountActivity.java | 35 |
10 files changed, 175 insertions, 10 deletions
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 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="128" + height="128" + id="svg4066" + version="1.1" + inkscape:version="0.48.5 r10040" + sodipodi:docname="ic_action_copy.svg"> + <defs + id="defs4068" /> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#000000" + borderopacity="0.54117647" + inkscape:pageopacity="0.0" + inkscape:pageshadow="2" + inkscape:zoom="2.67" + inkscape:cx="51.750573" + inkscape:cy="57.547291" + inkscape:document-units="px" + inkscape:current-layer="layer1" + showgrid="false" + borderlayer="false" + inkscape:window-width="1035" + inkscape:window-height="853" + inkscape:window-x="369" + inkscape:window-y="3" + inkscape:window-maximized="0" /> + <metadata + id="metadata4071"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title></dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1" + transform="translate(0,-924.36218)"> + <rect + ry="0" + height="91.708199" + width="71.625328" + stroke-miterlimit="4" + y="952.36743" + x="42.730034" + id="rect10" + style="fill:none;stroke:#000000;stroke-width:8.6679945;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:0.54117647;stroke-dasharray:none" + inkscape:transform-center-x="-21.391573" + inkscape:transform-center-y="28.294015" /> + <path + style="fill:#000000;fill-opacity:0.5411765;fill-rule:evenodd;stroke:#000000;stroke-width:0.41999999999999998;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.54117649999999995;stroke-miterlimit:4;stroke-dasharray:none" + d="m 20.552281,933.36985 0,0.0209 -0.128276,0 -0.399078,99.83215 0.213792,0 0,0.1463 13.212333,-0.021 0.05701,-8.1392 -4.076297,0.011 0.327814,-84.87039 58.436429,0 0.0285,3.427 11.10293,0 -0.0855,-9.25707 -0.057,0 0,-1.1493 -78.63263,0 z" + id="rect12-6" + inkscape:connector-curvature="0" /> + <rect + height="4.7259107" + width="37.242958" + y="967.49921" + x="50.137043" + id="rect12" + style="fill:#000000;fill-opacity:0.54117647;fill-rule:evenodd;stroke:#000000;stroke-width:0.23799089px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.54117647" /> + <rect + style="fill:#000000;fill-opacity:0.54117647000000002;fill-rule:evenodd;stroke:#000000;stroke-width:0.274;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.54117647000000002;stroke-miterlimit:4;stroke-dasharray:none" + id="rect4272" + x="50.137043" + y="982.49921" + width="49.452484" + height="4.7259107" /> + <rect + height="4.7259107" + width="43.542446" + y="997.49921" + x="50.137043" + id="rect4274" + style="fill:#000000;fill-opacity:0.54117647;fill-rule:evenodd;stroke:#000000;stroke-width:0.2573325px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.54117647" /> + <rect + style="fill:#000000;fill-opacity:0.54117647;fill-rule:evenodd;stroke:#000000;stroke-width:0.25050664px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.54117647" + id="rect4276" + x="50.137043" + y="1012.4992" + width="41.263123" + height="4.7259107" /> + <rect + height="4.7259107" + width="49.397911" + y="1027.4993" + x="50.137043" + id="rect4278" + style="fill:#000000;fill-opacity:0.54117647;fill-rule:evenodd;stroke:#000000;stroke-width:0.27408957px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.54117647" /> + </g> +</svg> 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 Binary files differnew file mode 100644 index 00000000..b47bb69c --- /dev/null +++ b/res/drawable-hdpi/ic_action_copy.png diff --git a/res/drawable-mdpi/ic_action_copy.png b/res/drawable-mdpi/ic_action_copy.png Binary files differnew file mode 100644 index 00000000..75788f1f --- /dev/null +++ b/res/drawable-mdpi/ic_action_copy.png diff --git a/res/drawable-xhdpi/ic_action_copy.png b/res/drawable-xhdpi/ic_action_copy.png Binary files differnew file mode 100644 index 00000000..a45423f6 --- /dev/null +++ b/res/drawable-xhdpi/ic_action_copy.png diff --git a/res/drawable-xxhdpi/ic_action_copy.png b/res/drawable-xxhdpi/ic_action_copy.png Binary files differnew file mode 100644 index 00000000..3a0e8449 --- /dev/null +++ b/res/drawable-xxhdpi/ic_action_copy.png 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" /> - <TextView - android:id="@+id/otr_fingerprint" + <RelativeLayout android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginTop="8dp" - android:textSize="?attr/TextSizeBody" - android:typeface="monospace" /> + android:layout_height="match_parent" + android:layout_marginTop="8dp"> + <LinearLayout + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentLeft="true" + android:layout_toLeftOf="@+id/action_copy_to_clipboard" + android:orientation="vertical" > + + <TextView + android:id="@+id/otr_fingerprint" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:textSize="?attr/TextSizeBody" + android:typeface="monospace" /> + </LinearLayout> + + <ImageButton + android:id="@+id/action_copy_to_clipboard" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:background="?android:selectableItemBackground" + android:layout_alignParentRight="true" + android:layout_centerVertical="true" + android:src="@drawable/ic_action_copy" + android:visibility="invisible" /> + </RelativeLayout> </LinearLayout> </LinearLayout> </ScrollView> @@ -226,4 +248,4 @@ android:textColor="@color/secondarytext" /> </LinearLayout> -</RelativeLayout>
\ No newline at end of file +</RelativeLayout> 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 @@ <string name="pref_expert_options_other">Sonstiges</string> <string name="pref_conference_name">Konferenz-Name</string> <string name="pref_conference_name_summary">Konferenz-Thema statt Raum-JID als Name verwenden</string> + <string name="toast_message_otr_fingerprint">OTR Fingerabdruck in die Zwischenablage kopiert!</string> </resources> 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 @@ <string name="pref_expert_options_other">Other</string> <string name="pref_conference_name">Conference name</string> <string name="pref_conference_name_summary">Use room’s subject instead of JID to identify conferences</string> + <string name="toast_message_otr_fingerprint">OTR fingerprint copied to clipboard!</string> -</resources>
\ No newline at end of file +</resources> 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; + } } |