Loading src/com/fsck/k9/K9.java +49 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ package com.fsck.k9; import java.io.File; import java.lang.reflect.Constructor; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; Loading @@ -22,6 +23,7 @@ import android.os.Environment; import android.os.Handler; import android.os.Looper; import android.text.format.Time; import android.text.style.AbsoluteSizeSpan; import android.util.Log; import com.fsck.k9.activity.MessageCompose; Loading Loading @@ -66,6 +68,10 @@ public class K9 extends Application { */ private static List<ApplicationAware> observers = new ArrayList<ApplicationAware>(); /** * @see K9#createAbsoluteSizeSpan(int) */ private static Constructor<AbsoluteSizeSpan> sAbsoluteSizeSpanConstructor; public enum BACKGROUND_OPS { WHEN_CHECKED, ALWAYS, NEVER, WHEN_CHECKED_AUTO_SYNC Loading Loading @@ -992,4 +998,47 @@ public class K9 extends Application { K9.mAttachmentDefaultPath = attachmentDefaultPath; } /** * Creates an {@link AbsoluteSizeSpan} object. * * <p> * Android versions prior to 2.0 don't support the constructor with two parameters * ({@link AbsoluteSizeSpan#AbsoluteSizeSpan(int, boolean)}). So we have to perform some * reflection magic to dynamically load the new constructor on devices that support it. * For devices with old Android versions we just use the size as pixels (instead of dip). * </p> * * @param size This is used as the {@code size} parameter for the AbsoluteSizeSpan constructor. * @return a AbsoluteSizeSpan object with the specified text size. */ public static AbsoluteSizeSpan createAbsoluteSizeSpan(int size) { if (Integer.parseInt(android.os.Build.VERSION.SDK) < 5) { // For Android 1.5/1.6 simply use the constructor with only the size parameter. // Yes, that will most likely look wrong! return new AbsoluteSizeSpan(size); } if (sAbsoluteSizeSpanConstructor == null) { try { sAbsoluteSizeSpanConstructor = AbsoluteSizeSpan.class.getConstructor(int.class, boolean.class); } catch (Exception e) { Log.e(K9.LOG_TAG, "Couldn't get the AbsoluteSizeSpan(int, boolean) constructor", e); // Fallback return new AbsoluteSizeSpan(size); } } AbsoluteSizeSpan result; try { result = sAbsoluteSizeSpanConstructor.newInstance(size, true); } catch (Exception e) { Log.e(K9.LOG_TAG, "Couldn't call the AbsoluteSizeSpan(int, boolean) constructor", e); // Fallback result = new AbsoluteSizeSpan(size); } return result; } } src/com/fsck/k9/activity/MessageList.java +2 −3 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ import android.graphics.drawable.Drawable; import android.os.Bundle; import android.text.Spannable; import android.text.SpannableStringBuilder; import android.text.style.AbsoluteSizeSpan; import android.text.style.ForegroundColorSpan; import android.text.style.StyleSpan; import android.util.Log; Loading Loading @@ -2166,7 +2165,7 @@ public class MessageList 0, noSender.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); str.setSpan(new AbsoluteSizeSpan(mFontSizes.getMessageListSender(), true), str.setSpan(K9.createAbsoluteSizeSpan(mFontSizes.getMessageListSender()), 0, noSender.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); Loading Loading @@ -2255,7 +2254,7 @@ public class MessageList 0, message.sender.length() + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); str.setSpan(new AbsoluteSizeSpan(mFontSizes.getMessageListSender(), true), str.setSpan(K9.createAbsoluteSizeSpan(mFontSizes.getMessageListSender()), 0, message.sender.length() + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); Loading Loading
src/com/fsck/k9/K9.java +49 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ package com.fsck.k9; import java.io.File; import java.lang.reflect.Constructor; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; Loading @@ -22,6 +23,7 @@ import android.os.Environment; import android.os.Handler; import android.os.Looper; import android.text.format.Time; import android.text.style.AbsoluteSizeSpan; import android.util.Log; import com.fsck.k9.activity.MessageCompose; Loading Loading @@ -66,6 +68,10 @@ public class K9 extends Application { */ private static List<ApplicationAware> observers = new ArrayList<ApplicationAware>(); /** * @see K9#createAbsoluteSizeSpan(int) */ private static Constructor<AbsoluteSizeSpan> sAbsoluteSizeSpanConstructor; public enum BACKGROUND_OPS { WHEN_CHECKED, ALWAYS, NEVER, WHEN_CHECKED_AUTO_SYNC Loading Loading @@ -992,4 +998,47 @@ public class K9 extends Application { K9.mAttachmentDefaultPath = attachmentDefaultPath; } /** * Creates an {@link AbsoluteSizeSpan} object. * * <p> * Android versions prior to 2.0 don't support the constructor with two parameters * ({@link AbsoluteSizeSpan#AbsoluteSizeSpan(int, boolean)}). So we have to perform some * reflection magic to dynamically load the new constructor on devices that support it. * For devices with old Android versions we just use the size as pixels (instead of dip). * </p> * * @param size This is used as the {@code size} parameter for the AbsoluteSizeSpan constructor. * @return a AbsoluteSizeSpan object with the specified text size. */ public static AbsoluteSizeSpan createAbsoluteSizeSpan(int size) { if (Integer.parseInt(android.os.Build.VERSION.SDK) < 5) { // For Android 1.5/1.6 simply use the constructor with only the size parameter. // Yes, that will most likely look wrong! return new AbsoluteSizeSpan(size); } if (sAbsoluteSizeSpanConstructor == null) { try { sAbsoluteSizeSpanConstructor = AbsoluteSizeSpan.class.getConstructor(int.class, boolean.class); } catch (Exception e) { Log.e(K9.LOG_TAG, "Couldn't get the AbsoluteSizeSpan(int, boolean) constructor", e); // Fallback return new AbsoluteSizeSpan(size); } } AbsoluteSizeSpan result; try { result = sAbsoluteSizeSpanConstructor.newInstance(size, true); } catch (Exception e) { Log.e(K9.LOG_TAG, "Couldn't call the AbsoluteSizeSpan(int, boolean) constructor", e); // Fallback result = new AbsoluteSizeSpan(size); } return result; } }
src/com/fsck/k9/activity/MessageList.java +2 −3 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ import android.graphics.drawable.Drawable; import android.os.Bundle; import android.text.Spannable; import android.text.SpannableStringBuilder; import android.text.style.AbsoluteSizeSpan; import android.text.style.ForegroundColorSpan; import android.text.style.StyleSpan; import android.util.Log; Loading Loading @@ -2166,7 +2165,7 @@ public class MessageList 0, noSender.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); str.setSpan(new AbsoluteSizeSpan(mFontSizes.getMessageListSender(), true), str.setSpan(K9.createAbsoluteSizeSpan(mFontSizes.getMessageListSender()), 0, noSender.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); Loading Loading @@ -2255,7 +2254,7 @@ public class MessageList 0, message.sender.length() + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); str.setSpan(new AbsoluteSizeSpan(mFontSizes.getMessageListSender(), true), str.setSpan(K9.createAbsoluteSizeSpan(mFontSizes.getMessageListSender()), 0, message.sender.length() + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); Loading