Commit 80facdc7 by Kim Peace

Fixed to display native progressbar in chat webview

parent 691a442a
Subproject commit 9ecee0d315a72826655fb964234d2271134482b2
Subproject commit caecb139064df9e006ead24b3c6d0272d1b86baf
......@@ -4,6 +4,7 @@ import android.app.Activity;
import android.app.AlertDialog;
import android.app.DownloadManager;
import android.app.PictureInPictureParams;
import android.app.ProgressDialog;
import android.content.BroadcastReceiver;
import android.content.ContentValues;
import android.content.Context;
......@@ -15,6 +16,7 @@ import android.content.res.Configuration;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.PixelFormat;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
......@@ -85,6 +87,7 @@ import jp.agentec.abook.abv.ui.common.util.AlertDialogUtil;
import jp.agentec.abook.abv.ui.home.helper.ActivityHandlingHelper;
import jp.agentec.abook.abv.ui.home.helper.VideoEncoder;
import jp.agentec.abook.abv.ui.home.view.ChatWebView;
import jp.agentec.abook.abv.ui.home.view.ChatWebViewDelegate;
import jp.agentec.abook.abv.ui.home.view.FullscreenableChromeClient;
import jp.agentec.abook.abv.ui.viewer.activity.CommunicationWebViewActivity;
import jp.agentec.adf.util.StringUtil;
......@@ -96,8 +99,9 @@ import static org.chromium.net.NetError.ERR_FAILED;
* Created by AIS-NB-048 on 2019/07/31.
*/
public class ChatWebViewActivity extends CommunicationWebViewActivity {
public class ChatWebViewActivity extends CommunicationWebViewActivity implements ChatWebViewDelegate {
private ChatWebView mChatWebView;
private ProgressDialog chatProgressDialog;
private String chatWebviewUrl;
private final String TAG = "ChatWebViewActivity";
......@@ -120,6 +124,7 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity {
private boolean needHostAlert = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......@@ -163,6 +168,7 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity {
private void setupChatWebView() {
mChatWebView = new ChatWebView(ChatWebViewActivity.this);
mChatWebView.configue(chatData);
mChatWebView.delegate = this;
}
private void setupDefaultChatWebViewURL() {
......@@ -561,7 +567,7 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity {
.getSystemService(Context.CONNECTIVITY_SERVICE);
if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(intent.getAction())) {
mChatWebView.dismissLoadingIndicator();
mChatWebView.hideLoadingIndicator();
}
if (intent.getAction().equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
......@@ -875,7 +881,6 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity {
}
}
// 共通資料画面表示
public void showCommonContent() {
Intent intent = new Intent();
......@@ -884,6 +889,52 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity {
startActivity(intent, NaviConsts.Left);
}
private void showChatWebViewProgressPopup() {
if (chatProgressDialog == null) {
chatProgressDialog = new ProgressDialog(this);
chatProgressDialog.setMessage(getResources().getString(R.string.progress));
chatProgressDialog.setIndeterminate(true);
chatProgressDialog.setCancelable(false);
if (chatProgressDialog.getWindow() != null) {
chatProgressDialog.getWindow().setFormat(PixelFormat.TRANSPARENT);
}
}
if (chatProgressDialog != null && !chatProgressDialog.isShowing() && !isFinishing()) {
chatProgressDialog.show();
}
}
private void closeChatWebViewProgressPopup() {
if (chatProgressDialog != null && chatProgressDialog.isShowing()) {
try {
chatProgressDialog.dismiss();
} catch (Exception e) {
Logger.e(TAG, "closeProgressPopup error. ", e); // ignore
}
}
}
@Override
public void chatWebViewNeedsShowProgressBar() {
runOnUiThread(new Runnable() {
@Override
public void run() {
showChatWebViewProgressPopup();
}
});
}
@Override
public void chatWebViewNeedsDismissProgressBar() {
runOnUiThread(new Runnable() {
@Override
public void run() {
closeChatWebViewProgressPopup();
}
});
}
public class NetworkTask extends AsyncTask<Void, Void, Bitmap> {
private String url;
......@@ -1292,4 +1343,5 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity {
// 最後のチャットのルーム
PreferenceUtil.putUserPref(getApplicationContext(), AppDefType.UserPrefKey.CHAT_LAST_ROOMID, roomId);
}
}
......@@ -23,6 +23,7 @@ public class ChatWebView extends WebView {
private final ChatWebViewActivity chatActivity;
private ChatData chatData;
public ChatWebViewDelegate delegate;
public ChatWebView(Context context) {
super(context);
......@@ -534,6 +535,21 @@ public class ChatWebView extends WebView {
return chatData.getRoomInfo();
}
@JavascriptInterface
public void showLoadingIndicator() {
if (delegate != null) {
delegate.chatWebViewNeedsShowProgressBar();
}
}
@JavascriptInterface
public void hideLoadingIndicator() {
if (delegate != null) {
delegate.chatWebViewNeedsDismissProgressBar();
}
}
public void loadChatViewUrl(final String urlString) {
post(new Runnable() {
@Override
......@@ -577,14 +593,6 @@ public class ChatWebView extends WebView {
loadUrl("javascript:penOff();");
}
public void showLoadingIndicator() {
loadChatViewUrl("javascript:Common.showLoadingIndicator();");
}
public void dismissLoadingIndicator() {
loadUrl("javascript:Common.dismissLoadingIndicator()");
}
public void refreshForOffline() {
loadUrl("javascript:Common.refreshForOffline();");
}
......
package jp.agentec.abook.abv.ui.home.view;
public interface ChatWebViewDelegate {
void chatWebViewNeedsShowProgressBar();
void chatWebViewNeedsDismissProgressBar();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment