| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
| |
When generating actionbar icons from clipart, do not strip surrounding
space, and do not add extra padding. The clipart images already
contain baked in padding suitable for action bar icons. This CL also
makes sure the UI disables the corresponding options in this mode.
It also renames and moves to the bottom the legacy menu and tab icon
generators, and fixes a file resource leak in the image loading code.
Change-Id: I8a0dd61c97862206cdc71dc591a207a0b6a050f8
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This checkin adds typo databases for six additional languages, as well
as several fixes to the infrastructure.
First, it now supports "globbing", since for example the German typo
database contains glob patterns of the form
"asymetrisch*->asymmetrisch*".
Second, it supports multiword typos (such as "all zu->allzu") which
caused some complications (since this means that the typo detector
can match beyond the word boundary it was passed in).
Third, it adds a bunch of validation code to the type dictionaries,
which uncovered a bunch of inconsistencies (duplicate entries, using
"-" instead of "->" for some separators, etc). There's now a unit test
which produces a cleaned up version of each dictionary file, as well
as tests to ensure that the ASCII and the UTF-8 comparison methods are
in sync (and this uncovered some bugs which were fixed.)
Finally, it fixes the HTML reporter such that it properly handles
UTF-8.
Change-Id: Ie32cbbe489687a7b50184696a027f87c2e21c409
|
|
|
|
|
|
|
|
|
|
|
|
| |
Maven places the source files and class files in different locations
than our default Eclipse and ant build systems. This changeset adds
--sources and --classes arguments to the lint CLI to allow a build
script to point to these custom locations. It also also looks in
Maven's default location if it doesn't find the normal bin/classes/
folder such that out of the box it might just work even in Maven
projects.
Change-Id: Ia91b05f0fc9d2c7e504c962d2e794c768085754c
|
|
|
|
|
|
|
|
|
|
|
| |
This changeset adds in the ASM analysis library (an optional part of
the ASM package lint is already using to process bytecode). It also
adds some basic flow analysis to the SecureRandom detector to detect
whether a given dispatch to a field of type java.util.Random is
actually pointing to a java.security.SecureRandom, in which case it
flags calls on it to setSeed() where the argument is a fixed integer.
Change-Id: If85ab9f8db0e801a01f1a3ea845865b4f98e259c
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This changeset adds new two lint bytecode-based detectors.
The WakelockDetector looks for problems with wakelocks:
- Calling release() in onDestroy() rather than in onPause()
- Calling acquire() but never calling release() anywhere in the app.
The SecureRandomDetector looks for problems with the SecureRandom
random number generator:
- Calling setSeed() with a fixed number, such as a string literal,
or something equivalent (such as a static field reference of
this or some other class)
- Calling setSeed() and passing in System.nanoTime or
currentTimeMillis since these are considered predictable seeds.
These are both using the new fast-dispatch mechanism for bytecode
detectors in lint. In both cases, there are more complex control flow
we should be checking using flow analysis; that's for an upcoming CL
where we add ASM's analysis library.
Change-Id: Iec2a95b042b8a3e4e976923cc62e9dccf2dfeca5
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
ADT uses a "window coordinator" which listens for various window
related events (such as part activation, editors getting maximized
etc) to implement its various layout editor handling (to dock property
sheets within the layout editor unless it's shown in the surrounding
frame), to activate/deactivate editors for keybinding handling, etc.
This did not take into account the possibility of multiple workbench
windows getting opened. This CL adds proper support for this. The
window coordinator is no longer a singleton; there is one instance per
workbench window, and AdtStartup listens for workbench events and
creates or disposes these on demand.
Change-Id: I298d9d82c7aefd684bcb1ace3bee0267e1f94a60
|
|
|
|
| |
Change-Id: Ibc8756c2580a9e263b63b3507224acdf09f264ed
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In Eclipse 4, the system calls setFocus on the outline view *after* a
mouse click inside the outline has been processed. This ends up
calling setFocus on the treeviewer. If you clicked in the property
sheet to for example start editing a text property, this means the
focus loss will cause the property editor to abort editing again. The
net result is that you always need to click twice to start editing
properties if the Outline view does not already contain focus.
This changeset adds a workaround for this. It has two parts.
First, simply make the OutlinePage's setFocus() method do nothing if
it's called during a mouse click in the property sheet (which we can
track with a mouse listener).
The second part is trickier. The outline view itself (which is
provided by Eclipse and we have no hooks into it) will be called
first, and it calls setFocus() on its first child, which is a
composite, so it ends up searching down for the first focusable
component. The workaround is to add our own widget as the first
child, and make it declare that it's focusable but make the setFocus
call a no-op. Second, make the widget invisible since we don't want
anything but the tree viewer in the outline.
Change-Id: Ib89943c410bce599723f59a4f202f339adab6327
|
|\ |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
When ADT encounters a custom view, it creates a view descriptor for
that custom view, and in ADT 20 it also finds the associated styles
and records these as attributes, which means code completion and the
property sheet will show these properties.
However, once the descriptor has been lazily created, it never
changes. If you go and edit the styles.xml file specifying the
attributes for your custom view, you need to restart the IDE before
code completion will pick up these changes.
This changeset makes this behavior more dynamic: It will now pick up
edits to the files specifying styles for a custom view.
Change-Id: I365119e18c74378a0a039c1e7a22641c94acf002
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
| |
This changes the thumbnail handling from templates from ad-hoc
attributes to a more selector-centric system. The template can specify
one or more thumbnails along with parameter values associated with
those thumbnails. When the user edits an attribute, the wizard
reevaluates the thumbnail and picks the best match (meaning one of the
thumbnails that matches all the parameter values, and among those the
one that matches the most.)
(This changeset also moves the metadata code into a new class.)
Change-Id: Ic75d58573df5b2ea200c6b2861bbf36ce17ea1c3
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This changeset adds several new templates, to create a new project, a
new activity, a new custom view, etc.
More importantly, it contains support for these wizards (and the
corresponding code generation) to be driven by templates.
A wizard contains metadata which provides a name, description and icon
for the template, as well as a list of parameters, along with type and
constraint metadata for those parameters. When a wizard is created for
this template, it automatically adds UI elements to input the
parameters and to validate the input. Parameters can also specify
their default values as templated expressions using the other
variables on the page, so in the New Blank Activity wizard for
example, editing the activity name automatically updates the suggested
layout name, by repeatedly evaluating a template expression to compute
a layout name from an activity name.
There's a recipe file for each template which states what actions to
take to create the template. In addition to obviously copying
resources (such as icons and jar files) and instantiating templates
(to rewrite text using variables and FreeMarker logic), it can also
merge XML contents (to for example insert activity registration
metadata into the manifest file, or add string definitions to the
strings.xml file), and it can cause files to be opened when the
template is created.
Tne new wizards also use JFace's decorator support to provide help and
to mark text fields that contain errors, when one or more of the page
fields do not validate, as well as to show tip text along the bottom
of the page. One example of this is that it explains what a "package
name" is when the package field has focus.
This changeset also contains a "Template Development Wizard" which
lets you point to a local directory containing a template definition,
and run a test wizard from there. This is useful for developing,
debugging and testing templates.
Change-Id: I08e7d2464a1ef00d09517f0154c42681249a7ff6
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This changeset replaces the configuration chooser with a new UI.
First, the two lines of comboboxes have been replaced by a toolbar,
which will wrap to two lines if it cannot fit on a single
line. However, it tries hard to avoid this scenario by using icons and
brief labels. For example, the rendering target is displayed as an
Android icon along with just "4.0" instead of "Android
4.0". Similarly, the "Other" locale is just shown as a globe icon, and
for example in the Device list "4.65in 720p (Galaxy Nexus)" is display
as just "Galaxy Nexus".
Second, the "current configuration" label is now a dropdown instead.
The text of the label displays the current configuration as before
(though using the brief name, e.g. "layout-land" instead of "Landscape
Configuration". In addition, it's a dropdown, and opening the menu
will display all other available configurations for this file. Thus,
if you have a special landscape version and a special tablet version
of a particular layout, the menu will contain default, landscape and
tablet (where the menu items display the full configuration names such
as "Landscape Orientation"). In addition, the configuration menu also
contains "Create New...", which is the new location for the Create
button which used to be in the toolbar itself.
Third, there is a new "Activity" dropdown. This displays the current
activity associated with this layout, next to an Eclipse "class" icon.
It is initially populated with our best guess of what the activity
is. The chosen activity determines which theme is initially assigned
to a layout (for example when there is a Manifest registration of a
theme to an activity). In the future we will use this facility to
drive other features as well, such as preview rendering the action bar
(where we need to know the associated activity) or assisting with
creating click handlers. The Activity dropdown menu also contains a
"Open <Activity class>..." action for jumping to the associated Java
code. The chosen activity is persisted as an XML attribute in the
layout so it should be preserved across IDE sessions and shared among
developers.
Fourth, all the dropdown menus are now native SWT menus rather than
dropdown menus, which means we can use icons, proper separators, and
nesting. The locale menu now shows flag icons next to each region (and
when a locale is chosen the corresponding icon is shown in the
configuration toolbar). In the Theme menu we no longer need to use
"-------" ASCII separators, we can use proper native menu separators
instead. And the Theme menu is now nested; rather than a really long
list of options, the menu is grouped into related sections:
* Currently selected theme
* Project Themes >
* Manifest Themes >
* Holo Themes >
* Holo.Light Themes >
* DeviceDefault Themes >
...
* All >
* Open "<current theme>" Declaration...
Fifth, the device configuration combobox has been replaced by three
inline icon radiobuttons, showing portrait, landscape and (if enabled)
square. This makes it easy to switch orientation through a single
click.
Sixth, the UI mode (Normal/Car/Dock) and Night mode (Day/Night) are no
longer directly shown in the configuration chooser since they are not
used frequently enough to warrant persistent space in the always
visible toolbar. Instead, there is an "Edit Configuration" icon on the
left you can click which brings up a full editor dialog where all the
previous combo boxes appear, along with the generic configuration
qualifier selection dialog. Here you can make more specific edits to
the current configuration state.
There are various fixes as well. For example the whole toolbar is
hidden during platform data loading and made visible at the end. When
creating a new configuration file, that new configuration file is
opened after creation. We now track whether the current theme (stored
in the IDE persistent property) is a project theme or a framework theme.
Change-Id: Ic8d9817c7bc4dbcae4535b6b9222393fb49cfde9
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This changeset improves the way the layout editor handles windows. In
particular, it attempts to make the property sheet and the outline
more visible.
Specifically:
* It adds the WindowBuilder docking support, which offers several
new features:
(1) You can collapse and expand the palette and structure views. If
you hover over a collapsed palette (for example) it temporarily
opens, and when you drag from it over to the canvas it collapses
again.
(2) The initial size is pixel based rather than percentage based, so
the default palette size is more reasonable on large displays
(it used to always take 20%, which was fine on a small screen
but a waste on larger screens).
(3) You can drag & drop to reconfigure the layout a bit. (This is
fairly limited though; in particular, you cannot drag these
views out of the editor area and mix them with Eclipse views.)
* When the property sheet view is not shown anywhere else, it is shown
as part of the outline instead (sharing the vertical space). This
works better for the new property sheet implementation since it
works better as a vertical window than a horizontal window.
* When the outline is not shown anywhere else, it is shown in a new
composite window *inside* the editor area. This mode is also entered
when you temporarily maximize the layout editor window.
* The layout canvas is auto-fit-zoomed when you enter and exit
maximized mode, as well as when you open or close docked windows
within the editor.
The goal is for these changes to offer a good layout editing
experience with the outline views and property sheets *without* using
a new perspective for layout editing. Note that this is not identical
to what WindowBuilder does; they always embed both the palette and the
structure views within the editor area, which means the structure view
is typically redundant with the outline view on the right unless you
maximize the view. With the approach above hopefully we'll avoid that
case and you'll always see the views without redundancy (and therefore
with more available space for the layouts).
Change-Id: I0d338b2781b9732e992f088fcc4e1ba46ff0954f
|
|
|
|
|
|
| |
This reverts commit 27dac06bfc4297dc9a018edc534f44ecf96cd724.
Change-Id: I6708bd4091f0cb677484669479357d479b9db5fa
|
|
|
|
| |
This reverts commit a7621238bf0202419677380ee3a268142358df83.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The WindowBuilder propertysheet has been extracted and added as a
library in external/eclipse-windowbuilder/.
This changeset removes the old propertysheet code (which used the
builtin Eclipse property sheet page), and replaces it with the
WindowBuilder one, along with new code to aggregate the properties
into some categories, as well as tagging some of the properties as
advanced. (This was computed by running the same analysis scripts used
to produce the most-frequent attributes (sdk/attribute_stats) and
instead computing which attributes are used very infrequently or not
at all in some representative sample code.)
The WindowBuilder propertysheet gives us the following new features:
- Highlighting (bold) of important attributes
- Masking (and when included, shown in gray italic) of advanced
attributes
- "Complex" attributes with nesting, used to for example aggregate all
the layout parameters into a single node, and the margin layout
attributes within those
- Tooltips over the attribute names, not values, so they never obscure
content
In addition, this changeset adds custom implementations of properties,
property editors and property dialogs for the core Android property
types (XML strings, flags and booleans), which adds the following new
features:
- Preview rendering of color and image resources inline
- Display of -default- attributes (those not specified in XML) using
the layoutlib facility getDefaultProperties() to render the implied
attributes. For example, if you look at a Button, it will show you
that the implied value of "Text Color Link" is
"@android:color/holo_blue_light" even though it is not set.
NOTE: This only happens for attributes that were actually queried by
the widget during rendering. Attributes that are not used by the
widget have no (displayed) value. Thus, EditText-specific attributes
in a TextView are not shown when a non-EditText TextView is
selected.
- Evaluation of the attributes. In the above example, in addition to
showing @android:color/holo_blue_light, it will chase down the value
of this to for example render a blue square next to the value. For
drawables it will render a thumbnail, and for String resources it
will display the actual value in parentheses.
- Field completion in text fields, completing all resource strings
(@string, @android:string, etc), as well as flag values. Enum values
are chosen in a dropdown.
- Checkbox support for boolean values, allowing you to click through
the three values true, false and null.
- Our custom version of the Property Sheet Page allows you to
expand/collapse all properties, and it also has an option letting
you switch between Alphabetical Sort (where all attributes are in a
flat table, sorted alphabetically by property value), or
hierarchical sorted "by category". Currently the categories are
simply the defining views, plus 2 more (layout parameters and
deprecated attributes). When we get more metadata, it would be nice
to switch these to more logical categories, such as "text",
"scrolling", "focus", etc. (There is some preliminary support for
this in the code, but since the defining-view categories seem to
work better those are used instead right now.)
Change-Id: Ie4959a3a2c36c083dcc1ba19a70f24b33739fe2f
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The FrameworkResources method which loads in the public resources
takes about ~500ms of the target loading time.
This changeset optimizes this down to < 50ms using the following
three optimizations:
1) Precompute a map from names to ResourceItems before processing the
public names. Before this, it would search sequentially through the
name list, which when done n times meant O(n^2); we can construct
the map in O(n) and then perform n lookups in O(1) => O(n).
Also, be smart about which maps we precompute names for: the
ResourceType.PUBLIC and ResourceType.DECLARE_STYLEABLE types have
about 2,000 items, none of which are public, so skip precomputing
maps for these two. (However, keep the linear search around such
that if any are exported in the future the code will work
correctly.
Similarly, we know "roughly" the size of the final public maps, so
initialize them in the right size range such that they don't have
to do any internal resize+copy operations as we insert into them.
2) In android-15 there are 1500 new <java-symbol> elements in the
public xml file, which were being processed, doubling the number of
exported symbols. Limit the processing to only the <public> tags.
3) Switch from DOM parsing to pull parsing. This helps since more than
half the file consists of <java-symbol> elements, and we can ignore
whitespace and id attributes etc, so there is much less object
creation involved.
Change-Id: I4761e1182b9bc0c50fe94aea7dcd9690754c7908
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This changeset adds support for the android support library's
GridLayout library project.
When you create a new layout with the GridLayout, or when you drop a
GridLayout, the IDE checks whether you need the compatibility version
of GridLayout (e.g. min sdk < 14), and if so, offers to install it.
This will then first run the SDK manager to install the android
support package into extras, and then it creates a local library
project in the Eclipse workspace, and updates the library dependency
to reference it.
Finally, it rewrites tags such that the layout will use the
compatibility package for the <GridLayout> and <Space> tags. This is
done in the node handler, so client rule code will automatically get
the right compatibility tag; they don't need to handle it there.
Change-Id: I6da926eee7ffa956832ddd311d4180e8ff38ae07
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The string format lint check might be processing strings not intended
for String.format (but intended for example for
android.text.format.Time#format), in which case it will be wrong about
whether two conversions are incompatible. (This does not fix all
scenarios; if a date string looks like a String.format in the sense
that all of its formatting characters are defined by String.format
then the string will assume to be intended for String.format.)
This changeset attempts to recognize this, and also make the "is
incompatible" check a bit more nuanced: it will now consider "d"
compatible with "x" for example.
Change-Id: I63ce082f40169e4033809d25cae3cf116c9e2044
|
|
|
|
|
|
|
|
|
|
|
| |
This changeset makes various improvements to the Lint error report:
the styles are now in a separate stylesheet, and the default style is
Holo-like. Paths are handled better when linting multiple projects
such that the report title includes the root-relative project path,
and all filenames are then relative to the project root. The table of
contents is now a table, and includes error and warning icons.
Change-Id: I4e49f7b226bfa4d7b46e3a29e006fe78a504e9ef
|
|
|
|
|
|
|
| |
This changeset adds support for suppressing lint warnings by
annotatating variable declarations, fields, methods and classes.
Change-Id: If274d65bccdc5c7d6426566c635245d6b3aae147
|
|
|
|
|
|
|
|
|
|
|
| |
If lint writes out multiple HTML reports (e.g. when specifying a directory to the --html flag), and
there are more projects than just one, write an overview doc which contains a table of all the
projects and the corresponding error and warning counts in decreasing order, with links to
the individual reports.
Also ensure that there are no case-insensitive filename clashes.
Change-Id: I4dcda14a625863e71022734088a027fc8ac357d0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This changeset adds several new Java parsetree-based lint detectors:
(1) String format checker. This checks several issues related to
formatting strings (%1$s), such as
- Is the string format valid?
- Is the string format consistent between different translations,
e.g. if argument #1 is of type "s" in locale A, is it also of
type "s" in locale B?
- Is the string format being called from Java with arguments of
the right type?
- Are strings which are not supposed to be formatted (e.g. ends
with a %) passed to String.format?
(2) View Cast checker. Looks at the views associated with specific
id's in layouts, and makes sure that any casts to views returned
by findViewById in Java is cast-compatible with the type in the
layout. For example, if you have a layout containing a <Button
id="foo">, then a cast to an EditText of findViewById(R.id.foo)
would be invalid.
(3) A security check which flags file creation calls that pass a
context of world-writeable.
(4) An "import android.R" checker. This looks for "import android.R"
in .java files and warns that this is potentially confusing.
(5) A hardcoded "/sdcard" string checker which looks for this prefix
in string literals and when found warns that the method
Environment.getExternalStorageDirectory().getPath() should be
used instead.
Change-Id: I14a4656f0ff6a58f25cde1b4bb23f6c47c47fdba
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This changeset makes a bunch of changes to the Lint Window
in Eclipse:
* First, it changes the view from a flat table into a hierarchical
tree. For any given type of error, there is one top level tree
node, and its children are the remaining occurrences of the same
error.
This makes it much easier to quickly skim through the different
issues without having to scroll; if you see an error you want to
fix, you can expand the node to jump to all the various occurrences.
The top level labels also include a count in the form of "(2 items)"
after the error message so you can get a sense of how many warnings
were found for each type.
* Second, it adds a bunch of new actions to the Lint View toolbar:
expand, collapse, configure (more on that later), settings, and
ignore file and ignore project (ignore global was already there).
It also updates the icons for some of the existing actions; the lint
toolbar action and window should look a bit better now.
* Third, it adds more columns (such as priority and category) to the
lint view, and makes the set of visible columns configurable. You
can click on the Configure toolbar action to bring up a dialog to
show which columns are included, and this selection is persisted
across IDE sessions (and it also persists the column sizes).
Furthermore, instead of separate file, path and line number columns,
there is now a new "Location" column, which is shown by default
instead of the separate file, path and line number columns. This
column displays combined info for all three: the file name, the line
number, the parent folder and the project name. This includes all
the relevant information in a more compact format such that there is
more room for the error message.
* Fourth, the table now supports sorting: you can click on any column
header, and the table will be sorted using that column as a
key. (This is not alphabetical but a logical sort defined for each
column; for line number and priority it's obviously numerical, but
for the default column it continues to be a combination of severity,
priority, issue type etc.)
Change-Id: I42695988780b493ad90aff5aeb5895e0fd8d3998
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This changeset adds support for library projects to lint. Lint now
checks all the library projects for errors as well, and projects that
depend on global analysis (such as the unused resource detector) will
properly handle resource declarations and references across projects.
This changeset also cleans up the multi-project handling for the Lint
window in Eclipse. The "Run Lint" toolbar action, in addition to
operating on multiple selection, now has a dropdown menu for choosing
which projects to check (and there are also actions for checking all
projects, the current file, and clearing markers). Running lint on a
project will also automatically include dependent library projects.
Finally, some misc UI improvements: The Lint preference dialog
includes buttons for quickly enabling and disabling all the checks;
the Lint View includes a Project column which is shown when more than
one project is checked, and the file and linenumber columns are now
blank when the location does not correspond to a specific file.
Change-Id: I733f5258102dfb0aebbc2b75cb02b9ba6ef974e8
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The XML DOM parser used by the lint CLI driver (which tracks
positions) is needed outside of lint, so pull it out of the lint/cli
project, and refactor it such that it does not directly reference the
lint Position APIs (but can utilize them when subclassed in lint).
In addition, handle non-UTF-8 file encodings. XML files can be encoded
in other character sets, and can specify this via the encoding
attribute in the XML prologue. Until now, the CLI lint runner would
just read the XML file contents in using the default encoding and
parse this. Now there's a new utility method which takes a byte[] and
infers the desired encoding and uses that to convert the byte[] into a
string using the correct encoding. (We can't just pass an InputStream
and let the SAX parser handle this on its own because the XML parser
needs to access the character stream in order to assign correct node
offsets.) This code now also handles the byte order mark more
cleanly.
There are some new unit tests too to check the new encoding, BOM and
offset handling.
Change-Id: Ib0badbbe72172e3408c6d5af2413be51280a7724
|
|
|
|
| |
Change-Id: Ifcc1d88dabb07dc05b2e5c934743ad52f9b6dc1d
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This changeset fixes a bunch of issues in the infrastructure:
(1) It cleans up the Context class quite a bit. It had some hardcoded
XML stuff in it, which is now in a separate XmlContext class (and
there will be a JavaContext class in the Java support CL).
It also hides a bunch of public fields, cleans up some unused
stuff, and introduces a couple of wrapper methods to make detector
code cleaner; in particular, rather than calling
context.client.report(context, ...
you can now just call
context.report(...
and similarly there are wrappers for logging and checking for
disabled issues.
(2) The IParser interface is renamed to IDomParser since in the next
CL there will also be an IJavaParser. Some other related cleanup.
(3) There is now a "Location.Handle" interface. This allows detectors
to create light-weight location holders, and later on call
handle.resolve() to create a full-fledged Location. This is useful
when detectors don't yet know whether they'll need a location for
a node, but want to store it for later in case they do. As an
example, the unused resource detector creates location handles for
declaration and only resolves full locations for those that are
found to be unused.
Locations can now carry custom messages. For example, for a
duplicate id error, the secondary location now contains a
"original declaration here" message. And the CLI and HTML reports
now include alternate locations in the output.
Some other location cleanup too; using factory methods to make the
code cleaner, some default implementations that can be shared,
etc.
(4) There's a new SDK info class intended to provide SDK information
from a tool client (such as resource resolution). It currently
just contains parent-view information, used for the
ObsoleteLayoutParams detector and an upcoming CL for a
ViewTypeDetector.
(5) The Detector class now provides dummy implementations for the
inner-interfaces, so we no longer need the adapter classes. This
makes it easy to implement the XmlScanner or JavaScanner
interfaces without needing to also stub out a bunch of methods.
Change-Id: I4b3aaabe51febb25b000f9086703653bea6cf7c9
|
|\ |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This changeset adds a new typography detector. This looks at the
strings defined by the application and makes various suggestions to
make the text look better typographically, such as
- suggesting directional single and double quotes instead of straight
single or or double quotes
- suggesting typographical apostrophes instead of straight ones
- suggesting n-dashes instead of hyphens in number ranges
- suggesting m-dashes instead of --'s
- suggesting fractional characters instead of strings like 1/2
- suggesting the ellipsis character instead of "..."
- suggesting the copyright symbol instead of (c)
There is also an Eclipse quick fix for these issues.
Change-Id: If3912f9d34841faf069174f291911f73e6b78c28
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This changeset adds a follow-up fix for 21124. The fix for that issue
fixes the problem where newly discovered files aren't assigned an
editor binding. However, it does not *retroactively* fix up editor
bindings for files that it didn't correctly initialize.
This changeset fixes that. It adds a project open hook which scans
through the resource folders and reassigns the editor type of any .xml
files based on the resource type. This hook is only run once - it uses
a project persistent property to ensure that it only performs this
check once (or whenever we rev the version number associated with the
scan.)
Change-Id: Id843a8a174c84e3794e88a1c108b67d4000a3e69
|
|
|
|
| |
Change-Id: Ia8375444bf99b33396616a57e781adb22d82175d
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This changeset adds a detector which finds two types of icon
duplication:
- Unrelated drawable resources which have the exact same bitmap. This
could mean that the wrong icon was checked in, or that you could
potentially consolidate to using a single resource.
- Resources which have the same bitmap for multiple different
configurations, such as the same icon in both -mdpi and in -hdpi.
Unlike the various dip size checking methods, this also works for nine
patch files.
Change-Id: Ibe2d0900cecb66c2589400f24c2af9a76ad8dabe
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This changeset adds a new image detector which looks for various
issues related to icons:
(1) Are there bitmap icons in the densityless res/drawable/ folder?
(2) Do the icons appear in all the density folders (except,
optionally, ldpi)
(3) Are the launcher/notification/etc icons of the expected size?
(For example a launcher icon should be 48x48 in mdpi). This
issue is disabled by default.
(4) Do the various bitmaps roughly have the same density-adjusted
sizes across all the densities for the same configuration
parameters? This will catch cases where assets are placed in the
wrong place.
(5) It warns about using .gif files since that format is supported but
discouraged.
Change-Id: Ibe0f97cba7cada5ac0deee244310a38dbc721873
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This changeset makes a number of infrastructure fixes to lint. It also
has some user visible aspects:
(1) The "run lint on export" option, which aborts Export APK if fatal
errors are found, now only checks for fatal issues, which should
be significantly faster (since it skips expensive detectors like
the unused resource detector).
(2) The command line lint tool lets you specify not just issue ids,
but categories to enable or disable as well. In addition to the
--enable and --disable flags to add or remove checks, there is
also a --check flag which runs the exact specified checks. Thus
you can for example run "lint --check Security" to run the
security related lint checks. When using --show to display the
available id's, they are organized and described under category
labels.
I also cleaned up the categories a bit; "Layout" isn't a category
anymore, and instead the layoutopt options are placed in other
categories like "Performance" or "Usability".
(3) From the command line you can now also specify multiple projects
or even search a directory for projects contained recursively
within it. This required a bunch of infrastructure changes to
handle partitioning up the arguments into related projects (since
checks have before-project and after-project hooks that need to
run properly).
(4) On the infrastructure side the "scope" concept was changed to
become a scope set, and a detector can declare that an issue
requires analysis of any of {manifest, resource file, java source
file, resource folder, ...} etc. When lint runs it determines
which detectors are applicable (for example, for a single-file
lint run it will ignore detectors which require a wider
scope). And when applicable, a detector will be called for all the
various scopes it requires. Therefore, the unused resource
detector, which used to have to manually scan the manifest file on
its own, now automatically gets called as part of the manifest
file parse, the resource file parses, and the java file scan.
Single-file linting is still only supported for XML files.
Change-Id: I49a5e2b27f8f6da22904085089aa0c4d2eee67f6
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This changeset adds two warnings:
(1) A new lint warning which checks the sizes (number of items) in
arrays of the same name across the various resource files and
warns if the number of items differ.
(2) A new "manifest order" detector which looks for element ordering
problems in manifest files, such as placing <uses-sdk> after the
<application> element.
It also cleans up the way XML detectors were handled such that a
detector can be an XML detector without being a resource detector
(such as the manifest detector for example).
Finally it also moves classpath initialization into the tool context
where it belongs.
Change-Id: I02fee56bfdbe1064874acf70f18db79897d8a908
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This changeset adds a static analyzer, "lint", which looks for various
potential bugs in Android projects. It has 3 parts:
(1) A library which performs the actual static checks.
This library is standalone: it does not depend on Eclipse.
(Technically the library has two halves: an API half, for use
by third party developers to write additional detectors, and
an actual implementation of a bunch of built-in checks.)
(2) A command line driver, "lint", which runs the static checks and
emits any warnings to standard out. This can be thought of as
a replacement for the layoutopt tool.
(3) Eclipse integration. Lint errors are added to the Problems view as
well as shown as editor annotations. There's an options panel for
controlling which detectors are enabled. There's also a quickfix
for disabling errors directly within the editor and a marker
resolution for disabling them via the Problems view.
The static checks are run on an XML file right after it has been
saved. (This is optional via a toggle on the same preference page
as the detector list.)
The static checks are also run when you export an APK, and if any
fatal errors are found the export is abandoned. (This is also
optional via an option).
Finally you can run a full lint through the Android Tools menu,
and there's also an action to clear all the lint markers there.
There's also a new indicator on the layout editor which shows
whether there are lint errors on the associated file, and when
clicked brings up a dialog listing the specific errors.
This changeset also includes a number of checks:
* An accessibility detector which warns about images missing
contentDescriptions
* A drawable selector detector which warns about state lists where not
all states are reachable (e.g. it is not the case that only the last
item in the list omits a state qualifier)
* A detector finding duplicate ids, not just in the current layout but
across included layouts (transitively) as well
* All the layoutopt ones ported to Java + DOM
* Unit tests for the above.
The focus here is on getting the infrastructure in place, and it
currently focuses on XML resource files and analyzing them
efficiently. See the comment in XmlVisitor for details on that.
Change-Id: Ic5f5f37d92bfb96ff901b959aaac24db33552ff7
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This changeset fixes various issues in the GridLayout support:
(1) Add custom Paste support for GridLayout. The default copy/paste
handler just treats a paste as a drag into (0,0) followed by a
drop. That doesn't work well for GridLayout since it ends up
writing the dragged elements into row/column 0,0. This changeset
adds a custom override of the paste handler such that it adds the
pasted elements into successive table cells instead. It still
needs to adjust the column spans to avoid changing the current
table structure; that will be done in a followup CL.
(2) Clean up the Layout Actions Bar a bit for GridLayout. Separate out
the "Show Structure" and "Grid Mode" actions, and make
grid-operations (Add/Remove Row/Column) only show up in Grid Mode,
and similarly only show Snap to Grid in Free Mode.
(3) The hidden <Space> widgets should also be hidden when selected via
Select All. Also fix a remaining issue with the action enablement
of Select All.
(4) Fix a bug where the preview bounding rectangle was drawn at the
wrong place when showing a center-horizontal proposal.
(5) Remove an assertion encountered during GridLayout conversion which
is not always true.
Change-Id: I8c4c0cac5052e59c5943e535b2f790f420303f9d
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This changeset changes the logic in the refactoring quickfix (which
adds the Android refactorings based on the current caret position,
lexical context and selection).
It now allows some of the refactorings to be run when there is a
selection (this fixes "20393: Extract string functionality in Android
XML files"), and it makes other refactorings work when there is no
selection (it implicitly selects the surrounding element).
It also ensures that the Extract Style refactoring won't be listed at
the top if the attribute under the cursor is not a stylable attribute,
and it makes some other adjustments to the proposal order.
Change-Id: I0714bb652032aa19e6c2502dc1af7bb5e4adf308
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
First, some improvements to Grid Layout handling:
(1) When dropping a new widget, look up the sizing metadata and use it
to determine what fill gravity to set. For example, a button will
use gravity left, and a text field will use gravity
fill_horizontal.
(2) Don't warn about reflection problems when failing to find
GridLayout layout data; this probably means the layout is being
attempted opened in an unsupporting SDK. There's a fallback case
to compute the data instead already.
Second, improvements to the conversion to GridLayout handling:
(1) It now looks at the layout_gravity values to see whether each row
and column is flexible, and if there's no flexible column in each
of the horizontal and vertical dimensions, it will insert a
special <Space> element to absorb any available extra space. This
avoids constraints warnings from GridLayout.
(2) It treats layout_width or layout_height attributes of match_parent
or fill_parent as the same as a fill gravity (and removes it) and
uses this in the flexibility computation above.
(3) It removes unsupported layout params for all children (earlier
this would only remove unsupported layout params on the direct
children of the layout, which isn't enough when a hierarchy is
being flattened.)
(4) It's smarter about computing implicit rows and columns, so it
avoids writing out redundant layout_row and layout_column
attributes in some cases.
(5) It avoids throwing refactoring errors in cases where an attribute
is removed twice
(6) Fixes a bug where the root layout was included when computing the
set of used x and y coordinates, which means you'd often end up
with a blank row and column 0.
(7) Various refactoring to make the code cleaner.
(8) More unit tests and updates to existing unit tests to reflect the
new behavior such as an absorbing spacer and removal of redundant
attributes.
Change-Id: Iee44c3ca749eefc107b83545669cc9d7f84615b1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This changeset adds a new "Welcome Wizard" which is shown the first
time a user runs Eclipse with the ADT plugin.
The welcome wizard asks for two pieces of information:
(1) The location of the SDK.
(2) Whether the user agrees to gathering usage statistics.
We've needed this information before, but collection of the data had
been more ad-hoc: The usage data permission dialog would show up on
its own, and the SDK information would be requested the first time
some code path touched it (e.g. opening a layout or opening the
preference dialog's Android page etc).
In addition, the wizard also offers to *install* SDKs if you don't
already have one. It gives the option between the latest available
platform, and one supported by a large majority of devices (currently
API level 7), or both. If you select this option, then when finishing
the wizard the SDK manager is run in a special mode where it installs
the required packages with a progress dialog.
This changeset also starts recording the chosen SDK location in the
~/.android settings file. This allows us to detect when you're running
Eclipse in a brand new workspace and you've already gone through the
SDK selection before, and we don't need to ask again -- we'll just use
the most recently known location.
The wizard will only be shown once. If you bypass or cancel out of the
wizard, you can still configure your SDK the old way - via the
Preference dialog. Note also that the usage permission page is only
shown if the user has not already opted in via say ddms.
NOTE: If you want to test this, make sure you haven't set the
environment variable ADT_TEST_SDK_PATH (as some of us do for running
unit tests) since it is treated as the user having selected the given
SDK root, and in particular it means the wizard won't be shown even if
you've wiped adtUsed=true from your ~/.android/ddms.cfg etc.
Change-Id: I0a4e2c4efce84aca9beae394ce67e4c145cbb000
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This changeset splits the New Project Wizard into multiple logical
wizards (a separate one for samples, testing and plain projects), and
each wizard contains multiple pages - such as a separate page for SDK
selection, a separate page for Sample selection, a separate page for
Test target selection, and so on.
In addition, sample projects are now copied into the workspace itself
such that they can be modified and deleted without affecting the mater
copy in the SDK install directory. Samples can also be accessed from a
new separate entry in the New wizard.
The SWT code is now maintained with WindowBuilder. Most of the code in
NewProjectWizard was related to actually building the projects, and
this code is preserved in the new NewProjectCreator class which is
used by unit tests etc such that we don't need to create a stub wizard
and stub wizard page anymore.
Change-Id: I64872722e320a109870403d25fdf051270b526ed
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This changeset ports the remaining graphic generators from the HTML5
version (notifications, tabs, action bar), and hooks up wizard support
for them.
It also adds unit tests for the generators which generates images and
compares them to known good versions. I ran these tests comparing them
to the output from the HTML5 version of Asset Studio and all but 3 of
the images varied less than 5% (and I verified the remaining manually
and they're all fine and the difference is due to the images being
aligned slightly differently.)
The icon wizard is now also hooked up to the "New" button in the
Resource Chooser for drawable resources, and this changeset also fixes
a few related issues ("New" didn't work for file-based resources, and
newly created resources weren't showing up in the selection list.)
Change-Id: I48c49f1d5de452aa5b78e491d9b07e7156397fa9
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This fixes:
http://code.google.com/p/android/issues/detail?id=19447
Turns out that on Linux, painting an image with a scale transform can
be extremely expensive - it can take multiple seconds, which makes for
example interactive dragging in a RelativeLayout over a zoomed canvas
appear not to work at all (because in some cases each drag update
takes up to ten seconds).
We rely on scaling image painting when the canvas is zoomed.
To work around this, we "prescale" the images instead: Using the
source AWT image, apply a scale once (whenever the image or the zoom
level has changed), and then store the scaled image as a plain SWT
image which we can then paint on each paint refresh using a normal
(not scaling) image paint.
This change also revealed that during a palette drag, the source image
would get trashed by the palette preview code because the editor XML
model was marked as modified. This is not necessary, so during preview
painting the editor is instructed to ignore XML model updates.
Change-Id: I78f3adb77754d4f9b0daaeeb662d53f1d7ed6042
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This changeset changes the Actions mechanism for view rules to add
support for the following:
* Delayed computation of submenu contents. Before this, a view rule
would have to produce the full tree of actions to be shown in menus
and submenus - for example including all the properties, and in turn
all the enumerated values for those properties and so on. Now
there's a Provider interface which can be used to compute these menu
items only when the menu is actually opened. The properties menu now
takes advantage of this.
This was also necessary to implement the following new feature:
* The layout editor context menu now also lists not just the
properties for the currently selected views, but also the
properties for the parents. For example, if you open the context
menu, you'll see the properties for the button you just right
clicked on, but there will also be a "frameLayout1" submenu
containing the actions for the <FrameLayout> parent of the button,
and a "linearLayout1" submenu for the parent linear layout. This
is useful when a parent layout doesn't have blank space on its own
so it is difficult to target.
A future CL will use the lazy initialization to add more options to
the properties menu.
* Support for arbitrary nesting. Submenus can contain submenus can
contain other submenus etc.
* Custom ordering. This changeset moves the "sort priority" concept
(which was already used for layout actions) up to all actions, which
makes it easier for rules to cooperate on ordering because instead
of appending or prepending to the superclass' context menu result,
actions can now just be initialized with a sorting priority value
which makes it trivial to interleave actions regardless of who adds
them. This also makes it a lot easier to use custom ordering in
choice menus where the ordering used to be alphabetically sorting on
keys.
* Improved support for multiselection. The callback interface now
takes a list of nodes to apply the callback to, and actions can
indicate whether they support multiple nodes. This makes it possible
for actions to more directly support the case where you apply an
action to multiple nodes. As before, the available actions in the
context menu is limited such that it only shows the actions common
to all. But now those actions can do something specific. For
example, if you select "Edit Text..." on many nodes, you will get
the input-string dialog once, and then the value is applied to
all. Similarly, if you select "Edit Id..." it will ask for a
separate id for each value (and you can cancel out of this loop).
There are various API changes too. Since the Choices action (which had
a map-based set of values) was removed, the OrderedChoices is now
renamed Choices. The Actions subclass of MenuAction which all actions
also extended has simply been moved up to the top level MenuAction.
And MenuAction has been renamed to RuleActions since they are used
not just for menus but for toolbars etc and the key thing about this
interface is that they are intended for use by rules.
Change-Id: If49f75213f2041ebfef7e84254d70d219bb766ab
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Eclipse has a Go to Matching feature, bound to Ctrl-Shift-P. However,
for XML documents it only works on the character level, so if the
caret is inside a tag it does nothing, and if you place it on an angle
bracket, it just jumps to the opposite angle bracket for the same tag.
This changeset adds a new character pair matcher which works at the
tag level, so if you for example place the caret anywhere in an end
tag, it will highlight the first character of the opening tag, and if
you jump it will jump to that opening tag. Similarly, if you place the
caret next to the < or tag name of an opening tag, it will jump to the
closing tag.
Change-Id: Id25487b24616abf79c71de5eec21f8c0f07e68cc
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This changeset adds a new "auto edit strategy" for Android XML files,
which replaces the default XML auto-indenter (which just copied the
indentation of the previous line.)
The new indenter instead uses the lexical information to indent based
on the tag and bracket balance.
For example, if the | represents the caret position, then the
following shows how the edits are transformed:
<foo name="value"/>| => <foo name="value"/>
|
<foo name="value">| => <foo name="value">
|
<foo <foo
attr1 = "value1"|> => attr1 = "value1"
|>
<foo <foo
attr1 = "value1"/>| => attr1 = "value1"/>
|
It can also modify the text after the caret, as in the following
transformation:
<foo>|</foo> => <foo>
|
</foo>
See the unit test for more cases.
Change-Id: Ia99ecf6573ff4a9473970aa2fd481d2228ddf45d
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This changeset adds a custom XML formatter for the Android XML
editors.
There is an option for turning off this formatter and using the
standard XML formatter instead.
The new custom formatter offers the following features:
* By default, it formats files following the Android conventions for
XML formatting. This means not only that it indents with 4 space
characters (instead of the Eclipse default of one tab character),
but it places attributes on a line of their own, it adds blank
lines in certain places, and so on.
* It sorts attributes (logically, alphabetically, or none)
* It formats files with different styles depending on the context.
For example, in layout files it always places a single blank line
between view elements, whereas in manifest files it only places
blank lines between elements of different types such that for
example the <uses-permission> elements all form a logical group,
separated from <uses-sdk> and so on.
The fact that strings.xml and layout.xml are usually formatted with
different flavors is one of the reasons setting up the old Eclipse
XML formatter to do the right thing was not possible.
In addition, there are various user options added to the Editors
preference page where you can tweak the behavior of the formatter,
such as turning off blank lines completely, controlling whether there
is a space before the > or /> closing characters, and you can also
tell the formatter to use Eclipse's indentation setting (indentation
size and whether to use spaces or tabs).
Finally, there is a new "Format on Save" option which behaves just
like Format on Save for Java files: when you press Ctrl-S to save a
file, the XML content will be formatted before the file is saved.
Change-Id: Ic6f05c768ab063b09f6f0248f60fbe8722fb149d
|
|
|
|
|
|
|
|
|
|
|
| |
This changeset adds a Quick Assistant to Java files in Android
projects, which proposes "Extract String" when the caret is within a
String literal.
It also moves a couple of utility methods from the Hyperlinks class to
the AdtUtils class.
Change-Id: Ica5ff40e32e3e145481d6c895178109289ed1d9b
|