summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/java/android/appwidget/AppWidgetHostView.java55
-rw-r--r--core/java/android/bluetooth/BluetoothDevice.java38
-rw-r--r--core/res/res/values-sw600dp/dimens.xml6
-rw-r--r--core/res/res/values/public.xml1
4 files changed, 63 insertions, 37 deletions
diff --git a/core/java/android/appwidget/AppWidgetHostView.java b/core/java/android/appwidget/AppWidgetHostView.java
index 761c7eb..61a9dce 100644
--- a/core/java/android/appwidget/AppWidgetHostView.java
+++ b/core/java/android/appwidget/AppWidgetHostView.java
@@ -26,6 +26,7 @@ import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
+import android.graphics.Rect;
import android.os.Build;
import android.os.Parcel;
import android.os.Parcelable;
@@ -41,8 +42,8 @@ import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.FrameLayout;
import android.widget.RemoteViews;
-import android.widget.TextView;
import android.widget.RemoteViewsAdapter.RemoteAdapterConnectionCallback;
+import android.widget.TextView;
/**
* Provides the glue to show AppWidget views. This class offers automatic animation
@@ -106,7 +107,9 @@ public class AppWidgetHostView extends FrameLayout {
}
/**
- * Set the AppWidget that will be displayed by this view.
+ * Set the AppWidget that will be displayed by this view. This method also adds default padding
+ * to widgets, as described in {@link #getDefaultPaddingForWidget(Context, ComponentName, Rect)}
+ * and can be overridden in order to add custom padding.
*/
public void setAppWidget(int appWidgetId, AppWidgetProviderInfo info) {
mAppWidgetId = appWidgetId;
@@ -116,49 +119,57 @@ public class AppWidgetHostView extends FrameLayout {
// a widget, eg. for some widgets in safe mode.
if (info != null) {
// We add padding to the AppWidgetHostView if necessary
- Padding padding = getPaddingForWidget(info.provider);
+ Rect padding = getDefaultPaddingForWidget(mContext, info.provider, null);
setPadding(padding.left, padding.top, padding.right, padding.bottom);
}
}
- private static class Padding {
- int left = 0;
- int right = 0;
- int top = 0;
- int bottom = 0;
- }
-
/**
* As of ICE_CREAM_SANDWICH we are automatically adding padding to widgets targeting
* ICE_CREAM_SANDWICH and higher. The new widget design guidelines strongly recommend
* that widget developers do not add extra padding to their widgets. This will help
* achieve consistency among widgets.
+ *
+ * Note: this method is only needed by developers of AppWidgetHosts. The method is provided in
+ * order for the AppWidgetHost to account for the automatic padding when computing the number
+ * of cells to allocate to a particular widget.
+ *
+ * @param context the current context
+ * @param component the component name of the widget
+ * @param padding Rect in which to place the output, if null, a new Rect will be allocated and
+ * returned
+ * @return default padding for this widget
*/
- private Padding getPaddingForWidget(ComponentName component) {
- PackageManager packageManager = mContext.getPackageManager();
- Padding p = new Padding();
+ public static Rect getDefaultPaddingForWidget(Context context, ComponentName component,
+ Rect padding) {
+ PackageManager packageManager = context.getPackageManager();
ApplicationInfo appInfo;
+ if (padding == null) {
+ padding = new Rect(0, 0, 0, 0);
+ } else {
+ padding.set(0, 0, 0, 0);
+ }
+
try {
appInfo = packageManager.getApplicationInfo(component.getPackageName(), 0);
- } catch (Exception e) {
+ } catch (NameNotFoundException e) {
// if we can't find the package, return 0 padding
- return p;
+ return padding;
}
if (appInfo.targetSdkVersion >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
- Resources r = getResources();
- p.left = r.getDimensionPixelSize(com.android.internal.
+ Resources r = context.getResources();
+ padding.left = r.getDimensionPixelSize(com.android.internal.
R.dimen.default_app_widget_padding_left);
- p.right = r.getDimensionPixelSize(com.android.internal.
+ padding.right = r.getDimensionPixelSize(com.android.internal.
R.dimen.default_app_widget_padding_right);
- p.top = r.getDimensionPixelSize(com.android.internal.
+ padding.top = r.getDimensionPixelSize(com.android.internal.
R.dimen.default_app_widget_padding_top);
- p.bottom = r.getDimensionPixelSize(com.android.internal.
+ padding.bottom = r.getDimensionPixelSize(com.android.internal.
R.dimen.default_app_widget_padding_bottom);
}
-
- return p;
+ return padding;
}
public int getAppWidgetId() {
diff --git a/core/java/android/bluetooth/BluetoothDevice.java b/core/java/android/bluetooth/BluetoothDevice.java
index 4cb8220..0306521 100644
--- a/core/java/android/bluetooth/BluetoothDevice.java
+++ b/core/java/android/bluetooth/BluetoothDevice.java
@@ -247,13 +247,12 @@ public final class BluetoothDevice implements Parcelable {
* has been fetched. This intent is sent only when the UUIDs of the remote
* device are requested to be fetched using Service Discovery Protocol
* <p> Always contains the extra field {@link #EXTRA_DEVICE}
- * <p> Always contains the extra filed {@link #EXTRA_UUID}
+ * <p> Always contains the extra field {@link #EXTRA_UUID}
* <p>Requires {@link android.Manifest.permission#BLUETOOTH} to receive.
- * @hide
*/
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
public static final String ACTION_UUID =
- "android.bleutooth.device.action.UUID";
+ "android.bluetooth.device.action.UUID";
/**
* Broadcast Action: Indicates a failure to retrieve the name of a remote
@@ -451,7 +450,6 @@ public final class BluetoothDevice implements Parcelable {
* Used as an extra field in {@link #ACTION_UUID} intents,
* Contains the {@link android.os.ParcelUuid}s of the remote device which
* is a parcelable version of {@link UUID}.
- * @hide
*/
public static final String EXTRA_UUID = "android.bluetooth.device.extra.UUID";
@@ -770,7 +768,18 @@ public final class BluetoothDevice implements Parcelable {
return false;
}
- /** @hide */
+ /**
+ * Returns the supported features (UUIDs) of the remote device.
+ *
+ * <p>This method does not start a service discovery procedure to retrieve the UUIDs
+ * from the remote device. Instead, the local cached copy of the service
+ * UUIDs are returned.
+ * <p>Use {@link #fetchUuidsWithSdp} if fresh UUIDs are desired.
+ * <p>Requires {@link android.Manifest.permission#BLUETOOTH}.
+ *
+ * @return the supported features (UUIDs) of the remote device,
+ * or null on error
+ */
public ParcelUuid[] getUuids() {
try {
return sService.getRemoteUuids(mAddress);
@@ -779,18 +788,19 @@ public final class BluetoothDevice implements Parcelable {
}
/**
- * Perform a SDP query on the remote device to get the UUIDs
- * supported. This API is asynchronous and an Intent is sent,
- * with the UUIDs supported by the remote end. If there is an error
- * in getting the SDP records or if the process takes a long time,
- * an Intent is sent with the UUIDs that is currently present in the
- * cache. Clients should use the {@link #getUuids} to get UUIDs
- * is SDP is not to be performed.
+ * Perform a service discovery on the remote device to get the UUIDs supported.
+ *
+ * <p>This API is asynchronous and {@link #ACTION_UUID} intent is sent,
+ * with the UUIDs supported by the remote end. If there is an error
+ * in getting the SDP records or if the process takes a long time,
+ * {@link #ACTION_UUID} intent is sent with the UUIDs that is currently
+ * present in the cache. Clients should use the {@link #getUuids} to get UUIDs
+ * if service discovery is not to be performed.
+ * <p>Requires {@link android.Manifest.permission#BLUETOOTH}.
*
- * @return False if the sanity check fails, True if the process
+ * @return False if the sanity check fails, True if the process
* of initiating an ACL connection to the remote device
* was started.
- * @hide
*/
public boolean fetchUuidsWithSdp() {
try {
diff --git a/core/res/res/values-sw600dp/dimens.xml b/core/res/res/values-sw600dp/dimens.xml
index 551c1d8..5b488c0 100644
--- a/core/res/res/values-sw600dp/dimens.xml
+++ b/core/res/res/values-sw600dp/dimens.xml
@@ -60,6 +60,12 @@
<!-- Compensate for double margin : preference_screen_side_margin + 4 (frame background shadow) = -preference_screen_side_margin_negative -->
<dimen name="preference_screen_side_margin_negative">-4dp</dimen>
+ <!-- Default padding to apply to AppWidgetHostViews containing widgets targeting API level 14 and up. -->
+ <dimen name="default_app_widget_padding_left">12dp</dimen>
+ <dimen name="default_app_widget_padding_top">12dp</dimen>
+ <dimen name="default_app_widget_padding_right">4dp</dimen>
+ <dimen name="default_app_widget_padding_bottom">20dp</dimen>
+
<!-- Minimum width for an action button in the menu area of an action bar -->
<dimen name="action_button_min_width">64dip</dimen>
</resources>
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index 97d5afe..4d97ad2 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -1974,5 +1974,4 @@
<public type="color" name="holo_orange_dark" id="0x01060019" />
<public type="color" name="holo_purple" id="0x0106001a" />
<public type="color" name="holo_blue_bright" id="0x0106001b" />
-
</resources>