mirror of
https://github.com/moparisthebest/k-9
synced 2025-02-17 07:30:16 -05:00
Removed helper function to create AbsoluteSizeSpan objects
This commit is contained in:
parent
5eb2533bcb
commit
85f556e6c9
@ -2,7 +2,6 @@
|
||||
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;
|
||||
@ -23,7 +22,6 @@ 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;
|
||||
@ -68,11 +66,6 @@ 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
|
||||
}
|
||||
@ -1012,48 +1005,4 @@ public class K9 extends Application {
|
||||
public static void setAttachmentDefaultPath(String attachmentDefaultPath) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ 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;
|
||||
@ -2181,7 +2182,7 @@ public class MessageList
|
||||
0,
|
||||
noSender.length(),
|
||||
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
str.setSpan(K9.createAbsoluteSizeSpan(mFontSizes.getMessageListSender()),
|
||||
str.setSpan(new AbsoluteSizeSpan(mFontSizes.getMessageListSender(), true),
|
||||
0,
|
||||
noSender.length(),
|
||||
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
@ -2270,7 +2271,7 @@ public class MessageList
|
||||
0,
|
||||
message.sender.length() + 1,
|
||||
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
str.setSpan(K9.createAbsoluteSizeSpan(mFontSizes.getMessageListSender()),
|
||||
str.setSpan(new AbsoluteSizeSpan(mFontSizes.getMessageListSender(), true),
|
||||
0,
|
||||
message.sender.length() + 1,
|
||||
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
|
Loading…
Reference in New Issue
Block a user