mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-26 23:25:20 +03:00
extract new call item to layout
This commit is contained in:
parent
deaa761736
commit
797755221c
5 changed files with 80 additions and 127 deletions
|
@ -1,101 +0,0 @@
|
||||||
/*
|
|
||||||
* 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/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.nextcloud.talk.adapters.items;
|
|
||||||
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.RelativeLayout;
|
|
||||||
|
|
||||||
import com.nextcloud.talk.R;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import eu.davidea.flexibleadapter.FlexibleAdapter;
|
|
||||||
import eu.davidea.flexibleadapter.items.AbstractHeaderItem;
|
|
||||||
import eu.davidea.flexibleadapter.items.IFlexible;
|
|
||||||
import eu.davidea.flexibleadapter.items.IHeader;
|
|
||||||
import eu.davidea.viewholders.FlexibleViewHolder;
|
|
||||||
|
|
||||||
public class NewCallHeaderItem extends AbstractHeaderItem<NewCallHeaderItem.HeaderViewHolder>
|
|
||||||
implements IHeader<NewCallHeaderItem.HeaderViewHolder> {
|
|
||||||
|
|
||||||
HeaderViewHolder headerViewHolder;
|
|
||||||
|
|
||||||
public NewCallHeaderItem() {
|
|
||||||
super();
|
|
||||||
setSelectable(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLayoutRes() {
|
|
||||||
return R.layout.rv_item_call_header;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void bindViewHolder(FlexibleAdapter<IFlexible> adapter, HeaderViewHolder holder, int position, List<Object> payloads) {
|
|
||||||
headerViewHolder = holder;
|
|
||||||
|
|
||||||
if (holder.secondaryRelativeLayout.getVisibility() == View.GONE && adapter.isSelected(position)) {
|
|
||||||
togglePublicCall(true);
|
|
||||||
} else if (holder.initialRelativeLayout.getVisibility() == View.GONE && !adapter.isSelected(position)) {
|
|
||||||
togglePublicCall(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public HeaderViewHolder createViewHolder(View view, FlexibleAdapter adapter) {
|
|
||||||
headerViewHolder = new HeaderViewHolder(view, adapter);
|
|
||||||
return headerViewHolder;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void togglePublicCall(boolean showDescription) {
|
|
||||||
if (!showDescription) {
|
|
||||||
headerViewHolder.secondaryRelativeLayout.setVisibility(View.GONE);
|
|
||||||
headerViewHolder.initialRelativeLayout.setVisibility(View.VISIBLE);
|
|
||||||
} else {
|
|
||||||
headerViewHolder.initialRelativeLayout.setVisibility(View.GONE);
|
|
||||||
headerViewHolder.secondaryRelativeLayout.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static class HeaderViewHolder extends FlexibleViewHolder {
|
|
||||||
|
|
||||||
@BindView(R.id.initial_relative_layout)
|
|
||||||
public RelativeLayout initialRelativeLayout;
|
|
||||||
|
|
||||||
@BindView(R.id.secondary_relative_layout)
|
|
||||||
public RelativeLayout secondaryRelativeLayout;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Default constructor.
|
|
||||||
*/
|
|
||||||
HeaderViewHolder(View view, FlexibleAdapter adapter) {
|
|
||||||
super(view, adapter, true);
|
|
||||||
ButterKnife.bind(this, view);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -44,6 +44,7 @@ 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.Button;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
|
|
||||||
import com.bluelinelabs.conductor.RouterTransaction;
|
import com.bluelinelabs.conductor.RouterTransaction;
|
||||||
import com.bluelinelabs.conductor.changehandler.HorizontalChangeHandler;
|
import com.bluelinelabs.conductor.changehandler.HorizontalChangeHandler;
|
||||||
|
@ -51,7 +52,6 @@ import com.bluelinelabs.conductor.changehandler.VerticalChangeHandler;
|
||||||
import com.kennyc.bottomsheet.BottomSheet;
|
import com.kennyc.bottomsheet.BottomSheet;
|
||||||
import com.nextcloud.talk.R;
|
import com.nextcloud.talk.R;
|
||||||
import com.nextcloud.talk.activities.CallActivity;
|
import com.nextcloud.talk.activities.CallActivity;
|
||||||
import com.nextcloud.talk.adapters.items.NewCallHeaderItem;
|
|
||||||
import com.nextcloud.talk.adapters.items.UserHeaderItem;
|
import com.nextcloud.talk.adapters.items.UserHeaderItem;
|
||||||
import com.nextcloud.talk.adapters.items.UserItem;
|
import com.nextcloud.talk.adapters.items.UserItem;
|
||||||
import com.nextcloud.talk.api.NcApi;
|
import com.nextcloud.talk.api.NcApi;
|
||||||
|
@ -120,6 +120,15 @@ public class ContactsController extends BaseController implements SearchView.OnQ
|
||||||
@Inject
|
@Inject
|
||||||
EventBus eventBus;
|
EventBus eventBus;
|
||||||
|
|
||||||
|
@BindView(R.id.call_header_layout)
|
||||||
|
public RelativeLayout callHeaderLayout;
|
||||||
|
|
||||||
|
@BindView(R.id.initial_relative_layout)
|
||||||
|
public RelativeLayout initialRelativeLayout;
|
||||||
|
|
||||||
|
@BindView(R.id.secondary_relative_layout)
|
||||||
|
public RelativeLayout secondaryRelativeLayout;
|
||||||
|
|
||||||
@BindView(R.id.recycler_view)
|
@BindView(R.id.recycler_view)
|
||||||
RecyclerView recyclerView;
|
RecyclerView recyclerView;
|
||||||
|
|
||||||
|
@ -153,7 +162,7 @@ public class ContactsController extends BaseController implements SearchView.OnQ
|
||||||
private boolean isNewConversationView;
|
private boolean isNewConversationView;
|
||||||
private boolean isPublicCall;
|
private boolean isPublicCall;
|
||||||
|
|
||||||
private HashMap<String, UserHeaderItem> userHeaderItems = new HashMap<String, UserHeaderItem>();
|
private HashMap<String, UserHeaderItem> userHeaderItems = new HashMap<>();
|
||||||
|
|
||||||
public ContactsController() {
|
public ContactsController() {
|
||||||
super();
|
super();
|
||||||
|
@ -170,7 +179,7 @@ public class ContactsController extends BaseController implements SearchView.OnQ
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected View inflateView(@NonNull LayoutInflater inflater, @NonNull ViewGroup container) {
|
protected View inflateView(@NonNull LayoutInflater inflater, @NonNull ViewGroup container) {
|
||||||
return inflater.inflate(R.layout.controller_generic_rv, container, false);
|
return inflater.inflate(R.layout.controller_contacts_rv, container, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -466,7 +475,9 @@ public class ContactsController extends BaseController implements SearchView.OnQ
|
||||||
});
|
});
|
||||||
|
|
||||||
if (isNewConversationView) {
|
if (isNewConversationView) {
|
||||||
contactItems.add(0, new NewCallHeaderItem());
|
callHeaderLayout.setVisibility(View.VISIBLE);
|
||||||
|
} else {
|
||||||
|
callHeaderLayout.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
adapter.updateDataSet(contactItems, true);
|
adapter.updateDataSet(contactItems, true);
|
||||||
|
@ -743,12 +754,21 @@ public class ContactsController extends BaseController implements SearchView.OnQ
|
||||||
|
|
||||||
checkAndHandleBottomButtons();
|
checkAndHandleBottomButtons();
|
||||||
}
|
}
|
||||||
} else if (adapter.getItem(position) instanceof NewCallHeaderItem) {
|
|
||||||
adapter.toggleSelection(position);
|
|
||||||
isPublicCall = adapter.isSelected(position);
|
|
||||||
((NewCallHeaderItem) adapter.getItem(position)).togglePublicCall(isPublicCall);
|
|
||||||
checkAndHandleBottomButtons();
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OnClick(R.id.call_header_layout)
|
||||||
|
private void toggleCallHeader() {
|
||||||
|
adapter.toggleSelection(0);
|
||||||
|
isPublicCall = adapter.isSelected(0);
|
||||||
|
if (!isPublicCall) {
|
||||||
|
secondaryRelativeLayout.setVisibility(View.GONE);
|
||||||
|
initialRelativeLayout.setVisibility(View.VISIBLE);
|
||||||
|
} else {
|
||||||
|
initialRelativeLayout.setVisibility(View.GONE);
|
||||||
|
secondaryRelativeLayout.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
checkAndHandleBottomButtons();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
29
app/src/main/res/layout/controller_contacts_rv.xml
Normal file
29
app/src/main/res/layout/controller_contacts_rv.xml
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
~ Nextcloud Talk application
|
||||||
|
~
|
||||||
|
~ @author Andy Scherzinger
|
||||||
|
~ Copyright (C) 2018 Andy Scherzinger
|
||||||
|
~
|
||||||
|
~ 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/>.
|
||||||
|
-->
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<include layout="@layout/rv_item_call_header"/>
|
||||||
|
|
||||||
|
<include layout="@layout/controller_generic_rv" />
|
||||||
|
</LinearLayout>
|
|
@ -20,10 +20,11 @@
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:id="@+id/generic_rv_layout"
|
||||||
android:layout_height="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:background="@color/nc_white_color">
|
android:layout_height="match_parent"
|
||||||
|
android:background="@color/nc_white_color">
|
||||||
|
|
||||||
<android.support.v4.widget.SwipeRefreshLayout
|
<android.support.v4.widget.SwipeRefreshLayout
|
||||||
android:id="@+id/swipe_refresh_layout"
|
android:id="@+id/swipe_refresh_layout"
|
||||||
|
|
|
@ -20,10 +20,11 @@
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:id="@+id/call_header_layout"
|
||||||
android:layout_height="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:orientation="vertical">
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/initial_relative_layout"
|
android:id="@+id/initial_relative_layout"
|
||||||
|
@ -32,25 +33,28 @@
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/public_call_link"
|
android:id="@+id/public_call_link"
|
||||||
android:layout_width="40dp"
|
android:layout_width="32dp"
|
||||||
android:layout_height="40dp"
|
android:layout_height="32dp"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:layout_marginStart="24dp"
|
android:layout_marginEnd="8dp"
|
||||||
android:src="@drawable/ic_group_black_24px"/>
|
android:layout_marginStart="@dimen/activity_horizontal_margin"
|
||||||
|
android:contentDescription="@null"
|
||||||
|
android:src="@drawable/ic_group_black_24px"
|
||||||
|
android:tint="@color/colorPrimary" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/description_text"
|
android:id="@+id/description_text"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:layout_marginEnd="24dp"
|
android:layout_marginEnd="@dimen/activity_horizontal_margin"
|
||||||
android:layout_marginStart="8dp"
|
android:layout_marginStart="@dimen/activity_horizontal_margin"
|
||||||
android:layout_toEndOf="@id/public_call_link"
|
android:layout_toEndOf="@id/public_call_link"
|
||||||
android:ellipsize="middle"
|
android:ellipsize="middle"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:text="@string/nc_public_call"
|
android:text="@string/nc_public_call"
|
||||||
android:textAppearance="?android:attr/textAppearanceListItem"
|
android:textAppearance="?android:attr/textAppearanceListItem"
|
||||||
tools:text="@string/nc_public_call"/>
|
tools:text="@string/nc_public_call" />
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
@ -72,7 +76,7 @@
|
||||||
android:text="@string/nc_public_call_explanation"
|
android:text="@string/nc_public_call_explanation"
|
||||||
android:textAlignment="center"
|
android:textAlignment="center"
|
||||||
android:textAppearance="?android:attr/textAppearanceListItem"
|
android:textAppearance="?android:attr/textAppearanceListItem"
|
||||||
tools:text="@string/nc_public_call_explanation"/>
|
tools:text="@string/nc_public_call_explanation" />
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
Loading…
Reference in a new issue