Skip to content

Commit

Permalink
update log
Browse files Browse the repository at this point in the history
  • Loading branch information
Justson committed Aug 27, 2017
1 parent aa12fd1 commit deeda46
Show file tree
Hide file tree
Showing 16 changed files with 84 additions and 76 deletions.
8 changes: 4 additions & 4 deletions library/src/main/java/com/just/library/AgentWeb.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ private void doCompat() {

mJavaObjects.put("agentWeb", mAgentWebJsInterfaceCompat = new AgentWebJsInterfaceCompat(this, mActivity));

LogUtils.i("Info", "AgentWebConfig.isUseAgentWebView:" + AgentWebConfig.WEBVIEW_TYPE + " mChromeClientCallbackManager:" + mChromeClientCallbackManager);
LogUtils.i(TAG, "AgentWebConfig.isUseAgentWebView:" + AgentWebConfig.WEBVIEW_TYPE + " mChromeClientCallbackManager:" + mChromeClientCallbackManager);
if (AgentWebConfig.WEBVIEW_TYPE == AgentWebConfig.WEBVIEW_AGENTWEB_SAFE_TYPE) {
this.mChromeClientCallbackManager.setAgentWebCompatInterface((ChromeClientCallbackManager.AgentWebCompatInterface) mWebCreator.get());
this.mWebViewClientCallbackManager.setPageLifeCycleCallback((WebViewClientCallbackManager.PageLifeCycleCallback) mWebCreator.get());
Expand Down Expand Up @@ -202,7 +202,7 @@ public JsEntraceAccess getJsEntraceAccess() {
public AgentWeb clearWebCache() {

if (this.getWebCreator().get() != null) {
Log.i("Info", "清空 webview 缓存");
Log.i(TAG, "清空 webview 缓存");
AgentWebUtils.clearWebViewAllCache(mActivity, this.getWebCreator().get());
} else {
AgentWebUtils.clearWebViewAllCache(mActivity);
Expand Down Expand Up @@ -369,7 +369,7 @@ public void destroy() {
public void destroyAndKill() {
destroy();
if (!AgentWebUtils.isMainProcess(mActivity)) {
LogUtils.i("Info", "退出进程");
LogUtils.i(TAG, "退出进程");
System.exit(0);
}
}
Expand All @@ -386,7 +386,7 @@ public void uploadFileResult(int requestCode, int resultCode, Intent data) {

if (mIFileUploadChooser == null)
mIFileUploadChooser = mAgentWebJsInterfaceCompat.pop();
LogUtils.i("Info", "file upload:" + mIFileUploadChooser);
LogUtils.i(TAG, "file upload:" + mIFileUploadChooser);
if (mIFileUploadChooser != null)
mIFileUploadChooser.fetchFilePathFromIntent(requestCode, resultCode, data);

Expand Down
3 changes: 2 additions & 1 deletion library/src/main/java/com/just/library/AgentWebConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class AgentWebConfig {
public static final int WEBVIEW_CUSTOM_TYPE = 3;
static int WEBVIEW_TYPE = WEBVIEW_DEFAULT_TYPE;
private static boolean isInit = false;
private static final String TAG=AgentWebConfig.class.getSimpleName();


//获取Cookie
Expand Down Expand Up @@ -96,7 +97,7 @@ private static ValueCallback<Boolean> getDefaultIgnoreCallback() {
return new ValueCallback<Boolean>() {
@Override
public void onReceiveValue(Boolean ignore) {
LogUtils.i("Info", "removeExpiredCookies:" + ignore);
LogUtils.i(TAG, "removeExpiredCookies:" + ignore);
}
};
}
Expand Down
2 changes: 1 addition & 1 deletion library/src/main/java/com/just/library/AgentWebUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ static String getFileAbsolutePath(Activity context, Uri fileUri) {
if (context == null || fileUri == null)
return null;

LogUtils.i("Info", "getAuthority:" + fileUri.getAuthority() + " getHost:" + fileUri.getHost() + " getPath:" + fileUri.getPath() + " getScheme:" + fileUri.getScheme() + " query:" + fileUri.getQuery());
LogUtils.i(TAG, "getAuthority:" + fileUri.getAuthority() + " getHost:" + fileUri.getHost() + " getPath:" + fileUri.getPath() + " getScheme:" + fileUri.getScheme() + " query:" + fileUri.getQuery());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && DocumentsContract.isDocumentUri(context, fileUri)) {
if (isExternalStorageDocument(fileUri)) {
String docId = DocumentsContract.getDocumentId(fileUri);
Expand Down
10 changes: 5 additions & 5 deletions library/src/main/java/com/just/library/AgentWebView.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
*
*/
public class AgentWebView extends WebView implements ChromeClientCallbackManager.AgentWebCompatInterface,WebViewClientCallbackManager.PageLifeCycleCallback{
private static final String TAG = "AgentWebView";
private static final String TAG = AgentWebView.class.getSimpleName();
private Map<String, JsCallJava> mJsCallJavas;
private Map<String, String> mInjectJavaScripts;
private FixedOnReceivedTitle mFixedOnReceivedTitle;
Expand Down Expand Up @@ -69,11 +69,11 @@ public void addJavascriptInterface(Object interfaceObj, String interfaceName) {

if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.JELLY_BEAN_MR1){
super.addJavascriptInterface(interfaceObj,interfaceName);
Log.i("Info","注入");
Log.i(TAG,"注入");
return;
}

LogUtils.i("Info","addJavascriptInterface:"+interfaceObj+" interfaceName:"+interfaceName);
LogUtils.i(TAG,"addJavascriptInterface:"+interfaceObj+" interfaceName:"+interfaceName);
if (mJsCallJavas == null) {
mJsCallJavas = new HashMap<String, JsCallJava>();
}
Expand Down Expand Up @@ -105,7 +105,7 @@ public void destroy() {
if (mIsInited) {
resetAccessibilityEnabled();
//
LogUtils.i("Info","destroy web");
LogUtils.i(TAG,"destroy web");
super.destroy();
}
}
Expand Down Expand Up @@ -217,7 +217,7 @@ public String buildTryCatchInjectJS(String js) {

@Override
public boolean onJsPrompt(WebView view, String url, String message, String defaultValue, JsPromptResult result) {
Log.i("Info","onJsPrompt:"+url+" message:"+message+" d:"+defaultValue+" ");
Log.i(TAG,"onJsPrompt:"+url+" message:"+message+" d:"+defaultValue+" ");
if (mJsCallJavas != null && JsCallJava.isSafeWebViewCallMsg(message)) {
JSONObject jsonObject = JsCallJava.getMsgJSONObject(message);
String interfacedName = JsCallJava.getInterfacedName(jsonObject);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ public boolean onJsPrompt(WebView view, String url, String message, String defau
}
if (AgentWebConfig.WEBVIEW_TYPE == AgentWebConfig.WEBVIEW_AGENTWEB_SAFE_TYPE && mChromeClientCallbackManager != null && mChromeClientCallbackManager.getAgentWebCompatInterface() != null) {

LogUtils.i("Info", "mChromeClientCallbackManager.getAgentWebCompatInterface():" + mChromeClientCallbackManager.getAgentWebCompatInterface());
LogUtils.i(TAG, "mChromeClientCallbackManager.getAgentWebCompatInterface():" + mChromeClientCallbackManager.getAgentWebCompatInterface());
if (mChromeClientCallbackManager.getAgentWebCompatInterface().onJsPrompt(view, url, message, defaultValue, result))
return true;
}
Expand Down
45 changes: 23 additions & 22 deletions library/src/main/java/com/just/library/DefaultMsgConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,47 +10,47 @@
public final class DefaultMsgConfig {


private DownLoadMsgConfig mDownLoadMsgConfig=null;
private DownLoadMsgConfig mDownLoadMsgConfig = null;

private ChromeClientMsgCfg mChromeClientMsgCfg=new ChromeClientMsgCfg();
private ChromeClientMsgCfg mChromeClientMsgCfg = new ChromeClientMsgCfg();

public ChromeClientMsgCfg getChromeClientMsgCfg() {
return mChromeClientMsgCfg;
}

DefaultMsgConfig(){
DefaultMsgConfig() {

mDownLoadMsgConfig= new DownLoadMsgConfig();
mDownLoadMsgConfig = new DownLoadMsgConfig();
}

public DownLoadMsgConfig getDownLoadMsgConfig() {
return mDownLoadMsgConfig;
}

public static class DownLoadMsgConfig implements Parcelable {
public static class DownLoadMsgConfig implements Parcelable {


private String mTaskHasBeenExist="该任务已经存在 , 请勿重复点击下载!";
private String mTaskHasBeenExist = "该任务已经存在 , 请勿重复点击下载!";

private String mTips="提示";
private String mTips = "提示";

private String mHoneycomblow="您正在使用手机流量 , 继续下载该文件吗?";
private String mHoneycomblow = "您正在使用手机流量 , 继续下载该文件吗?";

private String mDownLoad="下载";
private String mDownLoad = "下载";

private String mCancel="取消";
private String mCancel = "取消";

private String mDownLoadFail="下载失败 , 出错了 !";
private String mDownLoadFail = "下载失败!";

private String mLoading="当前进度:%s";
private String mLoading = "当前进度:%s";

private String mTrickter="您有一条新通知";
private String mTrickter = "您有一条新通知";

private String mFileDownLoad="文件下载";
private String mFileDownLoad = "文件下载";

private String mClickOpen="点击打开";
private String mClickOpen = "点击打开";

private String preLoading="即将开始下载文件";
private String preLoading = "即将开始下载文件";

public String getPreLoading() {
return preLoading;
Expand All @@ -60,7 +60,7 @@ public void setPreLoading(String preLoading) {
this.preLoading = preLoading;
}

DownLoadMsgConfig(){
DownLoadMsgConfig() {

}

Expand Down Expand Up @@ -226,21 +226,22 @@ public void writeToParcel(Parcel dest, int flags) {
}


public static final class ChromeClientMsgCfg{
public static final class ChromeClientMsgCfg {

private FileUploadMsgConfig mFileUploadMsgConfig=new FileUploadMsgConfig();
private FileUploadMsgConfig mFileUploadMsgConfig = new FileUploadMsgConfig();

public FileUploadMsgConfig getFileUploadMsgConfig() {
return mFileUploadMsgConfig;
}

public static final class FileUploadMsgConfig implements Parcelable{
public static final class FileUploadMsgConfig implements Parcelable {

private String[]medias=new String[]{"相机","文件选择器"};
private String[] medias = new String[]{"相机", "文件选择器"};

FileUploadMsgConfig(){
FileUploadMsgConfig() {

}

protected FileUploadMsgConfig(Parcel in) {
medias = in.createStringArray();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public static final EventHandlerImpl getInstantce(WebView view,EventInterceptor
}

public EventHandlerImpl(WebView webView,EventInterceptor eventInterceptor) {
LogUtils.i("Info","EventInterceptor:"+eventInterceptor);
this.mWebView = webView;
this.mEventInterceptor = eventInterceptor;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public class FileUpLoadChooserImpl implements IFileUploadChooser {
private boolean cameraState = false;
private PermissionInterceptor mPermissionInterceptor;
private int FROM_INTENTION_CODE = 21;


public FileUpLoadChooserImpl(Builder builder) {

Expand Down Expand Up @@ -341,7 +342,7 @@ public void run() {
try {
Queue<FileParcel> mQueue = AgentWebUtils.convertFile(paths);
String result = AgentWebUtils.convertFileParcelObjectsToJson(mQueue);
LogUtils.i("Info", "result:" + result);
LogUtils.i(TAG, "result:" + result);
if (mJsChannelCallback != null)
mJsChannelCallback.call(result);

Expand Down
30 changes: 16 additions & 14 deletions library/src/main/java/com/just/library/LogUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,40 @@

public class LogUtils {

private static final String PREFIX = " agentweb ---> "; //

public static boolean isDebug() {
static boolean isDebug() {
return AgentWebConfig.DEBUG;
}

public static void i(String tag,String message){
static void i(String tag, String message) {

if(isDebug())
Log.i(tag,message);
if (isDebug())
Log.i(PREFIX.concat(tag), message);
}

public static void v(String tag,String message){
static void v(String tag, String message) {

if(isDebug())
Log.v(tag,message);
if (isDebug())
Log.v(PREFIX.concat(tag), message);

}

public static void safeCheckCrash(String tag, String msg, Throwable tr) {
static void safeCheckCrash(String tag, String msg, Throwable tr) {
if (isDebug()) {
throw new RuntimeException(tag + " " + msg, tr);
throw new RuntimeException(PREFIX.concat(tag) + " " + msg, tr);
} else {
Log.e(tag, msg, tr);
Log.e(PREFIX.concat(tag), msg, tr);
}
}

public static void e(String tag, String msg, Throwable tr) {
static void e(String tag, String msg, Throwable tr) {
Log.e(tag, msg, tr);
}
public static void e(String tag,String message){

if(BuildConfig.DEBUG)
Log.e(tag,message);
static void e(String tag, String message) {

if (BuildConfig.DEBUG)
Log.e(PREFIX.concat(tag), message);
}
}
Loading

0 comments on commit deeda46

Please sign in to comment.