Commit 8c4ca5d8 by Kim Peace

Merge branch 'communication/refactoring/indicator' into 'communication/develop'

Fixed to display native progressbar in chat webview

See merge request !191
parents 691a442a 80facdc7
Subproject commit 9ecee0d315a72826655fb964234d2271134482b2 Subproject commit caecb139064df9e006ead24b3c6d0272d1b86baf
...@@ -4,6 +4,7 @@ import android.app.Activity; ...@@ -4,6 +4,7 @@ import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.DownloadManager; import android.app.DownloadManager;
import android.app.PictureInPictureParams; import android.app.PictureInPictureParams;
import android.app.ProgressDialog;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.ContentValues; import android.content.ContentValues;
import android.content.Context; import android.content.Context;
...@@ -15,6 +16,7 @@ import android.content.res.Configuration; ...@@ -15,6 +16,7 @@ import android.content.res.Configuration;
import android.database.Cursor; import android.database.Cursor;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
import android.graphics.PixelFormat;
import android.net.ConnectivityManager; import android.net.ConnectivityManager;
import android.net.NetworkInfo; import android.net.NetworkInfo;
import android.net.Uri; import android.net.Uri;
...@@ -85,6 +87,7 @@ import jp.agentec.abook.abv.ui.common.util.AlertDialogUtil; ...@@ -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.ActivityHandlingHelper;
import jp.agentec.abook.abv.ui.home.helper.VideoEncoder; 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.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.home.view.FullscreenableChromeClient;
import jp.agentec.abook.abv.ui.viewer.activity.CommunicationWebViewActivity; import jp.agentec.abook.abv.ui.viewer.activity.CommunicationWebViewActivity;
import jp.agentec.adf.util.StringUtil; import jp.agentec.adf.util.StringUtil;
...@@ -96,8 +99,9 @@ import static org.chromium.net.NetError.ERR_FAILED; ...@@ -96,8 +99,9 @@ import static org.chromium.net.NetError.ERR_FAILED;
* Created by AIS-NB-048 on 2019/07/31. * 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 ChatWebView mChatWebView;
private ProgressDialog chatProgressDialog;
private String chatWebviewUrl; private String chatWebviewUrl;
private final String TAG = "ChatWebViewActivity"; private final String TAG = "ChatWebViewActivity";
...@@ -120,6 +124,7 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity { ...@@ -120,6 +124,7 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity {
private boolean needHostAlert = false; private boolean needHostAlert = false;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
...@@ -163,6 +168,7 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity { ...@@ -163,6 +168,7 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity {
private void setupChatWebView() { private void setupChatWebView() {
mChatWebView = new ChatWebView(ChatWebViewActivity.this); mChatWebView = new ChatWebView(ChatWebViewActivity.this);
mChatWebView.configue(chatData); mChatWebView.configue(chatData);
mChatWebView.delegate = this;
} }
private void setupDefaultChatWebViewURL() { private void setupDefaultChatWebViewURL() {
...@@ -561,7 +567,7 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity { ...@@ -561,7 +567,7 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity {
.getSystemService(Context.CONNECTIVITY_SERVICE); .getSystemService(Context.CONNECTIVITY_SERVICE);
if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(intent.getAction())) { if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(intent.getAction())) {
mChatWebView.dismissLoadingIndicator(); mChatWebView.hideLoadingIndicator();
} }
if (intent.getAction().equals(ConnectivityManager.CONNECTIVITY_ACTION)) { if (intent.getAction().equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
...@@ -875,7 +881,6 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity { ...@@ -875,7 +881,6 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity {
} }
} }
// 共通資料画面表示 // 共通資料画面表示
public void showCommonContent() { public void showCommonContent() {
Intent intent = new Intent(); Intent intent = new Intent();
...@@ -884,6 +889,52 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity { ...@@ -884,6 +889,52 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity {
startActivity(intent, NaviConsts.Left); 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> { public class NetworkTask extends AsyncTask<Void, Void, Bitmap> {
private String url; private String url;
...@@ -1292,4 +1343,5 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity { ...@@ -1292,4 +1343,5 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity {
// 最後のチャットのルーム // 最後のチャットのルーム
PreferenceUtil.putUserPref(getApplicationContext(), AppDefType.UserPrefKey.CHAT_LAST_ROOMID, roomId); PreferenceUtil.putUserPref(getApplicationContext(), AppDefType.UserPrefKey.CHAT_LAST_ROOMID, roomId);
} }
} }
...@@ -23,6 +23,7 @@ public class ChatWebView extends WebView { ...@@ -23,6 +23,7 @@ public class ChatWebView extends WebView {
private final ChatWebViewActivity chatActivity; private final ChatWebViewActivity chatActivity;
private ChatData chatData; private ChatData chatData;
public ChatWebViewDelegate delegate;
public ChatWebView(Context context) { public ChatWebView(Context context) {
super(context); super(context);
...@@ -534,6 +535,21 @@ public class ChatWebView extends WebView { ...@@ -534,6 +535,21 @@ public class ChatWebView extends WebView {
return chatData.getRoomInfo(); 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) { public void loadChatViewUrl(final String urlString) {
post(new Runnable() { post(new Runnable() {
@Override @Override
...@@ -577,14 +593,6 @@ public class ChatWebView extends WebView { ...@@ -577,14 +593,6 @@ public class ChatWebView extends WebView {
loadUrl("javascript:penOff();"); loadUrl("javascript:penOff();");
} }
public void showLoadingIndicator() {
loadChatViewUrl("javascript:Common.showLoadingIndicator();");
}
public void dismissLoadingIndicator() {
loadUrl("javascript:Common.dismissLoadingIndicator()");
}
public void refreshForOffline() { public void refreshForOffline() {
loadUrl("javascript:Common.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