Commit 659952bf authored by Tiago Cunha's avatar Tiago Cunha Committed by GitHub

Merge pull request #212 from RocketChat/fix/firebase-crashes-20170220

Fix/firebase crashes 20170220
parents 3b05bafe 32982d9f
...@@ -33,8 +33,8 @@ android { ...@@ -33,8 +33,8 @@ android {
applicationId "chat.rocket.android" applicationId "chat.rocket.android"
minSdkVersion 16 minSdkVersion 16
targetSdkVersion 25 targetSdkVersion 25
versionCode 10 versionCode 11
versionName "1.0.1" versionName "1.0.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true vectorDrawables.useSupportLibrary = true
......
...@@ -75,7 +75,7 @@ abstract class AbstractAuthedActivity extends AbstractFragmentActivity { ...@@ -75,7 +75,7 @@ abstract class AbstractAuthedActivity extends AbstractFragmentActivity {
} }
} else { } else {
if (hostname.equals(newHostname)) { if (hostname.equals(newHostname)) {
// we are good updateHostname(newHostname);
return; return;
} }
......
...@@ -99,23 +99,27 @@ public abstract class AbstractDDPDocEventSubscriber implements Registrable { ...@@ -99,23 +99,27 @@ public abstract class AbstractDDPDocEventSubscriber implements Registrable {
.filter(event -> event instanceof DDPSubscription.DocEvent) .filter(event -> event instanceof DDPSubscription.DocEvent)
.cast(DDPSubscription.DocEvent.class) .cast(DDPSubscription.DocEvent.class)
.filter(event -> isTarget(event.collection)) .filter(event -> isTarget(event.collection))
.subscribe(docEvent -> { .subscribe(
try { docEvent -> {
if (docEvent instanceof DDPSubscription.Added.Before) { try {
onDocumentAdded((DDPSubscription.Added) docEvent); //ignore Before if (docEvent instanceof DDPSubscription.Added.Before) {
} else if (docEvent instanceof DDPSubscription.Added) { onDocumentAdded((DDPSubscription.Added) docEvent); //ignore Before
onDocumentAdded((DDPSubscription.Added) docEvent); } else if (docEvent instanceof DDPSubscription.Added) {
} else if (docEvent instanceof DDPSubscription.Removed) { onDocumentAdded((DDPSubscription.Added) docEvent);
onDocumentRemoved((DDPSubscription.Removed) docEvent); } else if (docEvent instanceof DDPSubscription.Removed) {
} else if (docEvent instanceof DDPSubscription.Changed) { onDocumentRemoved((DDPSubscription.Removed) docEvent);
onDocumentChanged((DDPSubscription.Changed) docEvent); } else if (docEvent instanceof DDPSubscription.Changed) {
} else if (docEvent instanceof DDPSubscription.MovedBefore) { onDocumentChanged((DDPSubscription.Changed) docEvent);
//ignore movedBefore } else if (docEvent instanceof DDPSubscription.MovedBefore) {
//ignore movedBefore
}
} catch (Exception exception) {
RCLog.w(exception, "failed to handle subscription callback");
}
},
throwable -> {
} }
} catch (Exception exception) { );
RCLog.w(exception, "failed to handle subscription callback");
}
});
} }
protected void onDocumentAdded(DDPSubscription.Added docEvent) { protected void onDocumentAdded(DDPSubscription.Added docEvent) {
......
...@@ -109,9 +109,17 @@ public class MethodCallObserver extends AbstractModelObserver<MethodCall> { ...@@ -109,9 +109,17 @@ public class MethodCallObserver extends AbstractModelObserver<MethodCall> {
if (task.isFaulted()) { if (task.isFaulted()) {
return realmHelper.executeTransaction(realm -> { return realmHelper.executeTransaction(realm -> {
Exception exception = task.getError(); Exception exception = task.getError();
final String errMessage = (exception instanceof DDPClientCallback.RPC.Error) final String errMessage;
? ((DDPClientCallback.RPC.Error) exception).error.toString()
: exception.getMessage(); if (exception instanceof DDPClientCallback.RPC.Error) {
errMessage = ((DDPClientCallback.RPC.Error) exception).error.toString();
} else if (exception instanceof DDPClientCallback.RPC.Timeout) {
// temp "fix"- we need to rewrite the connection layer a bit
errMessage = "{\"message\": \"Connection Timeout\"}";
} else {
errMessage = exception.getMessage();
}
realm.createOrUpdateObjectFromJson(MethodCall.class, new JSONObject() realm.createOrUpdateObjectFromJson(MethodCall.class, new JSONObject()
.put(MethodCall.ID, methodCallId) .put(MethodCall.ID, methodCallId)
.put(MethodCall.SYNC_STATE, SyncState.FAILED) .put(MethodCall.SYNC_STATE, SyncState.FAILED)
......
...@@ -11,7 +11,7 @@ public class RealmPreferences extends RealmObject { ...@@ -11,7 +11,7 @@ public class RealmPreferences extends RealmObject {
@PrimaryKey private String id; @PrimaryKey private String id;
private String newRoomNotification; private String newRoomNotification;
private boolean newMessageNotification; private String newMessageNotification;
private boolean useEmojis; private boolean useEmojis;
private boolean convertAsciiEmoji; private boolean convertAsciiEmoji;
private boolean saveMobileBandwidth; private boolean saveMobileBandwidth;
...@@ -52,7 +52,7 @@ public class RealmPreferences extends RealmObject { ...@@ -52,7 +52,7 @@ public class RealmPreferences extends RealmObject {
return newRoomNotification; return newRoomNotification;
} }
public boolean isNewMessageNotification() { public String getNewMessageNotification() {
return newMessageNotification; return newMessageNotification;
} }
...@@ -123,7 +123,8 @@ public class RealmPreferences extends RealmObject { ...@@ -123,7 +123,8 @@ public class RealmPreferences extends RealmObject {
: that.newRoomNotification == null) { : that.newRoomNotification == null) {
return false; return false;
} }
if (newMessageNotification != that.newMessageNotification) { if (newMessageNotification != null ? newMessageNotification.equals(that.newMessageNotification)
: that.newMessageNotification == null) {
return false; return false;
} }
if (useEmojis != that.useEmojis) { if (useEmojis != that.useEmojis) {
...@@ -174,7 +175,7 @@ public class RealmPreferences extends RealmObject { ...@@ -174,7 +175,7 @@ public class RealmPreferences extends RealmObject {
public int hashCode() { public int hashCode() {
int result = id != null ? id.hashCode() : 0; int result = id != null ? id.hashCode() : 0;
result = 31 * result + (newRoomNotification != null ? newRoomNotification.hashCode() : 0); result = 31 * result + (newRoomNotification != null ? newRoomNotification.hashCode() : 0);
result = 31 * result + (newMessageNotification ? 1 : 0); result = 31 * result + (newMessageNotification != null ? newMessageNotification.hashCode() : 0);
result = 31 * result + (useEmojis ? 1 : 0); result = 31 * result + (useEmojis ? 1 : 0);
result = 31 * result + (convertAsciiEmoji ? 1 : 0); result = 31 * result + (convertAsciiEmoji ? 1 : 0);
result = 31 * result + (saveMobileBandwidth ? 1 : 0); result = 31 * result + (saveMobileBandwidth ? 1 : 0);
......
...@@ -87,7 +87,7 @@ public class RealmUser extends RealmObject { ...@@ -87,7 +87,7 @@ public class RealmUser extends RealmObject {
public User asUser() { public User asUser() {
// convert email list // convert email list
final int total = emails.size(); final int total = emails != null ? emails.size() : 0;
final List<Email> coreEmails = new ArrayList<>(total); final List<Email> coreEmails = new ArrayList<>(total);
for (int i = 0; i < total; i++) { for (int i = 0; i < total; i++) {
......
...@@ -52,6 +52,9 @@ public class ImageKeyboardEditText extends EditText { ...@@ -52,6 +52,9 @@ public class ImageKeyboardEditText extends EditText {
@Override @Override
public InputConnection onCreateInputConnection(EditorInfo editorInfo) { public InputConnection onCreateInputConnection(EditorInfo editorInfo) {
final InputConnection inputConnection = super.onCreateInputConnection(editorInfo); final InputConnection inputConnection = super.onCreateInputConnection(editorInfo);
if (inputConnection == null) {
return null;
}
EditorInfoCompat.setContentMimeTypes(editorInfo, mimeTypes); EditorInfoCompat.setContentMimeTypes(editorInfo, mimeTypes);
......
...@@ -12,7 +12,8 @@ public abstract class Preferences { ...@@ -12,7 +12,8 @@ public abstract class Preferences {
@Nullable @Nullable
public abstract String getNewRoomNotification(); public abstract String getNewRoomNotification();
public abstract boolean isNewMessageNotification(); @Nullable
public abstract String getNewMessageNotification();
public abstract boolean isUseEmojis(); public abstract boolean isUseEmojis();
...@@ -51,7 +52,7 @@ public abstract class Preferences { ...@@ -51,7 +52,7 @@ public abstract class Preferences {
public abstract Builder setNewRoomNotification(String newRoomNotification); public abstract Builder setNewRoomNotification(String newRoomNotification);
public abstract Builder setNewMessageNotification(boolean newMessageNotification); public abstract Builder setNewMessageNotification(String newMessageNotification);
public abstract Builder setUseEmojis(boolean useEmojis); public abstract Builder setUseEmojis(boolean useEmojis);
......
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