Merge change 5906 into donut
* changes: resolve complex value in application context instead of system context.
This commit is contained in:
@@ -21,7 +21,9 @@ import android.content.Context;
|
|||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
|
import android.util.DisplayMetrics;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.util.TypedValue;
|
||||||
import android.widget.RemoteViews;
|
import android.widget.RemoteViews;
|
||||||
|
|
||||||
import com.android.internal.appwidget.IAppWidgetService;
|
import com.android.internal.appwidget.IAppWidgetService;
|
||||||
@@ -187,6 +189,8 @@ public class AppWidgetManager {
|
|||||||
|
|
||||||
Context mContext;
|
Context mContext;
|
||||||
|
|
||||||
|
private DisplayMetrics mDisplayMetrics;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the AppWidgetManager instance to use for the supplied {@link android.content.Context
|
* Get the AppWidgetManager instance to use for the supplied {@link android.content.Context
|
||||||
* Context} object.
|
* Context} object.
|
||||||
@@ -213,6 +217,7 @@ public class AppWidgetManager {
|
|||||||
|
|
||||||
private AppWidgetManager(Context context) {
|
private AppWidgetManager(Context context) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
|
mDisplayMetrics = context.getResources().getDisplayMetrics();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -292,7 +297,15 @@ public class AppWidgetManager {
|
|||||||
*/
|
*/
|
||||||
public AppWidgetProviderInfo getAppWidgetInfo(int appWidgetId) {
|
public AppWidgetProviderInfo getAppWidgetInfo(int appWidgetId) {
|
||||||
try {
|
try {
|
||||||
return sService.getAppWidgetInfo(appWidgetId);
|
AppWidgetProviderInfo info = sService.getAppWidgetInfo(appWidgetId);
|
||||||
|
if (info != null) {
|
||||||
|
// Converting complex to dp.
|
||||||
|
info.minWidth =
|
||||||
|
TypedValue.complexToDimensionPixelSize(info.minWidth, mDisplayMetrics);
|
||||||
|
info.minHeight =
|
||||||
|
TypedValue.complexToDimensionPixelSize(info.minHeight, mDisplayMetrics);
|
||||||
|
}
|
||||||
|
return info;
|
||||||
}
|
}
|
||||||
catch (RemoteException e) {
|
catch (RemoteException e) {
|
||||||
throw new RuntimeException("system server dead?", e);
|
throw new RuntimeException("system server dead?", e);
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ import android.os.RemoteException;
|
|||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.util.TypedValue;
|
||||||
import android.util.Xml;
|
import android.util.Xml;
|
||||||
import android.widget.RemoteViews;
|
import android.widget.RemoteViews;
|
||||||
|
|
||||||
@@ -695,10 +696,16 @@ class AppWidgetService extends IAppWidgetService.Stub
|
|||||||
|
|
||||||
TypedArray sa = mContext.getResources().obtainAttributes(attrs,
|
TypedArray sa = mContext.getResources().obtainAttributes(attrs,
|
||||||
com.android.internal.R.styleable.AppWidgetProviderInfo);
|
com.android.internal.R.styleable.AppWidgetProviderInfo);
|
||||||
info.minWidth = sa.getDimensionPixelSize(
|
|
||||||
com.android.internal.R.styleable.AppWidgetProviderInfo_minWidth, 0);
|
// These dimensions has to be resolved in the application's context.
|
||||||
info.minHeight = sa.getDimensionPixelSize(
|
// We simply send back the raw complex data, which will be
|
||||||
com.android.internal.R.styleable.AppWidgetProviderInfo_minHeight, 0);
|
// converted to dp in {@link AppWidgetManager#getAppWidgetInfo}.
|
||||||
|
TypedValue value = sa.peekValue(
|
||||||
|
com.android.internal.R.styleable.AppWidgetProviderInfo_minWidth);
|
||||||
|
info.minWidth = value != null ? value.data : 0;
|
||||||
|
value = sa.peekValue(com.android.internal.R.styleable.AppWidgetProviderInfo_minHeight);
|
||||||
|
info.minHeight = value != null ? value.data : 0;
|
||||||
|
|
||||||
info.updatePeriodMillis = sa.getInt(
|
info.updatePeriodMillis = sa.getInt(
|
||||||
com.android.internal.R.styleable.AppWidgetProviderInfo_updatePeriodMillis, 0);
|
com.android.internal.R.styleable.AppWidgetProviderInfo_updatePeriodMillis, 0);
|
||||||
info.initialLayout = sa.getResourceId(
|
info.initialLayout = sa.getResourceId(
|
||||||
|
|||||||
Reference in New Issue
Block a user