Commit ad877e2d by Lee Munkyeong

Merge branch 'feature/1.4.100_kim-ec' into 'features/1.4.100'

#42998 I/O 帳票出力画面改善

See merge request !203
parents b7d64cd3 beaf139b
......@@ -23,9 +23,20 @@ import android.widget.AdapterView.OnItemClickListener;
import android.widget.ImageButton;
import android.widget.RelativeLayout;
import android.widget.Toast;
import android.app.DownloadManager;
import android.webkit.URLUtil;
import android.webkit.CookieManager;
import android.webkit.DownloadListener;
import android.os.Environment;
import android.webkit.WebViewClient;
import android.content.Context;
import android.graphics.Bitmap;
import java.util.ArrayList;
import java.util.List;
import java.io.File;
import java.io.FileOutputStream;
import java.util.Objects;
import jp.agentec.abook.abv.bl.acms.client.json.content.ContentJSON;
import jp.agentec.abook.abv.bl.acms.type.AcmsApis;
......@@ -128,6 +139,35 @@ public class HTMLWebViewActivity extends ParentWebViewActivity {
settings.setAllowUniversalAccessFromFileURLs(true);
settings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
webView.setDownloadListener(new DownloadListener() {
@Override
public void onDownloadStart(String url, String userAgent,
String contentDisposition, String mimetype,
long contentLength) {
DownloadManager.Request request = new DownloadManager.Request(
Uri.parse(url));
final String fileName = URLUtil.guessFileName(url, contentDisposition, mimetype);
request.setMimeType(mimetype);
//------------------------COOKIE!!------------------------
String cookies = CookieManager.getInstance().getCookie(url);
request.addRequestHeader("cookie", cookies);
//------------------------COOKIE!!------------------------
request.addRequestHeader("User-Agent", userAgent);
request.setTitle(fileName);
request.allowScanningByMediaScanner();
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); //Notify client once download is completed!
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, fileName);
DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
if (dm != null) {
dm.enqueue(request);
}
Toast.makeText(getApplicationContext(), getString(R.string.download_start), //To notify the Client that the file is being downloaded
Toast.LENGTH_LONG).show();
}
});
final RelativeLayout fl = (RelativeLayout) findViewById(R.id.frameTopbar);
......
......@@ -17,6 +17,14 @@ import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.RelativeLayout;
import android.widget.Toast;
import android.app.DownloadManager;
import android.webkit.URLUtil;
import android.webkit.CookieManager;
import android.webkit.DownloadListener;
import android.os.Environment;
import android.webkit.WebViewClient;
import android.content.Context;
import android.graphics.Bitmap;
import org.xwalk.core.XWalkNavigationHistory;
import org.xwalk.core.XWalkPreferences;
......@@ -26,11 +34,17 @@ import org.xwalk.core.XWalkUIClient;
import org.xwalk.core.XWalkView;
import org.xwalk.core.XWalkWebResourceRequest;
import org.xwalk.core.XWalkWebResourceResponse;
import org.xwalk.core.XWalkDownloadListener;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.ArrayList;
import java.util.List;
import java.io.File;
import java.io.FileOutputStream;
import java.util.Objects;
import jp.agentec.abook.abv.bl.acms.client.json.content.ContentJSON;
import jp.agentec.abook.abv.bl.common.ABVEnvironment;
......@@ -122,6 +136,36 @@ public class HTMLXWalkWebViewActivity extends ParentWebViewActivity {
if (Logger.isDebugEnabled()) {
XWalkPreferences.setValue(XWalkPreferences.REMOTE_DEBUGGING, true); //デバッグモード(chromeからinspect可)
}
webView.setDownloadListener(new XWalkDownloadListener(this) {
@Override
public void onDownloadStart(String url, String userAgent,
String contentDisposition, String mimetype,
long contentLength) {
DownloadManager.Request request = new DownloadManager.Request(
Uri.parse(url));
final String fileName = URLUtil.guessFileName(url, contentDisposition, mimetype);
request.setMimeType(mimetype);
//------------------------COOKIE!!------------------------
String cookies = CookieManager.getInstance().getCookie(url);
request.addRequestHeader("cookie", cookies);
//------------------------COOKIE!!------------------------
request.addRequestHeader("User-Agent", userAgent);
request.setTitle(fileName);
request.allowScanningByMediaScanner();
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); //Notify client once download is completed!
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, fileName);
DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
if (dm != null) {
dm.enqueue(request);
}
Toast.makeText(getApplicationContext(), getString(R.string.download_start), //To notify the Client that the file is being downloaded
Toast.LENGTH_LONG).show();
}
});
final RelativeLayout fl = (RelativeLayout) findViewById(R.id.frameTopbar);
......
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