am 4105ac05: scale AppWidgetManager values by density
* commit '4105ac05cd936955ca1bef3758e34438b6987d30':
scale AppWidgetManager values by density
diff --git a/src/com/android/alarmclock/WidgetUtils.java b/src/com/android/alarmclock/WidgetUtils.java
index d4a6b70..ad1bd63 100644
--- a/src/com/android/alarmclock/WidgetUtils.java
+++ b/src/com/android/alarmclock/WidgetUtils.java
@@ -44,12 +44,14 @@
options = widgetManager.getAppWidgetOptions(id);
}
if (options != null) {
- int minWidth = options.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH);
+ float minWidth = options.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH);
if (minWidth == 0) {
// No data , do no scaling
return 1f;
}
Resources res = context.getResources();
+ float density = res.getDisplayMetrics().density;
+ minWidth *= density;
float ratio = minWidth / res.getDimension(R.dimen.def_digital_widget_width);
return (ratio > 1) ? 1 : ratio;
}
@@ -84,9 +86,11 @@
// no data to make the calculation, show the list anyway
return true;
}
- int minHeight = options.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT);
- int neededSize = (int) context.getResources().
- getDimension(R.dimen.digital_widget_list_min_height);
+ float minHeight = options.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT);
+ Resources res = context.getResources();
+ float density = res.getDisplayMetrics().density;
+ minHeight *= density;
+ int neededSize = (int) res.getDimension(R.dimen.digital_widget_list_min_height);
return (minHeight > neededSize);
}
}