diff --git a/res/values/dimensions.xml b/res/values/dimensions.xml index 0ca5fec46..b80270ad4 100644 --- a/res/values/dimensions.xml +++ b/res/values/dimensions.xml @@ -18,8 +18,8 @@ 100sp - 70dip - 70dip + 70sp + 70sp 35dip 6dip 4dip diff --git a/src/com/android/email/activity/EmailActivity.java b/src/com/android/email/activity/EmailActivity.java index c3e4341cc..0cd842907 100644 --- a/src/com/android/email/activity/EmailActivity.java +++ b/src/com/android/email/activity/EmailActivity.java @@ -19,6 +19,7 @@ package com.android.email.activity; import android.app.Activity; import android.app.Fragment; import android.content.Intent; +import android.content.res.Configuration; import android.os.Bundle; import android.os.Handler; import android.text.TextUtils; @@ -63,6 +64,8 @@ public class EmailActivity extends Activity implements View.OnClickListener, Fra /** Loader IDs starting with this is safe to use from ActionBarController. */ static final int ACTION_BAR_CONTROLLER_LOADER_ID_BASE = 200; + private static float sLastFontScale = -1; + private Controller mController; private Controller.Result mControllerResult; @@ -161,6 +164,15 @@ public class EmailActivity extends Activity implements View.OnClickListener, Fra protected void onCreate(Bundle savedInstanceState) { if (Logging.DEBUG_LIFECYCLE && Email.DEBUG) Log.d(Logging.LOG_TAG, this + " onCreate"); + float fontScale = getResources().getConfiguration().fontScale; + if (sLastFontScale != -1 && sLastFontScale != fontScale) { + // If the font scale has been initialized, and has been detected to be different than + // the last time the Activity ran, it means the user changed the font while no + // Email Activity was running - we still need to purge static information though. + onFontScaleChangeDetected(); + } + sLastFontScale = fontScale; + // UIController is used in onPrepareOptionsMenu(), which can be called from within // super.onCreate(), so we need to initialize it here. initUIController(); @@ -399,4 +411,11 @@ public class EmailActivity extends Activity implements View.OnClickListener, Fra } } } + + /** + * Handle a change to the system font size. This invalidates some static caches we have. + */ + private void onFontScaleChangeDetected() { + MessageListItem.resetDrawingCaches(); + } } diff --git a/src/com/android/email/activity/MessageListItem.java b/src/com/android/email/activity/MessageListItem.java index fa4708d43..3a9b93101 100644 --- a/src/com/android/email/activity/MessageListItem.java +++ b/src/com/android/email/activity/MessageListItem.java @@ -183,6 +183,16 @@ public class MessageListItem extends View { } } + /** + * Invalidate all drawing caches associated with drawing message list items. + * This is an expensive operation, and should be done rarely, such as when system font size + * changes occurs. + */ + public static void resetDrawingCaches() { + MessageListItemCoordinates.resetCaches(); + sInit = false; + } + /** * Sets message subject and snippet safely, ensuring the cache is invalidated. */ diff --git a/src/com/android/email/activity/MessageListItemCoordinates.java b/src/com/android/email/activity/MessageListItemCoordinates.java index b4531935c..97ab04854 100644 --- a/src/com/android/email/activity/MessageListItemCoordinates.java +++ b/src/com/android/email/activity/MessageListItemCoordinates.java @@ -224,6 +224,13 @@ public class MessageListItemCoordinates { return SUBJECT_LENGTHS[mode]; } + /** + * Reset the caches associated with the coordinate layouts. + */ + static void resetCaches() { + mCache.clear(); + } + /** * Returns coordinates for elements inside a conversation header view given * the view width.