Merge "Add subdir under frameworks/base for code ported from icu4j."
diff --git a/core/cleanspec.mk b/core/cleanspec.mk
index 675c7da..d3fc9a4 100644
--- a/core/cleanspec.mk
+++ b/core/cleanspec.mk
@@ -178,6 +178,12 @@
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/Music*)
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/jsr305_intermediates)
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/guava_intermediates)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/*)
+$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/*)
+$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS)
# ************************************************
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
diff --git a/core/main.mk b/core/main.mk
index 7553ede..014c050 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -196,6 +196,9 @@
ifeq ($(user_variant),userdebug)
# Pick up some extra useful tools
tags_to_install += debug
+
+ # Enable Dalvik lock contention logging for userdebug builds.
+ ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.lockprof.threshold=500
else
# Disable debugging in plain user builds.
enable_target_debugging :=
diff --git a/core/prelink-linux-arm.map b/core/prelink-linux-arm.map
index 5ae1a78..a787888 100644
--- a/core/prelink-linux-arm.map
+++ b/core/prelink-linux-arm.map
@@ -165,3 +165,4 @@
libtrace_test.so 0x9A300000
libsrec_jni.so 0x9A200000
libjpeg.so 0x9A000000
+libbcc.so 0x99C00000
diff --git a/core/product.mk b/core/product.mk
index eca98ed..be32e9e 100644
--- a/core/product.mk
+++ b/core/product.mk
@@ -61,7 +61,6 @@
PRODUCT_PROPERTY_OVERRIDES \
PRODUCT_COPY_FILES \
PRODUCT_OTA_PUBLIC_KEYS \
- PRODUCT_POLICY \
PRODUCT_PACKAGE_OVERLAYS \
DEVICE_PACKAGE_OVERLAYS \
PRODUCT_CONTRIBUTORS_FILE \
diff --git a/core/product_config.mk b/core/product_config.mk
index ffb8d27..02334cf 100644
--- a/core/product_config.mk
+++ b/core/product_config.mk
@@ -226,9 +226,6 @@
PRODUCT_DEFAULT_WIFI_CHANNELS := \
$(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_DEFAULT_WIFI_CHANNELS))
-# Which policy should this product use
-PRODUCT_POLICY := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_POLICY))
-
# A list of words like <source path>:<destination path>. The file at
# the source path should be copied to the destination path when building
# this product. <destination path> is relative to $(PRODUCT_OUT), so
diff --git a/core/version_defaults.mk b/core/version_defaults.mk
index 244371e..d609cee 100644
--- a/core/version_defaults.mk
+++ b/core/version_defaults.mk
@@ -41,7 +41,7 @@
# which is the version that we reveal to the end user.
# Update this value when the platform version changes (rather
# than overriding it somewhere else). Can be an arbitrary string.
- PLATFORM_VERSION := Froyo
+ PLATFORM_VERSION := Kraken
endif
ifeq "" "$(PLATFORM_SDK_VERSION)"
@@ -53,13 +53,13 @@
# intermediate builds). During development, this number remains at the
# SDK version the branch is based on and PLATFORM_VERSION_CODENAME holds
# the code-name of the new development work.
- PLATFORM_SDK_VERSION := 7
+ PLATFORM_SDK_VERSION := 8
endif
ifeq "" "$(PLATFORM_VERSION_CODENAME)"
# This is the current development code-name, if the build is not a final
# release build. If this is a final release build, it is simply "REL".
- PLATFORM_VERSION_CODENAME := Froyo
+ PLATFORM_VERSION_CODENAME := Kraken
endif
ifeq "" "$(DEFAULT_APP_TARGET_SDK)"
diff --git a/envsetup.sh b/envsetup.sh
index 85465b1..8798344 100644
--- a/envsetup.sh
+++ b/envsetup.sh
@@ -29,8 +29,8 @@
echo "Couldn't locate the top of the tree. Try setting TOP." >&2
return
fi
- CALLED_FROM_SETUP=true BUILD_SYSTEM=build/core \
- make --no-print-directory -C "$T" -f build/core/config.mk dumpvar-abs-$1
+ (cd $T; CALLED_FROM_SETUP=true BUILD_SYSTEM=build/core \
+ make --no-print-directory -C "$T" -f build/core/config.mk dumpvar-abs-$1)
}
# Get the exact value of a build variable.
diff --git a/target/product/full.mk b/target/product/full.mk
index a86e89d..8725804 100644
--- a/target/product/full.mk
+++ b/target/product/full.mk
@@ -20,7 +20,12 @@
# in inherited configurations.
PRODUCT_PACKAGES := \
- VoiceDialer
+ OpenWnn \
+ PinyinIME \
+ VoiceDialer \
+ libWnnEngDic \
+ libWnnJpnDic \
+ libwnndict
# Additional settings used in all AOSP builds
PRODUCT_PROPERTY_OVERRIDES := \
diff --git a/target/product/generic.mk b/target/product/generic.mk
index 4d376a3..c1f286a 100644
--- a/target/product/generic.mk
+++ b/target/product/generic.mk
@@ -38,6 +38,7 @@
Music \
Provision \
Phone \
+ Protips \
QuickSearchBox \
Settings \
Sync \
diff --git a/target/product/sdk.mk b/target/product/sdk.mk
index 4a1db2c..e92d1e6 100644
--- a/target/product/sdk.mk
+++ b/target/product/sdk.mk
@@ -30,6 +30,7 @@
Gallery \
GPSEnable \
Launcher2 \
+ Protips \
Music \
Mms \
Settings \
@@ -55,6 +56,8 @@
PRODUCT_COPY_FILES := \
system/core/rootdir/etc/vold.fstab:system/etc/vold.fstab \
+ frameworks/base/data/sounds/effects/camera_click.ogg:system/media/audio/ui/camera_click.ogg \
+ frameworks/base/data/sounds/effects/VideoRecord.ogg:system/media/audio/ui/VideoRecord.ogg \
frameworks/base/data/etc/android.hardware.camera.autofocus.xml:system/etc/permissions/android.hardware.camera.autofocus.xml
$(call inherit-product, $(SRC_TARGET_DIR)/product/core.mk)
diff --git a/tools/apicheck/src/com/android/apicheck/ApiCheck.java b/tools/apicheck/src/com/android/apicheck/ApiCheck.java
index c8272dd..b2f2265 100644
--- a/tools/apicheck/src/com/android/apicheck/ApiCheck.java
+++ b/tools/apicheck/src/com/android/apicheck/ApiCheck.java
@@ -107,6 +107,7 @@
xmlreader.parse(new InputSource(fileReader));
ApiInfo apiInfo = handler.getApi();
apiInfo.resolveSuperclasses();
+ apiInfo.resolveInterfaces();
return apiInfo;
} catch (SAXParseException e) {
Errors.error(Errors.PARSE_ERROR,
diff --git a/tools/apicheck/src/com/android/apicheck/ApiInfo.java b/tools/apicheck/src/com/android/apicheck/ApiInfo.java
index c237814..47b9a15 100644
--- a/tools/apicheck/src/com/android/apicheck/ApiInfo.java
+++ b/tools/apicheck/src/com/android/apicheck/ApiInfo.java
@@ -31,14 +31,13 @@
return mAllClasses.get(name);
}
- private void resolveInterfaces() {
+ public void resolveInterfaces() {
for (ClassInfo c : mAllClasses.values()) {
c.resolveInterfaces(this);
}
}
public boolean isConsistent(ApiInfo otherApi) {
- resolveInterfaces();
boolean consistent = true;
for (PackageInfo pInfo : mPackages.values()) {
if (otherApi.getPackages().containsKey(pInfo.name())) {
diff --git a/tools/apicheck/src/com/android/apicheck/ClassInfo.java b/tools/apicheck/src/com/android/apicheck/ClassInfo.java
index e62a3d0..2555ea4 100644
--- a/tools/apicheck/src/com/android/apicheck/ClassInfo.java
+++ b/tools/apicheck/src/com/android/apicheck/ClassInfo.java
@@ -135,11 +135,7 @@
consistent = false;
}
for (String iface : mInterfaceNames) {
- boolean found = false;
- for (ClassInfo c = cl; c != null && !found; c = c.mSuperClass) {
- found = c.mInterfaceNames.contains(iface);
- }
- if (!found) {
+ if (!implementsInterface(cl, iface)) {
Errors.error(Errors.REMOVED_INTERFACE, cl.position(),
"Class " + qualifiedName() + " no longer implements " + iface);
}
@@ -274,6 +270,26 @@
return consistent;
}
+ /**
+ * Returns true if {@code cl} implements the interface {@code iface} either
+ * by either being that interface, implementing that interface or extending
+ * a type that implements the interface.
+ */
+ private boolean implementsInterface(ClassInfo cl, String iface) {
+ if (cl.qualifiedName().equals(iface)) {
+ return true;
+ }
+ for (ClassInfo clImplements : cl.mInterfaces) {
+ if (implementsInterface(clImplements, iface)) {
+ return true;
+ }
+ }
+ if (cl.mSuperClass != null && implementsInterface(cl.mSuperClass, iface)) {
+ return true;
+ }
+ return false;
+ }
+
public void resolveInterfaces(ApiInfo apiInfo) {
for (String interfaceName : mInterfaceNames) {
mInterfaces.add(apiInfo.findClass(interfaceName));
diff --git a/tools/droiddoc/src/LinkReference.java b/tools/droiddoc/src/LinkReference.java
index bbcd4db..b1f998a 100644
--- a/tools/droiddoc/src/LinkReference.java
+++ b/tools/droiddoc/src/LinkReference.java
@@ -59,6 +59,12 @@
Pattern.CASE_INSENSITIVE);
/**
+ * regex pattern to use when matching double-quoted reference text
+ */
+ private static final Pattern QUOTE_PATTERN
+ = Pattern.compile("^\"([^\"]*)\"[ \n\r\t]*$");
+
+ /**
* Parse and resolve a link string.
*
* @param text the original text
@@ -321,15 +327,15 @@
if (text.startsWith("\"")) {
// literal quoted reference (e.g., a book title)
- result.label = text.substring(1);
- skipHref = true;
- if (!result.label.endsWith("\"")) {
+ Matcher matcher = QUOTE_PATTERN.matcher(text);
+ if (! matcher.matches()) {
Errors.error(Errors.UNRESOLVED_LINK, pos,
"unbalanced quoted link/see tag: " + text.trim());
result.makeError();
return result;
}
- result.label = result.label.substring(0, result.label.length() - 1);
+ skipHref = true;
+ result.label = matcher.group(1);
result.kind = "@seeJustLabel";
}
else if (text.startsWith("<")) {
diff --git a/tools/droiddoc/templates-pdk/customization.cs b/tools/droiddoc/templates-pdk/customization.cs
index 3e9be06..3d80cc8 100644
--- a/tools/droiddoc/templates-pdk/customization.cs
+++ b/tools/droiddoc/templates-pdk/customization.cs
@@ -11,7 +11,6 @@
elif:doc.type == "source" ?>source<?cs
elif:doc.type == "porting" ?>porting<?cs
elif:doc.type == "compatibility" ?>compatibility<?cs
- elif:doc.type == "downloads" ?>downloads<?cs
elif:doc.type == "community" ?>community<?cs
elif:doc.type == "about" ?>about<?cs /if ?>">
<li id="home-link"><a href="<?cs var:toroot ?>index.html"><span>Home</span></a></li>
@@ -23,8 +22,6 @@
onClick="return loadLast('compatibility')"><span>Compatibility</span></a></li>
<li id="community-link"><a href="<?cs var:toroot ?>community/index.html"
onClick="return loadLast('community')"><span>Community</span></a></li>
- <li id="downloads-link"><a href="<?cs var:toroot ?>downloads/index.html"
- onClick="return loadLast('downloads')"><span>Downloads</span></a></li>
<li id="about-link"><a href="<?cs var:toroot ?>about/index.html"
onClick="return loadLast('about')"><span>About</span></a></li>
</ul>
@@ -102,21 +99,6 @@
</div>
<?cs /def ?>
-<?cs def:downloads_nav() ?>
- <div class="g-section g-tpl-240" id="body-content">
- <div class="g-unit g-first side-nav-resizable" id="side-nav">
- <div id="devdoc-nav"><?cs
- include:"../../../../development/pdk/docs/downloads/downloads_toc.cs" ?>
- </div>
- </div> <!-- end side-nav -->
- <script>
- addLoadEvent(function() {
- scrollIntoView("devdoc-nav");
- });
- </script>
- </div>
-<?cs /def ?>
-
<?cs def:compatibility_nav() ?>
<div class="g-section g-tpl-240" id="body-content">
<div class="g-unit g-first side-nav-resizable" id="side-nav">
@@ -140,8 +122,6 @@
<?cs call:porting_nav() ?>
<?cs elif:doc.type == "compatibility" ?>
<?cs call:compatibility_nav() ?>
- <?cs elif:doc.type == "downloads" ?>
- <?cs call:downloads_nav() ?>
<?cs elif:doc.type == "community" ?>
<?cs call:community_nav() ?>
<?cs elif:doc.type == "about" ?>
diff --git a/tools/droiddoc/templates-pdk/head_tag.cs b/tools/droiddoc/templates-pdk/head_tag.cs
index 915dc0e..cccbb14 100644
--- a/tools/droiddoc/templates-pdk/head_tag.cs
+++ b/tools/droiddoc/templates-pdk/head_tag.cs
@@ -1,6 +1,6 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
-<link rel="shortcut icon" type="image/x-icon" href="<?cs var:toroot ?>assets-pdk/favicon.ico" />
+<link rel="shortcut icon" type="image/x-icon" href="<?cs var:toroot ?>assets/favicon.ico" />
<title><?cs
if:page.title ?><?cs
var:page.title ?><?cs
@@ -9,7 +9,7 @@
/if ?> | <?cs
/if ?>Android Open Source</title>
<link href="<?cs var:toroot ?>assets/android-developer-docs-devguide.css" rel="stylesheet" type="text/css" />
-<link href="<?cs var:toroot ?>assets-pdk/pdk-local.css" rel="stylesheet" type="text/css" />
+<!-- <link href="<?cs var:toroot ?>assets-pdk/pdk-local.css" rel="stylesheet" type="text/css" /> -->
<script src="<?cs var:toroot ?>assets/search_autocomplete.js" type="text/javascript"></script>
<script src="<?cs var:toroot ?>assets/jquery-resizable.min.js" type="text/javascript"></script>
<script src="<?cs var:toroot ?>assets/android-developer-docs.js" type="text/javascript"></script>
@@ -28,7 +28,7 @@
}
}
</script>
-<script type="text/javascript>
+<script type="text/javascript">
jQuery(document).ready(function() {
jQuery("pre").addClass("prettyprint");
});
diff --git a/tools/droiddoc/templates/assets/android-developer-core.css b/tools/droiddoc/templates/assets/android-developer-core.css
index 2d1708a..92e4c53 100644
--- a/tools/droiddoc/templates/assets/android-developer-core.css
+++ b/tools/droiddoc/templates/assets/android-developer-core.css
@@ -28,21 +28,21 @@
color:#000;
font-size:13px;
color:#333;
- background-image:url(images/bg_fade.jpg);
+ background-image:url(images/bg_fade.jpg);
background-repeat:repeat-x;
}
-a, a code {
+a, a code {
color:#006699;
}
a:active,
-a:active code {
+a:active code {
color:#f00;
}
a:visited,
-a:visited code {
+a:visited code {
color:#006699;
}
@@ -107,7 +107,7 @@
padding:0;
}
-dt {
+dt {
margin:0;
padding:0;
}
@@ -129,7 +129,9 @@
margin:.5em 0 0 1em;
}
-dd pre, dd table, dd img {
+dd pre,
+#jd-content dd table,
+#jd-content dd img {
margin:1em 0 0 1em;
}
@@ -226,7 +228,7 @@
#header ul {
list-style: none;
- margin: 7px 0 0;
+ margin: 7px 0 0;
padding: 0;
height: 29px;
}
@@ -340,7 +342,7 @@
}
#mainBodyFixed h2,
-#mainBodyFluid h2 {
+#mainBodyFluid h2 {
color:#336666;
font-size:1.25em;
margin: 0;
@@ -348,7 +350,7 @@
}
#mainBodyFixed h1,
-#mainBodyFluid h1 {
+#mainBodyFluid h1 {
color:#435A6E;
font-size:1.7em;
margin: 1em 0;
@@ -356,7 +358,7 @@
#mainBodyFixed .green,
#mainBodyFluid .green,
-#jd-content .green {
+#jd-content .green {
color:#7BB026;
background-color:none;
}
@@ -364,13 +366,13 @@
#mainBodyLeft {
float: left;
width: 600px;
- margin-right: 20px;
+ margin-right: 20px;
color: #333;
position:relative;
}
div.indent {
- margin-left: 40px;
+ margin-left: 40px;
margin-right: 70px;
}
@@ -517,7 +519,7 @@
padding-right: 6px;
padding-top: 1px;
padding-bottom: 1px;
- font-size: .8em;
+ font-size: 0.81em;
border: none;
margin: 0;
line-height: 1.05em;
@@ -583,7 +585,7 @@
.gsc-cursor-box .gsc-cursor div.gsc-cursor-page,
.gsc-cursor-box .gsc-trailing-more-results a.gsc-trailing-more-results,
-#leftSearchControl a,
+#leftSearchControl a,
#leftSearchControl a b {
color:#006699;
}
@@ -669,7 +671,7 @@
#homeTitle {
padding:15px 15px 0;
- height:30px;
+ height:30px;
}
#homeTitle h2 {
@@ -704,8 +706,8 @@
}
#carouselMain {
- background: url(images/home/bg_home_carousel_board.png) 0 0 no-repeat;
- height:auto;
+ background: url(images/home/bg_home_carousel_board.png) 0 0 no-repeat;
+ height:auto;
padding: 25px 21px 0;
overflow:hidden;
position:relative;
@@ -717,19 +719,19 @@
}
#carouselMain .bulletinDesc h3 {
- margin:0;
- padding:0;
+ margin:0;
+ padding:0;
}
#carouselMain .bulletinDesc p {
- margin:0;
- padding:0.7em 0 0;
+ margin:0;
+ padding:0.7em 0 0;
}
#carouselWheel {
- background: url(images/home/bg_home_carousel_wheel.png) 0 0 no-repeat;
- padding-top:40px;
- height:150px;
+ background: url(images/home/bg_home_carousel_wheel.png) 0 0 no-repeat;
+ padding-top:40px;
+ height:150px;
}
.clearer { clear:both; }
@@ -748,17 +750,17 @@
margin:35px 10px 0 0;
}
a.arrow-left-off,
-a#arrow-left.arrow-left-off:hover {
+a#arrow-left.arrow-left-off:hover {
background-position:0 0;
}
-a.arrow-right-off,
-a#arrow-right.arrow-right-off:hover {
+a.arrow-right-off,
+a#arrow-right.arrow-right-off:hover {
background-position:-42px 0;
}
-a#arrow-left:hover {
+a#arrow-left:hover {
background-position:0 -42px;
}
-a#arrow-right:hover {
+a#arrow-right:hover {
background-position:-42px -42px;
}
a.arrow-left-on {
@@ -778,17 +780,17 @@
width:100%;
}
-div#list-clip {
- height:110px;
+div#list-clip {
+ height:110px;
width:438px;
- overflow:hidden;
- position:relative;
- float:left;
+ overflow:hidden;
+ position:relative;
+ float:left;
}
-div#app-list {
- left:0;
- z-index:1;
+div#app-list {
+ left:0;
+ z-index:1;
position:absolute;
margin:11px 0 0;
_margin-top:13px;
@@ -817,14 +819,14 @@
top:-4px;
}
-#app-list img {
+#app-list img {
width:90px;
height:70px;
margin:0;
}
-#app-list a.selected,
-#app-list a:active.selected,
+#app-list a.selected,
+#app-list a:active.selected,
#app-list a:hover.selected {
background:#A4C639;
color:#fff;
@@ -832,12 +834,12 @@
text-decoration:none;
}
-#app-list a:hover,
+#app-list a:hover,
#app-list a:active {
background:#ff9900;
}
-#app-list a:hover span,
+#app-list a:hover span,
#app-list a:active span {
text-decoration:underline;
}
@@ -851,7 +853,7 @@
/*IE6*/
* html #app-list a { zoom: 1; margin:0 24px 0 15px;}
-* html #list-clip {
+* html #list-clip {
width:430px !important;
}
@@ -1146,13 +1148,13 @@
}
#mainBodyRight ul.videoPreviews p {
- line-height:1.2em;
+ line-height:1.2em;
padding:0;
margin:4px 0 0 130px;
}
#mainBodyRight ul.videoPreviews img {
- margin-top:5px;
+ margin-top:5px;
}
/* Pretty printing styles. Used with prettify.js. */
@@ -1164,8 +1166,10 @@
.lit { color: #066; }
.pun { color: #660; }
.pln { color: #000; }
+dl.tag-list dt code,
.tag { color: #008; }
-.atn { color: #606; }
+dl.atn-list dt code,
+.atn { color: #828; }
.atv { color: #080; }
.dec { color: #606; }
diff --git a/tools/droiddoc/templates/assets/android-developer-docs.css b/tools/droiddoc/templates/assets/android-developer-docs.css
index 47a30a3..98f2d5e 100644
--- a/tools/droiddoc/templates/assets/android-developer-docs.css
+++ b/tools/droiddoc/templates/assets/android-developer-docs.css
@@ -100,7 +100,6 @@
#side-nav li a+a {
padding: 0;
}
-
/*second level (nested) list*/
#side-nav li li li a {
padding: 0 0 0 28px;
@@ -518,8 +517,7 @@
color:#111;
border-top:2px solid #ccc;
padding: .5em 0 0;
- margin: 1.5em 0 1em 0;
- max-width:968px;
+ margin: 2em 0 1em 0;
}
#jd-content h3 {
@@ -545,6 +543,10 @@
position:inherit;
}
+#jd-content table {
+ margin: 0 0 1em 1em;
+}
+
#jd-content img {
margin: 0 0 1em 1em;
}
@@ -807,13 +809,17 @@
div.figure {
float:right;
clear:right;
- padding:0 0 20px 20px;
+ padding:1em 0 1em 2em;
+ background-color:#fff;
/* width must be defined w/ an inline style matching the image width */
}
-#jd-content div.figure img {
- display:block;
- margin:0 0 10px 0;
+p.img-caption {
+ margin: -0.5em 0 1em 1em; /* matches default img left-margin */
+}
+
+p.table-caption {
+ margin: 0 0 0.5em 1em; /* matches default table left-margin */
}
/* BEGIN quickview sidebar element styles */
@@ -967,7 +973,7 @@
td.image-caption-i {
font-size:92%;
- padding:0;
+ padding:0 5px;
margin:0;
border:0;
}
@@ -982,10 +988,6 @@
text-align:center;
}
-.image-list .caption {
- margin:0 2px;
-}
-
td.image-caption-c {
font-size:92%;
padding:1em 2px 2px 2px;
diff --git a/tools/droiddoc/templates/assets/search_autocomplete.js b/tools/droiddoc/templates/assets/search_autocomplete.js
index 4fa47a5..dd4552f 100644
--- a/tools/droiddoc/templates/assets/search_autocomplete.js
+++ b/tools/droiddoc/templates/assets/search_autocomplete.js
@@ -2,7 +2,7 @@
var gSelectedID = -1;
var gMatches = new Array();
var gLastText = "";
-var ROW_COUNT = 30;
+var ROW_COUNT = 20;
var gInitialized = false;
var DEFAULT_TEXT = "search developer docs";
@@ -22,7 +22,7 @@
function set_row_values(toroot, row, match)
{
var link = row.cells[0].childNodes[0];
- link.innerHTML = match.label;
+ link.innerHTML = match.__hilabel || match.label;
link.href = toroot + match.link
// row.cells[1].innerHTML = match.type;
}
@@ -104,7 +104,7 @@
function search_changed(e, kd, toroot)
{
var search = document.getElementById("search_autocomplete");
- var text = search.value;
+ var text = search.value.replace(/(^ +)|( +$)/g, '');
// 13 = enter
if (e.keyCode == 13) {
@@ -137,21 +137,112 @@
gMatches = new Array();
matchedCount = 0;
gSelectedIndex = -1;
- for (i=0; i<DATA.length; i++) {
+ for (var i=0; i<DATA.length; i++) {
var s = DATA[i];
- if (text.length != 0 && s.label.indexOf(text) != -1) {
+ if (text.length != 0 &&
+ s.label.toLowerCase().indexOf(text.toLowerCase()) != -1) {
gMatches[matchedCount] = s;
- if (gSelectedID == s.id) {
- gSelectedIndex = matchedCount;
- }
matchedCount++;
}
}
+ rank_autocomplete_results(text);
+ for (var i=0; i<gMatches.length; i++) {
+ var s = gMatches[i];
+ if (gSelectedID == s.id) {
+ gSelectedIndex = i;
+ }
+ }
+ highlight_autocomplete_result_labels(text);
sync_selection_table(toroot);
return true; // allow the event to bubble up to the search api
}
}
+function rank_autocomplete_results(query) {
+ query = query || '';
+ if (!gMatches || !gMatches.length)
+ return;
+
+ // helper function that gets the last occurence index of the given regex
+ // in the given string, or -1 if not found
+ var _lastSearch = function(s, re) {
+ if (s == '')
+ return -1;
+ var l = -1;
+ var tmp;
+ while ((tmp = s.search(re)) >= 0) {
+ if (l < 0) l = 0;
+ l += tmp;
+ s = s.substr(tmp + 1);
+ }
+ return l;
+ };
+
+ // helper function that counts the occurrences of a given character in
+ // a given string
+ var _countChar = function(s, c) {
+ var n = 0;
+ for (var i=0; i<s.length; i++)
+ if (s.charAt(i) == c) ++n;
+ return n;
+ };
+
+ var queryLower = query.toLowerCase();
+ var queryAlnum = (queryLower.match(/\w+/) || [''])[0];
+ var partPrefixAlnumRE = new RegExp('\\b' + queryAlnum);
+ var partExactAlnumRE = new RegExp('\\b' + queryAlnum + '\\b');
+
+ var _resultScoreFn = function(result) {
+ // scores are calculated based on exact and prefix matches,
+ // and then number of path separators (dots) from the last
+ // match (i.e. favoring classes and deep package names)
+ var score = 1.0;
+ var labelLower = result.label.toLowerCase();
+ var t;
+ t = _lastSearch(labelLower, partExactAlnumRE);
+ if (t >= 0) {
+ // exact part match
+ var partsAfter = _countChar(labelLower.substr(t + 1), '.');
+ score *= 200 / (partsAfter + 1);
+ } else {
+ t = _lastSearch(labelLower, partPrefixAlnumRE);
+ if (t >= 0) {
+ // part prefix match
+ var partsAfter = _countChar(labelLower.substr(t + 1), '.');
+ score *= 20 / (partsAfter + 1);
+ }
+ }
+
+ return score;
+ };
+
+ for (var i=0; i<gMatches.length; i++) {
+ gMatches[i].__resultScore = _resultScoreFn(gMatches[i]);
+ }
+
+ gMatches.sort(function(a,b){
+ var n = b.__resultScore - a.__resultScore;
+ if (n == 0) // lexicographical sort if scores are the same
+ n = (a.label < b.label) ? -1 : 1;
+ return n;
+ });
+}
+
+function highlight_autocomplete_result_labels(query) {
+ query = query || '';
+ if (!gMatches || !gMatches.length)
+ return;
+
+ var queryLower = query.toLowerCase();
+ var queryAlnumDot = (queryLower.match(/[\w\.]+/) || [''])[0];
+ var queryRE = new RegExp(
+ '(' + queryAlnumDot.replace(/\./g, '\\.') + ')', 'ig');
+ for (var i=0; i<gMatches.length; i++) {
+ gMatches[i].__hilabel = gMatches[i].label.replace(
+ queryRE, '<b>$1</b>');
+ }
+}
+
function search_focus_changed(obj, focused)
{
if (focused) {