i自然 v1.5.2版本的 MD5 值为:4186de3133535afd3ad8a76e7e4d0eff
以下内容为反编译后的 IsShowTBarActivity.java 源代码,内容仅作参考
package com.mnr.app.cms.view;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.Html;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.webkit.ValueCallback;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.huawei.hms.framework.common.ContainerUtils;
import com.mnr.app.R;
import com.mnr.app.cms.CommonWebViewClient;
import com.mnr.app.cms.CommonWebViewListener;
import com.mnr.app.cms.SuperBaseActivity;
import com.tencent.connect.common.Constants;
import com.umeng.socialize.ShareAction;
import com.umeng.socialize.UMAuthListener;
import com.umeng.socialize.UMShareAPI;
import com.umeng.socialize.UMShareListener;
import com.umeng.socialize.bean.SHARE_MEDIA;
import com.umeng.socialize.shareboard.ShareBoardConfig;
import java.net.URLDecoder;
import java.util.Map;
import org.android.agoo.common.AgooConstants;
import org.droidparts.contract.Constants;
public class IsShowTBarActivity extends SuperBaseActivity implements CommonWebViewListener {
private static final int FILECHOOSER_RESULTCODE = 2;
public static final int INPUT_FILE_REQUEST_CODE = 1;
private String escapeUrl;
private String flag;
private ImageView iv_btn_back;
private String mCameraPhotoPath;
private ValueCallback<Uri[]> mFilePathCallback;
ValueCallback<Uri[]> mUploadCallbackAboveL;
private ValueCallback<Uri> mUploadMessage;
private WebView mWebview;
private RelativeLayout rl_titleBar;
private TextView tvTitle;
private String url;
private String TAG = "IsShowTBarActivity";
private UMShareListener umShareListener = new UMShareListener() {
@Override
public void onStart(SHARE_MEDIA platform) {
if (platform == SHARE_MEDIA.SINA) {
UMShareAPI.get(IsShowTBarActivity.this).getPlatformInfo(IsShowTBarActivity.this, SHARE_MEDIA.SINA, IsShowTBarActivity.this.authListener);
return;
}
if (platform == SHARE_MEDIA.QQ) {
Log.e(IsShowTBarActivity.this.TAG, "QQ分享");
return;
}
if (platform == SHARE_MEDIA.WEIXIN) {
Log.e(IsShowTBarActivity.this.TAG, "微信分享");
return;
}
if (platform == SHARE_MEDIA.EMAIL) {
Log.e(IsShowTBarActivity.this.TAG, "邮件分享");
sendMail(IsShowTBarActivity.this.mWebview.getUrl());
return;
}
if (platform == SHARE_MEDIA.SMS) {
Log.e(IsShowTBarActivity.this.TAG, "短信分享");
sendSMS();
return;
}
if (platform == SHARE_MEDIA.QZONE) {
Log.e(IsShowTBarActivity.this.TAG, "QQ空间分享");
return;
}
if (platform == SHARE_MEDIA.WEIXIN_CIRCLE) {
Log.e(IsShowTBarActivity.this.TAG, "微信朋友圈分享");
return;
}
if (platform == SHARE_MEDIA.MORE) {
ClipboardManager clipboardManager = (ClipboardManager) IsShowTBarActivity.this.getSystemService("clipboard");
clipboardManager.setText(IsShowTBarActivity.this.mWebview.getUrl());
if (clipboardManager.getText() != null) {
Toast.makeText(IsShowTBarActivity.this, "复制链接成功", 0).show();
} else {
Toast.makeText(IsShowTBarActivity.this, "复制链接失败", 0).show();
}
}
}
private void sendMail(String emailBody) {
Intent intent = new Intent("android.intent.action.SEND");
intent.setType("plain/text");
intent.putExtra("android.intent.extra.SUBJECT", "共享软件");
intent.putExtra("android.intent.extra.TEXT", emailBody);
IsShowTBarActivity.this.startActivityForResult(Intent.createChooser(intent, "请选择邮件发送软件"), 1001);
}
private void sendSMS() {
Intent intent = new Intent("android.intent.action.VIEW", Uri.parse("smsto:"));
intent.putExtra("sms_body", IsShowTBarActivity.this.mWebview.getUrl());
intent.setType("vnd.android-dir/mms-sms");
IsShowTBarActivity.this.startActivityForResult(intent, 1002);
}
@Override
public void onResult(SHARE_MEDIA platform) {
Log.e("plat", "platform" + platform);
Toast.makeText(IsShowTBarActivity.this, platform + " 分享成功啦", 0).show();
}
@Override
public void onError(SHARE_MEDIA platform, Throwable t) {
if (t != null) {
Log.e("throw", "throw:" + t.getMessage());
}
}
@Override
public void onCancel(SHARE_MEDIA platform) {
Toast.makeText(IsShowTBarActivity.this, platform + " 分享取消了", 0).show();
}
};
UMAuthListener authListener = new UMAuthListener() {
@Override
public void onCancel(SHARE_MEDIA platform, int action) {
}
@Override
public void onComplete(SHARE_MEDIA platform, int action, Map<String, String> data) {
}
@Override
public void onError(SHARE_MEDIA platform, int action, Throwable t) {
}
@Override
public void onStart(SHARE_MEDIA platform) {
}
};
private WebChromeClient mWebChromeClient = new WebChromeClient() {
@Override
public void onReceivedTitle(WebView view, String title) {
super.onReceivedTitle(view, title);
IsShowTBarActivity.this.tvTitle.setText(title);
}
public void openFileChooser(ValueCallback<Uri> uploadMsg) {
Log.d(IsShowTBarActivity.this.TAG, "openFileChoose(ValueCallback<Uri> uploadMsg)");
IsShowTBarActivity.this.mUploadMessage = uploadMsg;
Intent intent = new Intent("android.intent.action.GET_CONTENT");
intent.addCategory("android.intent.category.OPENABLE");
intent.setType("image/*");
IsShowTBarActivity.this.startActivityForResult(Intent.createChooser(intent, "File Chooser"), 2);
}
public void openFileChooser(ValueCallback uploadMsg, String acceptType) {
Log.d(IsShowTBarActivity.this.TAG, "openFileChoose( ValueCallback uploadMsg, String acceptType )");
IsShowTBarActivity.this.mUploadMessage = uploadMsg;
Intent intent = new Intent("android.intent.action.GET_CONTENT");
intent.addCategory("android.intent.category.OPENABLE");
intent.setType("image/*");
IsShowTBarActivity.this.startActivityForResult(Intent.createChooser(intent, "File Browser"), 2);
}
public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) {
Log.d(IsShowTBarActivity.this.TAG, "openFileChoose(ValueCallback<Uri> uploadMsg, String acceptType, String capture)");
IsShowTBarActivity.this.mUploadMessage = uploadMsg;
Intent intent = new Intent("android.intent.action.GET_CONTENT");
intent.addCategory("android.intent.category.OPENABLE");
intent.setType("image/*");
IsShowTBarActivity.this.startActivityForResult(Intent.createChooser(intent, "File Browser"), 2);
}
@Override
public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, WebChromeClient.FileChooserParams fileChooserParams) {
Log.d(IsShowTBarActivity.this.TAG, "onShowFileChooser: show");
IsShowTBarActivity.this.mUploadCallbackAboveL = filePathCallback;
Intent intent = new Intent("android.intent.action.GET_CONTENT");
intent.addCategory("android.intent.category.OPENABLE");
intent.setType("image/*");
IsShowTBarActivity.this.startActivityForResult(Intent.createChooser(intent, "File Browser"), 2);
return true;
}
};
@Override
public void OnPageError() {
}
@Override
protected int getResLayoutId() {
return R.layout.activity_is_show_tbar;
}
@Override
public void onPageFinished() {
}
@Override
public void onPageStarted() {
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
RelativeLayout relativeLayout = (RelativeLayout) findViewById(R.id.rl_titleBar);
this.rl_titleBar = relativeLayout;
relativeLayout.setVisibility(8);
this.iv_btn_back = (ImageView) findViewById(R.id.iv_btn_back);
this.tvTitle = (TextView) findViewById(R.id.tvTitle);
this.mWebview = (WebView) findViewById(R.id.mWebview);
initSetting();
initGetIntent();
this.mWebview.loadUrl(this.url);
this.iv_btn_back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
IsShowTBarActivity.this.finish();
}
});
initShouldUrlLoading();
}
private void initGetIntent() {
Intent intent = getIntent();
this.url = intent.getStringExtra("url");
String stringExtra = intent.getStringExtra(AgooConstants.MESSAGE_FLAG);
this.flag = stringExtra;
if (stringExtra != null) {
if (stringExtra.equals("newPage")) {
this.rl_titleBar.setVisibility(0);
} else if (this.flag.equals("newPageWithoutTBar")) {
this.rl_titleBar.setVisibility(8);
}
}
}
private void initSetting() {
this.mWebview.getSettings().setJavaScriptEnabled(true);
this.mWebview.getSettings().setUseWideViewPort(true);
this.mWebview.getSettings().setLoadWithOverviewMode(true);
this.mWebview.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
this.mWebview.getSettings().setPluginState(WebSettings.PluginState.ON);
this.mWebview.getSettings().setGeolocationEnabled(true);
this.mWebview.getSettings().setDomStorageEnabled(true);
this.mWebview.getSettings().setAppCacheMaxSize(8388608L);
this.mWebview.getSettings().setAppCachePath(getApplicationContext().getCacheDir().getAbsolutePath());
this.mWebview.getSettings().setAllowFileAccess(true);
this.mWebview.getSettings().setAppCacheEnabled(true);
this.mWebview.setWebChromeClient(this.mWebChromeClient);
String userAgentString = this.mWebview.getSettings().getUserAgentString();
this.mWebview.getSettings().setUserAgentString(userAgentString + "; MTApp");
}
private void initShouldUrlLoading() {
setCommonWebViewClient(new CommonWebViewClient(this));
this.mWebview.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
try {
Log.i("URL----", url);
if (!url.contains(ContainerUtils.KEY_VALUE_DELIMITER)) {
url = URLDecoder.decode(IsShowTBarActivity.this.escapeUrl, Constants.UTF8).toString();
Log.i("URL----", IsShowTBarActivity.this.escapeUrl);
} else {
String[] split = url.split(ContainerUtils.KEY_VALUE_DELIMITER);
IsShowTBarActivity.this.escapeUrl = Html.escapeHtml(split[1]);
IsShowTBarActivity isShowTBarActivity = IsShowTBarActivity.this;
isShowTBarActivity.escapeUrl = URLDecoder.decode(isShowTBarActivity.escapeUrl, Constants.UTF8).toString();
}
} catch (Exception e) {
e.printStackTrace();
}
if (url.contains("newPageWithoutTBar")) {
Log.i("newPageWithoutTBar", IsShowTBarActivity.this.escapeUrl);
IsShowTBarActivity.this.rl_titleBar.setVisibility(8);
Intent intent = new Intent(IsShowTBarActivity.this, (Class<?>) IsShowTBarActivity.class);
intent.putExtra("url", IsShowTBarActivity.this.escapeUrl);
intent.putExtra(AgooConstants.MESSAGE_FLAG, "newPageWithoutTBar");
IsShowTBarActivity.this.startActivity(intent);
return true;
}
if (url.contains("newPage")) {
Log.i("newPage", IsShowTBarActivity.this.escapeUrl);
Intent intent2 = new Intent(IsShowTBarActivity.this, (Class<?>) IsShowTBarActivity.class);
intent2.putExtra("url", IsShowTBarActivity.this.escapeUrl);
intent2.putExtra(AgooConstants.MESSAGE_FLAG, "newPage");
IsShowTBarActivity.this.startActivity(intent2);
return true;
}
if (url.contains("appShare")) {
Toast.makeText(IsShowTBarActivity.this, "分享", 0).show();
IsShowTBarActivity.this.UmengShare();
Log.i("appShare", Constants.JumpUrlConstants.SRC_TYPE_APP);
return true;
}
if (url.contains("closePage")) {
IsShowTBarActivity.this.finish();
Log.i("closePage", "close");
return true;
}
return super.shouldOverrideUrlLoading(view, url);
}
});
}
public void UmengShare() {
SHARE_MEDIA[] share_mediaArr = {SHARE_MEDIA.SINA, SHARE_MEDIA.QQ, SHARE_MEDIA.WEIXIN, SHARE_MEDIA.EMAIL, SHARE_MEDIA.SMS, SHARE_MEDIA.QZONE, SHARE_MEDIA.WEIXIN_CIRCLE};
ShareBoardConfig shareBoardConfig = new ShareBoardConfig();
shareBoardConfig.setMenuItemBackgroundShape(ShareBoardConfig.BG_SHAPE_CIRCULAR);
new ShareAction(this).withText("").setDisplayList(share_mediaArr).addButton("复制链接", "", "", "").setCallback(this.umShareListener).open(shareBoardConfig);
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == 4 && this.url.contains("http://baosong.aimingtai.com/mobile/main/main.html")) {
Intent intent = new Intent("android.intent.action.MAIN");
intent.setFlags(268435456);
intent.addCategory("android.intent.category.HOME");
startActivity(intent);
return true;
}
return super.onKeyDown(keyCode, event);
}
public void setCommonWebViewClient(CommonWebViewClient client) {
if (client == null) {
return;
}
client.setCommonWebViewListener(this);
this.mWebview.setWebViewClient(client);
}
@Override
public void onBackPressed() {
scrollToFinishActivity();
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
Uri[] uriArr;
UMShareAPI.get(this).onActivityResult(requestCode, resultCode, data);
Log.d(this.TAG, "onActivityResult");
if (requestCode == 2) {
if (requestCode == 2) {
if (this.mUploadMessage == null && this.mUploadCallbackAboveL == null) {
return;
}
Uri data2 = (data == null || resultCode != -1) ? null : data.getData();
if (this.mUploadCallbackAboveL != null) {
onActivityResultAboveL(requestCode, resultCode, data);
return;
}
ValueCallback<Uri> valueCallback = this.mUploadMessage;
if (valueCallback != null) {
valueCallback.onReceiveValue(data2);
this.mUploadMessage = null;
return;
}
return;
}
return;
}
if (requestCode == 1 && this.mFilePathCallback != null) {
if (resultCode == -1) {
if (data == null) {
String str = this.mCameraPhotoPath;
if (str != null) {
Log.d("camera_photo_path", str);
uriArr = new Uri[]{Uri.parse(this.mCameraPhotoPath)};
}
} else {
String dataString = data.getDataString();
Log.d("camera_dataString", dataString);
if (dataString != null) {
uriArr = new Uri[]{Uri.parse(dataString)};
}
}
this.mFilePathCallback.onReceiveValue(uriArr);
this.mFilePathCallback = null;
return;
}
uriArr = null;
this.mFilePathCallback.onReceiveValue(uriArr);
this.mFilePathCallback = null;
return;
}
super.onActivityResult(requestCode, resultCode, data);
}
private void onActivityResultAboveL(int requestCode, int resultCode, Intent data) {
Uri[] uriArr;
if (requestCode != 2 || this.mUploadCallbackAboveL == null) {
return;
}
if (resultCode != -1 || data == null) {
uriArr = null;
} else {
String dataString = data.getDataString();
ClipData clipData = data.getClipData();
if (clipData != null) {
uriArr = new Uri[clipData.getItemCount()];
for (int i = 0; i < clipData.getItemCount(); i++) {
uriArr[i] = clipData.getItemAt(i).getUri();
}
} else {
uriArr = null;
}
if (dataString != null) {
uriArr = new Uri[]{Uri.parse(dataString)};
}
}
this.mUploadCallbackAboveL.onReceiveValue(uriArr);
this.mUploadCallbackAboveL = null;
}
}