Commit 72652690 authored by Rafael Kellermann Streit's avatar Rafael Kellermann Streit Committed by GitHub

Merge pull request #507 from RocketChat/develop

[RELEASE] Merge develop into master
parents 189a3c69 a2acf159
......@@ -174,7 +174,7 @@ public class DDPClientImpl {
disposables.clear();
}
},
err -> task.setError(new DDPClientCallback.Ping.Timeout(client))
err -> task.trySetError(new DDPClientCallback.Ping.Timeout(client))
)
);
......@@ -213,7 +213,7 @@ public class DDPClientImpl {
"error")) {
String _id = response.optString("id");
if (id.equals(_id)) {
task.setError(new DDPSubscription.NoSub.Error(client, id,
task.trySetError(new DDPSubscription.NoSub.Error(client, id,
response.optJSONObject("error")));
disposables.clear();
}
......@@ -284,7 +284,7 @@ public class DDPClientImpl {
String _id = response.optString("id");
if (id.equals(_id)) {
if (!response.isNull("error")) {
task.setError(new DDPClientCallback.RPC.Error(client, id,
task.trySetError(new DDPClientCallback.RPC.Error(client, id,
response.optJSONObject("error")));
} else {
String result = response.optString("result");
......@@ -296,7 +296,7 @@ public class DDPClientImpl {
},
err -> {
if (err instanceof TimeoutException) {
task.setError(new DDPClientCallback.RPC.Timeout(client));
task.trySetError(new DDPClientCallback.RPC.Timeout(client));
}
}
)
......@@ -427,7 +427,7 @@ public class DDPClientImpl {
}
},
err -> {
task.trySetError(new Exception(err));
setTaskError(task, new Exception(err));
disposables.clear();
}
)
......@@ -442,7 +442,10 @@ public class DDPClientImpl {
}
}
private void setTaskError(TaskCompletionSource<? extends RxWebSocketCallback.Base> task, Throwable throwable) {
private void setTaskError(TaskCompletionSource task, Throwable throwable) {
if (task.getTask().isCompleted()) {
return;
}
if (throwable instanceof Exception) {
task.setError((Exception) throwable);
} else {
......
......@@ -46,8 +46,8 @@ android {
applicationId "chat.rocket.android"
minSdkVersion 16
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 40
versionName "1.0.20"
versionCode 41
versionName "1.0.21"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
......
......@@ -121,7 +121,6 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
}
}
});
}
if (toolbar != null) {
toolbar.setNavigationOnClickListener(view -> {
......@@ -131,6 +130,7 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
});
}
}
}
private boolean closeSidebarIfNeeded() {
// REMARK: Tablet UI doesn't have SlidingPane!
......@@ -251,12 +251,6 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
R.string.server_config_activity_authenticating, Snackbar.LENGTH_INDEFINITE));
}
public void showLogoutMessage() {
statusTicker.updateStatus(StatusTicker.STATUS_LOGGING_OUT,
Snackbar.make(findViewById(getLayoutContainerForFragment()),
"Logging Out...", Snackbar.LENGTH_INDEFINITE));
}
@Override
public void showConnectionOk() {
statusTicker.updateStatus(StatusTicker.STATUS_DISMISS, null);
......@@ -314,11 +308,6 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
}
}
@DebugLog
public void hideLogoutMessage() {
statusTicker.updateStatus(StatusTicker.STATUS_DISMISS, null);
}
@DebugLog
public void onLogout() {
if (new RocketChatCache(getApplicationContext()).getSelectedServerHostname() == null) {
......
......@@ -34,6 +34,7 @@ import chat.rocket.android.fragment.sidebar.SidebarMainFragment;
import chat.rocket.android.helper.AbsoluteUrlHelper;
import chat.rocket.android.helper.FileUploadHelper;
import chat.rocket.android.helper.LoadMoreScrollListener;
import chat.rocket.android.helper.Logger;
import chat.rocket.android.helper.OnBackPressListener;
import chat.rocket.android.helper.RecyclerViewAutoScrollManager;
import chat.rocket.android.helper.RecyclerViewScrolledToBottomListener;
......@@ -49,6 +50,7 @@ import chat.rocket.android.layouthelper.extra_action.upload.AbstractUploadAction
import chat.rocket.android.layouthelper.extra_action.upload.AudioUploadActionItem;
import chat.rocket.android.layouthelper.extra_action.upload.ImageUploadActionItem;
import chat.rocket.android.layouthelper.extra_action.upload.VideoUploadActionItem;
import chat.rocket.android.log.RCLog;
import chat.rocket.android.renderer.RocketChatUserStatusProvider;
import chat.rocket.android.service.ConnectivityManager;
import chat.rocket.android.service.temp.DeafultTempSpotlightRoomCaller;
......@@ -340,6 +342,7 @@ public class RoomFragment extends AbstractChatRoomFragment implements
SlidingPaneLayout subPane = getActivity().findViewById(R.id.sub_sliding_pane);
sidebarFragment = (SidebarMainFragment) getActivity().getSupportFragmentManager().findFragmentById(R.id.sidebar_fragment_container);
if (pane != null) {
pane.setPanelSlideListener(new SlidingPaneLayout.PanelSlideListener() {
@Override
public void onPanelSlide(View view, float v) {
......@@ -363,6 +366,7 @@ public class RoomFragment extends AbstractChatRoomFragment implements
}
});
}
}
public void closeUserActionContainer() {
sidebarFragment.closeUserActionContainer();
......@@ -537,6 +541,8 @@ public class RoomFragment extends AbstractChatRoomFragment implements
try {
inputContentInfo.releasePermission();
} catch (Exception e) {
RCLog.e(e);
Logger.report(e);
}
return true;
......@@ -552,10 +558,12 @@ public class RoomFragment extends AbstractChatRoomFragment implements
@Override
public void setupWith(RocketChatAbsoluteUrl rocketChatAbsoluteUrl) {
if (rocketChatAbsoluteUrl != null) {
token = rocketChatAbsoluteUrl.getToken();
userId = rocketChatAbsoluteUrl.getUserId();
messageListAdapter.setAbsoluteUrl(rocketChatAbsoluteUrl);
}
}
@Override
public void render(Room room) {
......@@ -657,6 +665,9 @@ public class RoomFragment extends AbstractChatRoomFragment implements
}
private void showRoomListFragment(int actionId) {
//TODO: oddly sometimes getActivity() yields null. Investigate the situations this might happen
//and fix it, removing this null-check
if (getActivity() != null) {
Intent intent = new Intent(getActivity(), RoomActivity.class).putExtra("actionId", actionId)
.putExtra("roomId", roomId)
.putExtra("roomType", roomType)
......@@ -665,4 +676,5 @@ public class RoomFragment extends AbstractChatRoomFragment implements
.putExtra("userId", userId);
startActivity(intent);
}
}
}
\ No newline at end of file
......@@ -19,6 +19,7 @@ import com.jakewharton.rxbinding2.support.v7.widget.RxSearchView;
import com.jakewharton.rxbinding2.widget.RxCompoundButton;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import bolts.Task;
......@@ -58,7 +59,7 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain
private RoomListAdapter adapter;
private SearchView searchView;
private TextView loadMoreResultsText;
private List<RoomSidebar> roomSidebarList;
private List<RoomSidebar> roomSidebarList = Collections.emptyList();
private Disposable spotlightDisposable;
private String hostname;
private static final String HOSTNAME = "hostname";
......@@ -325,7 +326,6 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain
public void onLogoutCleanUp() {
Activity activity = getActivity();
if (activity != null && activity instanceof MainActivity) {
((MainActivity) activity).hideLogoutMessage();
((MainActivity) activity).onLogout();
presenter.onLogout(task -> {
if (task.isFaulted()) {
......@@ -343,7 +343,6 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain
presenter.beforeLogoutCleanUp();
final Activity activity = getActivity();
if (activity != null && activity instanceof MainActivity) {
((MainActivity) activity).showLogoutMessage();
// Clear subscriptions on MainPresenter.
((MainActivity) activity).beforeLogoutCleanUp();
}
......
......@@ -2,6 +2,7 @@ package chat.rocket.android.fragment.sidebar;
import android.support.annotation.NonNull;
import android.support.v4.util.Pair;
import android.webkit.CookieManager;
import java.util.ArrayList;
import java.util.List;
......@@ -154,7 +155,8 @@ public class SidebarMainPresenter extends BasePresenter<SidebarMainContract.View
String currentHostname = rocketChatCache.getSelectedServerHostname();
RealmHelper realmHelper = RealmStore.getOrCreate(currentHostname);
realmHelper.executeTransaction(realm -> {
realm.deleteAll();
realm.executeTransactionAsync(realmObj -> realmObj.deleteAll());
CookieManager.getInstance().removeAllCookie();
ConnectivityManagerApi connectivityManagerApi = ConnectivityManager.getInstance(RocketChatApplication.getInstance());
connectivityManagerApi.removeServer(currentHostname);
rocketChatCache.removeHostname(currentHostname);
......
......@@ -12,6 +12,7 @@ import java.util.HashMap;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
import chat.rocket.android.helper.Logger;
import chat.rocket.persistence.realm.RealmStore;
import hugo.weaving.DebugLog;
import rx.Observable;
......@@ -113,6 +114,10 @@ public class RocketChatService extends Service implements ConnectivityServiceInt
.doOnSuccess(thread -> {
webSocketThreads.put(hostname, thread);
webSocketThreadLock.release();
})
.doOnError(throwable -> {
Logger.report(throwable);
webSocketThreadLock.release();
});
});
}
......
......@@ -122,7 +122,7 @@ public class RealmHelper {
return task.getTask();
}
private Task<Void> executeTransactionAsync(final RealmHelper.Transaction transaction) {
public Task<Void> executeTransactionAsync(final RealmHelper.Transaction transaction) {
final TaskCompletionSource<Void> task = new TaskCompletionSource<>();
final Realm realm = instance();
......
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