Class: Confetti::Template::AndroidManifest
- Inherits:
-
Base
- Object
- Mustache
- Base
- Confetti::Template::AndroidManifest
show all
- Includes:
- JavaChecks
- Defined in:
- lib/confetti/templates/android_manifest.rb
Constant Summary
collapse
- DEFAULT_MIN_SDK =
"7"
- GAP_PERMISSIONS_MAP =
{
"camera" => %w{CAMERA},
"notification" => %w{VIBRATE},
"geolocation" => %w{ACCESS_COARSE_LOCATION
ACCESS_FINE_LOCATION
ACCESS_LOCATION_EXTRA_COMMANDS},
"media" => %w{RECORD_AUDIO
RECORD_VIDEO
MODIFY_AUDIO_SETTINGS},
"contacts" => %w{READ_CONTACTS
WRITE_CONTACTS
GET_ACCOUNTS},
"file" => %w{WRITE_EXTERNAL_STORAGE},
"network" => %w{ACCESS_NETWORK_STATE},
"battery" => %w{BROADCAST_STICKY}
}
- ORIENTATIONS_MAP =
{
:default => "unspecified",
:landscape => "landscape",
:portrait => "portrait"
}
Constants included
from JavaChecks
JavaChecks::RESERVED_WORDS
Instance Method Summary
collapse
Methods included from JavaChecks
#convert_to_java_identifier, #convert_to_java_package_id, #is_java_identifier, #is_java_package_id, #reserved_word?
Methods inherited from Base
#initialize
Instance Method Details
#app_orientation ⇒ Object
51
52
53
|
# File 'lib/confetti/templates/android_manifest.rb', line 51
def app_orientation
ORIENTATIONS_MAP[@config.orientation]
end
|
#class_name ⇒ Object
35
36
37
|
# File 'lib/confetti/templates/android_manifest.rb', line 35
def class_name
convert_to_java_identifier(@config.name.name) if @config
end
|
#install_location ⇒ Object
72
73
74
75
76
77
|
# File 'lib/confetti/templates/android_manifest.rb', line 72
def install_location
valid_choices = %w(internalOnly auto preferExternal)
choice = @config.preference("android-installLocation").to_s
valid_choices.include?(choice) ? choice : "internalOnly"
end
|
#int_value?(val) ⇒ Boolean
93
94
95
96
97
98
|
# File 'lib/confetti/templates/android_manifest.rb', line 93
def int_value? val
return if val.nil?
integer = /^\d+$/
val.to_s.match(integer)
end
|
#max_sdk_version_attribute ⇒ Object
85
86
87
88
89
90
91
|
# File 'lib/confetti/templates/android_manifest.rb', line 85
def max_sdk_version_attribute
choice = @config.preference("android-maxSdkVersion")
if int_value?(choice)
"android:maxSdkVersion=\"#{ choice }\""
end
end
|
#min_sdk_version ⇒ Object
79
80
81
82
83
|
# File 'lib/confetti/templates/android_manifest.rb', line 79
def min_sdk_version
choice = @config.preference("android-minSdkVersion").to_s
int_value?(choice) ? choice : DEFAULT_MIN_SDK
end
|
#output_filename ⇒ Object
39
40
41
|
# File 'lib/confetti/templates/android_manifest.rb', line 39
def output_filename
"AndroidManifest.xml"
end
|
#package_name ⇒ Object
31
32
33
|
# File 'lib/confetti/templates/android_manifest.rb', line 31
def package_name
convert_to_java_package_id(@config.package)
end
|
#permissions ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/confetti/templates/android_manifest.rb', line 55
def permissions
permissions = []
phonegap_api = /http\:\/\/api.phonegap.com\/1[.]0\/(\w+)/
feature_names = @config.feature_set.map { |f| f.name }
feature_names.sort
feature_names.each do |f|
feature_name = f.match(phonegap_api)[1] if f.match(phonegap_api)
associated_permissions = GAP_PERMISSIONS_MAP[feature_name]
permissions.concat(associated_permissions) if associated_permissions
end
permissions.sort!
permissions.map { |f| { :name => f } }
end
|
#version ⇒ Object
43
44
45
|
# File 'lib/confetti/templates/android_manifest.rb', line 43
def version
@config.version_string || '0.0.1'
end
|
#version_code ⇒ Object
47
48
49
|
# File 'lib/confetti/templates/android_manifest.rb', line 47
def version_code
@config.version_code || '1'
end
|