Cosmetic changes to MessageView
- Don't show the progress icon unless loading from network - Don't show the content until LoadAttachmentsTask finishes - Disable the fade-in animation. It causes some weird positioning issue with the GL accelerated webview. - Use WebView.clearView() to clear its content. - Use the "normal" layout mode, otherwise WebView won't use its entire width - Don't hide the vertical scrollbar Bug 3287729 Bug 3225068 Bug 3295761 Bug 3304396 Change-Id: Ic4b8baac99b71dc0da58021849ff7c1dbd6dbe55
This commit is contained in:
parent
9c4458dcd7
commit
ab1674a2d6
|
@ -61,8 +61,6 @@ import android.util.Patterns;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.animation.Animation;
|
|
||||||
import android.view.animation.AnimationUtils;
|
|
||||||
import android.webkit.WebSettings;
|
import android.webkit.WebSettings;
|
||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
import android.webkit.WebViewClient;
|
import android.webkit.WebViewClient;
|
||||||
|
@ -128,9 +126,6 @@ public abstract class MessageViewFragmentBase extends Fragment implements View.O
|
||||||
private View mAttachmentsScroll;
|
private View mAttachmentsScroll;
|
||||||
private View mInviteScroll;
|
private View mInviteScroll;
|
||||||
|
|
||||||
private Animation mFadeInAnimation;
|
|
||||||
private Animation mFadeOutAnimation;
|
|
||||||
|
|
||||||
private long mAccountId = -1;
|
private long mAccountId = -1;
|
||||||
private long mMessageId = -1;
|
private long mMessageId = -1;
|
||||||
private Message mMessage;
|
private Message mMessage;
|
||||||
|
@ -286,9 +281,6 @@ public abstract class MessageViewFragmentBase extends Fragment implements View.O
|
||||||
|
|
||||||
mController = Controller.getInstance(mContext);
|
mController = Controller.getInstance(mContext);
|
||||||
mMessageObserver = new MessageObserver(new Handler(), mContext);
|
mMessageObserver = new MessageObserver(new Handler(), mContext);
|
||||||
|
|
||||||
mFadeInAnimation = AnimationUtils.loadAnimation(mContext, android.R.anim.fade_in);
|
|
||||||
mFadeOutAnimation = AnimationUtils.loadAnimation(mContext, android.R.anim.fade_out);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -335,7 +327,6 @@ public abstract class MessageViewFragmentBase extends Fragment implements View.O
|
||||||
mAttachmentsScroll = view.findViewById(R.id.attachments_scroll);
|
mAttachmentsScroll = view.findViewById(R.id.attachments_scroll);
|
||||||
mInviteScroll = view.findViewById(R.id.invite_scroll);
|
mInviteScroll = view.findViewById(R.id.invite_scroll);
|
||||||
|
|
||||||
mMessageContentView.setVerticalScrollBarEnabled(false);
|
|
||||||
WebSettings webSettings = mMessageContentView.getSettings();
|
WebSettings webSettings = mMessageContentView.getSettings();
|
||||||
webSettings.setBlockNetworkLoads(true);
|
webSettings.setBlockNetworkLoads(true);
|
||||||
webSettings.setSupportZoom(true);
|
webSettings.setSupportZoom(true);
|
||||||
|
@ -488,33 +479,24 @@ public abstract class MessageViewFragmentBase extends Fragment implements View.O
|
||||||
* Show/hide the content. We hide all the content (except for the bottom buttons) when loading,
|
* Show/hide the content. We hide all the content (except for the bottom buttons) when loading,
|
||||||
* to avoid flicker.
|
* to avoid flicker.
|
||||||
*/
|
*/
|
||||||
private void showContent(boolean show) {
|
private void showContent(boolean showContent, boolean showProgressWhenHidden) {
|
||||||
if (mLoadingProgress == null) {
|
if (mLoadingProgress == null) {
|
||||||
// Phone UI doesn't have it yet.
|
// Phone UI doesn't have it yet.
|
||||||
// TODO Add loading_progress and main_panel to the phone layout too.
|
// TODO Add loading_progress and main_panel to the phone layout too.
|
||||||
} else {
|
} else {
|
||||||
mMainView.clearAnimation();
|
makeVisible(mMainView, showContent);
|
||||||
mLoadingProgress.clearAnimation();
|
makeVisible(mLoadingProgress, !showContent && showProgressWhenHidden);
|
||||||
makeVisible(mMainView, show);
|
|
||||||
makeVisible(mLoadingProgress, !show);
|
|
||||||
if (show) {
|
|
||||||
// When showing, fade it in. I'll look much smoother.
|
|
||||||
mMainView.startAnimation(mFadeInAnimation);
|
|
||||||
mLoadingProgress.startAnimation(mFadeOutAnimation);
|
|
||||||
} else {
|
|
||||||
// When hiding, don't fade it out, to hide flicker.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void resetView() {
|
protected void resetView() {
|
||||||
showContent(false);
|
showContent(false, false);
|
||||||
setCurrentTab(TAB_MESSAGE);
|
setCurrentTab(TAB_MESSAGE);
|
||||||
updateTabFlags(0);
|
updateTabFlags(0);
|
||||||
if (mMessageContentView != null) {
|
if (mMessageContentView != null) {
|
||||||
mMessageContentView.getSettings().setBlockNetworkLoads(true);
|
mMessageContentView.getSettings().setBlockNetworkLoads(true);
|
||||||
mMessageContentView.scrollTo(0, 0);
|
mMessageContentView.scrollTo(0, 0);
|
||||||
mMessageContentView.loadUrl("file:///android_asset/empty.html");
|
mMessageContentView.clearView();
|
||||||
|
|
||||||
// Dynamic configuration of WebView
|
// Dynamic configuration of WebView
|
||||||
WebSettings.TextSize textZoom;
|
WebSettings.TextSize textZoom;
|
||||||
|
@ -526,7 +508,9 @@ public abstract class MessageViewFragmentBase extends Fragment implements View.O
|
||||||
case Preferences.TEXT_ZOOM_HUGE: textZoom = WebSettings.TextSize.LARGEST; break;
|
case Preferences.TEXT_ZOOM_HUGE: textZoom = WebSettings.TextSize.LARGEST; break;
|
||||||
default: textZoom = WebSettings.TextSize.NORMAL; break;
|
default: textZoom = WebSettings.TextSize.NORMAL; break;
|
||||||
}
|
}
|
||||||
mMessageContentView.getSettings().setTextSize(textZoom);
|
final WebSettings settings = mMessageContentView.getSettings();
|
||||||
|
settings.setTextSize(textZoom);
|
||||||
|
settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL);
|
||||||
}
|
}
|
||||||
mAttachmentsScroll.scrollTo(0, 0);
|
mAttachmentsScroll.scrollTo(0, 0);
|
||||||
mInviteScroll.scrollTo(0, 0);
|
mInviteScroll.scrollTo(0, 0);
|
||||||
|
@ -918,6 +902,7 @@ public abstract class MessageViewFragmentBase extends Fragment implements View.O
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (message == null) {
|
if (message == null) {
|
||||||
|
resetView();
|
||||||
mCallback.onMessageNotExists();
|
mCallback.onMessageNotExists();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1013,6 +998,7 @@ public abstract class MessageViewFragmentBase extends Fragment implements View.O
|
||||||
if (mErrorLoadingMessageBody) {
|
if (mErrorLoadingMessageBody) {
|
||||||
Utility.showToast(getActivity(), R.string.error_loading_message_body);
|
Utility.showToast(getActivity(), R.string.error_loading_message_body);
|
||||||
}
|
}
|
||||||
|
resetView();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
reloadUiFromBody(results[0], results[1]); // text, html
|
reloadUiFromBody(results[0], results[1]); // text, html
|
||||||
|
@ -1036,6 +1022,7 @@ public abstract class MessageViewFragmentBase extends Fragment implements View.O
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Attachment[] attachments) {
|
protected void onPostExecute(Attachment[] attachments) {
|
||||||
|
try {
|
||||||
if (isCancelled() || attachments == null) {
|
if (isCancelled() || attachments == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1063,6 +1050,9 @@ public abstract class MessageViewFragmentBase extends Fragment implements View.O
|
||||||
mMessageContentView.loadDataWithBaseURL("email://", mHtmlTextWebView,
|
mMessageContentView.loadDataWithBaseURL("email://", mHtmlTextWebView,
|
||||||
"text/html", "utf-8", null);
|
"text/html", "utf-8", null);
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
showContent(true, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1331,7 +1321,6 @@ public abstract class MessageViewFragmentBase extends Fragment implements View.O
|
||||||
mLoadAttachmentsTask.execute(mMessage.mId);
|
mLoadAttachmentsTask.execute(mMessage.mId);
|
||||||
|
|
||||||
mIsMessageLoadedForTest = true;
|
mIsMessageLoadedForTest = true;
|
||||||
showContent(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1385,7 +1374,8 @@ public abstract class MessageViewFragmentBase extends Fragment implements View.O
|
||||||
switch (progress) {
|
switch (progress) {
|
||||||
case 0:
|
case 0:
|
||||||
mCallback.onLoadMessageStarted();
|
mCallback.onLoadMessageStarted();
|
||||||
loadBodyContent("file:///android_asset/loading.html");
|
// Loading from network -- show the progress icon.
|
||||||
|
showContent(false, true);
|
||||||
break;
|
break;
|
||||||
case 100:
|
case 100:
|
||||||
mWaitForLoadMessageId = -1;
|
mWaitForLoadMessageId = -1;
|
||||||
|
@ -1404,13 +1394,7 @@ public abstract class MessageViewFragmentBase extends Fragment implements View.O
|
||||||
mWaitForLoadMessageId = -1;
|
mWaitForLoadMessageId = -1;
|
||||||
String error = mContext.getString(R.string.status_network_error);
|
String error = mContext.getString(R.string.status_network_error);
|
||||||
mCallback.onLoadMessageError(error);
|
mCallback.onLoadMessageError(error);
|
||||||
loadBodyContent("file:///android_asset/empty.html");
|
resetView();
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadBodyContent(String uri) {
|
|
||||||
if (mMessageContentView != null) {
|
|
||||||
mMessageContentView.loadUrl(uri);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue