Conversion de Chatlist en RecyclerView terminee, selection + suppression terminee, desactivation de la TabBar+SideMenu durant le mode de selection
This commit is contained in:
parent
10565fd636
commit
e368fb0cc2
14 changed files with 436 additions and 123 deletions
|
@ -64,7 +64,9 @@
|
|||
android:icon="@mipmap/ic_launcher"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:label="@string/app_name"
|
||||
android:largeHeap="true">
|
||||
android:largeHeap="true"
|
||||
>
|
||||
|
||||
<activity
|
||||
android:name=".activities.LinphoneLauncherActivity"
|
||||
android:exported="true"
|
||||
|
|
|
@ -49,6 +49,9 @@ dependencies {
|
|||
}
|
||||
implementation 'com.android.support:support-v4:27.1.1'
|
||||
implementation 'com.android.support:recyclerview-v7:27.1.1'
|
||||
implementation 'com.android.support:appcompat-v7:27.1.1'
|
||||
implementation 'com.android.support:design:27.1.1'
|
||||
|
||||
}
|
||||
|
||||
if (firebaseEnable()) {
|
||||
|
|
|
@ -72,7 +72,7 @@ public class LogsActivity extends Activity {
|
|||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
// Inflate the menu; this adds items to the action bar if it is present.
|
||||
// Inflate the menu; this adds items to the action context_bar if it is present.
|
||||
getMenuInflater().inflate(R.menu.activity_logs, menu);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ public class MainActivity extends Activity {
|
|||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
// Inflate the menu; this adds items to the action bar if it is present.
|
||||
// Inflate the menu; this adds items to the action context_bar if it is present.
|
||||
getMenuInflater().inflate(R.menu.activity_main, menu);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ public class SuitesActivity extends Activity {
|
|||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
// Inflate the menu; this adds items to the action bar if it is present.
|
||||
// Inflate the menu; this adds items to the action context_bar if it is present.
|
||||
getMenuInflater().inflate(R.menu.activity_suites, menu);
|
||||
return true;
|
||||
}
|
||||
|
|
11
res/drawable/cancel_with_padding.xml
Normal file
11
res/drawable/cancel_with_padding.xml
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:bottom="40dp"
|
||||
android:left="20dp"
|
||||
android:right="20dp"
|
||||
android:top="40dp">
|
||||
|
||||
<bitmap android:src="@drawable/cancel_edit"/>
|
||||
</item>
|
||||
</layer-list>
|
|
@ -54,7 +54,7 @@
|
|||
</LinearLayout>
|
||||
|
||||
<include layout="@layout/edit_list"/>
|
||||
|
||||
<!--<include layout="@layout/context_bar"></include>-->
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/chatList"
|
||||
android:layout_width="match_parent"
|
||||
|
|
135
res/layout/context_bar.xml
Normal file
135
res/layout/context_bar.xml
Normal file
|
@ -0,0 +1,135 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/context_bar"
|
||||
android:background="@color/colorA"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="100dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<!--<RelativeLayout-->
|
||||
<!--android:id="@+id/status_bar"-->
|
||||
<!--android:layout_width="match_parent"-->
|
||||
<!--android:layout_height="40dp"-->
|
||||
<!--android:layout_alignParentTop="true">-->
|
||||
|
||||
<!--<ImageView-->
|
||||
<!--android:id="@+id/side_menu_button"-->
|
||||
<!--android:src="@drawable/menu_burger"-->
|
||||
<!--android:contentDescription="@string/content_description_menu"-->
|
||||
<!--android:layout_width="wrap_content"-->
|
||||
<!--android:layout_height="wrap_content"-->
|
||||
<!--android:padding="10dp"-->
|
||||
<!--android:layout_centerInParent="true"-->
|
||||
<!--android:layout_alignParentLeft="true"/>-->
|
||||
|
||||
<!--<ImageView-->
|
||||
<!--android:id="@+id/call_quality"-->
|
||||
<!--android:src="@drawable/call_quality_indicator_0"-->
|
||||
<!--android:contentDescription="@string/content_description_call_quality"-->
|
||||
<!--android:layout_width="wrap_content"-->
|
||||
<!--android:layout_height="wrap_content"-->
|
||||
<!--android:padding="10dp"-->
|
||||
<!--android:layout_centerInParent="true"-->
|
||||
<!--android:layout_alignParentLeft="true"-->
|
||||
<!--android:visibility="invisible" />-->
|
||||
|
||||
<!--<ImageView-->
|
||||
<!--android:id="@+id/status_led"-->
|
||||
<!--android:src="@drawable/led_disconnected"-->
|
||||
<!--android:paddingLeft="5dp"-->
|
||||
<!--android:adjustViewBounds="true"-->
|
||||
<!--android:layout_width="20dp"-->
|
||||
<!--android:layout_height="wrap_content"-->
|
||||
<!--android:layout_centerInParent="true"-->
|
||||
<!--android:layout_toRightOf="@id/side_menu_button"/>-->
|
||||
|
||||
<!--<TextView-->
|
||||
<!--android:id="@+id/status_text"-->
|
||||
<!--android:text="@string/status_not_connected"-->
|
||||
<!--style="@style/font16"-->
|
||||
<!--android:paddingLeft="5dp"-->
|
||||
<!--android:layout_centerVertical="true"-->
|
||||
<!--android:layout_width="wrap_content"-->
|
||||
<!--android:layout_height="match_parent"-->
|
||||
<!--android:gravity="center_vertical"-->
|
||||
<!--android:layout_toRightOf="@id/status_led" />-->
|
||||
|
||||
<!--<ImageView-->
|
||||
<!--android:id="@+id/voicemail"-->
|
||||
<!--android:src="@drawable/voicemail"-->
|
||||
<!--android:layout_centerVertical="true"-->
|
||||
<!--android:layout_width="wrap_content"-->
|
||||
<!--android:layout_height="match_parent"-->
|
||||
<!--android:gravity="center_vertical"-->
|
||||
<!--android:visibility="gone" />-->
|
||||
|
||||
<!--<TextView-->
|
||||
<!--android:id="@+id/voicemail_count"-->
|
||||
<!--style="@style/font16"-->
|
||||
<!--android:layout_alignParentRight="true"-->
|
||||
<!--android:paddingLeft="5dp"-->
|
||||
<!--android:paddingRight="10dp"-->
|
||||
<!--android:layout_centerVertical="true"-->
|
||||
<!--android:layout_width="wrap_content"-->
|
||||
<!--android:layout_height="match_parent"-->
|
||||
<!--android:visibility="gone" />-->
|
||||
|
||||
<!--<ImageView-->
|
||||
<!--android:id="@+id/encryption"-->
|
||||
<!--android:src="@drawable/security_ko"-->
|
||||
<!--android:contentDescription="@string/content_description_encryption"-->
|
||||
<!--android:layout_width="wrap_content"-->
|
||||
<!--android:layout_height="wrap_content"-->
|
||||
<!--android:adjustViewBounds="true"-->
|
||||
<!--android:padding="5dp"-->
|
||||
<!--android:layout_centerInParent="true"-->
|
||||
<!--android:visibility="gone"-->
|
||||
<!--android:layout_alignParentRight="true" />-->
|
||||
<!--</RelativeLayout>-->
|
||||
<LinearLayout
|
||||
android:id="@+id/top_bar"
|
||||
android:orientation="horizontal"
|
||||
android:background="@color/colorF"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/new_discussion"
|
||||
android:src="@drawable/chat_add"
|
||||
android:background="@drawable/toolbar_button"
|
||||
android:contentDescription="@string/content_description_new_discussion"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.2"
|
||||
android:padding="15dp"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/back_in_call"
|
||||
android:src="@drawable/call_back"
|
||||
android:background="@drawable/toolbar_button"
|
||||
android:contentDescription="@string/content_description_back_call"
|
||||
android:visibility="invisible"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.2"
|
||||
android:padding="15dp"/>
|
||||
|
||||
<View
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.4"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/edit"
|
||||
android:src="@drawable/edit_list_button"
|
||||
android:background="@drawable/toolbar_button"
|
||||
android:contentDescription="@string/content_description_edit_list"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.2"
|
||||
android:padding="15dp"/>
|
||||
<include layout="@layout/edit_list"/>
|
||||
</LinearLayout>
|
||||
</android.support.v7.widget.Toolbar>
|
|
@ -1,58 +1,34 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"-->
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/edit_list"
|
||||
xmlns:app="https://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/edit_list_menu"
|
||||
android:orientation="horizontal"
|
||||
android:background="@color/colorF"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:visibility="gone">
|
||||
android:background="@color/colorA"
|
||||
android:height="100dp"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="100dp"
|
||||
android:visibility="gone"
|
||||
>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/cancel"
|
||||
android:src="@drawable/cancel_edit"
|
||||
android:background="@drawable/toolbar_button"
|
||||
android:contentDescription="@string/content_description_cancel_button"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.2"
|
||||
android:padding="15dp"/>
|
||||
|
||||
<View
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.4"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/select_all"
|
||||
android:src="@drawable/select_all"
|
||||
android:background="@drawable/toolbar_button"
|
||||
android:contentDescription="@string/content_description_select_all"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.2"
|
||||
android:padding="15dp"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/deselect_all"
|
||||
android:src="@drawable/deselect_all"
|
||||
android:background="@drawable/toolbar_button"
|
||||
android:contentDescription="@string/content_description_deselect_all"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.2"
|
||||
android:visibility="gone"
|
||||
android:padding="15dp"/>
|
||||
|
||||
<ImageView
|
||||
<item
|
||||
android:id="@+id/delete"
|
||||
android:src="@drawable/delete_button"
|
||||
android:background="@drawable/toolbar_button"
|
||||
android:contentDescription="@string/content_description_delete_selection"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.2"
|
||||
android:padding="15dp"/>
|
||||
|
||||
android:icon="@drawable/delete"
|
||||
app:showAsAction="ifRoom"
|
||||
android:orderInCategory="1000"
|
||||
android:title=""/>
|
||||
<item
|
||||
android:id="@+id/select_all"
|
||||
android:icon="@drawable/select_all"
|
||||
app:showAsAction="ifRoom"
|
||||
android:orderInCategory="100"
|
||||
android:title=""/>
|
||||
<item
|
||||
android:id="@+id/deselect_all"
|
||||
android:icon="@drawable/deselect_all"
|
||||
app:showAsAction="ifRoom"
|
||||
android:orderInCategory="200"
|
||||
android:visible="false"
|
||||
android:title=""/>
|
||||
|
||||
</menu>
|
|
@ -5,16 +5,48 @@
|
|||
<item name="android:fastScrollThumbDrawable">@drawable/fast_scroll</item>
|
||||
<item name="android:fastScrollTextColor">@android:color/white</item>
|
||||
<item name="android:fastScrollPreviewBackgroundRight">@drawable/fast_scroll_preview</item>
|
||||
<item name="android:windowActionModeOverlay">true</item>
|
||||
<!--<item name="windowActionBar">false</item>-->
|
||||
</style>
|
||||
|
||||
<style name="NoTitle.ActionMode" parent="@style/Widget.AppCompat.ActionMode">
|
||||
<item name="android:background">@color/colorE</item>
|
||||
<item name="android:height">100dp</item>
|
||||
</style>
|
||||
|
||||
<style name="ActionModeButtonStyle" parent="Widget.AppCompat.ActionButton">
|
||||
<item name="android:minWidth">30dp</item>
|
||||
<item name="android:maxWidth">48dp</item>
|
||||
<item name="android:width">48dp</item>
|
||||
|
||||
</style>
|
||||
|
||||
<style name="NoCloseButton" parent="@android:style/Widget.ActionButton.CloseMode">
|
||||
<!--<item name="android:visibility">invisible</item>-->
|
||||
<item name="android:maxWidth">10dp</item>
|
||||
<item name="android:minWidth">10dp</item>
|
||||
<item name="android:width">10dp</item>
|
||||
|
||||
</style>
|
||||
|
||||
<style name="NoTitle" parent="android:Theme.Holo.Light.NoActionBar">
|
||||
<item name="android:actionButtonStyle">@style/ActionModeButtonStyle</item>
|
||||
<item name="android:actionModeStyle">@style/NoTitle.ActionMode</item>
|
||||
<item name="android:actionModeCloseDrawable">@drawable/cancel_with_padding</item>
|
||||
<item name="android:actionModeCloseButtonStyle">@style/NoCloseButton</item>
|
||||
<!--<item name="android:actionModeBackground">@color/colorE</item>-->
|
||||
<item name="android:fastScrollThumbDrawable">@drawable/fast_scroll</item>
|
||||
<item name="android:fastScrollTextColor">@android:color/white</item>
|
||||
<item name="android:fastScrollPreviewBackgroundRight">@drawable/fast_scroll_preview</item>
|
||||
<item name="android:windowActionModeOverlay">true</item>
|
||||
<!--<item name="windowActionBar">true</item>-->
|
||||
</style>
|
||||
<style name="FullScreen" parent="android:Theme.Holo.Light.NoActionBar.Fullscreen">
|
||||
<style name="FullScreen" parent="android:Theme.Holo.Light.NoActionBar">
|
||||
<item name="android:fastScrollThumbDrawable">@drawable/fast_scroll</item>
|
||||
<item name="android:fastScrollTextColor">@android:color/white</item>
|
||||
<item name="android:fastScrollPreviewBackgroundRight">@drawable/fast_scroll_preview</item>
|
||||
<item name="android:windowActionModeOverlay">true</item>
|
||||
<!--<item name="windowActionBar">false</item>-->
|
||||
</style>
|
||||
|
||||
<style name="font1" parent="@android:style/TextAppearance.Medium">
|
||||
|
|
|
@ -1593,6 +1593,7 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
|
|||
menu.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
||||
if(sideMenu.isDrawerVisible(Gravity.LEFT)){
|
||||
sideMenu.closeDrawer(sideMenuContent);
|
||||
} else {
|
||||
|
|
|
@ -152,8 +152,8 @@ public class CodecDownloaderFragment extends Fragment {
|
|||
if (savedInstanceState.containsKey("downloaded"))
|
||||
downloaded.setVisibility((Integer) savedInstanceState.getSerializable("downloaded"));
|
||||
|
||||
if (savedInstanceState.containsKey("bar"))
|
||||
bar.setVisibility((Integer) savedInstanceState.getSerializable("bar"));
|
||||
if (savedInstanceState.containsKey("context_bar"))
|
||||
bar.setVisibility((Integer) savedInstanceState.getSerializable("context_bar"));
|
||||
|
||||
if (savedInstanceState.containsKey("downloadingInfo"))
|
||||
downloadingInfo.setVisibility((Integer) savedInstanceState.getSerializable("downloadingInfo"));
|
||||
|
@ -177,7 +177,7 @@ public class CodecDownloaderFragment extends Fragment {
|
|||
if (yes != null) outState.putSerializable("yes", yes.getVisibility());
|
||||
if (no != null) outState.putSerializable("no", no.getVisibility());
|
||||
if (ok != null) outState.putSerializable("ok", ok.getVisibility());
|
||||
if (bar != null) outState.putSerializable("bar", bar.getVisibility());
|
||||
if (bar != null) outState.putSerializable("context_bar", bar.getVisibility());
|
||||
if (downloadingInfo != null) outState.putSerializable("downloadingInfo", downloadingInfo.getVisibility());
|
||||
super.onSaveInstanceState(outState);
|
||||
}
|
||||
|
|
|
@ -19,39 +19,41 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
|
||||
package org.linphone.chat;
|
||||
|
||||
//import android.support.v7.view.ActionMode;
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.widget.DrawerLayout;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.text.Layout;
|
||||
import android.view.ActionMode;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.linphone.contacts.ContactsManager;
|
||||
import org.linphone.core.ChatRoomListenerStub;
|
||||
import org.linphone.core.EventLog;
|
||||
import org.linphone.mediastream.Log;
|
||||
import org.linphone.ui.ListSelectionHelper;
|
||||
import org.linphone.contacts.ContactsUpdatedListener;
|
||||
import org.linphone.fragments.FragmentsAvailable;
|
||||
import org.linphone.activities.LinphoneActivity;
|
||||
//import android.widget.Toolbar;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.R;
|
||||
import org.linphone.activities.LinphoneActivity;
|
||||
import org.linphone.contacts.ContactsManager;
|
||||
import org.linphone.contacts.ContactsUpdatedListener;
|
||||
import org.linphone.core.ChatMessage;
|
||||
import org.linphone.core.ChatRoom;
|
||||
import org.linphone.core.ChatRoomListenerStub;
|
||||
import org.linphone.core.Core;
|
||||
import org.linphone.core.CoreListenerStub;
|
||||
import org.linphone.fragments.FragmentsAvailable;
|
||||
import org.linphone.mediastream.Log;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
@ -63,8 +65,11 @@ public class ChatListFragment extends Fragment implements ContactsUpdatedListene
|
|||
// private LayoutInflater mInflater;
|
||||
private ActionModeCallback actionModeCallback = new ActionModeCallback();
|
||||
private ActionMode actionMode;
|
||||
private LinearLayout mEditTopBar, mTopBar;
|
||||
private ImageView mEditButton, mSelectAllButton, mDeselectAllButton, mDeleteSelectionButton, mCancelButton;
|
||||
|
||||
private LinearLayout mEditTopBar, mTabBar;
|
||||
private DrawerLayout mSideMenu;
|
||||
private ImageView mEditButton;
|
||||
private MenuItem mSelectAllButton, mDeselectAllButton, mDeleteButton;
|
||||
private RecyclerView mChatRoomsList;
|
||||
private TextView mNoChatHistory;
|
||||
private ImageView mNewDiscussionButton, mBackToCallButton;
|
||||
|
@ -78,7 +83,7 @@ public class ChatListFragment extends Fragment implements ContactsUpdatedListene
|
|||
private List<ChatRoom> mRooms;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
// mInflater = inflater;
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
@ -89,7 +94,16 @@ public class ChatListFragment extends Fragment implements ContactsUpdatedListene
|
|||
View view = inflater.inflate(R.layout.chatlist, container, false);
|
||||
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(mContext);
|
||||
|
||||
mChatRoomsAdapter = new ChatRoomsAdapter(mContext, R.layout.chatlist_cell, mRooms);
|
||||
Toolbar toolbar = this.getActivity().findViewById(R.id.context_bar);
|
||||
|
||||
// mChatRoomsAdapter = new ChatRoomsAdapter(mContext, R.layout.chatlist_cell, mRooms);
|
||||
mChatRoomsAdapter = new ChatRoomsAdapter(mContext, R.layout.chatlist_cell, mRooms,this);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// mSelectionHelper = new ListSelectionHelper(view, this);
|
||||
// mChatRoomsAdapter = new ChatRoomsAdapter(this, mSelectionHelper, mRooms);
|
||||
// mSelectionHelper.setAdapter(mChatRoomsAdapter);
|
||||
|
@ -108,28 +122,42 @@ public class ChatListFragment extends Fragment implements ContactsUpdatedListene
|
|||
// mNoChatHistory = view.findViewById(R.id.noChatHistory);
|
||||
|
||||
// mNoChatHistory.setVisibility(View.GONE);
|
||||
mEditTopBar = view.findViewById(R.id.edit_list);
|
||||
mTopBar = view.findViewById(R.id.top_bar);
|
||||
mSelectAllButton = view.findViewById(R.id.select_all);
|
||||
//mEditTopBar = view.findViewById(R.id.edit_list_menu);
|
||||
|
||||
|
||||
|
||||
// mTopBar = view.findViewById(R.id.top_bar);
|
||||
// Toolbar toolbar = this.getActivity().findViewById(R.id.context_bar);
|
||||
|
||||
|
||||
|
||||
|
||||
// mStatusBar = view.findViewById(R.id.status);
|
||||
|
||||
mEditButton = view.findViewById(R.id.edit);
|
||||
mEditButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
actionMode = getActivity().startActionMode(actionModeCallback);
|
||||
// mChatRoomsAdapter.setEditionMode(actionMode);
|
||||
|
||||
|
||||
|
||||
// getActivity().setActionBar();
|
||||
// mChatRoomsAdapter.setEditionMode(actionMode);
|
||||
// mTopBar.setVisibility(View.GONE);
|
||||
// mEditTopBar.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
|
||||
mCancelButton = view.findViewById(R.id.cancel);
|
||||
// mCancelButton = view.findViewById(R.id.cancel);
|
||||
// mCancelButton.setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View v) {
|
||||
// actionMode.invalidate();
|
||||
// }
|
||||
// });
|
||||
mDeselectAllButton = view.findViewById(R.id.deselect_all);
|
||||
// mDeselectAllButton = view.findViewById(R.id.deselect_all);
|
||||
// mSelectAllButton = view.findViewById(R.id.select_all);
|
||||
|
||||
|
||||
|
||||
|
@ -200,6 +228,7 @@ public class ChatListFragment extends Fragment implements ContactsUpdatedListene
|
|||
if (actionMode == null) {
|
||||
|
||||
actionMode = getActivity().startActionMode(actionModeCallback);
|
||||
|
||||
}
|
||||
|
||||
toggleSelection(position);
|
||||
|
@ -212,18 +241,21 @@ public class ChatListFragment extends Fragment implements ContactsUpdatedListene
|
|||
//
|
||||
int count = mChatRoomsAdapter.getSelectedItemCount();
|
||||
|
||||
if (count <= mChatRoomsAdapter.getItemCount()) {
|
||||
if (count < mChatRoomsAdapter.getItemCount()) {
|
||||
// actionMode.finish();
|
||||
mDeselectAllButton.setVisibility(View.GONE);
|
||||
mSelectAllButton.setVisibility(View.VISIBLE);
|
||||
actionMode.invalidate();
|
||||
mDeselectAllButton.setVisible(false);
|
||||
mSelectAllButton.setVisible(true);
|
||||
|
||||
} else {
|
||||
|
||||
// actionMode.setTitle(String.valueOf(count));
|
||||
mSelectAllButton.setVisibility(View.GONE);
|
||||
mDeselectAllButton.setVisibility(View.VISIBLE);
|
||||
actionMode.invalidate();
|
||||
mDeselectAllButton.setVisible(true);
|
||||
mSelectAllButton.setVisible(false);
|
||||
|
||||
}
|
||||
getActivity().invalidateOptionsMenu();
|
||||
actionMode.invalidate();
|
||||
|
||||
}
|
||||
|
||||
private class ActionModeCallback implements ActionMode.Callback {
|
||||
|
@ -232,36 +264,40 @@ public class ChatListFragment extends Fragment implements ContactsUpdatedListene
|
|||
|
||||
@Override
|
||||
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
|
||||
mTopBar.setVisibility(View.GONE);
|
||||
mEditTopBar.setVisibility(View.VISIBLE);
|
||||
//mTopBar.setVisibility(View.GONE);
|
||||
// Toolbar contextBar =
|
||||
// (RelativeLayout) view.findViewById(R.id.status);
|
||||
// getActivity().getContext();
|
||||
// View v = View.inflate(R.layout.status, null);
|
||||
// View view = (RelativeLayout)inflater.inflate(R.layout.chatlist, container, false);
|
||||
// mStatusBar.setVisibility(View.VISIBLE);
|
||||
mode.getMenuInflater().inflate (R.menu.edit_list_menu, menu);
|
||||
// Menu contextBar = menu;
|
||||
mDeselectAllButton = menu.findItem(R.id.deselect_all);
|
||||
mSelectAllButton = menu.findItem(R.id.select_all);
|
||||
mDeleteButton = menu.findItem(R.id.select_all);
|
||||
mTabBar = (LinearLayout) getActivity().findViewById(R.id.footer);
|
||||
mTabBar.setVisibility(View.INVISIBLE);
|
||||
mSideMenu=(DrawerLayout) getActivity().findViewById(R.id.side_menu);
|
||||
|
||||
mSideMenu.setDrawerLockMode(1);
|
||||
// SlidingDrawer simpleSlidingDrawer = (SlidingDrawer) getActivity().findViewById(R.id.side_menu); // initiate the SlidingDrawer
|
||||
// simpleSlidingDrawer.lock(); // lock the sliderDrawer so that touch event are disabled
|
||||
|
||||
// menu.findItem(R.id.menu_search).getActionView();
|
||||
// LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
// View tv= inflater.inflate(R.layout.context_bar, null);
|
||||
// mode.setCustomView(tv);
|
||||
|
||||
// (Toolbar) findViewById(R.id.status);
|
||||
|
||||
|
||||
//mEditTopBar.setVisibility(View.VISIBLE);
|
||||
|
||||
for (Integer i = 0; i <= mChatRoomsAdapter.getItemCount(); i++) {
|
||||
mChatRoomsAdapter.setEditionMode(mode);
|
||||
}
|
||||
mode.getMenuInflater().inflate (R.menu.edit_list_menu, menu);
|
||||
|
||||
mCancelButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
actionMode.finish();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//Add all non-selected items to the selection
|
||||
mSelectAllButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
for (Integer i = 0; i <= mChatRoomsAdapter.getItemCount(); i++) {
|
||||
if (!mChatRoomsAdapter.isSelected(i)) {
|
||||
toggleSelection(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -271,30 +307,54 @@ public class ChatListFragment extends Fragment implements ContactsUpdatedListene
|
|||
// mChatRoomsAdapter.setEditionMode(mode);
|
||||
// cpt++;
|
||||
// }
|
||||
// final MenuItem alertMenuItem = menu.findItem(R.id.menu_search);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.delete_button:
|
||||
|
||||
case R.id.delete:
|
||||
// TODO: actually remove items
|
||||
Log.d(TAG, "menu_remove");
|
||||
// Log.d(TAG, "menu_remove");
|
||||
mChatRoomsAdapter.removeItems(mChatRoomsAdapter.getSelectedItems());
|
||||
mode.finish();
|
||||
return true;
|
||||
case R.id.cancel:
|
||||
mode.finish();
|
||||
|
||||
case R.id.select_all:
|
||||
//Add all non-selected items to the selection
|
||||
for (Integer i = 0; i < mChatRoomsAdapter.getItemCount(); i++) {
|
||||
if (!mChatRoomsAdapter.isSelected(i)) {
|
||||
toggleSelection(i);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case R.id.deselect_all:
|
||||
for (Integer i = 0; i < mChatRoomsAdapter.getItemCount(); i++) {
|
||||
if (mChatRoomsAdapter.isSelected(i)) {
|
||||
toggleSelection(i);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
// case R.id.cancel:
|
||||
// mode.finish();
|
||||
default:
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyActionMode(ActionMode mode) {
|
||||
mTopBar.setVisibility(View.VISIBLE);
|
||||
mEditTopBar.setVisibility(View.GONE);
|
||||
|
||||
mChatRoomsAdapter.clearSelection();
|
||||
mTabBar.setVisibility(View.VISIBLE);
|
||||
mSideMenu.setDrawerLockMode(0);
|
||||
|
||||
actionMode = null;
|
||||
mChatRoomsAdapter.setEditionMode(actionMode);
|
||||
|
||||
|
@ -310,7 +370,6 @@ public class ChatListFragment extends Fragment implements ContactsUpdatedListene
|
|||
|
||||
|
||||
|
||||
|
||||
private void refreshChatRoomsList() {
|
||||
mChatRoomsAdapter.refresh();
|
||||
// mNoChatHistory.setVisibility(mChatRoomsAdapter.getItemCount() == 0 ? View.VISIBLE : View.GONE);
|
||||
|
@ -357,6 +416,14 @@ public class ChatListFragment extends Fragment implements ContactsUpdatedListene
|
|||
lc.removeListener(mListener);
|
||||
}
|
||||
ContactsManager.removeContactsListener(this);
|
||||
|
||||
|
||||
mChatRoomsAdapter.clearSelection();
|
||||
// mTabBar.setVisibility(View.VISIBLE);
|
||||
|
||||
actionMode = null;
|
||||
mChatRoomsAdapter.setEditionMode(actionMode);
|
||||
|
||||
mChatRoomsAdapter.clear();
|
||||
super.onPause();
|
||||
}
|
||||
|
@ -398,5 +465,8 @@ public class ChatListFragment extends Fragment implements ContactsUpdatedListene
|
|||
// adapter.notifyDataSetInvalidated();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -45,6 +45,8 @@ import org.linphone.core.Address;
|
|||
import org.linphone.core.ChatMessage;
|
||||
import org.linphone.core.ChatRoom;
|
||||
import org.linphone.core.ChatRoomListenerStub;
|
||||
import org.linphone.core.Core;
|
||||
import org.linphone.ui.SelectableAdapter;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.InputStream;
|
||||
|
@ -135,15 +137,43 @@ public class ChatRoomsAdapter extends RecyclerView.Adapter<ChatRoomsAdapter.Chat
|
|||
|
||||
public String getContact(ChatRoom mRoom) {
|
||||
LinphoneContact contact;
|
||||
contact = ContactsManager.getInstance().findContactFromAddress(mRoom.getPeerAddress());
|
||||
// contact = ContactsManager.getInstance().findContactFromAddress(mRoom.getPeerAddress());
|
||||
contact = ContactsManager.getInstance().findContactFromAddress(mRoom.getLastMessageInHistory().getFromAddress());
|
||||
if (contact != null) {
|
||||
|
||||
return (contact.getFullName());
|
||||
|
||||
} else {
|
||||
return (LinphoneUtils.getAddressDisplayName(mRoom.getPeerAddress()));
|
||||
return (LinphoneUtils.getAddressDisplayName(mRoom.getLastMessageInHistory().getFromAddress()));
|
||||
}
|
||||
}
|
||||
//// Address remoteAddress = chatRoom.getPeerAddress();
|
||||
//// Address contactAddress = remoteAddress;
|
||||
// if (chatRoom.hasCapability(ChatRoomCapabilities.OneToOne.toInt())) {
|
||||
// LinphoneContact contact;
|
||||
// if (chatRoom.getParticipants().length > 0) {
|
||||
// contact = ContactsManager.getInstance().findContactFromAddress(chatRoom.getParticipants()[0].getAddress());
|
||||
// if (contact != null) {
|
||||
// holder.displayName.setText(contact.getFullName());
|
||||
// LinphoneUtils.setThumbnailPictureFromUri(LinphoneActivity.instance(), holder.contactPicture, contact.getThumbnailUri());
|
||||
// } else {
|
||||
// holder.displayName.setText(LinphoneUtils.getAddressDisplayName(chatRoom.getParticipants()[0].getAddress()));
|
||||
// }
|
||||
// } else {
|
||||
// contact = ContactsManager.getInstance().findContactFromAddress(contactAddress);
|
||||
// if (contact != null) {
|
||||
// holder.displayName.setText(contact.getFullName());
|
||||
// LinphoneUtils.setThumbnailPictureFromUri(LinphoneActivity.instance(), holder.contactPicture, contact.getThumbnailUri());
|
||||
// } else {
|
||||
// holder.displayName.setText(LinphoneUtils.getAddressDisplayName(contactAddress));
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// holder.displayName.setText(chatRoom.getSubject());
|
||||
|
||||
|
||||
|
||||
|
||||
public void getAvatar(ChatRoom mRoom) {
|
||||
mDefaultBitmap = ContactsManager.getInstance().getDefaultAvatarBitmap();
|
||||
LinphoneContact contact = ContactsManager.getInstance().findContactFromAddress(mRoom.getPeerAddress());
|
||||
|
@ -248,6 +278,59 @@ public class ChatRoomsAdapter extends RecyclerView.Adapter<ChatRoomsAdapter.Chat
|
|||
mRooms.clear();
|
||||
}
|
||||
|
||||
|
||||
public void removeItem(int position) {
|
||||
|
||||
Core lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||
// mRooms.get(position).addListener(mChatRoomListener);
|
||||
lc.deleteChatRoom(mRooms.get(position));
|
||||
mRooms.remove(position);
|
||||
notifyItemRemoved(position);
|
||||
}
|
||||
|
||||
public void removeItems(List<Integer> positions) {
|
||||
// Reverse-sort the list
|
||||
Collections.sort(positions, new Comparator<Integer>() {
|
||||
@Override
|
||||
public int compare(Integer lhs, Integer rhs) {
|
||||
return rhs - lhs;
|
||||
}
|
||||
});
|
||||
|
||||
// Split the list in ranges
|
||||
while (!positions.isEmpty()) {
|
||||
if (positions.size() == 1) {
|
||||
removeItem(positions.get(0));
|
||||
positions.remove(0);
|
||||
} else {
|
||||
int count = 1;
|
||||
while (positions.size() > count && positions.get(count).equals(positions.get(count - 1) - 1)) {
|
||||
++count;
|
||||
}
|
||||
|
||||
if (count == 1) {
|
||||
removeItem(positions.get(0));
|
||||
} else {
|
||||
removeRange(positions.get(count - 1), count);
|
||||
}
|
||||
|
||||
for (int i = 0; i < count; ++i) {
|
||||
positions.remove(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void removeRange(int positionStart, int itemCount) {
|
||||
for (int i = 0; i < itemCount; ++i) {
|
||||
mRooms.remove(positionStart);
|
||||
}
|
||||
notifyItemRangeRemoved(positionStart, itemCount);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Adapter's methods
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue