mirror of
https://github.com/nextcloud/talk-android
synced 2025-01-31 11:32:00 +00:00
parent
1cfb005150
commit
bdbb3a8cd1
@ -28,7 +28,6 @@ import android.os.Handler;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.BottomNavigationView;
|
||||
import android.support.design.widget.CoordinatorLayout;
|
||||
import android.support.v4.view.MenuItemCompat;
|
||||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
@ -43,7 +42,6 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.Button;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import com.bluelinelabs.conductor.RouterTransaction;
|
||||
@ -68,7 +66,6 @@ import com.nextcloud.talk.models.json.rooms.RoomOverall;
|
||||
import com.nextcloud.talk.models.json.sharees.Sharee;
|
||||
import com.nextcloud.talk.models.json.sharees.ShareesOverall;
|
||||
import com.nextcloud.talk.utils.ApiUtils;
|
||||
import com.nextcloud.talk.utils.animations.ViewHidingBehaviourAnimation;
|
||||
import com.nextcloud.talk.utils.bundle.BundleKeys;
|
||||
import com.nextcloud.talk.utils.database.user.UserUtils;
|
||||
|
||||
@ -130,16 +127,9 @@ public class ContactsController extends BaseController implements SearchView.OnQ
|
||||
@BindView(R.id.swipe_refresh_layout)
|
||||
SwipeRefreshLayout swipeRefreshLayout;
|
||||
|
||||
@BindView(R.id.bottom_buttons_layout)
|
||||
CoordinatorLayout bottomButtonsLinearLayout;
|
||||
|
||||
@BindView(R.id.fast_scroller)
|
||||
FastScroller fastScroller;
|
||||
|
||||
@Nullable
|
||||
@BindView(R.id.clear_button)
|
||||
Button clearButton;
|
||||
|
||||
private UserEntity currentUser;
|
||||
private Disposable contactsQueryDisposable;
|
||||
private Disposable cacheQueryDisposable;
|
||||
@ -165,6 +155,8 @@ public class ContactsController extends BaseController implements SearchView.OnQ
|
||||
private boolean canFetchFurther = true;
|
||||
private boolean canFetchSearchFurther = true;
|
||||
|
||||
private MenuItem doneMenuItem;
|
||||
|
||||
public ContactsController() {
|
||||
super();
|
||||
setHasOptionsMenu(true);
|
||||
@ -195,7 +187,7 @@ public class ContactsController extends BaseController implements SearchView.OnQ
|
||||
if (isNewConversationView) {
|
||||
toggleNewCallHeaderVisibility(!isPublicCall);
|
||||
|
||||
checkAndHandleBottomButtons();
|
||||
checkAndHandleDoneMenuItem();
|
||||
|
||||
if (getActionBar() != null) {
|
||||
getActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
@ -257,29 +249,7 @@ public class ContactsController extends BaseController implements SearchView.OnQ
|
||||
adapter.addListener(this);
|
||||
}
|
||||
|
||||
@Optional
|
||||
@OnClick(R.id.clear_button)
|
||||
public void onClearButtonClick() {
|
||||
if (adapter != null) {
|
||||
List<Integer> selectedPositions = adapter.getSelectedPositions();
|
||||
for (Integer position : selectedPositions) {
|
||||
if (adapter.getItem(position) instanceof UserItem) {
|
||||
UserItem userItem = (UserItem) adapter.getItem(position);
|
||||
adapter.toggleSelection(position);
|
||||
if (userItem != null) {
|
||||
userItem.flipItemSelection();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
checkAndHandleBottomButtons();
|
||||
}
|
||||
|
||||
@Optional
|
||||
@OnClick(R.id.done_button)
|
||||
public void onDoneButtonClick() {
|
||||
|
||||
private void selectionDone() {
|
||||
if (!isPublicCall && adapter.getSelectedPositions().size() == 1) {
|
||||
RetrofitBucket retrofitBucket = ApiUtils.getRetrofitBucketForCreateRoom(currentUser.getBaseUrl(), "1",
|
||||
((UserItem) adapter.getItem(adapter.getSelectedPositions().get(0))).getModel().getUserId(), null);
|
||||
@ -411,6 +381,9 @@ public class ContactsController extends BaseController implements SearchView.OnQ
|
||||
case android.R.id.home:
|
||||
getRouter().popCurrentController();
|
||||
return true;
|
||||
case R.id.contacts_selection_done:
|
||||
selectionDone();
|
||||
return true;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
@ -421,7 +394,9 @@ public class ContactsController extends BaseController implements SearchView.OnQ
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
inflater.inflate(R.menu.menu_conversation_plus_filter, menu);
|
||||
searchItem = menu.findItem(R.id.action_search);
|
||||
doneMenuItem = menu.findItem(R.id.contacts_selection_done);
|
||||
menu.findItem(R.id.action_new_conversation).setVisible(false);
|
||||
|
||||
initSearchView();
|
||||
}
|
||||
|
||||
@ -576,7 +551,7 @@ public class ContactsController extends BaseController implements SearchView.OnQ
|
||||
}
|
||||
|
||||
if (isNewConversationView) {
|
||||
checkAndHandleBottomButtons();
|
||||
checkAndHandleDoneMenuItem();
|
||||
}
|
||||
}
|
||||
;
|
||||
@ -648,9 +623,6 @@ public class ContactsController extends BaseController implements SearchView.OnQ
|
||||
return "";
|
||||
}
|
||||
});
|
||||
|
||||
CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) bottomButtonsLinearLayout.getLayoutParams();
|
||||
layoutParams.setBehavior(new ViewHidingBehaviourAnimation());
|
||||
}
|
||||
|
||||
private void dispose(@Nullable Disposable disposable) {
|
||||
@ -725,23 +697,18 @@ public class ContactsController extends BaseController implements SearchView.OnQ
|
||||
return onQueryTextChange(query);
|
||||
}
|
||||
|
||||
private void checkAndHandleBottomButtons() {
|
||||
if (adapter != null && bottomButtonsLinearLayout != null && clearButton != null) {
|
||||
private void checkAndHandleDoneMenuItem() {
|
||||
if (adapter != null && doneMenuItem != null) {
|
||||
if (adapter.getSelectedItemCount() > 0 || isPublicCall) {
|
||||
if (bottomButtonsLinearLayout.getVisibility() != View.VISIBLE) {
|
||||
bottomButtonsLinearLayout.setVisibility(View.VISIBLE);
|
||||
if (!doneMenuItem.isVisible()) {
|
||||
doneMenuItem.setVisible(true);
|
||||
}
|
||||
|
||||
if (adapter.getSelectedItemCount() == 0) {
|
||||
clearButton.setVisibility(View.GONE);
|
||||
} else {
|
||||
clearButton.setVisibility(View.VISIBLE);
|
||||
}
|
||||
} else {
|
||||
bottomButtonsLinearLayout.setVisibility(View.GONE);
|
||||
doneMenuItem.setVisible(false);
|
||||
}
|
||||
} else if (bottomButtonsLinearLayout != null) {
|
||||
bottomButtonsLinearLayout.setVisibility(View.GONE);
|
||||
} else if (doneMenuItem != null) {
|
||||
doneMenuItem.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -865,7 +832,7 @@ public class ContactsController extends BaseController implements SearchView.OnQ
|
||||
((UserItem) adapter.getItem(position)).flipItemSelection();
|
||||
adapter.toggleSelection(position);
|
||||
|
||||
checkAndHandleBottomButtons();
|
||||
checkAndHandleDoneMenuItem();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@ -876,7 +843,7 @@ public class ContactsController extends BaseController implements SearchView.OnQ
|
||||
void toggleCallHeader() {
|
||||
toggleNewCallHeaderVisibility(isPublicCall);
|
||||
isPublicCall = !isPublicCall;
|
||||
checkAndHandleBottomButtons();
|
||||
checkAndHandleDoneMenuItem();
|
||||
}
|
||||
|
||||
private void toggleNewCallHeaderVisibility(boolean showInitialLayout) {
|
||||
|
@ -1,59 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Nextcloud Talk application
|
||||
~
|
||||
~ @author Mario Danic
|
||||
~ Copyright (C) 2017-2018 Mario Danic <mario@lovelyhq.com>
|
||||
~
|
||||
~ This program is free software: you can redistribute it and/or modify
|
||||
~ it under the terms of the GNU General Public License as published by
|
||||
~ the Free Software Foundation, either version 3 of the License, or
|
||||
~ at your option) any later version.
|
||||
~
|
||||
~ This program is distributed in the hope that it will be useful,
|
||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
~ GNU General Public License for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU General Public License
|
||||
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/bottom_buttons_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:animateLayoutChanges="true"
|
||||
android:gravity="bottom"
|
||||
android:orientation="horizontal"
|
||||
android:visibility="visible">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<Button
|
||||
android:id="@+id/clear_button"
|
||||
style="?android:attr/borderlessButtonStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.6"
|
||||
android:background="@color/nc_darkRed"
|
||||
android:text="@string/nc_contacts_clear"
|
||||
android:textAlignment="center"
|
||||
android:textColor="@android:color/white"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/done_button"
|
||||
style="?android:attr/borderlessButtonStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.4"
|
||||
android:background="@color/nc_darkGreen"
|
||||
android:text="@string/nc_contacts_done"
|
||||
android:textAlignment="center"
|
||||
android:textColor="@android:color/white"/>
|
||||
|
||||
</LinearLayout>
|
||||
</android.support.design.widget.CoordinatorLayout>
|
@ -45,9 +45,5 @@
|
||||
|
||||
</android.support.v4.widget.SwipeRefreshLayout>
|
||||
|
||||
<include
|
||||
layout="@layout/bottom_buttons"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<include layout="@layout/fast_scroller"/>
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
|
30
app/src/main/res/menu/menu_contacts.xml
Normal file
30
app/src/main/res/menu/menu_contacts.xml
Normal file
@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Nextcloud Talk application
|
||||
~
|
||||
~ @author Mario Danic
|
||||
~ Copyright (C) 2017-2018 Mario Danic <mario@lovelyhq.com>
|
||||
~
|
||||
~ This program is free software: you can redistribute it and/or modify
|
||||
~ it under the terms of the GNU General Public License as published by
|
||||
~ the Free Software Foundation, either version 3 of the License, or
|
||||
~ at your option) any later version.
|
||||
~
|
||||
~ This program is distributed in the hope that it will be useful,
|
||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
~ GNU General Public License for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU General Public License
|
||||
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item
|
||||
android:id="@+id/contacts_selection_done"
|
||||
android:title="@string/nc_contacts_done"
|
||||
app:showAsAction="always"
|
||||
android:visible="false"/>
|
||||
</menu>
|
@ -35,4 +35,11 @@
|
||||
android:title="@string/nc_new_conversation"
|
||||
android:icon="@drawable/ic_add_white_24px"
|
||||
app:showAsAction="ifRoom"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/contacts_selection_done"
|
||||
android:title="@string/nc_contacts_done"
|
||||
app:showAsAction="always"
|
||||
android:visible="false"/>
|
||||
|
||||
</menu>
|
||||
|
Loading…
Reference in New Issue
Block a user