mirror of
https://github.com/leanote/leanote-android.git
synced 2025-10-14 22:25:40 +00:00
use XLog as the app's logger, disable logging when in production mode
This commit is contained in:
@@ -110,5 +110,6 @@ dependencies {
|
||||
|
||||
compile 'net.danlew:android.joda:2.9.5'
|
||||
compile group: 'com.tencent.bugly', name: 'crashreport_upgrade', version: '1.2.1'
|
||||
compile 'com.elvishew:xlog:1.3.0'
|
||||
|
||||
}
|
||||
|
@@ -5,6 +5,8 @@ import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
|
||||
import com.elvishew.xlog.LogLevel;
|
||||
import com.elvishew.xlog.XLog;
|
||||
import com.facebook.stetho.Stetho;
|
||||
import com.raizlabs.android.dbflow.config.FlowConfig;
|
||||
import com.raizlabs.android.dbflow.config.FlowManager;
|
||||
@@ -28,6 +30,7 @@ public class Leamonax extends Application {
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
mContext = this;
|
||||
XLog.init(BuildConfig.DEBUG ? LogLevel.ALL : LogLevel.NONE);
|
||||
initBugly();
|
||||
|
||||
EventBus.builder()
|
||||
|
@@ -5,7 +5,8 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.IBinder;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.util.Log;
|
||||
|
||||
import com.elvishew.xlog.XLog;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.houxg.leamonax.model.SyncEvent;
|
||||
@@ -22,11 +23,11 @@ import rx.schedulers.Schedulers;
|
||||
*/
|
||||
public class NoteSyncService extends Service {
|
||||
|
||||
private static final String TAG = "NoteSyncService";
|
||||
private static final String TAG = "NoteSyncService:";
|
||||
|
||||
public static void startServiceForNote(Context context) {
|
||||
if (!AccountService.isSignedIn()) {
|
||||
Log.w(TAG, "Trying to sync but not login");
|
||||
XLog.w(TAG + "Trying to sync but not login");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -35,7 +35,7 @@ import java.util.List;
|
||||
@Database(name = "leanote_db", version = 3)
|
||||
public class AppDataBase {
|
||||
|
||||
private static final String TAG = "AppDataBase";
|
||||
private static final String TAG = "AppDataBase:";
|
||||
|
||||
@Migration(version = 2, database = AppDataBase.class)
|
||||
public static class UpdateTag extends BaseMigration {
|
||||
|
@@ -2,7 +2,6 @@ package org.houxg.leamonax.editor;
|
||||
|
||||
|
||||
import android.net.Uri;
|
||||
import android.util.Log;
|
||||
import android.webkit.ConsoleMessage;
|
||||
import android.webkit.JsResult;
|
||||
import android.webkit.WebChromeClient;
|
||||
@@ -10,6 +9,8 @@ import android.webkit.WebResourceResponse;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
|
||||
import com.elvishew.xlog.XLog;
|
||||
|
||||
import org.houxg.leamonax.service.NoteFileService;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -83,14 +84,14 @@ public abstract class Editor {
|
||||
|
||||
protected class EditorClient extends WebViewClient {
|
||||
|
||||
private static final String TAG = "WebViewClient";
|
||||
private static final String TAG = "WebViewClient:";
|
||||
|
||||
@Override
|
||||
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
|
||||
Uri uri = Uri.parse(url);
|
||||
Log.i(TAG, "shouldInterceptRequest(), request=" + url + ", scheme=" + uri.getScheme() + ", authority=" + uri.getAuthority());
|
||||
XLog.i(TAG + "shouldInterceptRequest(), request=" + url + ", scheme=" + uri.getScheme() + ", authority=" + uri.getAuthority());
|
||||
if (NoteFileService.isLocalImageUri(uri)) {
|
||||
Log.i(TAG, "get image");
|
||||
XLog.i(TAG + "get image");
|
||||
WebResourceResponse resourceResponse = new WebResourceResponse("image/png", "utf-8", NoteFileService.getImage(uri.getQueryParameter("id")));
|
||||
return resourceResponse;
|
||||
} else {
|
||||
@@ -101,36 +102,36 @@ public abstract class Editor {
|
||||
@Override
|
||||
public void onLoadResource(WebView view, String url) {
|
||||
super.onLoadResource(view, url);
|
||||
Log.i(TAG, "onLoadResource(), rul=" + url);
|
||||
XLog.i(TAG + "onLoadResource(), rul=" + url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||
Log.i(TAG, "shouldOverrideUrlLoading(), url=" + url);
|
||||
XLog.i(TAG + "shouldOverrideUrlLoading(), url=" + url);
|
||||
return super.shouldOverrideUrlLoading(view, url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageFinished(WebView view, String url) {
|
||||
super.onPageFinished(view, url);
|
||||
Log.i(TAG, "onPageFinished()");
|
||||
XLog.i(TAG + "onPageFinished()");
|
||||
mListener.onPageLoaded();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
|
||||
super.onReceivedError(view, errorCode, description, failingUrl);
|
||||
Log.i(TAG, "onReceivedError(), code=" + errorCode + ", desc=" + description + ", url=" + failingUrl);
|
||||
XLog.i(TAG + "onReceivedError(), code=" + errorCode + ", desc=" + description + ", url=" + failingUrl);
|
||||
}
|
||||
}
|
||||
|
||||
protected class EditorChromeClient extends WebChromeClient {
|
||||
|
||||
private static final String TAG = "ChromeClient";
|
||||
private static final String TAG = "ChromeClient:";
|
||||
|
||||
@Override
|
||||
public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
|
||||
Log.i(TAG, String.format("source=%s, line=%d, msg=%s",
|
||||
XLog.i(TAG + String.format("source=%s, line=%d, msg=%s",
|
||||
consoleMessage.sourceId(),
|
||||
consoleMessage.lineNumber(),
|
||||
consoleMessage.message()));
|
||||
@@ -139,7 +140,7 @@ public abstract class Editor {
|
||||
|
||||
@Override
|
||||
public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
|
||||
Log.i(TAG, "alert: url=" + url + ", msg=" + message);
|
||||
XLog.i(TAG + "alert: url=" + url + ", msg=" + message);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -1,8 +1,9 @@
|
||||
package org.houxg.leamonax.editor;
|
||||
|
||||
import android.util.Log;
|
||||
import android.webkit.JavascriptInterface;
|
||||
|
||||
import com.elvishew.xlog.XLog;
|
||||
|
||||
import org.houxg.leamonax.utils.HtmlUtils;
|
||||
import org.houxg.leamonax.utils.JSONUtils;
|
||||
import org.json.JSONException;
|
||||
@@ -15,7 +16,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class JsCallbackHandler {
|
||||
private static final String TAG = "JsCallbackHandler";
|
||||
private static final String TAG = "JsCallbackHandler:";
|
||||
|
||||
private static final String JS_CALLBACK_DELIMITER = "~";
|
||||
|
||||
@@ -81,22 +82,22 @@ public class JsCallbackHandler {
|
||||
break;
|
||||
case CALLBACK_FOCUS_IN:
|
||||
// TODO: Needed to handle displaying/graying the format bar when focus changes between the title and content
|
||||
Log.d(TAG, "Focus in callback received");
|
||||
XLog.d(TAG + "Focus in callback received");
|
||||
break;
|
||||
case CALLBACK_FOCUS_OUT:
|
||||
// TODO: Needed to handle displaying/graying the format bar when focus changes between the title and content
|
||||
Log.d(TAG, "Focus out callback received");
|
||||
XLog.d(TAG + "Focus out callback received");
|
||||
break;
|
||||
case CALLBACK_NEW_FIELD:
|
||||
// TODO: Used for logging/testing purposes on iOS
|
||||
Log.d(TAG, "New field created, " + params);
|
||||
XLog.d(TAG + "New field created, " + params);
|
||||
break;
|
||||
case CALLBACK_IMAGE_REPLACED:
|
||||
// TODO: Notifies that image upload has finished and that the local url was replaced by the remote url in the ZSS editor
|
||||
Log.d(TAG, "Image replaced, " + params);
|
||||
XLog.d(TAG + "Image replaced, " + params);
|
||||
break;
|
||||
case CALLBACK_IMAGE_TAP:
|
||||
Log.d(TAG, "Image tapped, " + params);
|
||||
XLog.d(TAG + "Image tapped, " + params);
|
||||
|
||||
String uploadStatus = "";
|
||||
|
||||
@@ -133,7 +134,7 @@ public class JsCallbackHandler {
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
Log.d(TAG, "Media meta data from callback-image-tap was not JSON-formatted");
|
||||
XLog.d(TAG + "Media meta data from callback-image-tap was not JSON-formatted");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,7 +142,7 @@ public class JsCallbackHandler {
|
||||
break;
|
||||
case CALLBACK_LINK_TAP:
|
||||
// Extract and HTML-decode the link data from the callback params
|
||||
Log.d(TAG, "Link tapped, " + params);
|
||||
XLog.d(TAG + "Link tapped, " + params);
|
||||
|
||||
List<String> linkIds = new ArrayList<>();
|
||||
linkIds.add("url");
|
||||
@@ -164,10 +165,10 @@ public class JsCallbackHandler {
|
||||
break;
|
||||
case CALLBACK_LOG:
|
||||
// Strip 'msg=' from beginning of string
|
||||
Log.d(TAG, callbackId + ": " + params.substring(4));
|
||||
XLog.d(TAG + callbackId + ": " + params.substring(4));
|
||||
break;
|
||||
case CALLBACK_RESPONSE_STRING:
|
||||
Log.d(TAG, callbackId + ": " + params);
|
||||
XLog.d(TAG + callbackId + ": " + params);
|
||||
Set<String> responseDataSet;
|
||||
if (params.startsWith("function=")) {
|
||||
String functionName = params.substring("function=".length(), params.indexOf(JS_CALLBACK_DELIMITER));
|
||||
@@ -192,7 +193,7 @@ public class JsCallbackHandler {
|
||||
mListener.onGetHtmlResponse(HtmlUtils.buildMapFromKeyValuePairs(responseDataSet));
|
||||
break;
|
||||
default:
|
||||
Log.d(TAG, "Unhandled callback: " + callbackId + ":" + params);
|
||||
XLog.d(TAG + "Unhandled callback: " + callbackId + ":" + params);
|
||||
}
|
||||
}
|
||||
}
|
@@ -2,23 +2,24 @@ package org.houxg.leamonax.editor;
|
||||
|
||||
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
import android.webkit.ValueCallback;
|
||||
import android.webkit.WebView;
|
||||
|
||||
import com.elvishew.xlog.XLog;
|
||||
|
||||
import org.houxg.leamonax.utils.StringUtils;
|
||||
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class JsRunner implements ValueCallback<String> {
|
||||
private static final String TAG = "JsRunner";
|
||||
private static final String TAG = "JsRunner:";
|
||||
private String mResult;
|
||||
private CountDownLatch mLatch;
|
||||
|
||||
public String get(final WebView webView, final String script) {
|
||||
if (Looper.myLooper() == Looper.getMainLooper()) {
|
||||
Log.w(TAG, "Call from main thread");
|
||||
XLog.w(TAG + "Call from main thread");
|
||||
}
|
||||
mLatch = new CountDownLatch(1);
|
||||
webView.post(new Runnable() {
|
||||
@@ -37,7 +38,7 @@ public class JsRunner implements ValueCallback<String> {
|
||||
|
||||
@Override
|
||||
public void onReceiveValue(String value) {
|
||||
Log.i(TAG, "rsp=" + value);
|
||||
XLog.i(TAG + "rsp=" + value);
|
||||
mResult = value.substring(1, value.length() - 1);
|
||||
mLatch.countDown();
|
||||
}
|
||||
|
@@ -12,7 +12,7 @@ import java.util.Locale;
|
||||
import static android.view.View.SCROLLBARS_OUTSIDE_OVERLAY;
|
||||
|
||||
public class MarkdownEditor extends Editor {
|
||||
private static final String TAG = "MarkdownEditor";
|
||||
private static final String TAG = "MarkdownEditor:";
|
||||
private WebView mWebView;
|
||||
|
||||
public MarkdownEditor(Editor.EditorListener listener) {
|
||||
|
@@ -4,7 +4,8 @@ package org.houxg.leamonax.editor;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.webkit.WebView;
|
||||
|
||||
import org.houxg.leamonax.utils.AppLog;
|
||||
import com.elvishew.xlog.XLog;
|
||||
|
||||
import org.houxg.leamonax.utils.HtmlUtils;
|
||||
|
||||
import java.util.Locale;
|
||||
@@ -14,7 +15,7 @@ import static android.view.View.SCROLLBARS_OUTSIDE_OVERLAY;
|
||||
|
||||
public class RichTextEditor extends Editor implements TinnyMceCallback.TinnyMceListener {
|
||||
|
||||
private static final String TAG = "RichTextEditor";
|
||||
private static final String TAG = "RichTextEditor:";
|
||||
private static final String JS_CALLBACK_HANDLER = "nativeCallbackHandler";
|
||||
private WebView mWebView;
|
||||
|
||||
@@ -65,7 +66,7 @@ public class RichTextEditor extends Editor implements TinnyMceCallback.TinnyMceL
|
||||
@Override
|
||||
public void setContent(String content) {
|
||||
content = HtmlUtils.escapeHtml(content);
|
||||
AppLog.i(TAG, "escaped=" + content);
|
||||
XLog.i(TAG + "escaped=" + content);
|
||||
execJs(String.format(Locale.US, "tinyMCE.editors[0].setContent('%s');", content));
|
||||
}
|
||||
|
||||
@@ -73,7 +74,7 @@ public class RichTextEditor extends Editor implements TinnyMceCallback.TinnyMceL
|
||||
public String getContent() {
|
||||
String content = new JsRunner().get(mWebView, "getContent();");
|
||||
content = HtmlUtils.unescapeHtml(content);
|
||||
AppLog.i(TAG, "unescaped=" + content);
|
||||
XLog.i(TAG + "unescaped=" + content);
|
||||
if ("<p><br data-mce-bogus=\"1\"></p>".equals(content)) {
|
||||
content = "";
|
||||
}
|
||||
|
@@ -1,9 +1,9 @@
|
||||
package org.houxg.leamonax.editor;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.Log;
|
||||
import android.webkit.JavascriptInterface;
|
||||
|
||||
import com.elvishew.xlog.XLog;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -11,7 +11,7 @@ import java.util.Map;
|
||||
|
||||
public class TinnyMceCallback {
|
||||
|
||||
private static final String TAG = "TinnyMceCallback";
|
||||
private static final String TAG = "TinnyMceCallback:";
|
||||
|
||||
private TinnyMceListener mListener;
|
||||
private Gson mGson = new Gson();
|
||||
@@ -45,7 +45,7 @@ public class TinnyMceCallback {
|
||||
|
||||
@JavascriptInterface
|
||||
public void onCursorChanged(String data) {
|
||||
Log.i(TAG, data);
|
||||
XLog.i(TAG + data);
|
||||
if (mListener == null) {
|
||||
return;
|
||||
}
|
||||
|
@@ -1,7 +1,6 @@
|
||||
package org.houxg.leamonax.model;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.elvishew.xlog.XLog;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.raizlabs.android.dbflow.annotation.Column;
|
||||
import com.raizlabs.android.dbflow.annotation.PrimaryKey;
|
||||
@@ -22,6 +21,8 @@ import java.util.List;
|
||||
@Table(name = "Note", database = AppDataBase.class)
|
||||
public class Note extends BaseModel implements Serializable {
|
||||
|
||||
public static final String TAG = "Note:";
|
||||
|
||||
@SerializedName("Ok")
|
||||
boolean isOk = true;
|
||||
@SerializedName("Msg")
|
||||
@@ -284,8 +285,8 @@ public class Note extends BaseModel implements Serializable {
|
||||
private boolean isChanged(String message, Object l, Object r) {
|
||||
boolean isEqual = l.equals(r);
|
||||
if (!isEqual) {
|
||||
Log.i("Note", message + " changed, origin =" + l);
|
||||
Log.i("Note", message + " changed, modified=" + r);
|
||||
XLog.i(TAG + message + " changed, origin =" + l);
|
||||
XLog.i(TAG + message + " changed, modified=" + r);
|
||||
}
|
||||
return !isEqual;
|
||||
}
|
||||
|
@@ -1,8 +1,7 @@
|
||||
package org.houxg.leamonax.network;
|
||||
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.elvishew.xlog.XLog;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.TypeAdapter;
|
||||
|
||||
@@ -20,6 +19,7 @@ import retrofit2.Converter;
|
||||
public class LeaResponseConverter<T> implements Converter<ResponseBody, T> {
|
||||
private final Gson gson;
|
||||
private final TypeAdapter<T> adapter;
|
||||
public static final String TAG = "LeaResponseConverter:";
|
||||
|
||||
LeaResponseConverter(Gson gson, TypeAdapter<T> adapter) {
|
||||
this.gson = gson;
|
||||
@@ -44,7 +44,7 @@ public class LeaResponseConverter<T> implements Converter<ResponseBody, T> {
|
||||
}
|
||||
return val;
|
||||
} catch (Exception ex) {
|
||||
Log.i("LeaResponseConverter", ex.getMessage());
|
||||
XLog.i(TAG + ex.getMessage());
|
||||
BaseResponse response = gson.fromJson(jsonString, BaseResponse.class);
|
||||
throw new LeaFailure(response);
|
||||
}finally {
|
||||
|
@@ -2,7 +2,8 @@ package org.houxg.leamonax.service;
|
||||
|
||||
import android.net.Uri;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.elvishew.xlog.XLog;
|
||||
|
||||
import org.bson.types.ObjectId;
|
||||
import org.houxg.leamonax.Leamonax;
|
||||
@@ -23,7 +24,7 @@ import okio.Sink;
|
||||
|
||||
public class NoteFileService {
|
||||
|
||||
private static final String TAG = "NoteFileService";
|
||||
private static final String TAG = "NoteFileService:";
|
||||
|
||||
private static final String SCHEME = "file";
|
||||
private static final String IMAGE_PATH = "getImage";
|
||||
@@ -65,14 +66,14 @@ public class NoteFileService {
|
||||
String filePath = null;
|
||||
if (isLocalFileExist(noteFile.getLocalPath())) {
|
||||
filePath = noteFile.getLocalPath();
|
||||
Log.i(TAG, "use local image, path=" + filePath);
|
||||
XLog.i(TAG + "use local image, path=" + filePath);
|
||||
} else {
|
||||
String url = NoteFileService.getUrl(AccountService.getCurrent().getHost(), noteFile.getServerId(), AccountService.getCurrent().getAccessToken());
|
||||
Log.i(TAG, "use server image, url=" + url);
|
||||
XLog.i(TAG + "use server image, url=" + url);
|
||||
try {
|
||||
filePath = NoteFileService.getImageFromServer(Uri.parse(url), Leamonax.getContext().getCacheDir());
|
||||
noteFile.setLocalPath(filePath);
|
||||
Log.i(TAG, "download finished, path=" + filePath);
|
||||
XLog.i(TAG + "download finished, path=" + filePath);
|
||||
noteFile.save();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
@@ -93,7 +94,7 @@ public class NoteFileService {
|
||||
URI target = URI.create(targetUri.toString());
|
||||
String fileName = String.format(Locale.US, "leanote-%s.png", new ObjectId().toString());
|
||||
File file = new File(parentDir, fileName);
|
||||
// Log.i(TAG, "target=" + target.toString() + ", file=" + file.getAbsolutePath());
|
||||
// XLog.i(TAG + "target=" + target.toString() + ", file=" + file.getAbsolutePath());
|
||||
|
||||
InputStream input = target.toURL().openStream();
|
||||
BufferedSource source = Okio.buffer(Okio.source(input));
|
||||
|
@@ -4,9 +4,9 @@ package org.houxg.leamonax.service;
|
||||
import android.net.Uri;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.webkit.MimeTypeMap;
|
||||
|
||||
import com.elvishew.xlog.XLog;
|
||||
import com.raizlabs.android.dbflow.sql.language.SQLite;
|
||||
|
||||
import org.bson.types.ObjectId;
|
||||
@@ -41,7 +41,7 @@ import rx.Subscriber;
|
||||
|
||||
public class NoteService {
|
||||
|
||||
private static final String TAG = "NoteService";
|
||||
private static final String TAG = "NoteService:";
|
||||
private static final String TRUE = "1";
|
||||
private static final String FALSE = "0";
|
||||
private static final String MULTIPART_FORM_DATA = "multipart/form-data";
|
||||
@@ -56,10 +56,10 @@ public class NoteService {
|
||||
for (Notebook remoteNotebook : notebooks) {
|
||||
Notebook localNotebook = AppDataBase.getNotebookByServerId(remoteNotebook.getNotebookId());
|
||||
if (localNotebook == null) {
|
||||
Log.i(TAG, "notebook insert, usn=" + remoteNotebook.getUsn() + ", id=" + remoteNotebook.getNotebookId());
|
||||
XLog.i(TAG + "notebook insert, usn=" + remoteNotebook.getUsn() + ", id=" + remoteNotebook.getNotebookId());
|
||||
remoteNotebook.insert();
|
||||
} else {
|
||||
Log.i(TAG, "notebook update, usn=" + remoteNotebook.getUsn() + ", id=" + remoteNotebook.getNotebookId());
|
||||
XLog.i(TAG + "notebook update, usn=" + remoteNotebook.getUsn() + ", id=" + remoteNotebook.getNotebookId());
|
||||
remoteNotebook.setId(localNotebook.getId());
|
||||
remoteNotebook.setIsDirty(false);
|
||||
remoteNotebook.update();
|
||||
@@ -88,18 +88,18 @@ public class NoteService {
|
||||
if (localNote == null) {
|
||||
localId = remoteNote.insert();
|
||||
remoteNote.setId(localId);
|
||||
Log.i(TAG, "note insert, usn=" + remoteNote.getUsn() + ", id=" + remoteNote.getNoteId() + ", local=" + localId);
|
||||
XLog.i(TAG + "note insert, usn=" + remoteNote.getUsn() + ", id=" + remoteNote.getNoteId() + ", local=" + localId);
|
||||
} else {
|
||||
long id = localNote.getId();
|
||||
if (localNote.isDirty()) {
|
||||
Log.w(TAG, "note conflict, usn=" + remoteNote.getUsn() + ", id=" + remoteNote.getNoteId());
|
||||
XLog.w(TAG + "note conflict, usn=" + remoteNote.getUsn() + ", id=" + remoteNote.getNoteId());
|
||||
//save local version as a local note
|
||||
localNote.setId(null);
|
||||
localNote.setTitle(localNote.getTitle() + "--conflict");
|
||||
localNote.setNoteId("");
|
||||
localNote.insert();
|
||||
}
|
||||
Log.i(TAG, "note update, usn=" + remoteNote.getUsn() + ", id=" + remoteNote.getNoteId());
|
||||
XLog.i(TAG + "note update, usn=" + remoteNote.getUsn() + ", id=" + remoteNote.getNoteId());
|
||||
remoteNote.setId(id);
|
||||
localId = localNote.getId();
|
||||
}
|
||||
@@ -109,7 +109,7 @@ public class NoteService {
|
||||
} else {
|
||||
remoteNote.setContent(convertToLocalImageLinkForRichText(localId, remoteNote.getContent()));
|
||||
}
|
||||
Log.i(TAG, "content=" + remoteNote.getContent());
|
||||
XLog.i(TAG + "content=" + remoteNote.getContent());
|
||||
remoteNote.update();
|
||||
handleFile(localId, remoteNote.getNoteFiles());
|
||||
updateTagsToLocal(localId, remoteNote.getTagData());
|
||||
@@ -127,7 +127,7 @@ public class NoteService {
|
||||
if (CollectionUtils.isEmpty(remoteFiles)) {
|
||||
return;
|
||||
}
|
||||
Log.i(TAG, "file size=" + remoteFiles.size());
|
||||
XLog.i(TAG + "file size=" + remoteFiles.size());
|
||||
List<String> excepts = new ArrayList<>();
|
||||
for (NoteFile remote : remoteFiles) {
|
||||
NoteFile local;
|
||||
@@ -137,10 +137,10 @@ public class NoteService {
|
||||
local = AppDataBase.getNoteFileByLocalId(remote.getLocalId());
|
||||
}
|
||||
if (local != null) {
|
||||
Log.i(TAG, "has local file, id=" + remote.getServerId());
|
||||
XLog.i(TAG + "has local file, id=" + remote.getServerId());
|
||||
local.setServerId(remote.getServerId());
|
||||
} else {
|
||||
Log.i(TAG, "need to insert, id=" + remote.getServerId());
|
||||
XLog.i(TAG + "need to insert, id=" + remote.getServerId());
|
||||
local = new NoteFile();
|
||||
local.setLocalId(new ObjectId().toString());
|
||||
}
|
||||
@@ -159,7 +159,7 @@ public class NoteService {
|
||||
new StringUtils.Replacer() {
|
||||
@Override
|
||||
public String replaceWith(String original, Object... extraData) {
|
||||
Log.i(TAG, "in=" + original);
|
||||
XLog.i(TAG + "in=" + original);
|
||||
Uri linkUri = Uri.parse(original.substring(6, original.length() - 1));
|
||||
String serverId = linkUri.getQueryParameter("fileId");
|
||||
NoteFile noteFile = AppDataBase.getNoteFileByServerId(serverId);
|
||||
@@ -172,7 +172,7 @@ public class NoteService {
|
||||
}
|
||||
String localId = noteFile.getLocalId();
|
||||
String result = String.format(Locale.US, " src=\"%s\"", NoteFileService.getLocalImageUri(localId).toString());
|
||||
Log.i(TAG, "out=" + result);
|
||||
XLog.i(TAG + "out=" + result);
|
||||
return result;
|
||||
}
|
||||
}, noteLocalId);
|
||||
@@ -501,7 +501,7 @@ public class NoteService {
|
||||
try {
|
||||
tempFile = new File(noteFile.getLocalPath());
|
||||
if (!tempFile.isFile()) {
|
||||
Log.w(TAG, "not a file");
|
||||
XLog.w(TAG + "not a file");
|
||||
return null;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package org.houxg.leamonax.service;
|
||||
|
||||
|
||||
import android.util.Log;
|
||||
import com.elvishew.xlog.XLog;
|
||||
|
||||
import org.houxg.leamonax.database.AppDataBase;
|
||||
import org.houxg.leamonax.model.Account;
|
||||
@@ -11,7 +11,7 @@ import org.houxg.leamonax.utils.RetrofitUtils;
|
||||
|
||||
public class NotebookService {
|
||||
|
||||
private static final String TAG = "NotebookService";
|
||||
private static final String TAG = "NotebookService:";
|
||||
|
||||
public static void addNotebook(String title, String parentNotebookId) {
|
||||
Notebook notebook = RetrofitUtils.excute(ApiProvider.getInstance().getNotebookApi().addNotebook(title, parentNotebookId));
|
||||
@@ -21,7 +21,7 @@ public class NotebookService {
|
||||
if (notebook.isOk()) {
|
||||
Account account = AccountService.getCurrent();
|
||||
if (notebook.getUsn() - account.getNotebookUsn() == 1) {
|
||||
Log.d(TAG, "update usn=" + notebook.getUsn());
|
||||
XLog.d(TAG + "update usn=" + notebook.getUsn());
|
||||
account.setNotebookUsn(notebook.getUsn());
|
||||
account.save();
|
||||
}
|
||||
|
@@ -11,11 +11,12 @@ import android.support.v7.widget.DefaultItemAnimator;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.elvishew.xlog.XLog;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
@@ -44,7 +45,7 @@ import rx.schedulers.Schedulers;
|
||||
|
||||
public class NoteFragment extends Fragment implements NoteAdapter.NoteAdapterListener {
|
||||
|
||||
private static final String TAG = "NoteFragment";
|
||||
private static final String TAG = "NoteFragment:";
|
||||
private static final String EXT_SCROLL_POSITION = "ext_scroll_position";
|
||||
private static final String EXT_SHOULD_FETCH_NOTES = "ext_should_fetch_notes";
|
||||
|
||||
@@ -129,7 +130,7 @@ public class NoteFragment extends Fragment implements NoteAdapter.NoteAdapterLis
|
||||
mSwipeRefresh.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Log.i(TAG, "fetch notes");
|
||||
XLog.i(TAG + "fetch notes");
|
||||
mSwipeRefresh.setRefreshing(true);
|
||||
syncNotes();
|
||||
}
|
||||
@@ -182,7 +183,7 @@ public class NoteFragment extends Fragment implements NoteAdapter.NoteAdapterLis
|
||||
}
|
||||
|
||||
private void refreshNotes() {
|
||||
Log.i(TAG, "refresh:" + mCurrentMode);
|
||||
XLog.i(TAG + "refresh:" + mCurrentMode);
|
||||
switch (mCurrentMode) {
|
||||
case RECENT_NOTES:
|
||||
mNotes = AppDataBase.getAllNotes(AccountService.getCurrent().getUserId());
|
||||
@@ -248,7 +249,7 @@ public class NoteFragment extends Fragment implements NoteAdapter.NoteAdapterLis
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onEvent(SyncEvent event) {
|
||||
Log.i(TAG, "RequestNotes rcv: isSucceed=" + event.isSucceed());
|
||||
XLog.i(TAG + "RequestNotes rcv: isSucceed=" + event.isSucceed());
|
||||
if (isAdded()) {
|
||||
mSwipeRefresh.setRefreshing(false);
|
||||
if (mSyncFinishListener != null) {
|
||||
|
@@ -10,6 +10,7 @@ import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
|
||||
import com.elvishew.xlog.XLog;
|
||||
import com.tencent.bugly.crashreport.CrashReport;
|
||||
|
||||
import org.houxg.leamonax.BuildConfig;
|
||||
@@ -19,7 +20,6 @@ import org.houxg.leamonax.model.Note;
|
||||
import org.houxg.leamonax.service.NoteService;
|
||||
import org.houxg.leamonax.ui.edit.EditorFragment;
|
||||
import org.houxg.leamonax.ui.edit.NoteEditActivity;
|
||||
import org.houxg.leamonax.utils.AppLog;
|
||||
import org.houxg.leamonax.utils.DialogDisplayer;
|
||||
import org.houxg.leamonax.utils.NetworkUtils;
|
||||
import org.houxg.leamonax.utils.ToastUtils;
|
||||
@@ -37,7 +37,7 @@ import rx.schedulers.Schedulers;
|
||||
|
||||
public class NotePreviewActivity extends BaseActivity implements EditorFragment.EditorFragmentListener {
|
||||
|
||||
private static final String TAG = "NotePreviewActivity";
|
||||
private static final String TAG = "NotePreviewActivity:";
|
||||
public static final String EXT_NOTE_LOCAL_ID = "ext_note_local_id";
|
||||
public static final int REQ_EDIT = 1;
|
||||
|
||||
@@ -102,7 +102,7 @@ public class NotePreviewActivity extends BaseActivity implements EditorFragment.
|
||||
.subscribe();
|
||||
return true;
|
||||
case R.id.action_print:
|
||||
AppLog.i(TAG, mNote.getContent());
|
||||
XLog.i(TAG + mNote.getContent());
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
@@ -37,7 +37,7 @@ import rx.schedulers.Schedulers;
|
||||
|
||||
public class SignInActivity extends BaseActivity implements TextWatcher {
|
||||
|
||||
private static final String TAG = "SignInActivity";
|
||||
private static final String TAG = "SignInActivity:";
|
||||
|
||||
private static final String LEANOTE_HOST = "https://leanote.com";
|
||||
private static final String FIND_PASSWORD = "/findPassword";
|
||||
|
@@ -14,7 +14,6 @@ import android.support.v4.app.Fragment;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.view.GravityCompat;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -27,6 +26,7 @@ import android.widget.PopupWindow;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.elvishew.xlog.XLog;
|
||||
import com.yuyh.library.imgsel.ImgSelActivity;
|
||||
import com.yuyh.library.imgsel.ImgSelConfig;
|
||||
|
||||
@@ -55,7 +55,7 @@ import rx.schedulers.Schedulers;
|
||||
|
||||
public class EditorFragment extends Fragment implements Editor.EditorListener {
|
||||
|
||||
private static final String TAG = "EditorFragment";
|
||||
private static final String TAG = "EditorFragment:";
|
||||
private static final String ARG_IS_MARKDOWN = "arg_is_markdown";
|
||||
private static final String ARG_ENABLE_EDIT = "arg_enable_edit";
|
||||
protected static final int REQ_SELECT_IMAGE = 879;
|
||||
@@ -217,7 +217,7 @@ public class EditorFragment extends Fragment implements Editor.EditorListener {
|
||||
DialogUtils.editLink(getActivity(), "", "", new DialogUtils.ChangedListener() {
|
||||
@Override
|
||||
public void onChanged(String title, String link) {
|
||||
Log.i(TAG, "title=" + title + ", url=" + link);
|
||||
XLog.i(TAG + "title=" + title + ", url=" + link);
|
||||
mEditor.insertLink(title, link);
|
||||
}
|
||||
});
|
||||
@@ -314,7 +314,7 @@ public class EditorFragment extends Fragment implements Editor.EditorListener {
|
||||
List<String> pathList = data.getStringArrayListExtra(ImgSelActivity.INTENT_RESULT);
|
||||
if (CollectionUtils.isNotEmpty(pathList)) {
|
||||
String path = pathList.get(0);
|
||||
Log.i(TAG, "path=" + path);
|
||||
XLog.i(TAG + "path=" + path);
|
||||
//create ImageObject
|
||||
Uri imageUri = mListener.createImage(path);
|
||||
//insert to note
|
||||
|
@@ -8,11 +8,12 @@ import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentPagerAdapter;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.elvishew.xlog.XLog;
|
||||
|
||||
import org.houxg.leamonax.R;
|
||||
import org.houxg.leamonax.database.AppDataBase;
|
||||
import org.houxg.leamonax.model.Note;
|
||||
@@ -41,7 +42,7 @@ import rx.schedulers.Schedulers;
|
||||
//TODO: hide action bar
|
||||
public class NoteEditActivity extends BaseActivity implements EditorFragment.EditorFragmentListener, SettingFragment.SettingFragmentListener {
|
||||
|
||||
private static final String TAG = "NoteEditActivity";
|
||||
private static final String TAG = "NoteEditActivity:";
|
||||
public static final String EXT_NOTE_LOCAL_ID = "ext_note_local_id";
|
||||
public static final String EXT_IS_NEW_NOTE = "ext_is_new_note";
|
||||
public static final String TAG_EDITOR = "tag_editor_tag";
|
||||
@@ -174,10 +175,10 @@ public class NoteEditActivity extends BaseActivity implements EditorFragment.Edi
|
||||
@Override
|
||||
public void call(Wrapper wrapper) {
|
||||
setResult(RESULT_OK);
|
||||
Log.i(TAG, wrapper.toString());
|
||||
XLog.i(TAG + wrapper.toString());
|
||||
|
||||
if (mIsNewNote && isTitleContentEmpty(wrapper.note)) {
|
||||
Log.i(TAG, "remove empty note, id=" + wrapper.note.getId());
|
||||
XLog.i(TAG + "remove empty note, id=" + wrapper.note.getId());
|
||||
AppDataBase.deleteNoteByLocalId(wrapper.note.getId());
|
||||
} else {
|
||||
saveAsDraft(wrapper);
|
||||
@@ -221,10 +222,10 @@ public class NoteEditActivity extends BaseActivity implements EditorFragment.Edi
|
||||
@Override
|
||||
public void call(Wrapper wrapper) {
|
||||
setResult(RESULT_OK);
|
||||
Log.i(TAG, wrapper.toString());
|
||||
XLog.i(TAG + wrapper.toString());
|
||||
|
||||
if (mIsNewNote && isTitleContentEmpty(wrapper.note)) {
|
||||
Log.i(TAG, "remove empty note, id=" + wrapper.note.getId());
|
||||
XLog.i(TAG + "remove empty note, id=" + wrapper.note.getId());
|
||||
AppDataBase.deleteNoteByLocalId(wrapper.note.getId());
|
||||
} else {
|
||||
saveAsDraft(wrapper);
|
||||
@@ -279,7 +280,7 @@ public class NoteEditActivity extends BaseActivity implements EditorFragment.Edi
|
||||
|
||||
private void saveAsDraft(Wrapper wrapper) {
|
||||
Note modifiedNote = wrapper.note;
|
||||
Log.i(TAG, "saveAsDraft(), local id=" + modifiedNote.getId());
|
||||
XLog.i(TAG + "saveAsDraft(), local id=" + modifiedNote.getId());
|
||||
Note noteFromDb = AppDataBase.getNoteByLocalId(modifiedNote.getId());
|
||||
noteFromDb.setContent(modifiedNote.getContent());
|
||||
noteFromDb.setTitle(modifiedNote.getTitle());
|
||||
|
@@ -38,7 +38,7 @@ import butterknife.OnClick;
|
||||
|
||||
public class SettingFragment extends Fragment {
|
||||
|
||||
private static final String TAG = "SettingFragment";
|
||||
private static final String TAG = "SettingFragment:";
|
||||
private static final Pattern TAG_PATTERN = Pattern.compile("[^,\\s]+\\s*[^,]*");
|
||||
|
||||
@BindView(R.id.sw_public)
|
||||
|
@@ -1,18 +0,0 @@
|
||||
package org.houxg.leamonax.utils;
|
||||
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
public class AppLog {
|
||||
|
||||
private static final int LOG_LIMIT = 3000;
|
||||
|
||||
public static void i(String tag, String message) {
|
||||
do {
|
||||
int offset = Math.min(message.length(), LOG_LIMIT);
|
||||
String print = message.substring(0, offset);
|
||||
message = message.substring(offset);
|
||||
Log.i(tag, print);
|
||||
} while (message.length() > 0);
|
||||
}
|
||||
}
|
@@ -7,7 +7,7 @@ import org.joda.time.format.DateTimeFormat;
|
||||
import java.util.Calendar;
|
||||
|
||||
public class TimeUtils {
|
||||
public static final String TAG = "TimeUtils";
|
||||
public static final String TAG = "TimeUtils:";
|
||||
|
||||
public static long toTimestamp(String serverTime) {
|
||||
return DateTime.parse(serverTime).getMillis();
|
||||
|
@@ -2,14 +2,15 @@ package org.houxg.leamonax.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.webkit.ValueCallback;
|
||||
import android.webkit.WebView;
|
||||
|
||||
import com.elvishew.xlog.XLog;
|
||||
|
||||
|
||||
public class LeaWebView extends WebView {
|
||||
|
||||
private static final String TAG = "LeaWebView";
|
||||
private static final String TAG = "LeaWebView:";
|
||||
|
||||
public LeaWebView(Context context) {
|
||||
super(context);
|
||||
@@ -21,7 +22,7 @@ public class LeaWebView extends WebView {
|
||||
|
||||
@Override
|
||||
public void evaluateJavascript(String script, ValueCallback<String> resultCallback) {
|
||||
Log.i(TAG, "execute=" + script);
|
||||
XLog.i(TAG + "execute=" + script);
|
||||
super.evaluateJavascript(script, resultCallback);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user