mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-04 19:39:47 +01:00
parent
1cfb005150
commit
bdbb3a8cd1
@ -28,7 +28,6 @@ import android.os.Handler;
|
|||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.design.widget.BottomNavigationView;
|
import android.support.design.widget.BottomNavigationView;
|
||||||
import android.support.design.widget.CoordinatorLayout;
|
|
||||||
import android.support.v4.view.MenuItemCompat;
|
import android.support.v4.view.MenuItemCompat;
|
||||||
import android.support.v4.widget.SwipeRefreshLayout;
|
import android.support.v4.widget.SwipeRefreshLayout;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
@ -43,7 +42,6 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.ViewTreeObserver;
|
import android.view.ViewTreeObserver;
|
||||||
import android.view.inputmethod.EditorInfo;
|
import android.view.inputmethod.EditorInfo;
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
|
|
||||||
import com.bluelinelabs.conductor.RouterTransaction;
|
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.Sharee;
|
||||||
import com.nextcloud.talk.models.json.sharees.ShareesOverall;
|
import com.nextcloud.talk.models.json.sharees.ShareesOverall;
|
||||||
import com.nextcloud.talk.utils.ApiUtils;
|
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.bundle.BundleKeys;
|
||||||
import com.nextcloud.talk.utils.database.user.UserUtils;
|
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)
|
@BindView(R.id.swipe_refresh_layout)
|
||||||
SwipeRefreshLayout swipeRefreshLayout;
|
SwipeRefreshLayout swipeRefreshLayout;
|
||||||
|
|
||||||
@BindView(R.id.bottom_buttons_layout)
|
|
||||||
CoordinatorLayout bottomButtonsLinearLayout;
|
|
||||||
|
|
||||||
@BindView(R.id.fast_scroller)
|
@BindView(R.id.fast_scroller)
|
||||||
FastScroller fastScroller;
|
FastScroller fastScroller;
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@BindView(R.id.clear_button)
|
|
||||||
Button clearButton;
|
|
||||||
|
|
||||||
private UserEntity currentUser;
|
private UserEntity currentUser;
|
||||||
private Disposable contactsQueryDisposable;
|
private Disposable contactsQueryDisposable;
|
||||||
private Disposable cacheQueryDisposable;
|
private Disposable cacheQueryDisposable;
|
||||||
@ -165,6 +155,8 @@ public class ContactsController extends BaseController implements SearchView.OnQ
|
|||||||
private boolean canFetchFurther = true;
|
private boolean canFetchFurther = true;
|
||||||
private boolean canFetchSearchFurther = true;
|
private boolean canFetchSearchFurther = true;
|
||||||
|
|
||||||
|
private MenuItem doneMenuItem;
|
||||||
|
|
||||||
public ContactsController() {
|
public ContactsController() {
|
||||||
super();
|
super();
|
||||||
setHasOptionsMenu(true);
|
setHasOptionsMenu(true);
|
||||||
@ -195,7 +187,7 @@ public class ContactsController extends BaseController implements SearchView.OnQ
|
|||||||
if (isNewConversationView) {
|
if (isNewConversationView) {
|
||||||
toggleNewCallHeaderVisibility(!isPublicCall);
|
toggleNewCallHeaderVisibility(!isPublicCall);
|
||||||
|
|
||||||
checkAndHandleBottomButtons();
|
checkAndHandleDoneMenuItem();
|
||||||
|
|
||||||
if (getActionBar() != null) {
|
if (getActionBar() != null) {
|
||||||
getActionBar().setDisplayHomeAsUpEnabled(true);
|
getActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
@ -257,29 +249,7 @@ public class ContactsController extends BaseController implements SearchView.OnQ
|
|||||||
adapter.addListener(this);
|
adapter.addListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Optional
|
private void selectionDone() {
|
||||||
@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() {
|
|
||||||
|
|
||||||
if (!isPublicCall && adapter.getSelectedPositions().size() == 1) {
|
if (!isPublicCall && adapter.getSelectedPositions().size() == 1) {
|
||||||
RetrofitBucket retrofitBucket = ApiUtils.getRetrofitBucketForCreateRoom(currentUser.getBaseUrl(), "1",
|
RetrofitBucket retrofitBucket = ApiUtils.getRetrofitBucketForCreateRoom(currentUser.getBaseUrl(), "1",
|
||||||
((UserItem) adapter.getItem(adapter.getSelectedPositions().get(0))).getModel().getUserId(), null);
|
((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:
|
case android.R.id.home:
|
||||||
getRouter().popCurrentController();
|
getRouter().popCurrentController();
|
||||||
return true;
|
return true;
|
||||||
|
case R.id.contacts_selection_done:
|
||||||
|
selectionDone();
|
||||||
|
return true;
|
||||||
default:
|
default:
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
@ -421,7 +394,9 @@ public class ContactsController extends BaseController implements SearchView.OnQ
|
|||||||
super.onCreateOptionsMenu(menu, inflater);
|
super.onCreateOptionsMenu(menu, inflater);
|
||||||
inflater.inflate(R.menu.menu_conversation_plus_filter, menu);
|
inflater.inflate(R.menu.menu_conversation_plus_filter, menu);
|
||||||
searchItem = menu.findItem(R.id.action_search);
|
searchItem = menu.findItem(R.id.action_search);
|
||||||
|
doneMenuItem = menu.findItem(R.id.contacts_selection_done);
|
||||||
menu.findItem(R.id.action_new_conversation).setVisible(false);
|
menu.findItem(R.id.action_new_conversation).setVisible(false);
|
||||||
|
|
||||||
initSearchView();
|
initSearchView();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -576,7 +551,7 @@ public class ContactsController extends BaseController implements SearchView.OnQ
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isNewConversationView) {
|
if (isNewConversationView) {
|
||||||
checkAndHandleBottomButtons();
|
checkAndHandleDoneMenuItem();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
@ -648,9 +623,6 @@ public class ContactsController extends BaseController implements SearchView.OnQ
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) bottomButtonsLinearLayout.getLayoutParams();
|
|
||||||
layoutParams.setBehavior(new ViewHidingBehaviourAnimation());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void dispose(@Nullable Disposable disposable) {
|
private void dispose(@Nullable Disposable disposable) {
|
||||||
@ -725,23 +697,18 @@ public class ContactsController extends BaseController implements SearchView.OnQ
|
|||||||
return onQueryTextChange(query);
|
return onQueryTextChange(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkAndHandleBottomButtons() {
|
private void checkAndHandleDoneMenuItem() {
|
||||||
if (adapter != null && bottomButtonsLinearLayout != null && clearButton != null) {
|
if (adapter != null && doneMenuItem != null) {
|
||||||
if (adapter.getSelectedItemCount() > 0 || isPublicCall) {
|
if (adapter.getSelectedItemCount() > 0 || isPublicCall) {
|
||||||
if (bottomButtonsLinearLayout.getVisibility() != View.VISIBLE) {
|
if (!doneMenuItem.isVisible()) {
|
||||||
bottomButtonsLinearLayout.setVisibility(View.VISIBLE);
|
doneMenuItem.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (adapter.getSelectedItemCount() == 0) {
|
|
||||||
clearButton.setVisibility(View.GONE);
|
|
||||||
} else {
|
|
||||||
clearButton.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
bottomButtonsLinearLayout.setVisibility(View.GONE);
|
doneMenuItem.setVisible(false);
|
||||||
}
|
}
|
||||||
} else if (bottomButtonsLinearLayout != null) {
|
} else if (doneMenuItem != null) {
|
||||||
bottomButtonsLinearLayout.setVisibility(View.GONE);
|
doneMenuItem.setVisible(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -865,7 +832,7 @@ public class ContactsController extends BaseController implements SearchView.OnQ
|
|||||||
((UserItem) adapter.getItem(position)).flipItemSelection();
|
((UserItem) adapter.getItem(position)).flipItemSelection();
|
||||||
adapter.toggleSelection(position);
|
adapter.toggleSelection(position);
|
||||||
|
|
||||||
checkAndHandleBottomButtons();
|
checkAndHandleDoneMenuItem();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -876,7 +843,7 @@ public class ContactsController extends BaseController implements SearchView.OnQ
|
|||||||
void toggleCallHeader() {
|
void toggleCallHeader() {
|
||||||
toggleNewCallHeaderVisibility(isPublicCall);
|
toggleNewCallHeaderVisibility(isPublicCall);
|
||||||
isPublicCall = !isPublicCall;
|
isPublicCall = !isPublicCall;
|
||||||
checkAndHandleBottomButtons();
|
checkAndHandleDoneMenuItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void toggleNewCallHeaderVisibility(boolean showInitialLayout) {
|
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>
|
</android.support.v4.widget.SwipeRefreshLayout>
|
||||||
|
|
||||||
<include
|
|
||||||
layout="@layout/bottom_buttons"
|
|
||||||
android:visibility="gone"/>
|
|
||||||
|
|
||||||
<include layout="@layout/fast_scroller"/>
|
<include layout="@layout/fast_scroller"/>
|
||||||
</android.support.design.widget.CoordinatorLayout>
|
</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:title="@string/nc_new_conversation"
|
||||||
android:icon="@drawable/ic_add_white_24px"
|
android:icon="@drawable/ic_add_white_24px"
|
||||||
app:showAsAction="ifRoom"/>
|
app:showAsAction="ifRoom"/>
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/contacts_selection_done"
|
||||||
|
android:title="@string/nc_contacts_done"
|
||||||
|
app:showAsAction="always"
|
||||||
|
android:visible="false"/>
|
||||||
|
|
||||||
</menu>
|
</menu>
|
||||||
|
Loading…
Reference in New Issue
Block a user