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