Commit 42fb1f71 authored by Yusuke Iwaki's avatar Yusuke Iwaki

remove Timber.

parent 2a77ce1f
...@@ -40,9 +40,9 @@ android { ...@@ -40,9 +40,9 @@ android {
} }
dependencies { dependencies {
compile project(':log-wrapper-dev')
compile rootProject.ext.supportAnnotations compile rootProject.ext.supportAnnotations
compile 'com.squareup.okhttp3:okhttp-ws:3.4.1' compile 'com.squareup.okhttp3:okhttp-ws:3.4.1'
compile rootProject.ext.rxJava compile rootProject.ext.rxJava
compile rootProject.ext.boltsTask compile rootProject.ext.boltsTask
compile rootProject.ext.timber
} }
...@@ -7,7 +7,6 @@ import chat.rocket.android_ddp.rx.RxWebSocketCallback; ...@@ -7,7 +7,6 @@ import chat.rocket.android_ddp.rx.RxWebSocketCallback;
import okhttp3.OkHttpClient; import okhttp3.OkHttpClient;
import org.json.JSONArray; import org.json.JSONArray;
import rx.Observable; import rx.Observable;
import timber.log.Timber;
public class DDPClient { public class DDPClient {
// reference: https://github.com/eddflrs/meteor-ddp/blob/master/meteor-ddp.js // reference: https://github.com/eddflrs/meteor-ddp/blob/master/meteor-ddp.js
...@@ -16,7 +15,6 @@ public class DDPClient { ...@@ -16,7 +15,6 @@ public class DDPClient {
public DDPClient(OkHttpClient client) { public DDPClient(OkHttpClient client) {
impl = new DDPClientImpl(this, client); impl = new DDPClientImpl(this, client);
Timber.plant(new Timber.DebugTree());
} }
public Task<DDPClientCallback.Connect> connect(String url) { public Task<DDPClientCallback.Connect> connect(String url) {
......
...@@ -5,6 +5,7 @@ import android.support.annotation.Nullable; ...@@ -5,6 +5,7 @@ import android.support.annotation.Nullable;
import android.text.TextUtils; import android.text.TextUtils;
import bolts.Task; import bolts.Task;
import bolts.TaskCompletionSource; import bolts.TaskCompletionSource;
import chat.rocket.android.log.RCLog;
import chat.rocket.android_ddp.rx.RxWebSocket; import chat.rocket.android_ddp.rx.RxWebSocket;
import chat.rocket.android_ddp.rx.RxWebSocketCallback; import chat.rocket.android_ddp.rx.RxWebSocketCallback;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
...@@ -16,7 +17,6 @@ import org.json.JSONObject; ...@@ -16,7 +17,6 @@ import org.json.JSONObject;
import rx.Observable; import rx.Observable;
import rx.functions.Func1; import rx.functions.Func1;
import rx.subscriptions.CompositeSubscription; import rx.subscriptions.CompositeSubscription;
import timber.log.Timber;
public class DDPClientImpl { public class DDPClientImpl {
private final DDPClient client; private final DDPClient client;
...@@ -86,7 +86,7 @@ public class DDPClientImpl { ...@@ -86,7 +86,7 @@ public class DDPClientImpl {
subscribeBaseListeners(); subscribeBaseListeners();
} catch (Exception e) { } catch (Exception e) {
Timber.e(e); RCLog.e(e);
} }
} }
...@@ -304,9 +304,7 @@ public class DDPClientImpl { ...@@ -304,9 +304,7 @@ public class DDPClientImpl {
observable.filter(callback -> callback instanceof RxWebSocketCallback.Close) observable.filter(callback -> callback instanceof RxWebSocketCallback.Close)
.cast(RxWebSocketCallback.Close.class) .cast(RxWebSocketCallback.Close.class)
.subscribe(close -> { .subscribe(task::setResult, err -> {
task.setResult(close);
}, err -> {
if (err instanceof Exception) { if (err instanceof Exception) {
task.setError((Exception) err); task.setError((Exception) err);
} else { } else {
...@@ -326,7 +324,7 @@ public class DDPClientImpl { ...@@ -326,7 +324,7 @@ public class DDPClientImpl {
String msg2 = (json == null ? origJson : json.create(origJson)).toString(); String msg2 = (json == null ? origJson : json.create(origJson)).toString();
websocket.sendText(msg2); websocket.sendText(msg2);
} catch (Exception e) { } catch (Exception e) {
Timber.e(e); RCLog.e(e);
} }
} }
...@@ -342,7 +340,7 @@ public class DDPClientImpl { ...@@ -342,7 +340,7 @@ public class DDPClientImpl {
try { try {
websocket.close(code, reason); websocket.close(code, reason);
} catch (Exception e) { } catch (Exception e) {
Timber.e(e); RCLog.e(e);
} }
} }
......
package chat.rocket.android_ddp.rx; package chat.rocket.android_ddp.rx;
import chat.rocket.android.log.RCLog;
import java.io.IOException; import java.io.IOException;
import okhttp3.OkHttpClient; import okhttp3.OkHttpClient;
import okhttp3.Request; import okhttp3.Request;
...@@ -14,7 +15,6 @@ import rx.Observable; ...@@ -14,7 +15,6 @@ import rx.Observable;
import rx.Subscriber; import rx.Subscriber;
import rx.exceptions.OnErrorNotImplementedException; import rx.exceptions.OnErrorNotImplementedException;
import rx.observables.ConnectableObservable; import rx.observables.ConnectableObservable;
import timber.log.Timber;
public class RxWebSocket { public class RxWebSocket {
private OkHttpClient httpClient; private OkHttpClient httpClient;
...@@ -44,7 +44,7 @@ public class RxWebSocket { ...@@ -44,7 +44,7 @@ public class RxWebSocket {
isConnected = false; isConnected = false;
subscriber.onError(new RxWebSocketCallback.Failure(webSocket, e, response)); subscriber.onError(new RxWebSocketCallback.Failure(webSocket, e, response));
} catch (OnErrorNotImplementedException ex) { } catch (OnErrorNotImplementedException ex) {
Timber.w(ex, "OnErrorNotImplementedException ignored"); RCLog.w(ex, "OnErrorNotImplementedException ignored");
} }
} }
......
package chat.rocket.android_ddp.rx; package chat.rocket.android_ddp.rx;
import chat.rocket.android.log.RCLog;
import java.io.IOException; import java.io.IOException;
import okhttp3.Response; import okhttp3.Response;
import okhttp3.ResponseBody; import okhttp3.ResponseBody;
import okhttp3.ws.WebSocket; import okhttp3.ws.WebSocket;
import okio.Buffer; import okio.Buffer;
import timber.log.Timber;
import static android.R.attr.type; import static android.R.attr.type;
...@@ -60,7 +60,7 @@ public class RxWebSocketCallback { ...@@ -60,7 +60,7 @@ public class RxWebSocketCallback {
try { try {
this.responseBodyString = responseBody.string(); this.responseBodyString = responseBody.string();
} catch (Exception e) { } catch (Exception e) {
Timber.e(e, "error in reading response(Message)"); RCLog.e(e, "error in reading response(Message)");
} }
} }
......
...@@ -75,14 +75,14 @@ android { ...@@ -75,14 +75,14 @@ android {
repositories { repositories {
mavenCentral() mavenCentral()
maven { url 'https://github.com/YusukeIwaki/realm-java-helpers/raw/master/repo' }
maven { url 'https://github.com/lijingle1/stetho-realm/raw/master/maven-repo' } maven { url 'https://github.com/lijingle1/stetho-realm/raw/master/maven-repo' }
maven { url 'https://github.com/RocketChat/Android-DDP/raw/master/repository' }
maven { url 'http://dl.bintray.com/amulyakhare/maven' } maven { url 'http://dl.bintray.com/amulyakhare/maven' }
maven { url "https://clojars.org/repo/" } //for icepick. maven { url "https://clojars.org/repo/" } //for icepick.
} }
dependencies { dependencies {
debugCompile project(':log-wrapper-dev')
releaseCompile project(':log-wrapper-rel')
compile project(':android-ddp') compile project(':android-ddp')
compile project(':rocket-chat-android-widgets') compile project(':rocket-chat-android-widgets')
compile project(':realm-helpers') compile project(':realm-helpers')
...@@ -104,7 +104,6 @@ dependencies { ...@@ -104,7 +104,6 @@ dependencies {
compile 'com.facebook.stetho:stetho-okhttp3:1.4.1' compile 'com.facebook.stetho:stetho-okhttp3:1.4.1'
compile 'com.uphyca:stetho_realm:2.0.1' compile 'com.uphyca:stetho_realm:2.0.1'
compile rootProject.ext.timber
compile 'com.jakewharton.rxbinding:rxbinding:0.4.0' compile 'com.jakewharton.rxbinding:rxbinding:0.4.0'
compile 'com.jakewharton.rxbinding:rxbinding-support-v4:0.4.0' compile 'com.jakewharton.rxbinding:rxbinding-support-v4:0.4.0'
......
...@@ -11,7 +11,6 @@ import com.uphyca.stetho_realm.RealmInspectorModulesProvider; ...@@ -11,7 +11,6 @@ import com.uphyca.stetho_realm.RealmInspectorModulesProvider;
import io.realm.Realm; import io.realm.Realm;
import io.realm.RealmConfiguration; import io.realm.RealmConfiguration;
import java.util.List; import java.util.List;
import timber.log.Timber;
/** /**
* Customized Application-class for Rocket.Chat * Customized Application-class for Rocket.Chat
...@@ -20,8 +19,6 @@ public class RocketChatApplication extends MultiDexApplication { ...@@ -20,8 +19,6 @@ public class RocketChatApplication extends MultiDexApplication {
@Override public void onCreate() { @Override public void onCreate() {
super.onCreate(); super.onCreate();
Timber.plant(new Timber.DebugTree());
Realm.init(this); Realm.init(this);
Realm.setDefaultConfiguration( Realm.setDefaultConfiguration(
new RealmConfiguration.Builder().deleteRealmIfMigrationNeeded().build()); new RealmConfiguration.Builder().deleteRealmIfMigrationNeeded().build());
......
...@@ -7,10 +7,10 @@ import android.support.v4.app.Fragment; ...@@ -7,10 +7,10 @@ import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentManager;
import android.view.MotionEvent; import android.view.MotionEvent;
import chat.rocket.android.helper.OnBackPressListener; import chat.rocket.android.helper.OnBackPressListener;
import chat.rocket.android.log.RCLog;
import com.instabug.library.InstabugTrackingDelegate; import com.instabug.library.InstabugTrackingDelegate;
import com.trello.rxlifecycle.components.support.RxAppCompatActivity; import com.trello.rxlifecycle.components.support.RxAppCompatActivity;
import icepick.Icepick; import icepick.Icepick;
import timber.log.Timber;
abstract class AbstractFragmentActivity extends RxAppCompatActivity { abstract class AbstractFragmentActivity extends RxAppCompatActivity {
...@@ -70,7 +70,7 @@ abstract class AbstractFragmentActivity extends RxAppCompatActivity { ...@@ -70,7 +70,7 @@ abstract class AbstractFragmentActivity extends RxAppCompatActivity {
try { try {
InstabugTrackingDelegate.notifyActivityGotTouchEvent(event, this); InstabugTrackingDelegate.notifyActivityGotTouchEvent(event, this);
} catch (IllegalStateException exception) { } catch (IllegalStateException exception) {
Timber.w(exception, "Instabug error (ignored)"); RCLog.w(exception, "Instabug error (ignored)");
} }
return super.dispatchTouchEvent(event); return super.dispatchTouchEvent(event);
} }
......
...@@ -4,6 +4,7 @@ import android.support.annotation.Nullable; ...@@ -4,6 +4,7 @@ import android.support.annotation.Nullable;
import bolts.Task; import bolts.Task;
import chat.rocket.android.helper.OkHttpHelper; import chat.rocket.android.helper.OkHttpHelper;
import chat.rocket.android.helper.TextUtils; import chat.rocket.android.helper.TextUtils;
import chat.rocket.android.log.RCLog;
import chat.rocket.android_ddp.DDPClient; import chat.rocket.android_ddp.DDPClient;
import chat.rocket.android_ddp.DDPClientCallback; import chat.rocket.android_ddp.DDPClientCallback;
import chat.rocket.android_ddp.DDPSubscription; import chat.rocket.android_ddp.DDPSubscription;
...@@ -11,7 +12,6 @@ import java.util.UUID; ...@@ -11,7 +12,6 @@ import java.util.UUID;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import rx.Observable; import rx.Observable;
import timber.log.Timber;
/** /**
* DDP client wrapper. * DDP client wrapper.
...@@ -83,13 +83,13 @@ public class DDPClientWraper { ...@@ -83,13 +83,13 @@ public class DDPClientWraper {
*/ */
public Task<DDPClientCallback.RPC> rpc(String methodCallId, String methodName, String params, public Task<DDPClientCallback.RPC> rpc(String methodCallId, String methodName, String params,
long timeoutMs) { long timeoutMs) {
Timber.d("rpc:[%s]> %s(%s) timeout=%d", methodCallId, methodName, params, timeoutMs); RCLog.d("rpc:[%s]> %s(%s) timeout=%d", methodCallId, methodName, params, timeoutMs);
if (TextUtils.isEmpty(params)) { if (TextUtils.isEmpty(params)) {
return ddpClient.rpc(methodName, null, methodCallId, timeoutMs).continueWithTask(task -> { return ddpClient.rpc(methodName, null, methodCallId, timeoutMs).continueWithTask(task -> {
if (task.isFaulted()) { if (task.isFaulted()) {
Timber.d("rpc:[%s]< error = %s", methodCallId, task.getError()); RCLog.d("rpc:[%s]< error = %s", methodCallId, task.getError());
} else { } else {
Timber.d("rpc:[%s]< result = %s", methodCallId, task.getResult().result); RCLog.d("rpc:[%s]< result = %s", methodCallId, task.getResult().result);
} }
return task; return task;
}); });
...@@ -99,9 +99,9 @@ public class DDPClientWraper { ...@@ -99,9 +99,9 @@ public class DDPClientWraper {
return ddpClient.rpc(methodName, new JSONArray(params), methodCallId, timeoutMs) return ddpClient.rpc(methodName, new JSONArray(params), methodCallId, timeoutMs)
.continueWithTask(task -> { .continueWithTask(task -> {
if (task.isFaulted()) { if (task.isFaulted()) {
Timber.d("rpc:[%s]< error = %s", methodCallId, task.getError()); RCLog.d("rpc:[%s]< error = %s", methodCallId, task.getError());
} else { } else {
Timber.d("rpc:[%s]< result = %s", methodCallId, task.getResult().result); RCLog.d("rpc:[%s]< result = %s", methodCallId, task.getResult().result);
} }
return task; return task;
}); });
......
...@@ -19,6 +19,7 @@ import chat.rocket.android.helper.OnBackPressListener; ...@@ -19,6 +19,7 @@ import chat.rocket.android.helper.OnBackPressListener;
import chat.rocket.android.layouthelper.chatroom.MessageComposerManager; import chat.rocket.android.layouthelper.chatroom.MessageComposerManager;
import chat.rocket.android.layouthelper.chatroom.MessageListAdapter; import chat.rocket.android.layouthelper.chatroom.MessageListAdapter;
import chat.rocket.android.layouthelper.chatroom.PairedMessage; import chat.rocket.android.layouthelper.chatroom.PairedMessage;
import chat.rocket.android.log.RCLog;
import chat.rocket.android.model.ServerConfig; import chat.rocket.android.model.ServerConfig;
import chat.rocket.android.model.SyncState; import chat.rocket.android.model.SyncState;
import chat.rocket.android.model.ddp.Message; import chat.rocket.android.model.ddp.Message;
...@@ -37,7 +38,6 @@ import io.realm.Sort; ...@@ -37,7 +38,6 @@ import io.realm.Sort;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.UUID; import java.util.UUID;
import org.json.JSONObject; import org.json.JSONObject;
import timber.log.Timber;
/** /**
* Chat room screen. * Chat room screen.
...@@ -175,7 +175,7 @@ public class RoomFragment extends AbstractChatRoomFragment ...@@ -175,7 +175,7 @@ public class RoomFragment extends AbstractChatRoomFragment
fieldSlidable.setAccessible(true); fieldSlidable.setAccessible(true);
fieldSlidable.setBoolean(pane, !opened); fieldSlidable.setBoolean(pane, !opened);
} catch (Exception exception) { } catch (Exception exception) {
Timber.w(exception, "failed to set CanSlide."); RCLog.w(exception);
} }
}); });
} }
...@@ -233,7 +233,7 @@ public class RoomFragment extends AbstractChatRoomFragment ...@@ -233,7 +233,7 @@ public class RoomFragment extends AbstractChatRoomFragment
MessageListAdapter adapter = (MessageListAdapter) listView.getAdapter(); MessageListAdapter adapter = (MessageListAdapter) listView.getAdapter();
final int syncstate = procedure.getSyncstate(); final int syncstate = procedure.getSyncstate();
final boolean hasNext = procedure.isHasNext(); final boolean hasNext = procedure.isHasNext();
Timber.d("hasNext: %s syncstate: %d", hasNext, syncstate); RCLog.d("hasNext: %s syncstate: %d", hasNext, syncstate);
if (syncstate == SyncState.SYNCED || syncstate == SyncState.FAILED) { if (syncstate == SyncState.SYNCED || syncstate == SyncState.FAILED) {
scrollListener.setLoadingDone(); scrollListener.setLoadingDone();
adapter.updateFooter(hasNext, true); adapter.updateFooter(hasNext, true);
......
...@@ -10,6 +10,7 @@ import android.widget.TextView; ...@@ -10,6 +10,7 @@ import android.widget.TextView;
import chat.rocket.android.R; import chat.rocket.android.R;
import chat.rocket.android.helper.LogcatIfError; import chat.rocket.android.helper.LogcatIfError;
import chat.rocket.android.layouthelper.chatroom.dialog.RoomUserAdapter; import chat.rocket.android.layouthelper.chatroom.dialog.RoomUserAdapter;
import chat.rocket.android.log.RCLog;
import chat.rocket.android.model.SyncState; import chat.rocket.android.model.SyncState;
import chat.rocket.android.model.internal.GetUsersOfRoomsProcedure; import chat.rocket.android.model.internal.GetUsersOfRoomsProcedure;
import chat.rocket.android.realm_helper.RealmObjectObserver; import chat.rocket.android.realm_helper.RealmObjectObserver;
...@@ -19,7 +20,6 @@ import java.util.List; ...@@ -19,7 +20,6 @@ import java.util.List;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import timber.log.Timber;
/** /**
* Dialog to show members in a room. * Dialog to show members in a room.
...@@ -122,7 +122,7 @@ public class UsersOfRoomDialogFragment extends AbstractChatroomDialogFragment { ...@@ -122,7 +122,7 @@ public class UsersOfRoomDialogFragment extends AbstractChatroomDialogFragment {
} }
onRenderUsers(users); onRenderUsers(users);
} catch (JSONException exception) { } catch (JSONException exception) {
Timber.e(exception); RCLog.e(exception);
} }
} }
} }
......
...@@ -9,13 +9,13 @@ import android.webkit.WebView; ...@@ -9,13 +9,13 @@ import android.webkit.WebView;
import chat.rocket.android.api.MethodCallHelper; import chat.rocket.android.api.MethodCallHelper;
import chat.rocket.android.fragment.AbstractWebViewFragment; import chat.rocket.android.fragment.AbstractWebViewFragment;
import chat.rocket.android.helper.LogcatIfError; import chat.rocket.android.helper.LogcatIfError;
import chat.rocket.android.log.RCLog;
import chat.rocket.android.model.ServerConfig; import chat.rocket.android.model.ServerConfig;
import chat.rocket.android.model.ddp.MeteorLoginServiceConfiguration; import chat.rocket.android.model.ddp.MeteorLoginServiceConfiguration;
import chat.rocket.android.realm_helper.RealmStore; import chat.rocket.android.realm_helper.RealmStore;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import timber.log.Timber;
public abstract class AbstractOAuthFragment extends AbstractWebViewFragment { public abstract class AbstractOAuthFragment extends AbstractWebViewFragment {
...@@ -91,7 +91,7 @@ public abstract class AbstractOAuthFragment extends AbstractWebViewFragment { ...@@ -91,7 +91,7 @@ public abstract class AbstractOAuthFragment extends AbstractWebViewFragment {
handleOAuthCallback(credentialToken, credentialSecret); handleOAuthCallback(credentialToken, credentialSecret);
resultOK = true; resultOK = true;
} catch (JSONException exception) { } catch (JSONException exception) {
Timber.e(exception, "failed to parse OAuth result."); RCLog.e(exception, "failed to parse OAuth result.");
} }
} }
......
...@@ -10,12 +10,12 @@ import chat.rocket.android.R; ...@@ -10,12 +10,12 @@ import chat.rocket.android.R;
import chat.rocket.android.api.MethodCallHelper; import chat.rocket.android.api.MethodCallHelper;
import chat.rocket.android.helper.TextUtils; import chat.rocket.android.helper.TextUtils;
import chat.rocket.android.layouthelper.oauth.OAuthProviderInfo; import chat.rocket.android.layouthelper.oauth.OAuthProviderInfo;
import chat.rocket.android.log.RCLog;
import chat.rocket.android.model.ddp.MeteorLoginServiceConfiguration; import chat.rocket.android.model.ddp.MeteorLoginServiceConfiguration;
import chat.rocket.android.realm_helper.RealmListObserver; import chat.rocket.android.realm_helper.RealmListObserver;
import chat.rocket.android.realm_helper.RealmStore; import chat.rocket.android.realm_helper.RealmStore;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import timber.log.Timber;
/** /**
* Login screen. * Login screen.
...@@ -87,7 +87,7 @@ public class LoginFragment extends AbstractServerConfigFragment { ...@@ -87,7 +87,7 @@ public class LoginFragment extends AbstractServerConfigFragment {
try { try {
fragment = info.fragmentClass.newInstance(); fragment = info.fragmentClass.newInstance();
} catch (Exception exception) { } catch (Exception exception) {
Timber.w(exception, "failed to create new Fragment"); RCLog.w(exception, "failed to create new Fragment");
} }
if (fragment != null) { if (fragment != null) {
Bundle args = new Bundle(); Bundle args = new Bundle();
......
...@@ -11,14 +11,12 @@ import android.os.Looper; ...@@ -11,14 +11,12 @@ import android.os.Looper;
import android.widget.ImageView; import android.widget.ImageView;
import bolts.Task; import bolts.Task;
import bolts.TaskCompletionSource; import bolts.TaskCompletionSource;
import chat.rocket.android.log.RCLog;
import com.amulyakhare.textdrawable.TextDrawable; import com.amulyakhare.textdrawable.TextDrawable;
import com.squareup.picasso.Picasso; import com.squareup.picasso.Picasso;
import com.squareup.picasso.Target; import com.squareup.picasso.Target;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.URLEncoder; import java.net.URLEncoder;
import timber.log.Timber;
import static android.R.attr.bitmap;
/** /**
* Helper for rendering user avatar image. * Helper for rendering user avatar image.
...@@ -66,7 +64,7 @@ public class Avatar { ...@@ -66,7 +64,7 @@ public class Avatar {
try { try {
return "https://" + hostname + "/avatar/" + URLEncoder.encode(username, "UTF-8") + ".jpg"; return "https://" + hostname + "/avatar/" + URLEncoder.encode(username, "UTF-8") + ".jpg";
} catch (UnsupportedEncodingException exception) { } catch (UnsupportedEncodingException exception) {
Timber.e(exception, "failed to get URL for user: %s", username); RCLog.e(exception, "failed to get URL for user: %s", username);
return null; return null;
} }
} }
......
package chat.rocket.android.helper; package chat.rocket.android.helper;
import chat.rocket.android.log.RCLog;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
import java.util.GregorianCalendar; import java.util.GregorianCalendar;
import java.util.TimeZone; import java.util.TimeZone;
import timber.log.Timber;
/** /**
* Utility class for converting epoch ms and date-time string. * Utility class for converting epoch ms and date-time string.
...@@ -64,7 +64,7 @@ public class DateTime { ...@@ -64,7 +64,7 @@ public class DateTime {
cal.setTime(DATE_FORMAT.parse(dateString)); cal.setTime(DATE_FORMAT.parse(dateString));
return cal.getTimeInMillis(); return cal.getTimeInMillis();
} catch (ParseException exception) { } catch (ParseException exception) {
Timber.w(exception, "failed to parse date: %s", dateString); RCLog.w(exception, "failed to parse date: %s", dateString);
} }
return 0; return 0;
} }
......
...@@ -2,7 +2,7 @@ package chat.rocket.android.helper; ...@@ -2,7 +2,7 @@ package chat.rocket.android.helper;
import bolts.Continuation; import bolts.Continuation;
import bolts.Task; import bolts.Task;
import timber.log.Timber; import chat.rocket.android.log.RCLog;
/** /**
* Bolts-Task continuation for just logging if error occurred. * Bolts-Task continuation for just logging if error occurred.
...@@ -10,7 +10,7 @@ import timber.log.Timber; ...@@ -10,7 +10,7 @@ import timber.log.Timber;
public class LogcatIfError implements Continuation { public class LogcatIfError implements Continuation {
@Override public Object then(Task task) throws Exception { @Override public Object then(Task task) throws Exception {
if (task.isFaulted()) { if (task.isFaulted()) {
Timber.w(task.getError()); RCLog.w(task.getError());
} }
return task; return task;
} }
......
...@@ -6,6 +6,7 @@ import bolts.Task; ...@@ -6,6 +6,7 @@ import bolts.Task;
import bolts.TaskCompletionSource; import bolts.TaskCompletionSource;
import chat.rocket.android.helper.LogcatIfError; import chat.rocket.android.helper.LogcatIfError;
import chat.rocket.android.helper.TextUtils; import chat.rocket.android.helper.TextUtils;
import chat.rocket.android.log.RCLog;
import chat.rocket.android.model.SyncState; import chat.rocket.android.model.SyncState;
import chat.rocket.android.realm_helper.RealmHelper; import chat.rocket.android.realm_helper.RealmHelper;
import chat.rocket.android.realm_helper.RealmObjectObserver; import chat.rocket.android.realm_helper.RealmObjectObserver;
...@@ -15,7 +16,6 @@ import io.realm.annotations.PrimaryKey; ...@@ -15,7 +16,6 @@ import io.realm.annotations.PrimaryKey;
import java.util.HashMap; import java.util.HashMap;
import java.util.UUID; import java.util.UUID;
import org.json.JSONObject; import org.json.JSONObject;
import timber.log.Timber;
public class MethodCall extends RealmObject { public class MethodCall extends RealmObject {
...@@ -116,7 +116,7 @@ public class MethodCall extends RealmObject { ...@@ -116,7 +116,7 @@ public class MethodCall extends RealmObject {
realm.where(MethodCall.class).equalTo("methodCallId", newId)); realm.where(MethodCall.class).equalTo("methodCallId", newId));
observer.setOnUpdateListener(methodCall -> { observer.setOnUpdateListener(methodCall -> {
int syncstate = methodCall.getSyncstate(); int syncstate = methodCall.getSyncstate();
Timber.d("MethodCall[%s] syncstate=%d", methodCall.getMethodCallId(), syncstate); RCLog.d("MethodCall[%s] syncstate=%d", methodCall.getMethodCallId(), syncstate);
if (syncstate == SyncState.SYNCED) { if (syncstate == SyncState.SYNCED) {
String resultJson = methodCall.getResultJson(); String resultJson = methodCall.getResultJson();
if (TextUtils.isEmpty(resultJson)) { if (TextUtils.isEmpty(resultJson)) {
......
...@@ -9,6 +9,7 @@ import bolts.TaskCompletionSource; ...@@ -9,6 +9,7 @@ import bolts.TaskCompletionSource;
import chat.rocket.android.api.DDPClientWraper; import chat.rocket.android.api.DDPClientWraper;
import chat.rocket.android.helper.LogcatIfError; import chat.rocket.android.helper.LogcatIfError;
import chat.rocket.android.helper.TextUtils; import chat.rocket.android.helper.TextUtils;
import chat.rocket.android.log.RCLog;
import chat.rocket.android.model.ServerConfig; import chat.rocket.android.model.ServerConfig;
import chat.rocket.android.model.internal.Session; import chat.rocket.android.model.internal.Session;
import chat.rocket.android.realm_helper.RealmHelper; import chat.rocket.android.realm_helper.RealmHelper;
...@@ -29,7 +30,6 @@ import java.lang.reflect.Constructor; ...@@ -29,7 +30,6 @@ import java.lang.reflect.Constructor;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import org.json.JSONObject; import org.json.JSONObject;
import timber.log.Timber;
/** /**
* Thread for handling WebSocket connection. * Thread for handling WebSocket connection.
...@@ -112,7 +112,7 @@ public class RocketChatWebSocketThread extends HandlerThread { ...@@ -112,7 +112,7 @@ public class RocketChatWebSocketThread extends HandlerThread {
@Override public boolean quit() { @Override public boolean quit() {
if (isAlive()) { if (isAlive()) {
new Handler(getLooper()).post(() -> { new Handler(getLooper()).post(() -> {
Timber.d("thread %s: quit()", Thread.currentThread().getId()); RCLog.d("thread %s: quit()", Thread.currentThread().getId());
unregisterListeners(); unregisterListeners();
RocketChatWebSocketThread.super.quit(); RocketChatWebSocketThread.super.quit();
}); });
...@@ -225,7 +225,7 @@ public class RocketChatWebSocketThread extends HandlerThread { ...@@ -225,7 +225,7 @@ public class RocketChatWebSocketThread extends HandlerThread {
listeners.add(registerable); listeners.add(registerable);
} }
} catch (Exception exception) { } catch (Exception exception) {
Timber.w(exception, "Failed to register listeners!!"); RCLog.w(exception, "Failed to register listeners!!");
} }
} }
} }
......
...@@ -4,6 +4,7 @@ import android.content.Context; ...@@ -4,6 +4,7 @@ import android.content.Context;
import android.text.TextUtils; import android.text.TextUtils;
import chat.rocket.android.api.DDPClientWraper; import chat.rocket.android.api.DDPClientWraper;
import chat.rocket.android.helper.LogcatIfError; import chat.rocket.android.helper.LogcatIfError;
import chat.rocket.android.log.RCLog;
import chat.rocket.android.realm_helper.RealmHelper; import chat.rocket.android.realm_helper.RealmHelper;
import chat.rocket.android.service.Registerable; import chat.rocket.android.service.Registerable;
import chat.rocket.android_ddp.DDPSubscription; import chat.rocket.android_ddp.DDPSubscription;
...@@ -14,7 +15,6 @@ import org.json.JSONArray; ...@@ -14,7 +15,6 @@ import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import rx.Subscription; import rx.Subscription;
import timber.log.Timber;
public abstract class AbstractDDPDocEventSubscriber implements Registerable { public abstract class AbstractDDPDocEventSubscriber implements Registerable {
protected final Context context; protected final Context context;
...@@ -65,7 +65,7 @@ public abstract class AbstractDDPDocEventSubscriber implements Registerable { ...@@ -65,7 +65,7 @@ public abstract class AbstractDDPDocEventSubscriber implements Registerable {
return null; return null;
}).continueWith(task -> { }).continueWith(task -> {
if (task.isFaulted()) { if (task.isFaulted()) {
Timber.w(task.getError(), "DDP subscription failed."); RCLog.w(task.getError(), "DDP subscription failed.");
} }
return null; return null;
}); });
...@@ -103,7 +103,7 @@ public abstract class AbstractDDPDocEventSubscriber implements Registerable { ...@@ -103,7 +103,7 @@ public abstract class AbstractDDPDocEventSubscriber implements Registerable {
//ignore movedBefore //ignore movedBefore
} }
} catch (Exception exception) { } catch (Exception exception) {
Timber.w(exception, "failed to handle subscription callback"); RCLog.w(exception, "failed to handle subscription callback");
} }
}); });
} }
......
...@@ -3,13 +3,13 @@ package chat.rocket.android.service.ddp.stream; ...@@ -3,13 +3,13 @@ package chat.rocket.android.service.ddp.stream;
import android.content.Context; import android.content.Context;
import chat.rocket.android.api.DDPClientWraper; import chat.rocket.android.api.DDPClientWraper;
import chat.rocket.android.helper.LogcatIfError; import chat.rocket.android.helper.LogcatIfError;
import chat.rocket.android.log.RCLog;
import chat.rocket.android.realm_helper.RealmHelper; import chat.rocket.android.realm_helper.RealmHelper;
import chat.rocket.android.service.ddp.AbstractDDPDocEventSubscriber; import chat.rocket.android.service.ddp.AbstractDDPDocEventSubscriber;
import chat.rocket.android_ddp.DDPSubscription; import chat.rocket.android_ddp.DDPSubscription;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import timber.log.Timber;
abstract class AbstractStreamNotifyEventSubscriber extends AbstractDDPDocEventSubscriber { abstract class AbstractStreamNotifyEventSubscriber extends AbstractDDPDocEventSubscriber {
protected AbstractStreamNotifyEventSubscriber(Context context, String hostname, protected AbstractStreamNotifyEventSubscriber(Context context, String hostname,
...@@ -49,7 +49,7 @@ abstract class AbstractStreamNotifyEventSubscriber extends AbstractDDPDocEventSu ...@@ -49,7 +49,7 @@ abstract class AbstractStreamNotifyEventSubscriber extends AbstractDDPDocEventSu
handleArgs(docEvent.fields.getJSONArray("args")); handleArgs(docEvent.fields.getJSONArray("args"));
} catch (Exception exception) { } catch (Exception exception) {
Timber.w(exception, "failed to save stream-notify event."); RCLog.w(exception, "failed to save stream-notify event.");
} }
} }
......
...@@ -4,6 +4,7 @@ import android.content.Context; ...@@ -4,6 +4,7 @@ import android.content.Context;
import bolts.Task; import bolts.Task;
import chat.rocket.android.api.DDPClientWraper; import chat.rocket.android.api.DDPClientWraper;
import chat.rocket.android.api.MethodCallHelper; import chat.rocket.android.api.MethodCallHelper;
import chat.rocket.android.log.RCLog;
import chat.rocket.android.model.SyncState; import chat.rocket.android.model.SyncState;
import chat.rocket.android.model.internal.GetUsersOfRoomsProcedure; import chat.rocket.android.model.internal.GetUsersOfRoomsProcedure;
import chat.rocket.android.realm_helper.RealmHelper; import chat.rocket.android.realm_helper.RealmHelper;
...@@ -11,7 +12,6 @@ import io.realm.Realm; ...@@ -11,7 +12,6 @@ import io.realm.Realm;
import io.realm.RealmResults; import io.realm.RealmResults;
import java.util.List; import java.util.List;
import org.json.JSONObject; import org.json.JSONObject;
import timber.log.Timber;
/** /**
* Model observer for executing getUsersOfRooms. * Model observer for executing getUsersOfRooms.
...@@ -58,7 +58,7 @@ public class GetUsersOfRoomsProcedureObserver ...@@ -58,7 +58,7 @@ public class GetUsersOfRoomsProcedureObserver
}) })
).continueWithTask(task -> { ).continueWithTask(task -> {
if (task.isFaulted()) { if (task.isFaulted()) {
Timber.w(task.getError()); RCLog.w(task.getError());
return realmHelper.executeTransaction(realm -> return realmHelper.executeTransaction(realm ->
realm.createOrUpdateObjectFromJson(GetUsersOfRoomsProcedure.class, new JSONObject() realm.createOrUpdateObjectFromJson(GetUsersOfRoomsProcedure.class, new JSONObject()
.put("roomId", roomId) .put("roomId", roomId)
......
...@@ -2,18 +2,18 @@ package chat.rocket.android.service.observer; ...@@ -2,18 +2,18 @@ package chat.rocket.android.service.observer;
import android.content.Context; import android.content.Context;
import bolts.Task; import bolts.Task;
import chat.rocket.android.api.DDPClientWraper;
import chat.rocket.android.api.MethodCallHelper; import chat.rocket.android.api.MethodCallHelper;
import chat.rocket.android.model.internal.LoadMessageProcedure; import chat.rocket.android.log.RCLog;
import chat.rocket.android.model.SyncState; import chat.rocket.android.model.SyncState;
import chat.rocket.android.model.ddp.Message; import chat.rocket.android.model.ddp.Message;
import chat.rocket.android.model.internal.LoadMessageProcedure;
import chat.rocket.android.realm_helper.RealmHelper; import chat.rocket.android.realm_helper.RealmHelper;
import chat.rocket.android.api.DDPClientWraper;
import io.realm.Realm; import io.realm.Realm;
import io.realm.RealmResults; import io.realm.RealmResults;
import io.realm.Sort; import io.realm.Sort;
import java.util.List; import java.util.List;
import org.json.JSONObject; import org.json.JSONObject;
import timber.log.Timber;
/** /**
* Background process for loading messages. * Background process for loading messages.
...@@ -70,7 +70,7 @@ public class LoadMessageProcedureObserver extends AbstractModelObserver<LoadMess ...@@ -70,7 +70,7 @@ public class LoadMessageProcedureObserver extends AbstractModelObserver<LoadMess
}) })
).continueWithTask(task -> { ).continueWithTask(task -> {
if (task.isFaulted()) { if (task.isFaulted()) {
Timber.w(task.getError()); RCLog.w(task.getError());
return realmHelper.executeTransaction(realm -> return realmHelper.executeTransaction(realm ->
realm.createOrUpdateObjectFromJson(LoadMessageProcedure.class, new JSONObject() realm.createOrUpdateObjectFromJson(LoadMessageProcedure.class, new JSONObject()
.put("roomId", roomId) .put("roomId", roomId)
......
...@@ -4,6 +4,7 @@ import android.content.Context; ...@@ -4,6 +4,7 @@ import android.content.Context;
import chat.rocket.android.api.DDPClientWraper; import chat.rocket.android.api.DDPClientWraper;
import chat.rocket.android.api.MethodCallHelper; import chat.rocket.android.api.MethodCallHelper;
import chat.rocket.android.helper.LogcatIfError; import chat.rocket.android.helper.LogcatIfError;
import chat.rocket.android.log.RCLog;
import chat.rocket.android.model.SyncState; import chat.rocket.android.model.SyncState;
import chat.rocket.android.model.ddp.Message; import chat.rocket.android.model.ddp.Message;
import chat.rocket.android.realm_helper.RealmHelper; import chat.rocket.android.realm_helper.RealmHelper;
...@@ -11,7 +12,6 @@ import io.realm.Realm; ...@@ -11,7 +12,6 @@ import io.realm.Realm;
import io.realm.RealmResults; import io.realm.RealmResults;
import java.util.List; import java.util.List;
import org.json.JSONObject; import org.json.JSONObject;
import timber.log.Timber;
/** /**
* Observe messages for sending. * Observe messages for sending.
...@@ -69,7 +69,7 @@ public class NewMessageObserver extends AbstractModelObserver<Message> { ...@@ -69,7 +69,7 @@ public class NewMessageObserver extends AbstractModelObserver<Message> {
}) })
).continueWith(task -> { ).continueWith(task -> {
if (task.isFaulted()) { if (task.isFaulted()) {
Timber.w(task.getError()); RCLog.w(task.getError());
realmHelper.executeTransaction(realm -> realmHelper.executeTransaction(realm ->
realm.createOrUpdateObjectFromJson(Message.class, new JSONObject() realm.createOrUpdateObjectFromJson(Message.class, new JSONObject()
.put("_id", messageId) .put("_id", messageId)
......
...@@ -16,7 +16,6 @@ ext { ...@@ -16,7 +16,6 @@ ext {
rxJava = 'io.reactivex:rxjava:1.2.2' rxJava = 'io.reactivex:rxjava:1.2.2'
boltsTask = 'com.parse.bolts:bolts-tasks:1.4.0' boltsTask = 'com.parse.bolts:bolts-tasks:1.4.0'
timber = 'com.jakewharton.timber:timber:4.3.1'
okhttp3 = 'com.squareup.okhttp3:okhttp:3.4.1' okhttp3 = 'com.squareup.okhttp3:okhttp:3.4.1'
picasso = 'com.squareup.picasso:picasso:2.5.2' picasso = 'com.squareup.picasso:picasso:2.5.2'
picasso2Okhttp3Downloader = 'com.jakewharton.picasso:picasso2-okhttp3-downloader:1.1.0' picasso2Okhttp3Downloader = 'com.jakewharton.picasso:picasso2-okhttp3-downloader:1.1.0'
......
apply plugin: 'com.android.library'
buildscript {
repositories {
jcenter()
}
dependencies {
classpath rootProject.ext.androidPlugin
}
}
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.compileSdkVersion
versionCode 1
versionName "1"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile rootProject.ext.supportAnnotations
}
\ No newline at end of file
<manifest package="chat.rocket.android.log"/>
\ No newline at end of file
package chat.rocket.android.log;
import android.util.Log;
public class RCLog {
public static void d(String log, Object... args) {
Log.d(getTag(), String.format(log, args));
}
public static void d(Throwable throwable) {
Log.d(getTag(), throwable.getMessage(), throwable);
}
public static void d(Throwable throwable, String log, Object... args) {
Log.d(getTag(), String.format(log, args), throwable);
}
public static void w(String log, Object... args) {
Log.w(getTag(), String.format(log, args));
}
public static void w(Throwable throwable) {
Log.w(getTag(), throwable.getMessage(), throwable);
}
public static void w(Throwable throwable, String log, Object... args) {
Log.w(getTag(), String.format(log, args), throwable);
}
public static void e(String log, Object... args) {
Log.e(getTag(), String.format(log, args));
}
public static void e(Throwable throwable) {
Log.e(getTag(), throwable.getMessage(), throwable);
}
public static void e(Throwable throwable, String log, Object... args) {
Log.e(getTag(), String.format(log, args), throwable);
}
private static String getTag() {
StackTraceElement[] elements = Thread.currentThread().getStackTrace();
if (elements.length >= 5) {
return getSimpleName(elements[4].getClassName());
} else {
return "Rocket.Chat";
}
}
private static String getSimpleName(String className) {
int idx = className.lastIndexOf(".");
return className.substring(idx + 1);
}
}
apply plugin: 'com.android.library'
buildscript {
repositories {
jcenter()
}
dependencies {
classpath rootProject.ext.androidPlugin
}
}
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.compileSdkVersion
versionCode 1
versionName "1"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile rootProject.ext.supportAnnotations
}
\ No newline at end of file
<manifest package="chat.rocket.android.log"/>
\ No newline at end of file
package chat.rocket.android.log;
public class RCLog {
public static void d(String log, Object... args) {
}
public static void d(Throwable throwable) {
}
public static void d(Throwable throwable, String log, Object... args) {
}
public static void w(String log, Object... args) {
}
public static void w(Throwable throwable) {
}
public static void w(Throwable throwable, String log, Object... args) {
}
public static void e(String log, Object... args) {
}
public static void e(Throwable throwable) {
}
public static void e(Throwable throwable, String log, Object... args) {
}
}
...@@ -43,8 +43,8 @@ android { ...@@ -43,8 +43,8 @@ android {
dependencies { dependencies {
testCompile 'junit:junit:4.12' testCompile 'junit:junit:4.12'
compile project(':log-wrapper-rel')
compile rootProject.ext.boltsTask compile rootProject.ext.boltsTask
compile rootProject.ext.timber
compile rootProject.ext.supportAnnotations compile rootProject.ext.supportAnnotations
compile rootProject.ext.supportAppCompat compile rootProject.ext.supportAppCompat
compile rootProject.ext.supportDesign compile rootProject.ext.supportDesign
......
...@@ -6,6 +6,7 @@ import android.os.Looper; ...@@ -6,6 +6,7 @@ import android.os.Looper;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import bolts.Task; import bolts.Task;
import bolts.TaskCompletionSource; import bolts.TaskCompletionSource;
import chat.rocket.android.log.RCLog;
import io.realm.Realm; import io.realm.Realm;
import io.realm.RealmConfiguration; import io.realm.RealmConfiguration;
import io.realm.RealmObject; import io.realm.RealmObject;
...@@ -13,7 +14,6 @@ import io.realm.RealmResults; ...@@ -13,7 +14,6 @@ import io.realm.RealmResults;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import org.json.JSONException; import org.json.JSONException;
import timber.log.Timber;
@SuppressLint("NewApi") @SuppressLint("NewApi")
public class RealmHelper { public class RealmHelper {
...@@ -61,7 +61,7 @@ public class RealmHelper { ...@@ -61,7 +61,7 @@ public class RealmHelper {
T source = transaction.execute(realm); T source = transaction.execute(realm);
return source != null ? realm.copyFromRealm(source) : null; return source != null ? realm.copyFromRealm(source) : null;
} catch (Exception exception) { } catch (Exception exception) {
Timber.w(exception, "failed to execute copyFromRealm"); RCLog.w(exception);
return null; return null;
} }
} }
...@@ -71,7 +71,7 @@ public class RealmHelper { ...@@ -71,7 +71,7 @@ public class RealmHelper {
try (Realm realm = instance()) { try (Realm realm = instance()) {
return realm.copyFromRealm(transaction.execute(realm)); return realm.copyFromRealm(transaction.execute(realm));
} catch (Exception exception) { } catch (Exception exception) {
Timber.w(exception, "failed to execute copyFromRealm"); RCLog.w(exception);
return Collections.emptyList(); return Collections.emptyList();
} }
} }
...@@ -85,13 +85,11 @@ public class RealmHelper { ...@@ -85,13 +85,11 @@ public class RealmHelper {
final TaskCompletionSource<Void> task = new TaskCompletionSource<>(); final TaskCompletionSource<Void> task = new TaskCompletionSource<>();
try (Realm realm = instance()) { try (Realm realm = instance()) {
realm.executeTransaction(new Realm.Transaction() { realm.executeTransaction(_realm -> {
@Override public void execute(Realm realm) { try {
try { transaction.execute(_realm);
transaction.execute(realm); } catch (JSONException exception) {
} catch (JSONException exception) { throw new RuntimeException(exception);
throw new RuntimeException(exception);
}
} }
}); });
task.setResult(null); task.setResult(null);
......
include ':app', ':android-ddp', ':rocket-chat-android-widgets', ':realm-helpers' include ':app', ':android-ddp', ':rocket-chat-android-widgets', ':realm-helpers',
':log-wrapper-dev',
':log-wrapper-rel'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment