2014-06-24 01:35:43 +02:00
|
|
|
#!/bin/env ruby
|
2015-07-19 14:26:03 +02:00
|
|
|
|
|
|
|
require 'xml'
|
|
|
|
|
|
|
|
resolutions = {
|
|
|
|
'mdpi' => 1,
|
2014-10-15 15:19:32 +02:00
|
|
|
'hdpi' => 1.5,
|
|
|
|
'xhdpi' => 2,
|
|
|
|
'xxhdpi' => 3,
|
2015-01-22 05:00:35 +01:00
|
|
|
'xxxhdpi' => 4,
|
2014-10-15 15:19:32 +02:00
|
|
|
}
|
2015-07-19 14:26:03 +02:00
|
|
|
|
2014-10-15 15:19:32 +02:00
|
|
|
images = {
|
2016-06-28 08:00:04 +02:00
|
|
|
'ic_launcher.svg' => ['ic_launcher', 48],
|
|
|
|
'main_logo.svg' => ['main_logo', 200],
|
2016-07-11 21:24:33 +02:00
|
|
|
'play_video.svg' => ['play_video', 96],
|
2014-10-15 15:19:32 +02:00
|
|
|
'conversations_mono.svg' => ['ic_notification', 24],
|
|
|
|
'ic_received_indicator.svg' => ['ic_received_indicator', 12],
|
2015-05-02 11:38:56 +02:00
|
|
|
'ic_send_text_offline.svg' => ['ic_send_text_offline', 36],
|
Dark theme, theme switch, icons, style, strings
added some white icons,
changed hardcoded icons to theme attributes,
changed icon_edit_dark to icon_edit_body to reflect icons position,
grey message bubbles in dark theme,
misc
purged ic_action_chat as it wasn't used
preference use_white_background changed to use_green_background, default true
grey chat bubbles darker, text white
replaced all grey600 with black icons and 0.54 alpha attribute
highlightColor in dark grey chat bubble now darker than background
2016-05-12 20:00:18 +02:00
|
|
|
'ic_send_text_offline_white.svg' => ['ic_send_text_offline_white', 36],
|
2015-05-02 11:38:56 +02:00
|
|
|
'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],
|
2015-07-19 14:26:03 +02:00
|
|
|
'ic_send_photo_online.svg' => ['ic_send_photo_online', 36],
|
|
|
|
'ic_send_photo_offline.svg' => ['ic_send_photo_offline', 36],
|
Dark theme, theme switch, icons, style, strings
added some white icons,
changed hardcoded icons to theme attributes,
changed icon_edit_dark to icon_edit_body to reflect icons position,
grey message bubbles in dark theme,
misc
purged ic_action_chat as it wasn't used
preference use_white_background changed to use_green_background, default true
grey chat bubbles darker, text white
replaced all grey600 with black icons and 0.54 alpha attribute
highlightColor in dark grey chat bubble now darker than background
2016-05-12 20:00:18 +02:00
|
|
|
'ic_send_photo_offline_white.svg' => ['ic_send_photo_offline_white', 36],
|
2015-07-19 14:26:03 +02:00
|
|
|
'ic_send_photo_away.svg' => ['ic_send_photo_away', 36],
|
|
|
|
'ic_send_photo_dnd.svg' => ['ic_send_photo_dnd', 36],
|
2015-05-02 11:38:56 +02:00
|
|
|
'ic_send_location_online.svg' => ['ic_send_location_online', 36],
|
2015-07-19 14:26:03 +02:00
|
|
|
'ic_send_location_offline.svg' => ['ic_send_location_offline', 36],
|
Dark theme, theme switch, icons, style, strings
added some white icons,
changed hardcoded icons to theme attributes,
changed icon_edit_dark to icon_edit_body to reflect icons position,
grey message bubbles in dark theme,
misc
purged ic_action_chat as it wasn't used
preference use_white_background changed to use_green_background, default true
grey chat bubbles darker, text white
replaced all grey600 with black icons and 0.54 alpha attribute
highlightColor in dark grey chat bubble now darker than background
2016-05-12 20:00:18 +02:00
|
|
|
'ic_send_location_offline_white.svg' => ['ic_send_location_offline_white', 36],
|
2015-07-19 14:26:03 +02:00
|
|
|
'ic_send_location_away.svg' => ['ic_send_location_away', 36],
|
|
|
|
'ic_send_location_dnd.svg' => ['ic_send_location_dnd', 36],
|
2015-05-02 11:38:56 +02:00
|
|
|
'ic_send_voice_online.svg' => ['ic_send_voice_online', 36],
|
2015-07-19 14:26:03 +02:00
|
|
|
'ic_send_voice_offline.svg' => ['ic_send_voice_offline', 36],
|
Dark theme, theme switch, icons, style, strings
added some white icons,
changed hardcoded icons to theme attributes,
changed icon_edit_dark to icon_edit_body to reflect icons position,
grey message bubbles in dark theme,
misc
purged ic_action_chat as it wasn't used
preference use_white_background changed to use_green_background, default true
grey chat bubbles darker, text white
replaced all grey600 with black icons and 0.54 alpha attribute
highlightColor in dark grey chat bubble now darker than background
2016-05-12 20:00:18 +02:00
|
|
|
'ic_send_voice_offline_white.svg' => ['ic_send_voice_offline_white', 36],
|
2015-07-19 14:26:03 +02:00
|
|
|
'ic_send_voice_away.svg' => ['ic_send_voice_away', 36],
|
|
|
|
'ic_send_voice_dnd.svg' => ['ic_send_voice_dnd', 36],
|
2015-05-03 09:30:30 +02:00
|
|
|
'ic_send_cancel_online.svg' => ['ic_send_cancel_online', 36],
|
2015-07-19 14:26:03 +02:00
|
|
|
'ic_send_cancel_offline.svg' => ['ic_send_cancel_offline', 36],
|
Dark theme, theme switch, icons, style, strings
added some white icons,
changed hardcoded icons to theme attributes,
changed icon_edit_dark to icon_edit_body to reflect icons position,
grey message bubbles in dark theme,
misc
purged ic_action_chat as it wasn't used
preference use_white_background changed to use_green_background, default true
grey chat bubbles darker, text white
replaced all grey600 with black icons and 0.54 alpha attribute
highlightColor in dark grey chat bubble now darker than background
2016-05-12 20:00:18 +02:00
|
|
|
'ic_send_cancel_offline_white.svg' => ['ic_send_cancel_offline_white', 36],
|
2015-07-19 14:26:03 +02:00
|
|
|
'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],
|
Dark theme, theme switch, icons, style, strings
added some white icons,
changed hardcoded icons to theme attributes,
changed icon_edit_dark to icon_edit_body to reflect icons position,
grey message bubbles in dark theme,
misc
purged ic_action_chat as it wasn't used
preference use_white_background changed to use_green_background, default true
grey chat bubbles darker, text white
replaced all grey600 with black icons and 0.54 alpha attribute
highlightColor in dark grey chat bubble now darker than background
2016-05-12 20:00:18 +02:00
|
|
|
'ic_send_picture_offline_white.svg' => ['ic_send_picture_offline_white', 36],
|
2015-07-19 14:26:03 +02:00
|
|
|
'ic_send_picture_away.svg' => ['ic_send_picture_away', 36],
|
|
|
|
'ic_send_picture_dnd.svg' => ['ic_send_picture_dnd', 36],
|
Dark theme, theme switch, icons, style, strings
added some white icons,
changed hardcoded icons to theme attributes,
changed icon_edit_dark to icon_edit_body to reflect icons position,
grey message bubbles in dark theme,
misc
purged ic_action_chat as it wasn't used
preference use_white_background changed to use_green_background, default true
grey chat bubbles darker, text white
replaced all grey600 with black icons and 0.54 alpha attribute
highlightColor in dark grey chat bubble now darker than background
2016-05-12 20:00:18 +02:00
|
|
|
'ic_notifications_none_white80.svg' => ['ic_notifications_none_white80', 24],
|
|
|
|
'ic_notifications_off_white80.svg' => ['ic_notifications_off_white80', 24],
|
|
|
|
'ic_notifications_paused_white80.svg' => ['ic_notifications_paused_white80', 24],
|
|
|
|
'ic_notifications_white80.svg' => ['ic_notifications_white80', 24],
|
2015-07-18 19:38:52 +02:00
|
|
|
'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],
|
2015-07-19 14:26:03 +02:00
|
|
|
'message_bubble_received.svg' => ['message_bubble_received.9', 0],
|
Dark theme, theme switch, icons, style, strings
added some white icons,
changed hardcoded icons to theme attributes,
changed icon_edit_dark to icon_edit_body to reflect icons position,
grey message bubbles in dark theme,
misc
purged ic_action_chat as it wasn't used
preference use_white_background changed to use_green_background, default true
grey chat bubbles darker, text white
replaced all grey600 with black icons and 0.54 alpha attribute
highlightColor in dark grey chat bubble now darker than background
2016-05-12 20:00:18 +02:00
|
|
|
'message_bubble_received_grey.svg' => ['message_bubble_received_grey.9', 0],
|
2016-06-10 22:39:02 +02:00
|
|
|
'message_bubble_received_dark.svg' => ['message_bubble_received_dark.9', 0],
|
2015-07-29 02:01:28 +02:00
|
|
|
'message_bubble_received_warning.svg' => ['message_bubble_received_warning.9', 0],
|
2015-08-24 20:56:25 +02:00
|
|
|
'message_bubble_received_white.svg' => ['message_bubble_received_white.9', 0],
|
2015-07-19 14:26:03 +02:00
|
|
|
'message_bubble_sent.svg' => ['message_bubble_sent.9', 0],
|
Dark theme, theme switch, icons, style, strings
added some white icons,
changed hardcoded icons to theme attributes,
changed icon_edit_dark to icon_edit_body to reflect icons position,
grey message bubbles in dark theme,
misc
purged ic_action_chat as it wasn't used
preference use_white_background changed to use_green_background, default true
grey chat bubbles darker, text white
replaced all grey600 with black icons and 0.54 alpha attribute
highlightColor in dark grey chat bubble now darker than background
2016-05-12 20:00:18 +02:00
|
|
|
'message_bubble_sent_grey.svg' => ['message_bubble_sent_grey.9', 0],
|
2014-10-15 15:19:32 +02:00
|
|
|
}
|
2015-07-19 14:26:03 +02:00
|
|
|
|
|
|
|
# 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}"
|
2014-06-24 01:35:43 +02:00
|
|
|
end
|
|
|
|
end
|