diff --git a/src/com/android/email/Clock.java b/src/com/fsck/k9/Clock.java similarity index 97% rename from src/com/android/email/Clock.java rename to src/com/fsck/k9/Clock.java index a2b44bb9b..a07841144 100644 --- a/src/com/android/email/Clock.java +++ b/src/com/fsck/k9/Clock.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.email; +package com.fsck.k9; /** * A class provide the current time (like {@link System#currentTimeMillis()}). diff --git a/src/com/android/email/Throttle.java b/src/com/fsck/k9/Throttle.java similarity index 97% rename from src/com/android/email/Throttle.java rename to src/com/fsck/k9/Throttle.java index 9edddf141..6e6b2dcad 100644 --- a/src/com/android/email/Throttle.java +++ b/src/com/fsck/k9/Throttle.java @@ -14,9 +14,7 @@ * limitations under the License. */ -package com.android.email; - -import com.android.emailcommon.Logging; +package com.fsck.k9; import android.os.Handler; import android.util.Log; @@ -96,7 +94,7 @@ public class Throttle { } private void debugLog(String message) { - Log.d(Logging.LOG_TAG, "Throttle: [" + mName + "] " + message); + Log.d(K9.LOG_TAG, "Throttle: [" + mName + "] " + message); } private boolean isCallbackScheduled() { diff --git a/src/com/fsck/k9/helper/Utility.java b/src/com/fsck/k9/helper/Utility.java index b8eef469f..e09ae2159 100644 --- a/src/com/fsck/k9/helper/Utility.java +++ b/src/com/fsck/k9/helper/Utility.java @@ -8,6 +8,8 @@ import android.database.Cursor; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.os.Build; +import android.os.Handler; +import android.os.Looper; import android.text.Editable; import android.util.Log; import android.widget.EditText; @@ -65,6 +67,8 @@ public class Utility { private static final Pattern TAG_PATTERN = Pattern.compile("\\[[-_a-z0-9]+\\] ", Pattern.CASE_INSENSITIVE); + private static Handler sMainThreadHandler; + public static boolean arrayContains(Object[] a, Object o) { for (Object element : a) { if (element.equals(o)) { @@ -714,4 +718,16 @@ public class Utility { return newArray; } + + /** + * @return a {@link Handler} tied to the main thread. + */ + public static Handler getMainThreadHandler() { + if (sMainThreadHandler == null) { + // No need to synchronize -- it's okay to create an extra Handler, which will be used + // only once and then thrown away. + sMainThreadHandler = new Handler(Looper.getMainLooper()); + } + return sMainThreadHandler; + } } diff --git a/src/com/fsck/k9/view/MessageWebView.java b/src/com/fsck/k9/view/MessageWebView.java index 73cbbd334..e48220659 100644 --- a/src/com/fsck/k9/view/MessageWebView.java +++ b/src/com/fsck/k9/view/MessageWebView.java @@ -17,7 +17,7 @@ import com.fsck.k9.helper.HtmlConverter; import java.lang.reflect.Method; -public class MessageWebView extends WebView { +public class MessageWebView extends RigidWebView { /** diff --git a/src/com/android/email/view/RigidWebView.java b/src/com/fsck/k9/view/RigidWebView.java similarity index 90% rename from src/com/android/email/view/RigidWebView.java rename to src/com/fsck/k9/view/RigidWebView.java index 1b31c08f2..2031648b7 100644 --- a/src/com/android/email/view/RigidWebView.java +++ b/src/com/fsck/k9/view/RigidWebView.java @@ -15,18 +15,17 @@ */ -package com.android.email.view; +package com.fsck.k9.view; import android.content.Context; import android.util.AttributeSet; import android.util.Log; import android.webkit.WebView; -import com.android.email.Clock; -import com.android.email.Email; -import com.android.email.Throttle; -import com.android.emailcommon.Logging; -import com.android.emailcommon.utility.Utility; +import com.fsck.k9.Clock; +import com.fsck.k9.K9; +import com.fsck.k9.Throttle; +import com.fsck.k9.helper.Utility; /** * A custom WebView that is robust to rapid resize events in sequence. @@ -75,8 +74,8 @@ public class RigidWebView extends WebView { if (mIgnoreNext) { mIgnoreNext = false; if (recentlySized) { - if (Email.DEBUG) { - Log.w(Logging.LOG_TAG, "Supressing size change in RigidWebView"); + if (K9.DEBUG) { + Log.w(K9.LOG_TAG, "Supressing size change in RigidWebView"); } return; }