-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provider generics interface to handle non-png icons #32
Conversation
161d70f
to
e168af5
Compare
@@ -168,3 +168,6 @@ Style/TrailingCommaInArrayLiteral: | |||
|
|||
Style/TrailingCommaInHashLiteral: | |||
Enabled: false | |||
|
|||
Style/AccessModifierDeclarations: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
end | ||
|
||
# Check whether or not this apk's icon is an adaptive icon | ||
# @return [Boolean] Return true if this apk has an *correct* adaptive icon, otherwise false. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*correct* means Technically correct.
# invalid xml file may throw an error | ||
Zip::File.open(filepath) do |zip_file| | ||
apk.adaptive_icon = zip_file.find_entry(adaptive_icon_path)&.get_input_stream do |entry| | ||
!!entry.read.include?("adaptive-icon") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this logic worked even if the xml is decoded but the result included false-positives. That's why I delegate the content look-up to aapt dump xmltree
.
@@ -16,7 +16,6 @@ Gem::Specification.new do |spec| | |||
spec.required_ruby_version = ">= 2.6.0" | |||
|
|||
spec.files = `git ls-files | grep -v 'spec/fixture'`.split($/) | |||
spec.test_files = spec.files.grep(%r{^(test|spec)/}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.verified = false | ||
self.test_only = false | ||
end | ||
|
||
# @return [Array<AndroidApk::AppIcon>] | ||
def app_icons |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will check this array from 0 to last to look up icons.
content&.split(/\n/) do |line| | ||
line.strip! | ||
|
||
if line.start_with?("E: ") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first E:
-prefixed line indicates the root element of the XML.
@root_element = nil | ||
|
||
line_num = 1 | ||
content&.split(/\n/) do |line| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tip: split
with block requires Ruby 2.6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Thank you so much~~~! |
Waiting for
Breaking changes
backward_compatible_adaptive_icon?
now returns true whenever it's configured properly.icon
,adaptive_icon,
backward_compatible_adaptive_icon`New itnerface