Respect system font size in message list.
- This makes dimensions according to scaled font sizes, and also resets the activity properly (invalidating drawing caches) when that font size happens. Bug: 5287961 Change-Id: I04cf117b027befd6a065edeadf95187f62fffc8a
This commit is contained in:
parent
e3b56df151
commit
28e496daef
|
@ -18,8 +18,8 @@
|
|||
|
||||
<resources>
|
||||
<dimen name="button_minWidth">100sp</dimen>
|
||||
<dimen name="message_list_item_height_wide">70dip</dimen>
|
||||
<dimen name="message_list_item_height_normal">70dip</dimen>
|
||||
<dimen name="message_list_item_height_wide">70sp</dimen>
|
||||
<dimen name="message_list_item_height_normal">70sp</dimen>
|
||||
<dimen name="message_list_item_color_tip_width">35dip</dimen>
|
||||
<dimen name="message_list_item_color_tip_height">6dip</dimen>
|
||||
<dimen name="message_list_badge_margin">4dip</dimen>
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue