正在查看: Adobe Acrobat v15.3 应用的 ARCloudPrintActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Adobe Acrobat v15.3 应用的 ARCloudPrintActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.adobe.reader.misc;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import android.util.Base64;
import android.webkit.JavascriptInterface;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import com.adobe.libs.c.a.a;
import com.adobe.reader.R;
import com.adobe.reader.filebrowser.ARFileEntry;
import com.adobe.reader.viewer.ARDocShareMenu;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
public class ARCloudPrintActivity extends a {
private static final String CLOSE_POST_MESSAGE_NAME = "cp-dialog-on-close";
private static final String CONTENT_TRANSFER_ENCODING = "base64";
private static final String JS_INTERFACE = "ReaderPrintDialog";
private Intent mCloudPrintIntent;
private String mFilePath;
private WebView mPrintWebView;
final class PrintDialogJavaScriptInterface {
PrintDialogJavaScriptInterface() {
}
@JavascriptInterface
public final String getContent() {
try {
InputStream openInputStream = ARCloudPrintActivity.this.getContentResolver().openInputStream(ARCloudPrintActivity.this.mCloudPrintIntent.getData());
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
byte[] bArr = new byte[4096];
for (int read = openInputStream.read(bArr); read >= 0; read = openInputStream.read(bArr)) {
byteArrayOutputStream.write(bArr, 0, read);
}
openInputStream.close();
byteArrayOutputStream.flush();
return Base64.encodeToString(byteArrayOutputStream.toByteArray(), 0);
} catch (FileNotFoundException e) {
e.printStackTrace();
return ARFileEntry.DEFAULT_ENTRY_ICON_STRING;
} catch (IOException e2) {
e2.printStackTrace();
return ARFileEntry.DEFAULT_ENTRY_ICON_STRING;
}
}
@JavascriptInterface
public final String getEncoding() {
return ARCloudPrintActivity.CONTENT_TRANSFER_ENCODING;
}
@JavascriptInterface
public final String getTitle() {
ARCloudPrintActivity.this.mFilePath = ARCloudPrintActivity.this.mCloudPrintIntent.getExtras().getString(ARDocShareMenu.FILEPATH_KEY);
return ARCloudPrintActivity.this.mFilePath.subSequence(ARCloudPrintActivity.this.mFilePath.lastIndexOf(47) + 1, ARCloudPrintActivity.this.mFilePath.length()).toString();
}
@JavascriptInterface
public final String getType() {
return ARCloudPrintActivity.this.mCloudPrintIntent.getType();
}
@JavascriptInterface
public final void onPostMessage(String str) {
if (str.startsWith(ARCloudPrintActivity.CLOSE_POST_MESSAGE_NAME)) {
ARCloudPrintActivity.this.finish();
}
}
}
final class PrintDialogWebClient extends WebViewClient {
private PrintDialogWebClient() {
}
@Override
public final void onPageFinished(WebView webView, String str) {
if (ARApp.getAppContext().getString(R.string.IDS_CLOUDPRINT_DIALOG_URL).equals(str)) {
webView.loadUrl("javascript:printDialog.setPrintDocument(printDialog.createPrintDocument(window.ReaderPrintDialog.getType(),window.ReaderPrintDialog.getTitle(),window.ReaderPrintDialog.getContent(),window.ReaderPrintDialog.getEncoding()))");
webView.loadUrl("javascript:window.addEventListener('message',function(evt){window.ReaderPrintDialog.onPostMessage(evt.data)}, false)");
}
}
}
@Override
public void onConfigurationChanged(Configuration configuration) {
super.onConfigurationChanged(configuration);
}
@Override
public void onCreateRAW(Bundle bundle) {
super.onCreateRAW(bundle);
setContentView(R.layout.print_dialog);
this.mPrintWebView = (WebView) findViewById(R.id.printWebview);
this.mCloudPrintIntent = getIntent();
WebSettings settings = this.mPrintWebView.getSettings();
settings.setJavaScriptEnabled(true);
settings.setLoadWithOverviewMode(true);
settings.setUseWideViewPort(true);
this.mPrintWebView.setWebViewClient(new PrintDialogWebClient());
this.mPrintWebView.addJavascriptInterface(new PrintDialogJavaScriptInterface(), JS_INTERFACE);
this.mPrintWebView.loadUrl(getString(R.string.IDS_CLOUDPRINT_DIALOG_URL));
}
@Override
public void onDestroyRAW() {
if (this.mCloudPrintIntent.getExtras().getBoolean(ARDocShareMenu.FLATTENED_KEY)) {
try {
File file = new File(this.mFilePath);
if (file.exists()) {
file.delete();
}
} catch (Exception e) {
}
}
super.onDestroyRAW();
}
}