aboutsummaryrefslogtreecommitdiffstats
path: root/art/render.rb
diff options
context:
space:
mode:
authorlookshe <github@lookshe.org>2016-02-11 10:45:27 +0100
committerlookshe <github@lookshe.org>2016-02-11 10:45:27 +0100
commit3824eb172ba9a4a6b9ea84b0d1045591bc4fa0e3 (patch)
tree0286423f053440a5900732032e35810d6cc076c6 /art/render.rb
parentcec1b0f1f8d3976ab6a437ff4584ac039b64fa9a (diff)
parentae83efe4a6c1b3349147904eee200f0b617741c3 (diff)
Merge tag '1.9.3' into trz/merge_1.9.3
Conflicts: .travis.yml CHANGELOG.md README.md art/render.rb build.gradle libs/openpgp-api-lib/build.gradle settings.gradle src/main/AndroidManifest.xml src/main/java/eu/siacs/conversations/Config.java src/main/java/eu/siacs/conversations/crypto/OtrService.java src/main/java/eu/siacs/conversations/crypto/PgpEngine.java src/main/java/eu/siacs/conversations/entities/Account.java src/main/java/eu/siacs/conversations/entities/Contact.java src/main/java/eu/siacs/conversations/entities/Conversation.java src/main/java/eu/siacs/conversations/entities/DownloadableFile.java src/main/java/eu/siacs/conversations/entities/Message.java src/main/java/eu/siacs/conversations/entities/MucOptions.java src/main/java/eu/siacs/conversations/entities/Transferable.java src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java src/main/java/eu/siacs/conversations/generator/IqGenerator.java src/main/java/eu/siacs/conversations/generator/MessageGenerator.java src/main/java/eu/siacs/conversations/generator/PresenceGenerator.java src/main/java/eu/siacs/conversations/http/HttpConnectionManager.java src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java src/main/java/eu/siacs/conversations/http/HttpUploadConnection.java src/main/java/eu/siacs/conversations/parser/AbstractParser.java src/main/java/eu/siacs/conversations/parser/IqParser.java src/main/java/eu/siacs/conversations/parser/MessageParser.java src/main/java/eu/siacs/conversations/parser/PresenceParser.java src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java src/main/java/eu/siacs/conversations/persistance/FileBackend.java src/main/java/eu/siacs/conversations/services/AbstractConnectionManager.java src/main/java/eu/siacs/conversations/services/AvatarService.java src/main/java/eu/siacs/conversations/services/MessageArchiveService.java src/main/java/eu/siacs/conversations/services/NotificationService.java src/main/java/eu/siacs/conversations/services/XmppConnectionService.java src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java src/main/java/eu/siacs/conversations/ui/ConversationActivity.java src/main/java/eu/siacs/conversations/ui/ConversationFragment.java src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java src/main/java/eu/siacs/conversations/ui/ManageAccountActivity.java src/main/java/eu/siacs/conversations/ui/PublishProfilePictureActivity.java src/main/java/eu/siacs/conversations/ui/SettingsActivity.java src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java src/main/java/eu/siacs/conversations/ui/XmppActivity.java src/main/java/eu/siacs/conversations/ui/adapter/AccountAdapter.java src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java src/main/java/eu/siacs/conversations/ui/adapter/ListItemAdapter.java src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java src/main/java/eu/siacs/conversations/utils/CryptoHelper.java src/main/java/eu/siacs/conversations/utils/DNSHelper.java src/main/java/eu/siacs/conversations/utils/ExceptionHelper.java src/main/java/eu/siacs/conversations/utils/MimeUtils.java src/main/java/eu/siacs/conversations/utils/PhoneHelper.java src/main/java/eu/siacs/conversations/utils/UIHelper.java src/main/java/eu/siacs/conversations/utils/Xmlns.java src/main/java/eu/siacs/conversations/xml/XmlReader.java src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java src/main/java/eu/siacs/conversations/xmpp/jingle/JingleInbandTransport.java src/main/java/eu/siacs/conversations/xmpp/jingle/JingleSocks5Transport.java src/main/java/eu/siacs/conversations/xmpp/stanzas/MessagePacket.java src/main/res/drawable-hdpi/ic_launcher.png src/main/res/drawable-hdpi/ic_notification.png src/main/res/drawable-mdpi/ic_launcher.png src/main/res/drawable-mdpi/ic_notification.png src/main/res/drawable-xhdpi/ic_launcher.png src/main/res/drawable-xhdpi/ic_notification.png src/main/res/drawable-xxhdpi/ic_launcher.png src/main/res/drawable-xxhdpi/ic_notification.png src/main/res/drawable-xxxhdpi/ic_launcher.png src/main/res/drawable-xxxhdpi/ic_notification.png src/main/res/layout/account_row.xml src/main/res/layout/activity_about.xml src/main/res/layout/activity_change_password.xml src/main/res/layout/activity_contact_details.xml src/main/res/layout/activity_edit_account.xml src/main/res/layout/activity_muc_details.xml src/main/res/layout/activity_publish_profile_picture.xml src/main/res/layout/activity_verify_otr.xml src/main/res/layout/contact.xml src/main/res/layout/contact_key.xml src/main/res/layout/conversation_list_row.xml src/main/res/layout/enter_jid_dialog.xml src/main/res/layout/fragment_conversation.xml src/main/res/layout/join_conference_dialog.xml src/main/res/layout/message_received.xml src/main/res/layout/message_sent.xml src/main/res/layout/message_status.xml src/main/res/layout/quickedit.xml src/main/res/values-ar-rEG/strings.xml src/main/res/values-bg/strings.xml src/main/res/values-ca/strings.xml src/main/res/values-cs/strings.xml src/main/res/values-de/strings.xml src/main/res/values-el/strings.xml src/main/res/values-es/strings.xml src/main/res/values-eu/strings.xml src/main/res/values-fa-rIR/strings.xml src/main/res/values-fr/strings.xml src/main/res/values-id/strings.xml src/main/res/values-it/strings.xml src/main/res/values-iw/strings.xml src/main/res/values-ja/strings.xml src/main/res/values-ko/strings.xml src/main/res/values-nl/strings.xml src/main/res/values-pl/strings.xml src/main/res/values-pt/strings.xml src/main/res/values-ru/strings.xml src/main/res/values-sk/strings.xml src/main/res/values-sr/strings.xml src/main/res/values-sv/strings.xml src/main/res/values-v21/themes.xml src/main/res/values-zh-rCN/strings.xml src/main/res/values/arrays.xml src/main/res/values/colors.xml src/main/res/values/dimens.xml src/main/res/values/strings.xml src/main/res/values/themes.xml src/main/res/xml/preferences.xml
Diffstat (limited to 'art/render.rb')
-rwxr-xr-xart/render.rb138
1 files changed, 110 insertions, 28 deletions
diff --git a/art/render.rb b/art/render.rb
index 23548d94..b4f84769 100755
--- a/art/render.rb
+++ b/art/render.rb
@@ -1,47 +1,129 @@
#!/bin/env ruby
-resolutions={
- 'mdpi'=> 1,
+
+require 'xml'
+
+resolutions = {
+ 'mdpi' => 1,
'hdpi' => 1.5,
'xhdpi' => 2,
'xxhdpi' => 3,
'xxxhdpi' => 4,
}
+
images = {
- #'conversations_baloon.svg' => ['ic_launcher', 48],
- 'conversations_plus_baloons.svg' => ['ic_launcher', 48],
+ 'conversations_baloon.svg' => ['ic_launcher', 48],
'conversations_mono.svg' => ['ic_notification', 24],
'ic_received_indicator.svg' => ['ic_received_indicator', 12],
'ic_send_text_offline.svg' => ['ic_send_text_offline', 36],
'ic_send_text_online.svg' => ['ic_send_text_online', 36],
'ic_send_text_away.svg' => ['ic_send_text_away', 36],
'ic_send_text_dnd.svg' => ['ic_send_text_dnd', 36],
- 'ic_send_photo_online.svg' => ['ic_send_photo_online', 36],
- 'ic_send_photo_offline.svg' => ['ic_send_photo_offline', 36],
- 'ic_send_photo_away.svg' => ['ic_send_photo_away', 36],
- 'ic_send_photo_dnd.svg' => ['ic_send_photo_dnd', 36],
+ 'ic_send_photo_online.svg' => ['ic_send_photo_online', 36],
+ 'ic_send_photo_offline.svg' => ['ic_send_photo_offline', 36],
+ 'ic_send_photo_away.svg' => ['ic_send_photo_away', 36],
+ 'ic_send_photo_dnd.svg' => ['ic_send_photo_dnd', 36],
'ic_send_location_online.svg' => ['ic_send_location_online', 36],
- 'ic_send_location_offline.svg' => ['ic_send_location_offline', 36],
- 'ic_send_location_away.svg' => ['ic_send_location_away', 36],
- 'ic_send_location_dnd.svg' => ['ic_send_location_dnd', 36],
+ 'ic_send_location_offline.svg' => ['ic_send_location_offline', 36],
+ 'ic_send_location_away.svg' => ['ic_send_location_away', 36],
+ 'ic_send_location_dnd.svg' => ['ic_send_location_dnd', 36],
'ic_send_voice_online.svg' => ['ic_send_voice_online', 36],
- 'ic_send_voice_offline.svg' => ['ic_send_voice_offline', 36],
- 'ic_send_voice_away.svg' => ['ic_send_voice_away', 36],
- 'ic_send_voice_dnd.svg' => ['ic_send_voice_dnd', 36],
+ 'ic_send_voice_offline.svg' => ['ic_send_voice_offline', 36],
+ 'ic_send_voice_away.svg' => ['ic_send_voice_away', 36],
+ 'ic_send_voice_dnd.svg' => ['ic_send_voice_dnd', 36],
'ic_send_cancel_online.svg' => ['ic_send_cancel_online', 36],
- 'ic_send_cancel_offline.svg' => ['ic_send_cancel_offline', 36],
- 'ic_send_cancel_away.svg' => ['ic_send_cancel_away', 36],
- 'ic_send_cancel_dnd.svg' => ['ic_send_cancel_dnd', 36],
- 'ic_send_picture_online.svg' => ['ic_send_picture_online', 36],
- 'ic_send_picture_offline.svg' => ['ic_send_picture_offline', 36],
- 'ic_send_picture_away.svg' => ['ic_send_picture_away', 36],
- 'ic_send_picture_dnd.svg' => ['ic_send_picture_dnd', 36]
+ 'ic_send_cancel_offline.svg' => ['ic_send_cancel_offline', 36],
+ 'ic_send_cancel_away.svg' => ['ic_send_cancel_away', 36],
+ 'ic_send_cancel_dnd.svg' => ['ic_send_cancel_dnd', 36],
+ 'ic_send_picture_online.svg' => ['ic_send_picture_online', 36],
+ 'ic_send_picture_offline.svg' => ['ic_send_picture_offline', 36],
+ 'ic_send_picture_away.svg' => ['ic_send_picture_away', 36],
+ 'ic_send_picture_dnd.svg' => ['ic_send_picture_dnd', 36],
+ 'md_switch_thumb_disable.svg' => ['switch_thumb_disable', 48],
+ 'md_switch_thumb_off_normal.svg' => ['switch_thumb_off_normal', 48],
+ 'md_switch_thumb_off_pressed.svg' => ['switch_thumb_off_pressed', 48],
+ 'md_switch_thumb_on_normal.svg' => ['switch_thumb_on_normal', 48],
+ 'md_switch_thumb_on_pressed.svg' => ['switch_thumb_on_pressed', 48],
+ 'message_bubble_received.svg' => ['message_bubble_received.9', 0],
+ 'message_bubble_received_warning.svg' => ['message_bubble_received_warning.9', 0],
+ 'message_bubble_received_white.svg' => ['message_bubble_received_white.9', 0],
+ 'message_bubble_sent.svg' => ['message_bubble_sent.9', 0],
}
-images.each do |source, result|
- resolutions.each do |name, factor|
- size = factor * result[1]
- path = "../src/main/res/drawable-#{name}/#{result[0]}.png"
- cmd = "inkscape -e #{path} -C -h #{size} -w #{size} #{source}"
- puts cmd
- system cmd
+
+# Executable paths for Mac OSX
+# "/Applications/Inkscape.app/Contents/Resources/bin/inkscape"
+
+inkscape = "inkscape"
+imagemagick = "convert"
+
+def execute_cmd(cmd)
+ puts cmd
+ system cmd
+end
+
+images.each do |source_filename, settings|
+ svg_content = File.read(source_filename)
+
+ svg = XML::Document.string(svg_content)
+ base_width = svg.root["width"].to_i
+ base_height = svg.root["height"].to_i
+
+ guides = svg.find(".//sodipodi:guide")
+
+ resolutions.each do |resolution, factor|
+ output_filename, base_size = settings
+
+ if base_size > 0
+ width = factor * base_size
+ height = factor * base_size
+ else
+ width = factor * base_width
+ height = factor * base_height
+ end
+
+ path = "../src/main/res/drawable-#{resolution}/#{output_filename}.png"
+ execute_cmd "#{inkscape} -f #{source_filename} -z -C -w #{width} -h #{height} -e #{path}"
+
+ top = []
+ right = []
+ bottom = []
+ left = []
+
+ guides.each do |guide|
+ orientation = guide["orientation"]
+ x, y = guide["position"].split(",")
+ x, y = x.to_i, y.to_i
+
+ if orientation == "1,0" and y == base_height
+ top.push(x * factor)
+ end
+
+ if orientation == "0,1" and x == base_width
+ right.push((base_height - y) * factor)
+ end
+
+ if orientation == "1,0" and y == 0
+ bottom.push(x * factor)
+ end
+
+ if orientation == "0,1" and x == 0
+ left.push((base_height - y) * factor)
+ end
+ end
+
+ next if top.length != 2
+ next if right.length != 2
+ next if bottom.length != 2
+ next if left.length != 2
+
+ execute_cmd "#{imagemagick} -background none PNG32:#{path} -gravity center -extent #{width+2}x#{height+2} PNG32:#{path}"
+
+ draw_format = "-draw \"rectangle %d,%d %d,%d\""
+ top_line = draw_format % [top.min + 1, 0, top.max, 0]
+ right_line = draw_format % [width + 1, right.min + 1, width + 1, right.max]
+ bottom_line = draw_format % [bottom.min + 1, height + 1, bottom.max, height + 1]
+ left_line = draw_format % [0, left.min + 1, 0, left.max]
+ draws = "#{top_line} #{right_line} #{bottom_line} #{left_line}"
+
+ execute_cmd "#{imagemagick} -background none PNG32:#{path} -fill black -stroke none #{draws} PNG32:#{path}"
end
end