Commit 097cf2c3 by yuichiro ogawa

標準フォームにて、Enterキー入力、もしくはIMEキーボードのフォーカス移動イベント発生時のハンドリング処理を追加

parent 961cafab
...@@ -184,17 +184,12 @@ ...@@ -184,17 +184,12 @@
</RelativeLayout> </RelativeLayout>
<FrameLayout <FrameLayout
android:id="@+id/frameWebView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_weight="1" android:layout_weight="1"
android:orientation="vertical" > android:orientation="vertical" >
<WebView
android:id="@+id/webView2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="0dp" />
<ProgressBar <ProgressBar
android:id="@+id/refresh_prog" android:id="@+id/refresh_prog"
style="?android:attr/progressBarStyleLarge" style="?android:attr/progressBarStyleLarge"
......
package jp.agentec.abook.abv.ui.Interface;
/**
* Created by ogawa-y on 2020/01/21.
*/
public interface KeyActionCallback {
void keyActionCallback();
}
...@@ -13,25 +13,21 @@ import android.view.Window; ...@@ -13,25 +13,21 @@ import android.view.Window;
import android.webkit.JavascriptInterface; import android.webkit.JavascriptInterface;
import android.webkit.ValueCallback; import android.webkit.ValueCallback;
import android.webkit.WebChromeClient; import android.webkit.WebChromeClient;
import android.webkit.WebResourceResponse;
import android.webkit.WebSettings; import android.webkit.WebSettings;
import android.webkit.WebSettings.PluginState; import android.webkit.WebSettings.PluginState;
import android.webkit.WebView; import android.webkit.WebView;
import android.webkit.WebViewClient; import android.webkit.WebViewClient;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener; import android.widget.AdapterView.OnItemClickListener;
import android.widget.FrameLayout;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.RelativeLayout; import android.widget.RelativeLayout;
import android.widget.Toast; import android.widget.Toast;
import org.apache.http.HttpResponse; import org.json.adf.JSONObject;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.Map; import java.util.Map;
import jp.agentec.abook.abv.bl.acms.client.json.content.ContentJSON; import jp.agentec.abook.abv.bl.acms.client.json.content.ContentJSON;
...@@ -41,27 +37,19 @@ import jp.agentec.abook.abv.bl.common.CommonExecutor; ...@@ -41,27 +37,19 @@ import jp.agentec.abook.abv.bl.common.CommonExecutor;
import jp.agentec.abook.abv.bl.common.Constant; import jp.agentec.abook.abv.bl.common.Constant;
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.dao.AbstractDao;
import jp.agentec.abook.abv.bl.data.dao.ContentDao;
import jp.agentec.abook.abv.bl.download.ContentDownloader; import jp.agentec.abook.abv.bl.download.ContentDownloader;
import jp.agentec.abook.abv.bl.download.ContentZipDownloadNotification; import jp.agentec.abook.abv.bl.download.ContentZipDownloadNotification;
import jp.agentec.abook.abv.bl.dto.ContentDto;
import jp.agentec.abook.abv.bl.logic.AbstractLogic;
import jp.agentec.abook.abv.bl.logic.ContractLogic;
import jp.agentec.abook.abv.cl.util.ContentLogUtil; import jp.agentec.abook.abv.cl.util.ContentLogUtil;
import jp.agentec.abook.abv.cl.util.LocationManagerUtil;
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.appinfo.AppDefType;
import jp.agentec.abook.abv.ui.common.appinfo.AppDefType.DefPrefKey;
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.common.util.ABVToastUtil; import jp.agentec.abook.abv.ui.common.util.ABVToastUtil;
import jp.agentec.abook.abv.ui.common.view.ABVPopupListWindow; import jp.agentec.abook.abv.ui.common.view.ABVPopupListWindow;
import jp.agentec.abook.abv.ui.home.helper.ActivityHandlingHelper; import jp.agentec.abook.abv.ui.Interface.KeyActionCallback;
import jp.agentec.abook.abv.ui.viewer.view.CheckFormWebview;
//TODO: later 遠隔連動関連はContentView,NoPdfViewと共通しているので要集約 //TODO: later 遠隔連動関連はContentView,NoPdfViewと共通しているので要集約
public class HTMLWebViewActivity extends ParentWebViewActivity { public class HTMLWebViewActivity extends ParentWebViewActivity implements KeyActionCallback {
private static final String TAG = "HTMLWebViewActivity"; private static final String TAG = "HTMLWebViewActivity";
/** /**
...@@ -74,7 +62,7 @@ public class HTMLWebViewActivity extends ParentWebViewActivity { ...@@ -74,7 +62,7 @@ public class HTMLWebViewActivity extends ParentWebViewActivity {
private ImageButton downloadButton; private ImageButton downloadButton;
private int objectLogId; private int objectLogId;
private WebView webView; private CheckFormWebview webView;
private JsInf jsInf = new JsInf(); private JsInf jsInf = new JsInf();
private ValueCallback<Uri[]> mUploadMessage; private ValueCallback<Uri[]> mUploadMessage;
...@@ -99,8 +87,12 @@ public class HTMLWebViewActivity extends ParentWebViewActivity { ...@@ -99,8 +87,12 @@ public class HTMLWebViewActivity extends ParentWebViewActivity {
mOperationId = intent.getLongExtra(ABookKeys.OPERATION_ID, -1); // OperationId mOperationId = intent.getLongExtra(ABookKeys.OPERATION_ID, -1); // OperationId
// ***** WebViewセット // ***** WebViewセット
// KAGOME Ph2 WebView上のIMEキーボード入力をハンドリングするため、カスタムWebViewに変更
FrameLayout frameLayout = findViewById(R.id.frameWebView);
this.webView = new CheckFormWebview(this);
frameLayout.addView(webView, new LinearLayout.LayoutParams(FP, FP));
this.webView.setEnterCallback(this);
webView = (WebView) findViewById(R.id.webView2);
webView.setVisibility(View.VISIBLE); webView.setVisibility(View.VISIBLE);
webView.setVerticalScrollbarOverlay(true); // スクロールバー部分の隙間を消す webView.setVerticalScrollbarOverlay(true); // スクロールバー部分の隙間を消す
if (Logger.isDebugEnabled()) { if (Logger.isDebugEnabled()) {
...@@ -687,4 +679,20 @@ public class HTMLWebViewActivity extends ParentWebViewActivity { ...@@ -687,4 +679,20 @@ public class HTMLWebViewActivity extends ParentWebViewActivity {
} }
}); });
} }
@Override
public void keyActionCallback() {
doEnterEvent();
}
@Override
protected void doEnterEvent() {
webView.post(new Runnable() {
@Override
public void run() {
Logger.i(TAG, "javascript:CHK.notifyMoveForcus()");
webViewLoadUrl("javascript:CHK.notifyMoveForcus()");
}
});
}
} }
...@@ -459,4 +459,22 @@ public class ParentWebViewActivity extends ABVContentViewActivity { ...@@ -459,4 +459,22 @@ public class ParentWebViewActivity extends ABVContentViewActivity {
public void callViewLoadUrl(String url) { public void callViewLoadUrl(String url) {
webViewLoadUrl(url); webViewLoadUrl(url);
} }
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
if (event.getAction()==KeyEvent.ACTION_DOWN || event.getAction()==KeyEvent.ACTION_UP) {
switch (event.getKeyCode()) {
case KeyEvent.KEYCODE_BACK:
// KAGOME Ph2 WebView表示時に戻るボタンの誤打で報告が消えることがあるため非活性に変更
return true;
case KeyEvent.KEYCODE_ENTER:
// KAGOME Ph2 バーコード読み取り時のEnterキー入力イベントをハンドリング
doEnterEvent();
break;
}
}
return super.dispatchKeyEvent(event);
}
protected void doEnterEvent() {}
} }
package jp.agentec.abook.abv.ui.viewer.view;
import android.content.Context;
import android.util.AttributeSet;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import android.view.inputmethod.InputConnectionWrapper;
import android.webkit.WebView;
import jp.agentec.abook.abv.ui.Interface.KeyActionCallback;
/**
* Created by ogawa-y on 2020/01/21.
*/
public class CheckFormWebview extends WebView {
private KeyActionCallback enterCallback;
public CheckFormWebview(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); }
public CheckFormWebview(Context context, AttributeSet attrs) { super(context, attrs); }
public CheckFormWebview(Context context) { super(context); }
public void setEnterCallback(KeyActionCallback function){ this.enterCallback = function; }
@Override public InputConnection onCreateInputConnection(EditorInfo ei) {
InputConnection input = super.onCreateInputConnection(ei);
if(input == null){
return null;
}
return new MyConnection(input);
}
private class MyConnection extends InputConnectionWrapper
{
public MyConnection(InputConnection wrapped) {
super(wrapped, false);
}
// WebView上でIMEキーボードのアクションがあった場合のハンドリングを行う
@Override public boolean performEditorAction(int action) {
if(action == EditorInfo.IME_ACTION_GO || action == EditorInfo.IME_ACTION_NEXT) {
if(enterCallback != null) {
enterCallback.keyActionCallback();
}
}
return true;
}
}
}
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