diff --git a/lib/classic.rb b/lib/classic.rb index 27053713..8c1ca2d8 100755 --- a/lib/classic.rb +++ b/lib/classic.rb @@ -103,9 +103,17 @@ class Classic FileUtils.cp File.join(framework_res_dir, "layout", f), File.join(app_res_dir, "layout", f) end # icon file copy - # if it is not in the www directory use the default one in the src dir %w(drawable-hdpi drawable-ldpi drawable-mdpi).each do |e| - currentIcon = (!@icons[e.to_sym].nil? && File.exists?(File.join(@www, @icons[e.to_sym]))) ? File.join(@www, @icons[e.to_sym]) : File.join(framework_res_dir, "drawable", "icon.png") + # if specific resolution icons are specified, use those. if not, see if a general purpose icon was defined. + # finally, fall back to using the default PhoneGap one. + currentIcon = "" + if !@icons[e.to_sym].nil? && File.exists?(File.join(@www, @icons[e.to_sym])) + currentIcon = File.join(@www, @icons[e.to_sym]) + elsif File.exists?(@icon) + currentIcon = @icon + else + currentIcon = File.join(framework_res_dir, "drawable", "icon.png") + end FileUtils.mkdir_p(File.join(app_res_dir, e)) FileUtils.cp(currentIcon, File.join(app_res_dir, e, "icon.png")) end diff --git a/lib/create.rb b/lib/create.rb index fe68806c..aef3dd49 100644 --- a/lib/create.rb +++ b/lib/create.rb @@ -40,12 +40,12 @@ class Create < Classic if File.exists?(config_file) require 'rexml/document' f = File.new config_file - doc = REXML::Document.new(f) + doc = REXML::Document.new(f) @config = {} @config[:id] = doc.root.attributes["id"] @config[:version] = doc.root.attributes["version"] @config[:icons] = {} - + defaultIconSize = 0 doc.root.elements.each do |n| @config[:name] = n.text.gsub('-','').gsub(' ','') if n.name == 'name' @config[:description] = n.text if n.name == 'description' @@ -53,12 +53,24 @@ class Create < Classic if n.name == 'icon' if n.attributes["width"] == '72' && n.attributes["height"] == '72' @config[:icons]["drawable-hdpi".to_sym] = n.attributes["src"] + if 72 > defaultIconSize + @config[:icon] = n.attributes["src"] + defaultIconSize = 72 + end elsif n.attributes["width"] == '48' && n.attributes["height"] == '48' @config[:icons]["drawable-mdpi".to_sym] = n.attributes["src"] + if 48 > defaultIconSize + @config[:icon] = n.attributes["src"] + defaultIconSize = 48 + end elsif n.attributes["width"] == '36' && n.attributes["height"] == '36' @config[:icons]["drawable-ldpi".to_sym] = n.attributes["src"] + if 36 > defaultIconSize + @config[:icon] = n.attributes["src"] + defaultIconSize = 36 + end else - @config[:icon] = n.attributes["src"] + @config[:icon] = n.attributes["src"] end end