Commit 87e5a70e authored by Leonardo Aramaki's avatar Leonardo Aramaki

Merge branch 'develop' into feature/multi-server

parents c39b5aa4 d773477b
...@@ -45,7 +45,7 @@ android { ...@@ -45,7 +45,7 @@ android {
applicationId "chat.rocket.android" applicationId "chat.rocket.android"
minSdkVersion 16 minSdkVersion 16
targetSdkVersion rootProject.ext.targetSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 35 versionCode 36
versionName "1.0.18" versionName "1.0.18"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true vectorDrawables.useSupportLibrary = true
......
...@@ -43,6 +43,7 @@ import hugo.weaving.DebugLog; ...@@ -43,6 +43,7 @@ import hugo.weaving.DebugLog;
public class MainActivity extends AbstractAuthedActivity implements MainContract.View { public class MainActivity extends AbstractAuthedActivity implements MainContract.View {
private RoomToolbar toolbar; private RoomToolbar toolbar;
private StatusTicker statusTicker; private StatusTicker statusTicker;
private SlidingPaneLayout pane;
private MainContract.Presenter presenter; private MainContract.Presenter presenter;
@Override @Override
...@@ -56,6 +57,8 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract ...@@ -56,6 +57,8 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
setContentView(R.layout.activity_main); setContentView(R.layout.activity_main);
toolbar = (RoomToolbar) findViewById(R.id.activity_main_toolbar); toolbar = (RoomToolbar) findViewById(R.id.activity_main_toolbar);
statusTicker = new StatusTicker(); statusTicker = new StatusTicker();
pane = (SlidingPaneLayout) findViewById(R.id.sliding_pane);
setupToolbar();
} }
@Override @Override
...@@ -82,9 +85,34 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract ...@@ -82,9 +85,34 @@ public class MainActivity extends AbstractAuthedActivity implements MainContract
startActivity(intent); startActivity(intent);
} }
private void setupToolbar() {
pane.setPanelSlideListener(new SlidingPaneLayout.PanelSlideListener() {
@Override
public void onPanelSlide(View view, float v) {
//Ref: ActionBarDrawerToggle#setProgress
toolbar.setNavigationIconProgress(v);
}
@Override
public void onPanelOpened(View view) {
toolbar.setNavigationIconVerticalMirror(true);
}
@Override
public void onPanelClosed(View view) {
toolbar.setNavigationIconVerticalMirror(false);
}
});
toolbar.setNavigationOnClickListener(view -> {
if (pane.isSlideable() && !pane.isOpen()) {
pane.openPane();
}
});
}
private boolean closeSidebarIfNeeded() { private boolean closeSidebarIfNeeded() {
// REMARK: Tablet UI doesn't have SlidingPane! // REMARK: Tablet UI doesn't have SlidingPane!
SlidingPaneLayout pane = (SlidingPaneLayout) findViewById(R.id.sliding_pane);
if (pane != null && pane.isSlideable() && pane.isOpen()) { if (pane != null && pane.isSlideable() && pane.isOpen()) {
pane.closePane(); pane.closePane();
return true; return true;
......
...@@ -43,16 +43,18 @@ import com.jakewharton.rxbinding2.support.v7.widget.RxSearchView; ...@@ -43,16 +43,18 @@ import com.jakewharton.rxbinding2.support.v7.widget.RxSearchView;
import com.jakewharton.rxbinding2.widget.RxCompoundButton; import com.jakewharton.rxbinding2.widget.RxCompoundButton;
import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class SidebarMainFragment extends AbstractFragment implements SidebarMainContract.View { public class SidebarMainFragment extends AbstractFragment implements SidebarMainContract.View {
private SidebarMainContract.Presenter presenter; private SidebarMainContract.Presenter presenter;
private RoomListAdapter adapter; private RoomListAdapter adapter;
private RecyclerView recyclerView;
private SearchView searchView; private SearchView searchView;
private TextView loadMoreResultsText; private TextView loadMoreResultsText;
private List<RoomSidebar> roomSidebarList; private List<RoomSidebar> roomSidebarList;
private Disposable spotlightDisposable;
private String hostname; private String hostname;
private static final String HOSTNAME = "hostname"; private static final String HOSTNAME = "hostname";
...@@ -139,7 +141,7 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain ...@@ -139,7 +141,7 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain
} }
}); });
recyclerView = rootView.findViewById(R.id.room_list_container); RecyclerView recyclerView = rootView.findViewById(R.id.room_list_container);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false)); recyclerView.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
recyclerView.setAdapter(adapter); recyclerView.setAdapter(adapter);
...@@ -148,15 +150,17 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain ...@@ -148,15 +150,17 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain
RxSearchView.queryTextChanges(searchView) RxSearchView.queryTextChanges(searchView)
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe(charSequence -> { .subscribe(charSequence -> {
adapter.setMode(RoomListAdapter.MODE_ROOM); if (spotlightDisposable != null && !spotlightDisposable.isDisposed()) {
spotlightDisposable.dispose();
}
presenter.disposeSubscriptions();
if (charSequence.length() == 0) { if (charSequence.length() == 0) {
loadMoreResultsText.setVisibility(View.GONE); loadMoreResultsText.setVisibility(View.GONE);
adapter.setMode(RoomListAdapter.MODE_ROOM);
presenter.bindView(this); presenter.bindView(this);
recyclerView.setVisibility(View.VISIBLE); } else {
} else { filterRoomSidebarList(charSequence);
presenter.disposeSubscriptions(); }
filterRoomSidebarList(charSequence);
}
}); });
loadMoreResultsText.setOnClickListener(view -> loadMoreResults()); loadMoreResultsText.setOnClickListener(view -> loadMoreResults());
...@@ -179,16 +183,16 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain ...@@ -179,16 +183,16 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain
} }
if (filteredRoomSidebarList.isEmpty()) { if (filteredRoomSidebarList.isEmpty()) {
recyclerView.setVisibility(View.GONE); loadMoreResults();
} else { } else {
recyclerView.setVisibility(View.VISIBLE); loadMoreResultsText.setVisibility(View.VISIBLE);
adapter.setMode(RoomListAdapter.MODE_ROOM);
adapter.setRoomSidebarList(filteredRoomSidebarList); adapter.setRoomSidebarList(filteredRoomSidebarList);
} }
loadMoreResultsText.setVisibility(View.VISIBLE);
} }
private void loadMoreResults() { private void loadMoreResults() {
presenter.searchSpotlight(searchView.getQuery().toString()) spotlightDisposable = presenter.searchSpotlight(searchView.getQuery().toString())
.toObservable() .toObservable()
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe(this::showSearchSuggestions); .subscribe(this::showSearchSuggestions);
...@@ -198,7 +202,6 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain ...@@ -198,7 +202,6 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain
loadMoreResultsText.setVisibility(View.GONE); loadMoreResultsText.setVisibility(View.GONE);
adapter.setMode(RoomListAdapter.MODE_SPOTLIGHT); adapter.setMode(RoomListAdapter.MODE_SPOTLIGHT);
adapter.setSpotlightList(spotlightList); adapter.setSpotlightList(spotlightList);
recyclerView.setVisibility(View.VISIBLE);
} }
@SuppressLint("RxLeakedSubscription") @SuppressLint("RxLeakedSubscription")
......
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