Commit b47469e9 by Jeong Gilmo

- 1.1.300_chat について修正

parent 3f8e9780
...@@ -791,6 +791,12 @@ public class AcmsClient implements AcmsClientResponseListener { ...@@ -791,6 +791,12 @@ public class AcmsClient implements AcmsClientResponseListener {
String apiUrl = AcmsApis.getApiUrl(env.acmsAddress, urlPath, methodName); String apiUrl = AcmsApis.getApiUrl(env.acmsAddress, urlPath, methodName);
//AISDevelop
if(apiUrl.equals("https://abookcheckdemo.abook.bz/acms/aisinfo/abvapi/push/"))
{
apiUrl = "http://192.168.1.6:8080/acms/aisinfo/chatapi/push/";
}
HttpResponse response = send(apiUrl, methodName, param); HttpResponse response = send(apiUrl, methodName, param);
// 最終アクセス時間更新 // 最終アクセス時間更新
......
...@@ -5,6 +5,7 @@ import com.sun.org.apache.bcel.internal.generic.PUSH; ...@@ -5,6 +5,7 @@ import com.sun.org.apache.bcel.internal.generic.PUSH;
import jp.agentec.abook.abv.bl.acms.client.AcmsClient; import jp.agentec.abook.abv.bl.acms.client.AcmsClient;
import jp.agentec.abook.abv.bl.common.exception.AcmsException; import jp.agentec.abook.abv.bl.common.exception.AcmsException;
import jp.agentec.abook.abv.bl.common.exception.JSONValidationException; import jp.agentec.abook.abv.bl.common.exception.JSONValidationException;
import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.bl.common.util.JsonUtil; import jp.agentec.abook.abv.bl.common.util.JsonUtil;
import jp.agentec.abook.abv.bl.dto.PushMessageDto; import jp.agentec.abook.abv.bl.dto.PushMessageDto;
import jp.agentec.adf.util.DateTimeFormat; import jp.agentec.adf.util.DateTimeFormat;
...@@ -50,9 +51,12 @@ public class ChatPushDataJSON extends AcmsCommonJSON { ...@@ -50,9 +51,12 @@ public class ChatPushDataJSON extends AcmsCommonJSON {
break; break;
} }
PushMessageDto pushMessageDto = new PushMessageDto(); PushMessageDto pushMessageDto = new PushMessageDto();
//pushMessageDto.pushMessageId = pushMessagetJsonArray.getJSONObject(k).getLong(PushMessageId); String tempDate = DateTimeUtil.toString(DateTimeUtil.toDate(pushMessagetJsonArray.getJSONObject(k).getString(PushSendDate), DateTimeFormat.yyyyMMddHHmmss_hyphen), DateTimeFormat.yyyyMMddHHmmssSSS_none);
pushMessageDto.pushMessageId = Long.valueOf(11); Logger.d("messageId","messageId : " + pushMessagetJsonArray.getJSONObject(k).getString(PushSendDate));
pushMessageDto.operationId = Long.valueOf(1111); Logger.d("oerationId","oerationId : " + pushMessagetJsonArray.getJSONObject(k).getString(PushSendDate)+1);
Logger.d("date","date : " + tempDate);
pushMessageDto.pushMessageId = Long.valueOf(tempDate);
pushMessageDto.operationId = Long.valueOf(tempDate+1);
pushMessageDto.pushSendLoginId = pushMessagetJsonArray.getJSONObject(k).getString(PushSendLoginId); pushMessageDto.pushSendLoginId = pushMessagetJsonArray.getJSONObject(k).getString(PushSendLoginId);
pushMessageDto.pushSendDate = DateTimeUtil.toDate(pushMessagetJsonArray.getJSONObject(k).getString(PushSendDate), DateTimeFormat.yyyyMMddHHmmss_hyphen); pushMessageDto.pushSendDate = DateTimeUtil.toDate(pushMessagetJsonArray.getJSONObject(k).getString(PushSendDate), DateTimeFormat.yyyyMMddHHmmss_hyphen);
pushMessageDto.roomId = pushMessagetJsonArray.getJSONObject(k).getLong(RoomId); pushMessageDto.roomId = pushMessagetJsonArray.getJSONObject(k).getLong(RoomId);
......
package jp.agentec.abook.abv.bl.data.dao; package jp.agentec.abook.abv.bl.data.dao;
import java.util.Date;
import java.util.List; import java.util.List;
import jp.agentec.abook.abv.bl.common.db.Cursor; import jp.agentec.abook.abv.bl.common.db.Cursor;
...@@ -122,4 +123,19 @@ public class PushMessageDao extends AbstractDao { ...@@ -122,4 +123,19 @@ public class PushMessageDao extends AbstractDao {
Logger.v(TAG, "sql=%s", sql); Logger.v(TAG, "sql=%s", sql);
return rawQueryGetDto(sql.toString(), args, PushMessageDto.class); return rawQueryGetDto(sql.toString(), args, PushMessageDto.class);
} }
public PushMessageDto selectChat(long pushMessageId, long pushOperstoinId, Date pushSendDate) {
String[] args = new String[] { "" + pushMessageId, "" + pushOperstoinId, "" + pushSendDate };
StringBuffer sql = new StringBuffer();
sql.append(" SELECT tpm.push_message_id, tpm.operation_id, tpm.push_send_login_id, tpm.push_send_date, tpm.push_message, tpm.reading_flg, top.operation_name, tpm.room_id, tpm.room_name ");
sql.append(" FROM t_push_message AS tpm ");
sql.append(" INNER JOIN t_operation AS top ");
sql.append(" ON tpm.operation_id = top.operation_id ");
sql.append(" WHERE tpm.push_message_id = ? ");
sql.append(" AND tpm.operation_id = ? ");
sql.append(" AND tpm.push_send_date = ? " );
Logger.v(TAG, "sql=%s", sql);
return rawQueryGetDto(sql.toString(), args, PushMessageDto.class);
}
} }
...@@ -119,8 +119,11 @@ public class OperationLogic extends AbstractLogic { ...@@ -119,8 +119,11 @@ public class OperationLogic extends AbstractLogic {
ChatPushDataJSON chatPushJson = AcmsClient.getInstance(cache.getUrlPath(), networkAdapter).getChatPushList(param); ChatPushDataJSON chatPushJson = AcmsClient.getInstance(cache.getUrlPath(), networkAdapter).getChatPushList(param);
for ( PushMessageDto dto : chatPushJson.pushMessageList) { for ( PushMessageDto dto : chatPushJson.pushMessageList) {
PushMessageDto dtoTemp = mPushMessageDao.selectChat(dto.pushMessageId, dto.operationId, dto.pushSendDate);
if (dtoTemp == null) {
mPushMessageDao.insert(dto); mPushMessageDao.insert(dto);
} }
}
for (OperationDto serverOperationDto : serverOperations) { for (OperationDto serverOperationDto : serverOperations) {
// 登録フラグ // 登録フラグ
......
package jp.agentec.abook.abv.bl.logic; package jp.agentec.abook.abv.bl.logic;
import java.io.IOException; import java.io.IOException;
import java.util.Date;
import java.util.List; import java.util.List;
import jp.agentec.abook.abv.bl.acms.client.AcmsClient; import jp.agentec.abook.abv.bl.acms.client.AcmsClient;
...@@ -62,4 +63,8 @@ public class PushMessageLogic extends AbstractLogic { ...@@ -62,4 +63,8 @@ public class PushMessageLogic extends AbstractLogic {
public void updateReadingFlg(long pushMessageId) { public void updateReadingFlg(long pushMessageId) {
mPushMessageDao.updateReadingFlg(pushMessageId); mPushMessageDao.updateReadingFlg(pushMessageId);
} }
public PushMessageDto getPushChatMessage(long pushMessageId, long pushOperationId, Date pushSendDate) {
return mPushMessageDao.selectChat(pushMessageId, pushOperationId, pushSendDate);
}
} }
...@@ -41,7 +41,8 @@ ...@@ -41,7 +41,8 @@
android:icon="@drawable/app_icon" android:icon="@drawable/app_icon"
android:label="@string/app_name" android:label="@string/app_name"
android:theme="@style/ABook" android:theme="@style/ABook"
android:largeHeap="true" > android:largeHeap="true"
android:usesCleartextTraffic="true">
<service android:name="jp.agentec.abook.abv.cl.push.ABVFcmListenerService"> <service android:name="jp.agentec.abook.abv.cl.push.ABVFcmListenerService">
<intent-filter> <intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"></action> <action android:name="com.google.firebase.MESSAGING_EVENT"></action>
...@@ -210,5 +211,6 @@ ...@@ -210,5 +211,6 @@
<activity android:name="jp.agentec.abook.abv.ui.viewer.activity.CheckOZDViewActivity" android:configChanges="orientation|screenSize"/> <activity android:name="jp.agentec.abook.abv.ui.viewer.activity.CheckOZDViewActivity" android:configChanges="orientation|screenSize"/>
<activity android:name="jp.agentec.abook.abv.ui.home.activity.ChatWebviewActivity" />
</application> </application>
</manifest> </manifest>
\ No newline at end of file
...@@ -36,7 +36,7 @@ function formatDate(date) { ...@@ -36,7 +36,7 @@ function formatDate(date) {
const TODAY = REFERENCE.clone().startOf('day'); const TODAY = REFERENCE.clone().startOf('day');
const YESTERDAY = REFERENCE.clone().subtract(1, 'days').startOf('day'); const YESTERDAY = REFERENCE.clone().subtract(1, 'days').startOf('day');
let createdAt = moment(date); let createdAt = moment(date);
const createdAtDay = createdAt.isSame(TODAY, 'd') ? "Today" : createdAt.isSame(YESTERDAY, 'd') ? "Yesterday" : createdAt.format('MMM DD'); const createdAtDay = createdAt.format('MMM DD');
const createdAtTime = createdAt.format('HH:mm'); const createdAtTime = createdAt.format('HH:mm');
if(createdAt.isSame(TODAY, 'd')){ if(createdAt.isSame(TODAY, 'd')){
createdAt = createdAtTime; createdAt = createdAtTime;
...@@ -131,7 +131,7 @@ socket.on('refreshRoomList', function(rooms, activeRoomId = null){ ...@@ -131,7 +131,7 @@ socket.on('refreshRoomList', function(rooms, activeRoomId = null){
// チャットルーム名を変更する // チャットルーム名を変更する
jQuery('.titleRoomName').text(room.roomName).data('roomName', room.roomName); jQuery('.titleRoomName').text(room.roomName).data('roomName', room.roomName);
android.saveVisitRoomInfo(room.roomId, room.roomName, room.roomId);//javascriptInterface android.saveVisitRoomInfo(room.roomId, room.roomName);
}); });
} }
}); });
...@@ -165,7 +165,7 @@ jQuery('#roomDeleteButton').on('click', function(e){ ...@@ -165,7 +165,7 @@ jQuery('#roomDeleteButton').on('click', function(e){
let roomName = jQuery(this).data('roomName'); let roomName = jQuery(this).data('roomName');
socket.emit('joinRoom', roomId, roomName, function () { socket.emit('joinRoom', roomId, roomName, function () {
jQuery('#messages').html(''); jQuery('#messages').html('');
jQuery('.titleRoomName').text(roomName).data('roomName', roomName); jQuery('.titleRoomName').text(roomId).data('roomName', roomName);
jQuery('#pills-chat-tab').tab('show'); jQuery('#pills-chat-tab').tab('show');
}); });
}); });
...@@ -182,10 +182,11 @@ jQuery('#roomDeleteButton').on('click', function(e){ ...@@ -182,10 +182,11 @@ jQuery('#roomDeleteButton').on('click', function(e){
// チャットルームの削除アイコンにクリックイベントを与える // チャットルームの削除アイコンにクリックイベントを与える
jQuery('.deleteBox').off('click'); jQuery('.deleteBox').off('click');
jQuery('.deleteBox').on('click', function(e){ jQuery('.deleteBox').on('click', function(e){
if(window.confirm('Do you want to leave this room?')){ if(window.confirm('Do you want to leave this room?')) {
// 現在接続されているチャットルームを離れるとメッセージテップを初期化する // 現在接続されているチャットルームを離れるとメッセージテップを初期化する
if(jQuery(this).data('activeRoom')){ if(jQuery(this).data('activeRoom')){
jQuery('#messages').html(''); jQuery('#messages').html('');
android.saveVisitRoomInfo('', '');
} }
// チャットルームから退場する // チャットルームから退場する
socket.emit('exitRoom', jQuery(this).data('roomId')); socket.emit('exitRoom', jQuery(this).data('roomId'));
...@@ -424,6 +425,7 @@ jQuery('#chatKeyword').on('keypress', function(event) { ...@@ -424,6 +425,7 @@ jQuery('#chatKeyword').on('keypress', function(event) {
// Exit Room // Exit Room
jQuery('#exitRoom').on('click', function(event){ jQuery('#exitRoom').on('click', function(event){
android.saveVisitRoomInfo('', '');
socket.emit('exitRoom'); socket.emit('exitRoom');
jQuery('#dismiss').click(); jQuery('#dismiss').click();
}); });
...@@ -465,7 +467,7 @@ socket.on('updateUserList', function(users, onlineUsers) { ...@@ -465,7 +467,7 @@ socket.on('updateUserList', function(users, onlineUsers) {
let li = jQuery('<li/>'); let li = jQuery('<li/>');
let a = jQuery('<a/>').text(user); let a = jQuery('<a/>').text(user);
if(onlineUsers.includes(user)){ if(onlineUsers.includes(user)){
// 접속해있는 유저라면 온라인 뱃지를 달아준다. // 接続されているユーザにマークを付ける。
a.append(jQuery('<span/>',{class:'badge badge-success'}).text('online')); a.append(jQuery('<span/>',{class:'badge badge-success'}).text('online'));
} }
li.append(a); li.append(a);
...@@ -566,6 +568,7 @@ socket.on('refreshUserListInGroup', function(users, isInvite){ ...@@ -566,6 +568,7 @@ socket.on('refreshUserListInGroup', function(users, isInvite){
socket.emit('createNewRoom', userIdList, newRoomName, function(newRoomId) { socket.emit('createNewRoom', userIdList, newRoomName, function(newRoomId) {
socket.emit('joinRoom', newRoomId, newRoomName, function () { socket.emit('joinRoom', newRoomId, newRoomName, function () {
jQuery('#messages').html(''); jQuery('#messages').html('');
android.saveVisitRoomInfo(newRoomId, newRoomName);
}); });
jQuery('.titleRoomName').text(newRoomName).data('roomName', newRoomName); jQuery('.titleRoomName').text(newRoomName).data('roomName', newRoomName);
jQuery('#pills-chat-tab').tab('show'); jQuery('#pills-chat-tab').tab('show');
......
...@@ -17,7 +17,7 @@ dependencies { ...@@ -17,7 +17,7 @@ dependencies {
} }
android { android {
compileSdkVersion 21 compileSdkVersion 23
buildToolsVersion '27.0.3' buildToolsVersion '27.0.3'
defaultConfig { defaultConfig {
......
...@@ -1409,6 +1409,6 @@ ...@@ -1409,6 +1409,6 @@
<string name="msg_error_edit_page_open">編集画面の表示に失敗しました。</string> <string name="msg_error_edit_page_open">編集画面の表示に失敗しました。</string>
<!-- Chat --> <!-- Chat -->
<string name="chat">Chat</string> <string name="chat">チャット</string>
</resources> </resources>
...@@ -1417,6 +1417,6 @@ ...@@ -1417,6 +1417,6 @@
<string name="msg_error_edit_page_open">편집창을 여는데 실패했습니다.</string> <string name="msg_error_edit_page_open">편집창을 여는데 실패했습니다.</string>
<!-- Chat --> <!-- Chat -->
<string name="chat">Chat</string> <string name="chat">채팅</string>
</resources> </resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent" android:orientation="vertical"
android:layout_height="match_parent"> style="@style/Theme_CustomProgressDialog"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background" >
<RelativeLayout
android:id="@+id/toolbar_layout"
style="@style/OperationSearchToolBar"
android:layout_height="50dp"
android:layout_width="match_parent">
<TextView
android:id="@+id/title"
style="@style/DialogToolBarTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/chat"
android:textColor="@color/edt_text"
android:textSize="18sp" />
<ImageButton
android:id="@+id/chat_close_btn"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="top|right"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp"
android:layout_alignParentRight="true"
android:background="@color/operation_search_button_color"
android:clickable="true"
android:src="@drawable/btn_close"
android:tint="@color/background" />
</RelativeLayout>
<WebView <WebView
android:id="@+id/chatWebview2" android:id="@+id/chatWebview2"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" /> android:layout_height="match_parent" />
</LinearLayout> </LinearLayout>
\ No newline at end of file
...@@ -67,6 +67,9 @@ public interface AppDefType { ...@@ -67,6 +67,9 @@ public interface AppDefType {
String OPERATION_GROUP_MASERT_ID = "operation_group_master_id"; // 作業種別のID String OPERATION_GROUP_MASERT_ID = "operation_group_master_id"; // 作業種別のID
String APERTURE_MASTER_DATA_FETCH_DATE = "apertureMasterDataFetchDate"; // 絞り検索マスタデータのFetchDate String APERTURE_MASTER_DATA_FETCH_DATE = "apertureMasterDataFetchDate"; // 絞り検索マスタデータのFetchDate
String CHAT_LAST_ROOMNAME = "chatLastRoom"; // 最後のルーム名
String CHAT_LAST_ROOMID = "chatLastRoomId"; // 最後のルームID
} }
/** /**
......
package jp.agentec.abook.abv.ui.home.activity; package jp.agentec.abook.abv.ui.home.activity;
import android.app.AlertDialog;
import android.app.DownloadManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.os.Environment;
import android.os.Looper;
import android.security.NetworkSecurityPolicy; import android.security.NetworkSecurityPolicy;
import android.view.KeyEvent;
import android.view.View; import android.view.View;
import android.view.Window; import android.view.Window;
import android.webkit.DownloadListener; import android.webkit.DownloadListener;
import android.webkit.JavascriptInterface; import android.webkit.JavascriptInterface;
import android.webkit.JsResult;
import android.webkit.ValueCallback; import android.webkit.ValueCallback;
import android.webkit.WebChromeClient; import android.webkit.WebChromeClient;
import android.webkit.WebView; import android.webkit.WebView;
import android.webkit.WebViewClient; import android.webkit.WebViewClient;
import android.widget.ImageButton;
import java.io.File; import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.util.List;
import jp.agentec.abook.abv.bl.common.constant.ABookKeys; import jp.agentec.abook.abv.bl.common.constant.ABookKeys;
import jp.agentec.abook.abv.bl.common.log.Logger; import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.bl.data.ABVDataCache;
import jp.agentec.abook.abv.bl.dto.PushMessageDto;
import jp.agentec.abook.abv.cl.util.PreferenceUtil;
import jp.agentec.abook.abv.launcher.android.R; import jp.agentec.abook.abv.launcher.android.R;
import jp.agentec.abook.abv.ui.common.activity.ABVUIActivity; import jp.agentec.abook.abv.ui.common.activity.ABVUIActivity;
import jp.agentec.abook.abv.ui.common.appinfo.AppDefType;
import jp.agentec.abook.abv.ui.common.constant.ErrorCode; import jp.agentec.abook.abv.ui.common.constant.ErrorCode;
import jp.agentec.abook.abv.ui.common.constant.ErrorMessage; import jp.agentec.abook.abv.ui.common.constant.ErrorMessage;
import jp.agentec.abook.abv.ui.viewer.activity.ParentWebViewActivity; import jp.agentec.abook.abv.ui.viewer.activity.ParentWebViewActivity;
...@@ -44,8 +61,18 @@ public class ChatWebviewActivity extends ParentWebViewActivity { ...@@ -44,8 +61,18 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
chatWebviewUrl = intent.getStringExtra("chatWebviewUrl"); chatWebviewUrl = intent.getStringExtra("chatWebviewUrl");
String sid = intent.getStringExtra("sid"); String sid = intent.getStringExtra("sid");
Long roomId = intent.getLongExtra("roomId", 0); Long roomId = intent.getLongExtra("roomId", 0);
String loginId = intent.getStringExtra("loginId");
String roomName = intent.getStringExtra("roomName"); String roomName = intent.getStringExtra("roomName");
// チャットViewのクローズボタン
final ImageButton imageButton = findViewById(R.id.chat_close_btn);
imageButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
}
});
mChatWebView = findViewById(R.id.chatWebview2); mChatWebView = findViewById(R.id.chatWebview2);
mChatWebView.setOverScrollMode(View.OVER_SCROLL_NEVER); //オーバースクロールしない。 mChatWebView.setOverScrollMode(View.OVER_SCROLL_NEVER); //オーバースクロールしない。
mChatWebView.setVerticalScrollBarEnabled(false); //スクロールバーを消す。 mChatWebView.setVerticalScrollBarEnabled(false); //スクロールバーを消す。
...@@ -53,16 +80,24 @@ public class ChatWebviewActivity extends ParentWebViewActivity { ...@@ -53,16 +80,24 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
mChatWebView.getSettings().setJavaScriptEnabled(true); //Javascriptを有効にする。 mChatWebView.getSettings().setJavaScriptEnabled(true); //Javascriptを有効にする。
mChatWebView.setWebContentsDebuggingEnabled(true); mChatWebView.setWebContentsDebuggingEnabled(true);
// 最後のチャットのルーム名
String lastRoomName = PreferenceUtil.getUserPref(getApplicationContext(), AppDefType.UserPrefKey.CHAT_LAST_ROOMNAME, "");
// 最後のチャットのルーム
String lastRoomId = PreferenceUtil.getUserPref(getApplicationContext(), AppDefType.UserPrefKey.CHAT_LAST_ROOMID, "");
mChatWebView.addJavascriptInterface(jsInf, "android"); mChatWebView.addJavascriptInterface(jsInf, "android");
//ページをロード //ページをロード
if(roomId != 0 && roomName != null) { if(roomId != 0 && roomName != null) { // by push message
mChatWebView.loadUrl(chatWebviewUrl + "?sid=" + sid + "&roomId=" + roomId + "&roomName=" + roomName); mChatWebView.loadUrl(chatWebviewUrl + "?sid=" + sid + "&roomId=" + roomId + "&roomName=" + roomName + "&loginId=" + loginId);
}
else { // Chat
if (lastRoomName.length() > 0 && lastRoomId.length() > 0) {
mChatWebView.loadUrl(chatWebviewUrl + "?sid=" + sid + "&roomId=" + lastRoomId + "&roomName=" + lastRoomName + "&loginId=" + loginId);
} else {
mChatWebView.loadUrl(chatWebviewUrl + "?sid=" + sid + "&loginId=" + loginId);
} }
else {
mChatWebView.loadUrl(chatWebviewUrl + "?sid=" + sid);
} }
mChatWebView.setWebChromeClient(new WebChromeClient() { mChatWebView.setWebChromeClient(new WebChromeClient() {
@Override @Override
public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, FileChooserParams fileChooserParams) { public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, FileChooserParams fileChooserParams) {
...@@ -76,8 +111,52 @@ public class ChatWebviewActivity extends ParentWebViewActivity { ...@@ -76,8 +111,52 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
} }
return result; return result;
} }
});
// WebView内のAlert Dialogを処理する
@Override
public boolean onJsAlert(WebView view, String url, String message, final JsResult result) {
AlertDialog dialog = new AlertDialog.Builder(view.getContext()).
setTitle("YourAlertTitle").
setMessage(message).
setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
//do nothing
}
}).create();
dialog.show();
result.confirm();
return true;
}
// WebView内のConfirm Dialogを処理する
@Override
public boolean onJsConfirm(WebView view, String url, String message, final JsResult result) {
new AlertDialog.Builder(view.getContext())
// .setTitle("App Titler")
.setMessage(message)
.setPositiveButton(android.R.string.ok,
new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int which)
{
result.confirm();
}
})
.setNegativeButton(android.R.string.cancel,
new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int which)
{
result.cancel();
}
})
.create()
.show();
return true;
}
});
mChatWebView.setDownloadListener(new DownloadListener() { mChatWebView.setDownloadListener(new DownloadListener() {
@Override @Override
...@@ -89,6 +168,43 @@ public class ChatWebviewActivity extends ParentWebViewActivity { ...@@ -89,6 +168,43 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
startActivity(i); startActivity(i);
} }
}); });
mChatWebView.setWebViewClient(new WebViewClient() {
@Override
public void onReceivedError(WebView view, int errorCode,
String description, String failingUrl) {
Logger.d("WEB_VIEW_TEST", "error code:" + errorCode + " - " + description);
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
Logger.d("url", "url : " + url);
// イメージをダウンロードする(png, jpg, jpeg)
if (url.toLowerCase().endsWith(".png") || url.toLowerCase().endsWith(".jpg") || url.toLowerCase().endsWith(".jpeg")) {
DownloadManager mdDownloadManager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
DownloadManager.Request request = new DownloadManager.Request(
Uri.parse(url));
File destinationFile = new File(
Environment.getExternalStorageDirectory(),
getFileName(url));
request.setDescription("Downloading ...");
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
request.setDestinationUri(Uri.fromFile(destinationFile));
mdDownloadManager.enqueue(request);
} else { // その他のファイルはurlのみ確認
Logger.d("download ", "download URL :" + url);
}
return true;
}
});
}
// 保存するファイルをjpgに固定する
public String getFileName(String url) {
String filenameWithoutExtension = "";
filenameWithoutExtension = String.valueOf(System.currentTimeMillis()
+ ".jpg");
return filenameWithoutExtension;
} }
@Override @Override
...@@ -142,7 +258,10 @@ public class ChatWebviewActivity extends ParentWebViewActivity { ...@@ -142,7 +258,10 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
public void saveVisitRoomInfo(String roomId, String roomName) { public void saveVisitRoomInfo(String roomId, String roomName) {
System.out.println("roomName : " + roomName); System.out.println("roomName : " + roomName);
System.out.println("roomId : " + roomId); System.out.println("roomId : " + roomId);
// 最後のチャットのルーム名
PreferenceUtil.putUserPref(getApplicationContext(), AppDefType.UserPrefKey.CHAT_LAST_ROOMNAME, roomName);
// 最後のチャットのルーム
PreferenceUtil.putUserPref(getApplicationContext(), AppDefType.UserPrefKey.CHAT_LAST_ROOMID, roomId);
} }
} }
} }
...@@ -1416,8 +1416,14 @@ public class OperationListActivity extends ABVUIActivity { ...@@ -1416,8 +1416,14 @@ public class OperationListActivity extends ABVUIActivity {
ll_menuItem_chat.setOnClickListener(new View.OnClickListener() { ll_menuItem_chat.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
// チャット利用のはネットワークが繋がる時のみ
if (ABVEnvironment.getInstance().networkAdapter.isNetworkConnected()) {
ActivityHandlingHelper.getInstance().startChatWebviewActivity(); ActivityHandlingHelper.getInstance().startChatWebviewActivity();
mCommunicationMenuDialog.dismiss(); mCommunicationMenuDialog.dismiss();
} else {
ABVToastUtil.showMakeText(OperationListActivity.this, R.string.request_network_connection, Toast.LENGTH_SHORT);
return;
}
} }
}); });
...@@ -1483,7 +1489,9 @@ public class OperationListActivity extends ABVUIActivity { ...@@ -1483,7 +1489,9 @@ public class OperationListActivity extends ABVUIActivity {
public void onDetailView(final PushMessageDto dto) { public void onDetailView(final PushMessageDto dto) {
if(dto.roomName != null && dto.roomId != 0) if(dto.roomName != null && dto.roomId != 0)
{ {
mPushMessageLogic.updateReadingFlg(dto.pushMessageId);
ActivityHandlingHelper.getInstance().startChatWebviewActivityWithPushMessage(dto); ActivityHandlingHelper.getInstance().startChatWebviewActivityWithPushMessage(dto);
mPushMessageListDialog.dismiss();
} else { } else {
showPushMessageDetailView(dto); showPushMessageDetailView(dto);
} }
......
...@@ -1550,6 +1550,8 @@ public class ActivityHandlingHelper extends ABookHelper implements RemoteObserve ...@@ -1550,6 +1550,8 @@ public class ActivityHandlingHelper extends ABookHelper implements RemoteObserve
intent.putExtra("chatWebviewUrl","file:///android_asset/chatPrototype/public/newstart.html"); intent.putExtra("chatWebviewUrl","file:///android_asset/chatPrototype/public/newstart.html");
String sid = ABVDataCache.getInstance().getMemberInfo().sid; String sid = ABVDataCache.getInstance().getMemberInfo().sid;
intent.putExtra("sid", sid); intent.putExtra("sid", sid);
String loginId = ABVDataCache.getInstance().getMemberInfo().loginId;
intent.putExtra("loginId", loginId);
if(dto != null) if(dto != null)
{ {
intent.putExtra("roomId",dto.roomId); intent.putExtra("roomId",dto.roomId);
...@@ -1561,6 +1563,7 @@ public class ActivityHandlingHelper extends ABookHelper implements RemoteObserve ...@@ -1561,6 +1563,7 @@ public class ActivityHandlingHelper extends ABookHelper implements RemoteObserve
activity.startActivity(intent); activity.startActivity(intent);
} }
} }
//チャットに入る //チャットに入る
public void startChatWebviewActivity() { public void startChatWebviewActivity() {
String className = ChatWebviewActivity.class.getName(); String className = ChatWebviewActivity.class.getName();
...@@ -1569,6 +1572,8 @@ public class ActivityHandlingHelper extends ABookHelper implements RemoteObserve ...@@ -1569,6 +1572,8 @@ public class ActivityHandlingHelper extends ABookHelper implements RemoteObserve
intent.putExtra("chatWebviewUrl","file:///android_asset/chatPrototype/public/newstart.html"); intent.putExtra("chatWebviewUrl","file:///android_asset/chatPrototype/public/newstart.html");
String sid = ABVDataCache.getInstance().getMemberInfo().sid; String sid = ABVDataCache.getInstance().getMemberInfo().sid;
intent.putExtra("sid", sid); intent.putExtra("sid", sid);
String loginId = ABVDataCache.getInstance().getMemberInfo().loginId;
intent.putExtra("loginId", loginId);
intent.setClassName(mContext.getPackageName(), className); intent.setClassName(mContext.getPackageName(), className);
Activity activity = getCurrentActivity(); Activity activity = getCurrentActivity();
if (activity != null) { if (activity != null) {
......
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