am e51b40c4: am 36a6b2e9: am 68898395: Merge "Tweak layouts for digital clock widget." into jb-mr1.1-dev
* commit 'e51b40c48405c7a8cc2afbd84165edc95a09ec49':
Tweak layouts for digital clock widget.
diff --git a/res/values-sw600dp-land/dimens.xml b/res/values-sw600dp-land/dimens.xml
index 8ecb43d..311d495 100644
--- a/res/values-sw600dp-land/dimens.xml
+++ b/res/values-sw600dp-land/dimens.xml
@@ -55,5 +55,7 @@
<dimen name="glowpadview_margin_right">-64dip</dimen>
- <dimen name="def_digital_widget_height">200dip</dimen>
+ <dimen name="min_digital_widget_resize_width">370dip</dimen>
+ <dimen name="min_digital_widget_height">200dip</dimen>
+ <dimen name="digital_widget_list_min_height">200dip</dimen>
</resources>
diff --git a/res/values-sw600dp/dimens.xml b/res/values-sw600dp/dimens.xml
index 544aa66..d14e6c6 100644
--- a/res/values-sw600dp/dimens.xml
+++ b/res/values-sw600dp/dimens.xml
@@ -84,11 +84,11 @@
<dimen name="glowpadview_margin_bottom">0dip</dimen>
- <dimen name="min_digital_widget_width">300dip</dimen>
+ <dimen name="min_digital_widget_width">450dip</dimen>
<dimen name="min_digital_widget_height">120dip</dimen>
- <dimen name="min_digital_widget_resize_width">200dip</dimen>
+ <dimen name="min_digital_widget_resize_width">450dip</dimen>
<dimen name="min_digital_widget_resize_height">120dip</dimen>
<dimen name="def_digital_widget_width">200dip</dimen>
- <dimen name="def_digital_widget_height">190dip</dimen>
+ <dimen name="digital_widget_list_min_height">190dip</dimen>
</resources>
diff --git a/res/values-sw720dp-land/dimens.xml b/res/values-sw720dp-land/dimens.xml
index de69a5d..bee4607 100644
--- a/res/values-sw720dp-land/dimens.xml
+++ b/res/values-sw720dp-land/dimens.xml
@@ -22,6 +22,7 @@
<dimen name="glowpadview_margin_right">48dip</dimen>
<dimen name="alarm_alert_clock_padding_left">128dp</dimen>
- <dimen name="def_digital_widget_height">150dip</dimen>
+ <dimen name="digital_widget_list_min_height">150dip</dimen>
+ <dimen name="min_digital_widget_resize_width">370dip</dimen>
</resources>
diff --git a/res/values-sw720dp/dimens.xml b/res/values-sw720dp/dimens.xml
index 51ffaf0..142ff79 100644
--- a/res/values-sw720dp/dimens.xml
+++ b/res/values-sw720dp/dimens.xml
@@ -18,5 +18,5 @@
<!-- These resources are around just to allow their values to be customized
for different hardware and product builds. -->
<resources>
- <dimen name="def_digital_widget_height">145dip</dimen>
+ <dimen name="digital_widget_list_min_height">100dip</dimen>
</resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 212dbd3..3c9ffe5 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -153,9 +153,10 @@
<dimen name="min_digital_widget_width">160dip</dimen>
<dimen name="min_digital_widget_height">70dip</dimen>
<dimen name="min_digital_widget_resize_width">160dip</dimen>
- <dimen name="min_digital_widget_resize_height">35dip</dimen>
+ <dimen name="min_digital_widget_resize_height">70dip</dimen>
<dimen name="def_digital_widget_width">160dip</dimen>
- <dimen name="def_digital_widget_height">70dip</dimen>
+ <dimen name="def_digital_widget_height">130dip</dimen>
+ <dimen name="digital_widget_list_min_height">70dip</dimen>
<dimen name="digital_widget_list_margin_top">12dip</dimen>
</resources>
diff --git a/src/com/android/alarmclock/DigitalWidgetViewsFactory.java b/src/com/android/alarmclock/DigitalWidgetViewsFactory.java
index d6d2b5d..29fee52 100644
--- a/src/com/android/alarmclock/DigitalWidgetViewsFactory.java
+++ b/src/com/android/alarmclock/DigitalWidgetViewsFactory.java
@@ -50,8 +50,10 @@
private boolean mReloadCitiesList = true;
private boolean mReloadCitiesDb = true;
private float mFontScale = 1;
+ private float mListScale = 1;
private PendingIntent mQuarterlyIntent;
+
// An adapter to provide the view for the list of cities in the world clock.
private class RemoteWorldClockAdapter extends WorldClockAdapter {
private final float mFontSize;
@@ -97,8 +99,9 @@
now.setTimeZone(TimeZone.getTimeZone(cityTZ));
int cityDayOfWeek = now.get(Calendar.DAY_OF_WEEK);
- clock.setTextViewTextSize(clockId1, TypedValue.COMPLEX_UNIT_PX, mFontSize * mFontScale);
- clock.setTextViewTextSize(clockId2, TypedValue.COMPLEX_UNIT_PX, mFontSize * mFontScale);
+ float scale = Math.min(mFontScale, mListScale);
+ clock.setTextViewTextSize(clockId1, TypedValue.COMPLEX_UNIT_PX, mFontSize * scale);
+ clock.setTextViewTextSize(clockId2, TypedValue.COMPLEX_UNIT_PX, mFontSize * scale);
clock.setString(clockId1, "setTimeZone", cityObj.mTimeZone);
clock.setString(clockId2, "setTimeZone", cityObj.mTimeZone);
@@ -205,6 +208,8 @@
}
mFontScale = WidgetUtils.getScaleRatio(mContext, null, mId);
+ mListScale = WidgetUtils.getHeightScaleRatio(mContext, null, mId);
+
}
@Override
diff --git a/src/com/android/alarmclock/WidgetUtils.java b/src/com/android/alarmclock/WidgetUtils.java
index 757e062..d4a6b70 100644
--- a/src/com/android/alarmclock/WidgetUtils.java
+++ b/src/com/android/alarmclock/WidgetUtils.java
@@ -56,6 +56,26 @@
return 1;
}
+ // Calculate the scale factor of the fonts in the list of the widget using the widget height
+ public static float getHeightScaleRatio(Context context, Bundle options, int id) {
+ AppWidgetManager widgetManager = AppWidgetManager.getInstance(context);
+ if (options == null) {
+ options = widgetManager.getAppWidgetOptions(id);
+ }
+ if (options != null) {
+ int minHeight = options.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT);
+ if (minHeight == 0) {
+ // No data , do no scaling
+ return 1f;
+ }
+ Resources res = context.getResources();
+ float ratio = minHeight / res.getDimension(R.dimen.def_digital_widget_height);
+ return (ratio > 1) ? 1 : ratio;
+ }
+ return 1;
+ }
+
+
// Decide if to show the list of world clock.
// Check to see if the widget size is big enough, if it is return true.
public static boolean showList(Context context, int id, float scale) {
@@ -66,7 +86,7 @@
}
int minHeight = options.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT);
int neededSize = (int) context.getResources().
- getDimension(R.dimen.def_digital_widget_height);
+ getDimension(R.dimen.digital_widget_list_min_height);
return (minHeight > neededSize);
}
}