summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/java/android/app/FragmentBreadCrumbs.java107
-rw-r--r--core/java/android/net/InterfaceConfiguration.java44
-rw-r--r--core/java/android/os/Vibrator.java18
-rw-r--r--core/java/android/preference/PreferenceActivity.java15
-rw-r--r--core/java/android/server/BluetoothService.java19
-rw-r--r--core/java/android/widget/Switch.java6
-rw-r--r--core/java/android/widget/TextView.java32
-rwxr-xr-xcore/res/res/values/attrs.xml10
-rw-r--r--core/res/res/values/public.xml1
9 files changed, 146 insertions, 106 deletions
diff --git a/core/java/android/app/FragmentBreadCrumbs.java b/core/java/android/app/FragmentBreadCrumbs.java
index 8d76ffe..fb89099 100644
--- a/core/java/android/app/FragmentBreadCrumbs.java
+++ b/core/java/android/app/FragmentBreadCrumbs.java
@@ -45,6 +45,10 @@ public class FragmentBreadCrumbs extends ViewGroup
// Hahah
BackStackRecord mTopEntry;
+ BackStackRecord mParentEntry;
+
+ /** Listener to inform when a parent entry is clicked */
+ private OnClickListener mParentClickListener;
public FragmentBreadCrumbs(Context context) {
this(context, null);
@@ -75,27 +79,51 @@ public class FragmentBreadCrumbs extends ViewGroup
}
/**
- * The maximum number of crumbs to show.
- * @hide
+ * The maximum number of breadcrumbs to show. Older fragment headers will be hidden from view.
+ * @param visibleCrumbs the number of visible breadcrumbs. This should be greater than zero.
*/
public void setMaxVisible(int visibleCrumbs) {
+ if (visibleCrumbs < 1) {
+ throw new IllegalArgumentException("visibleCrumbs must be greater than zero");
+ }
mMaxVisible = visibleCrumbs;
}
/**
+ * Inserts an optional parent entry at the first position in the breadcrumbs. Selecting this
+ * entry will result in a call to the specified listener's
+ * {@link android.view.View.OnClickListener#onClick(View)}
+ * method.
+ *
+ * @param title the title for the parent entry
+ * @param shortTitle the short title for the parent entry
+ * @param listener the {@link android.view.View.OnClickListener} to be called when clicked.
+ * A null will result in no action being taken when the parent entry is clicked.
+ */
+ public void setParentTitle(CharSequence title, CharSequence shortTitle,
+ OnClickListener listener) {
+ mParentEntry = createBackStackEntry(title, shortTitle);
+ mParentClickListener = listener;
+ updateCrumbs();
+ }
+
+ private BackStackRecord createBackStackEntry(CharSequence title, CharSequence shortTitle) {
+ if (title == null) return null;
+
+ final BackStackRecord entry = new BackStackRecord(
+ (FragmentManagerImpl) mActivity.getFragmentManager());
+ entry.setBreadCrumbTitle(title);
+ entry.setBreadCrumbShortTitle(shortTitle);
+ return entry;
+ }
+
+ /**
* Set a custom title for the bread crumbs. This will be the first entry
* shown at the left, representing the root of the bread crumbs. If the
* title is null, it will not be shown.
*/
public void setTitle(CharSequence title, CharSequence shortTitle) {
- if (title == null) {
- mTopEntry = null;
- } else {
- mTopEntry = new BackStackRecord((FragmentManagerImpl)
- mActivity.getFragmentManager());
- mTopEntry.setBreadCrumbTitle(title);
- mTopEntry.setBreadCrumbShortTitle(shortTitle);
- }
+ mTopEntry = createBackStackEntry(title, shortTitle);
updateCrumbs();
}
@@ -151,41 +179,66 @@ public class FragmentBreadCrumbs extends ViewGroup
updateCrumbs();
}
+ /**
+ * Returns the number of entries before the backstack, including the title of the current
+ * fragment and any custom parent title that was set.
+ */
+ private int getPreEntryCount() {
+ return (mTopEntry != null ? 1 : 0) + (mParentEntry != null ? 1 : 0);
+ }
+
+ /**
+ * Returns the pre-entry corresponding to the index. If there is a parent and a top entry
+ * set, parent has an index of zero and top entry has an index of 1. Returns null if the
+ * specified index doesn't exist or is null.
+ * @param index should not be more than {@link #getPreEntryCount()} - 1
+ */
+ private BackStackEntry getPreEntry(int index) {
+ // If there's a parent entry, then return that for zero'th item, else top entry.
+ if (mParentEntry != null) {
+ return index == 0 ? mParentEntry : mTopEntry;
+ } else {
+ return mTopEntry;
+ }
+ }
+
void updateCrumbs() {
FragmentManager fm = mActivity.getFragmentManager();
int numEntries = fm.countBackStackEntries();
+ int numPreEntries = getPreEntryCount();
int numViews = mContainer.getChildCount();
- for (int i = mTopEntry != null ? -1 : 0; i < numEntries; i++) {
- BackStackEntry bse = i == -1 ? mTopEntry : fm.getBackStackEntry(i);
- int viewI = mTopEntry != null ? i + 1 : i;
- if (viewI < numViews) {
- View v = mContainer.getChildAt(viewI);
+ for (int i = 0; i < numEntries + numPreEntries; i++) {
+ BackStackEntry bse = i < numPreEntries
+ ? getPreEntry(i)
+ : fm.getBackStackEntry(i - numPreEntries);
+ if (i < numViews) {
+ View v = mContainer.getChildAt(i);
Object tag = v.getTag();
if (tag != bse) {
- for (int j = viewI; j < numViews; j++) {
- mContainer.removeViewAt(viewI);
+ for (int j = i; j < numViews; j++) {
+ mContainer.removeViewAt(i);
}
- numViews = viewI;
+ numViews = i;
}
}
- if (viewI >= numViews) {
+ if (i >= numViews) {
final View item = mInflater.inflate(
com.android.internal.R.layout.fragment_bread_crumb_item,
this, false);
final TextView text = (TextView) item.findViewById(com.android.internal.R.id.title);
text.setText(bse.getBreadCrumbTitle());
text.setTag(bse);
- if (viewI == 0) {
+ if (i == 0) {
item.findViewById(com.android.internal.R.id.left_icon).setVisibility(View.GONE);
}
mContainer.addView(item);
text.setOnClickListener(mOnClickListener);
}
}
- int viewI = mTopEntry != null ? numEntries + 1 : numEntries;
+ int viewI = numEntries + numPreEntries;
numViews = mContainer.getChildCount();
while (numViews > viewI) {
- mContainer.removeViewAt(numViews-1);
+ mContainer.removeViewAt(numViews - 1);
numViews--;
}
// Adjust the visibility and availability of the bread crumbs and divider
@@ -208,8 +261,14 @@ public class FragmentBreadCrumbs extends ViewGroup
public void onClick(View v) {
if (v.getTag() instanceof BackStackEntry) {
BackStackEntry bse = (BackStackEntry) v.getTag();
- mActivity.getFragmentManager().popBackStack(bse.getId(),
- bse == mTopEntry? FragmentManager.POP_BACK_STACK_INCLUSIVE : 0);
+ if (bse == mParentEntry) {
+ if (mParentClickListener != null) {
+ mParentClickListener.onClick(v);
+ }
+ } else {
+ mActivity.getFragmentManager().popBackStack(bse.getId(),
+ bse == mTopEntry? FragmentManager.POP_BACK_STACK_INCLUSIVE : 0);
+ }
}
}
};
diff --git a/core/java/android/net/InterfaceConfiguration.java b/core/java/android/net/InterfaceConfiguration.java
index 915c5d7..980048c 100644
--- a/core/java/android/net/InterfaceConfiguration.java
+++ b/core/java/android/net/InterfaceConfiguration.java
@@ -19,14 +19,17 @@ package android.net;
import android.os.Parcelable;
import android.os.Parcel;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
/**
* A simple object for retrieving / setting an interfaces configuration
* @hide
*/
public class InterfaceConfiguration implements Parcelable {
public String hwAddr;
- public int ipAddr;
- public int netmask;
+ public InetAddress addr;
+ public InetAddress mask;
public String interfaceFlags;
public InterfaceConfiguration() {
@@ -36,21 +39,14 @@ public class InterfaceConfiguration implements Parcelable {
public String toString() {
StringBuffer str = new StringBuffer();
- str.append("ipddress "); putAddress(str, ipAddr);
- str.append(" netmask "); putAddress(str, netmask);
+ str.append("ipddress "); str.append(addr.toString());
+ str.append(" netmask "); str.append(mask.toString());
str.append(" flags ").append(interfaceFlags);
str.append(" hwaddr ").append(hwAddr);
return str.toString();
}
- private static void putAddress(StringBuffer buf, int addr) {
- buf.append((addr >> 24) & 0xff).append('.').
- append((addr >> 16) & 0xff).append('.').
- append((addr >> 8) & 0xff).append('.').
- append(addr & 0xff);
- }
-
/** Implement the Parcelable interface {@hide} */
public int describeContents() {
return 0;
@@ -59,8 +55,18 @@ public class InterfaceConfiguration implements Parcelable {
/** Implement the Parcelable interface {@hide} */
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(hwAddr);
- dest.writeInt(ipAddr);
- dest.writeInt(netmask);
+ if (addr != null) {
+ dest.writeByte((byte)1);
+ dest.writeByteArray(addr.getAddress());
+ } else {
+ dest.writeByte((byte)0);
+ }
+ if (mask != null) {
+ dest.writeByte((byte)1);
+ dest.writeByteArray(mask.getAddress());
+ } else {
+ dest.writeByte((byte)0);
+ }
dest.writeString(interfaceFlags);
}
@@ -70,8 +76,16 @@ public class InterfaceConfiguration implements Parcelable {
public InterfaceConfiguration createFromParcel(Parcel in) {
InterfaceConfiguration info = new InterfaceConfiguration();
info.hwAddr = in.readString();
- info.ipAddr = in.readInt();
- info.netmask = in.readInt();
+ if (in.readByte() == 1) {
+ try {
+ info.addr = InetAddress.getByAddress(in.createByteArray());
+ } catch (UnknownHostException e) {}
+ }
+ if (in.readByte() == 1) {
+ try {
+ info.mask = InetAddress.getByAddress(in.createByteArray());
+ } catch (UnknownHostException e) {}
+ }
info.interfaceFlags = in.readString();
return info;
}
diff --git a/core/java/android/os/Vibrator.java b/core/java/android/os/Vibrator.java
index e9428f7..3769cfe 100644
--- a/core/java/android/os/Vibrator.java
+++ b/core/java/android/os/Vibrator.java
@@ -22,6 +22,7 @@ import android.util.Log;
* Class that operates the vibrator on the device.
* <p>
* If your process exits, any vibration you started with will stop.
+ * </p>
*/
public class Vibrator
{
@@ -56,7 +57,7 @@ public class Vibrator
/**
* Turn the vibrator on.
*
- * @param milliseconds How long to vibrate for.
+ * @param milliseconds The number of milliseconds to vibrate.
*/
public void vibrate(long milliseconds)
{
@@ -75,12 +76,17 @@ public class Vibrator
* Vibrate with a given pattern.
*
* <p>
- * Pass in an array of ints that are the times at which to turn on or off
- * the vibrator. The first one is how long to wait before turning it on,
- * and then after that it alternates. If you want to repeat, pass the
- * index into the pattern at which to start the repeat.
+ * Pass in an array of ints that are the durations for which to turn on or off
+ * the vibrator in milliseconds. The first value indicates the number of milliseconds
+ * to wait before turning the vibrator on. The next value indicates the number of milliseconds
+ * for which to keep the vibrator on before turning it off. Subsequent values alternate
+ * between durations in milliseconds to turn the vibrator off or to turn the vibrator on.
+ * </p><p>
+ * To cause the pattern to repeat, pass the index into the pattern array at which
+ * to start the repeat, or -1 to disable repeating.
+ * </p>
*
- * @param pattern an array of longs of times to turn the vibrator on or off.
+ * @param pattern an array of longs of times for which to turn the vibrator on or off.
* @param repeat the index into pattern at which to repeat, or -1 if
* you don't want to repeat.
*/
diff --git a/core/java/android/preference/PreferenceActivity.java b/core/java/android/preference/PreferenceActivity.java
index d9039ab..7a186f3 100644
--- a/core/java/android/preference/PreferenceActivity.java
+++ b/core/java/android/preference/PreferenceActivity.java
@@ -1005,6 +1005,21 @@ public abstract class PreferenceActivity extends ListActivity implements
mFragmentBreadCrumbs.setActivity(this);
}
mFragmentBreadCrumbs.setTitle(title, shortTitle);
+ mFragmentBreadCrumbs.setParentTitle(null, null, null);
+ }
+
+ /**
+ * Should be called after onCreate to ensure that the breadcrumbs, if any, were created.
+ * This prepends a title to the fragment breadcrumbs and attaches a listener to any clicks
+ * on the parent entry.
+ * @param title the title for the breadcrumb
+ * @param shortTitle the short title for the breadcrumb
+ */
+ public void setParentTitle(CharSequence title, CharSequence shortTitle,
+ OnClickListener listener) {
+ if (mFragmentBreadCrumbs != null) {
+ mFragmentBreadCrumbs.setParentTitle(title, shortTitle, listener);
+ }
}
void setSelectedHeader(Header header) {
diff --git a/core/java/android/server/BluetoothService.java b/core/java/android/server/BluetoothService.java
index 1f19f9e..9e5abdc 100644
--- a/core/java/android/server/BluetoothService.java
+++ b/core/java/android/server/BluetoothService.java
@@ -75,6 +75,7 @@ import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
+import java.net.InetAddress;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -1660,20 +1661,10 @@ public class BluetoothService extends IBluetooth.Stub {
try {
ifcg = service.getInterfaceConfig(iface);
if (ifcg != null) {
- String[] addr = BLUETOOTH_NETMASK.split("\\.");
- ifcg.netmask = (Integer.parseInt(addr[0]) << 24) +
- (Integer.parseInt(addr[1]) << 16) +
- (Integer.parseInt(addr[2]) << 8) +
- (Integer.parseInt(addr[3]));
- if (ifcg.ipAddr == 0) {
- addr = address.split("\\.");
-
- ifcg.ipAddr = (Integer.parseInt(addr[0]) << 24) +
- (Integer.parseInt(addr[1]) << 16) +
- (Integer.parseInt(addr[2]) << 8) +
- (Integer.parseInt(addr[3]));
- ifcg.interfaceFlags =
- ifcg.interfaceFlags.replace("down", "up");
+ ifcg.mask = InetAddress.getByName(BLUETOOTH_NETMASK);
+ if (ifcg.addr == null) {
+ ifcg.addr = InetAddress.getByName(address);
+ ifcg.interfaceFlags = ifcg.interfaceFlags.replace("down", "up");
}
ifcg.interfaceFlags = ifcg.interfaceFlags.replace("running", "");
ifcg.interfaceFlags = ifcg.interfaceFlags.replace(" "," ");
diff --git a/core/java/android/widget/Switch.java b/core/java/android/widget/Switch.java
index 4223040..8fb6fa3 100644
--- a/core/java/android/widget/Switch.java
+++ b/core/java/android/widget/Switch.java
@@ -192,12 +192,6 @@ public class Switch extends CompoundButton {
setSwitchTypefaceByIndex(typefaceIndex, styleIndex);
- int lineHeight = appearance.getDimensionPixelSize(
- com.android.internal.R.styleable.TextAppearance_textLineHeight, 0);
- if (lineHeight != 0) {
- setLineHeight(lineHeight);
- }
-
appearance.recycle();
}
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 7fc7e54..c7ee57b 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -766,13 +766,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
mEditTextMultilineBackground = a.getDrawable(attr);
break;
- case com.android.internal.R.styleable.TextView_textLineHeight:
- int lineHeight = a.getDimensionPixelSize(attr, 0);
- if (lineHeight != 0) {
- setLineHeight(lineHeight);
- }
- break;
-
case com.android.internal.R.styleable.TextView_textIsSelectable:
mTextIsSelectable = a.getBoolean(attr, false);
break;
@@ -1133,15 +1126,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
* within the text can cause individual lines to be taller or shorter
* than this height, and the layout may contain additional first-
* or last-line padding.
- *
- * @attr ref android.R.styleable#TextView_textLineHeight
*/
public int getLineHeight() {
- if (mLineHeight != 0) {
- return mLineHeight;
- }
- return FastMath.round(mTextPaint.getFontMetricsInt(null) * mSpacingMult
- + mSpacingAdd);
+ return FastMath.round(mTextPaint.getFontMetricsInt(null) * mSpacingMult + mSpacingAdd);
}
/**
@@ -1728,26 +1715,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
setTypefaceByIndex(typefaceIndex, styleIndex);
- int lineHeight = appearance.getDimensionPixelSize(
- com.android.internal.R.styleable.TextAppearance_textLineHeight, 0);
- if (lineHeight != 0) {
- setLineHeight(lineHeight);
- }
-
appearance.recycle();
}
/**
- * Set the height of a line of text in pixels. This value will override line height
- * values stored in the font modified by lineSpacingExtra and lineSpacingMultiplier.
- *
- * @param lineHeight Desired height of a single line of text in pixels
- */
- public void setLineHeight(int lineHeight) {
- mLineHeight = lineHeight;
- }
-
- /**
* @return the size (in pixels) of the default text size in this TextView.
*/
public float getTextSize() {
@@ -9393,7 +9364,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
private float mSpacingMult = 1;
private float mSpacingAdd = 0;
- private int mLineHeight = 0;
private boolean mTextIsSelectable = false;
private static final int LINES = 1;
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index 181bbcc..f10e90f 100755
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -722,9 +722,6 @@
<!-- Color of link text (URLs). -->
<attr name="textColorLink" format="reference|color" />
- <!-- Height of a line of text. -->
- <attr name="textLineHeight" format="dimension" />
-
<!-- Indicates that the content of a non-editable TextView can be selected.
Default value is false. EditText content is always selectable. -->
<attr name="textIsSelectable" format="boolean" />
@@ -2429,8 +2426,6 @@
<attr name="textColorHint" />
<!-- Color of the links. -->
<attr name="textColorLink" />
- <!-- Height of a single line of text. -->
- <attr name="textLineHeight" />
</declare-styleable>
<declare-styleable name="TextSwitcher">
</declare-styleable>
@@ -2672,10 +2667,7 @@
<attr name="textEditPasteWindowLayout" />
<!-- Variation of textEditPasteWindowLayout displayed when the clipboard is empty. -->
<attr name="textEditNoPasteWindowLayout" />
-
- <!-- Height of a line of text. -->
- <attr name="textLineHeight" />
- <!-- Indicates that a non-editable text can be selected. -->
+ <!-- Indicates that the content of a non-editable text can be selected. -->
<attr name="textIsSelectable" />
<!-- A specific background drawable used by multi-line EditText only. -->
<attr name="multilineBackground" format="reference"/>
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index dcc88f0..3a5b238 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -1358,7 +1358,6 @@
<public type="attr" name="loopViews" />
<public type="attr" name="dialogTheme" />
<public type="attr" name="alertDialogTheme" />
- <public type="attr" name="textLineHeight" />
<public type="attr" name="dividerVertical" />
<public type="attr" name="homeAsUpIndicator" />
<public type="attr" name="enterFadeDuration" />