Correction de la date de reception de message
This commit is contained in:
parent
5058890443
commit
8006231a69
12 changed files with 460 additions and 346 deletions
|
@ -47,7 +47,8 @@ dependencies {
|
|||
if (firebaseEnable()) {
|
||||
implementation 'com.google.firebase:firebase-messaging:12.0.1'
|
||||
}
|
||||
implementation 'com.android.support:support-v4:26.0.1'
|
||||
implementation 'com.android.support:support-v4:27.1.1'
|
||||
implementation 'com.android.support:recyclerview-v7:27.1.1'
|
||||
}
|
||||
|
||||
if (firebaseEnable()) {
|
||||
|
|
|
@ -1,72 +0,0 @@
|
|||
**********************************
|
||||
* LINPHONE customs parameters *
|
||||
**********************************
|
||||
|
||||
In res/values/non_localizable_custom.xml (filled with linphone default options):
|
||||
|
||||
1. Global
|
||||
|
||||
* Set the default domain used by the application:
|
||||
<string name="default_domain">sip.linphone.org</string
|
||||
|
||||
2. Assistant
|
||||
|
||||
* Server xmlrpc url for accounts
|
||||
<string name="wizard_url">https://sip3.linphone.org:444/inapp.php</string>
|
||||
|
||||
* In CreateAccount, allow username instead of phone number for creating a new account
|
||||
<bool name="assistant_allow_username">true</bool>
|
||||
|
||||
* Hide buttons in assistant menu
|
||||
<bool name="hide_linphone_accounts_in_assistant">false</bool>
|
||||
<bool name="hide_generic_accounts_in_assistant">false</bool>
|
||||
<bool name="hide_remote_provisioning_in_assistant">false</bool>
|
||||
|
||||
|
||||
3. Inapp
|
||||
|
||||
* Enabled inapp purchase
|
||||
<bool name="enable_in_app_purchase">true</bool>
|
||||
|
||||
* Days before end of trial period that launch daily notification to remind user to buy an account
|
||||
<integer name="days_notification_shown">5</integer>
|
||||
|
||||
* Time between two inapp notifications in seconds
|
||||
<integer name="time_between_inapp_notification">86400</integer>
|
||||
|
||||
* Hide username field in purchase view (automatically get from default account)
|
||||
<bool name="hide_username_in_inapp">true</bool>
|
||||
|
||||
|
||||
In res/raw/linphonerc_factory sections:
|
||||
|
||||
[in-app-purchase]
|
||||
* Server xmlrpc url for inapp
|
||||
server_url=https://sip3.linphone.org:444/inapp.php
|
||||
|
||||
* Item ids from the google play store
|
||||
purchasable_items_ids=test_account_subscription
|
||||
|
||||
[app]
|
||||
|
||||
* Numbers of digits to enter for validation/recover account
|
||||
activation_code_length=4
|
||||
|
||||
|
||||
[assistant]
|
||||
|
||||
* Set the default domain used for account creation :
|
||||
domain=sip.linphone.org
|
||||
|
||||
* Set the default password length (min-max) :
|
||||
password_max_length=-1
|
||||
password_min_length=1
|
||||
|
||||
* Set the default username length (min-max) :
|
||||
username_length=-1
|
||||
username_max_length=64
|
||||
username_min_length=1
|
||||
username_regex=^[a-z0-9_.\-]*$
|
||||
|
||||
* Server xmlrpc url for accounts
|
||||
xmlrpc_url=https://sip3.linphone.org:444/inapp.php
|
|
@ -1,8 +0,0 @@
|
|||
// Signing APK Release
|
||||
RELEASE_STORE_FILE=""
|
||||
RELEASE_STORE_PASSWORD=
|
||||
RELEASE_KEY_ALIAS=
|
||||
RELEASE_KEY_PASSWORD=
|
||||
|
||||
org.gradle.jvmargs=-XX\:MaxHeapSize\=2048M -Xmx2048M
|
||||
#org.gradle.jvmargs=-Xmx1536M
|
|
@ -1,59 +0,0 @@
|
|||
all: copy-files
|
||||
../gradlew clean
|
||||
../gradlew uninstallDebug
|
||||
|
||||
run-all-tests: copy-files
|
||||
../gradlew :installDebugAndroidTest && \
|
||||
../gradlew :installDebug && \
|
||||
../gradlew :grantDebugPermissions -i && \
|
||||
../gradlew :connectedAndroidTest -i \
|
||||
|
||||
copy-libs:
|
||||
mkdir -p assets && \
|
||||
mkdir -p assets/config_files && \
|
||||
rm -rf libs/arm64-v8a
|
||||
if test -d "../liblinphone-sdk/android-arm64"; then \
|
||||
mkdir -p libs/arm64-v8a && \
|
||||
cp -f ../liblinphone-sdk/android-arm64/lib/*.so libs/arm64-v8a && \
|
||||
cp -f ../liblinphone-sdk/android-arm64/lib/mediastreamer/plugins/*.so libs/arm64-v8a && \
|
||||
cp -f ../liblinphone-sdk/android-arm64/share/linphone/rootca.pem assets/config_files; \
|
||||
fi
|
||||
if test -f "../liblinphone-sdk/android-arm64/bin/gdbserver"; then \
|
||||
cp -f ../liblinphone-sdk/android-arm64/bin/gdbserver libs/arm64-v8a && \
|
||||
cp -f ../liblinphone-sdk/android-arm64/bin/gdb.setup libs/arm64-v8a; \
|
||||
fi
|
||||
rm -rf libs/armeabi-v7a
|
||||
if test -d "../liblinphone-sdk/android-armv7"; then \
|
||||
mkdir -p libs/armeabi-v7a && \
|
||||
cp -f ../liblinphone-sdk/android-armv7/lib/*.so libs/armeabi-v7a && \
|
||||
cp -f ../liblinphone-sdk/android-armv7/lib/mediastreamer/plugins/*.so libs/armeabi-v7a && \
|
||||
cp -f ../liblinphone-sdk/android-armv7/share/linphone/rootca.pem assets/config_files; \
|
||||
fi
|
||||
if test -f "../liblinphone-sdk/android-armv7/bin/gdbserver"; then \
|
||||
cp -f ../liblinphone-sdk/android-armv7/bin/gdbserver libs/armeabi-v7a && \
|
||||
cp -f ../liblinphone-sdk/android-armv7/bin/gdb.setup libs/armeabi-v7a; \
|
||||
fi
|
||||
rm -rf libs/x86
|
||||
if test -d "../liblinphone-sdk/android-x86"; then \
|
||||
mkdir -p libs/x86 && \
|
||||
cp -f ../liblinphone-sdk/android-x86/lib/*.so libs/x86 && \
|
||||
cp -f ../liblinphone-sdk/android-x86/lib/mediastreamer/plugins/*.so libs/x86 && \
|
||||
cp -f ../liblinphone-sdk/android-x86/share/linphone/rootca.pem assets/config_files; \
|
||||
fi
|
||||
if test -f "../liblinphone-sdk/android-x86/bin/gdbserver"; then \
|
||||
cp -f ../liblinphone-sdk/android-x86/bin/gdbserver libs/x86 && \
|
||||
cp -f ../liblinphone-sdk/android-x86/bin/gdb.setup libs/x86; \
|
||||
fi
|
||||
|
||||
copy-files: ../submodules/linphone/tester/tester_hosts
|
||||
$(MAKE) copy-libs
|
||||
rm -rf assets/config_files
|
||||
mkdir -p assets/config_files
|
||||
for file in $^; do \
|
||||
cp -rf $$file assets/config_files/. ; \
|
||||
done
|
||||
cp -rf ../submodules/linphone/tester/certificates assets/config_files
|
||||
cp -rf ../submodules/linphone/tester/images assets/config_files
|
||||
cp -rf ../submodules/linphone/tester/rcfiles assets/config_files
|
||||
cp -rf ../submodules/linphone/tester/sounds assets/config_files
|
||||
cp -rf ../submodules/linphone/tester/vcards assets/config_files
|
|
@ -55,7 +55,7 @@
|
|||
|
||||
<include layout="@layout/edit_list"/>
|
||||
|
||||
<ListView
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/chatList"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
|
125
res/layout/chatlist_cell_active.xml
Normal file
125
res/layout/chatlist_cell_active.xml
Normal file
|
@ -0,0 +1,125 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="80dp"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingRight="10dp"
|
||||
android:paddingTop="5dp"
|
||||
android:background="@drawable/list_selector">
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/delete_chatroom"
|
||||
android:button="@drawable/checkbox"
|
||||
android:contentDescription="@string/content_description_delete"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:adjustViewBounds="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:visibility="invisible" android:layout_alignParentTop="true"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_centerVertical="true"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/avatar_layout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/contact_picture"
|
||||
android:src="@drawable/avatar"
|
||||
android:contentDescription="@string/content_description_contact_picture"
|
||||
android:layout_width="35dp"
|
||||
android:layout_height="35dp"
|
||||
android:adjustViewBounds="true"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/mask"
|
||||
android:src="@drawable/avatar_mask"
|
||||
android:layout_width="35dp"
|
||||
android:layout_height="35dp"
|
||||
android:adjustViewBounds="true"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/date"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/avatar_layout"
|
||||
android:layout_marginTop="5dp"
|
||||
android:maxLines="1"
|
||||
style="@style/font2"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_toLeftOf="@id/delete_chatroom"
|
||||
android:paddingLeft="10dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/sipUri"
|
||||
android:lines="1"
|
||||
android:ellipsize="end"
|
||||
android:scrollHorizontally="true"
|
||||
android:maxLines="1"
|
||||
style="@style/font6"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="30dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/unreadMessages"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:contentDescription="@string/content_description_unread_chat_message"
|
||||
android:background="@drawable/chat_list_indicator"
|
||||
style="@style/font18"
|
||||
android:gravity="center"
|
||||
android:maxLines="1"
|
||||
android:layout_above="@+id/lastMessageLayout"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentEnd="true"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@id/lastMessageLayout"
|
||||
android:layout_below="@id/sipUri"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/lastMessageSender"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/font11"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/lastMessage"
|
||||
android:maxLines="2"
|
||||
android:ellipsize="end"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="30dp"
|
||||
style="@style/font11"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
58
res/menu/edit_list_menu.xml
Normal file
58
res/menu/edit_list_menu.xml
Normal file
|
@ -0,0 +1,58 @@
|
|||
<?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"
|
||||
android:orientation="horizontal"
|
||||
android:background="@color/colorF"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
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
|
||||
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"/>
|
||||
|
||||
|
||||
</menu>
|
|
@ -1,45 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
||||
targetNamespace="http://www.linphone.org/xsds/lpconfig.xsd"
|
||||
xmlns:tns="http://www.linphone.org/xsds/lpconfig.xsd"
|
||||
elementFormDefault="qualified">
|
||||
|
||||
<xs:element name="config" type="tns:LPConfig"></xs:element>
|
||||
|
||||
<xs:complexType name="LPConfig">
|
||||
<xs:sequence>
|
||||
<xs:element name="section" type="tns:LPSection" minOccurs="0" maxOccurs="unbounded"></xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
|
||||
<xs:complexType name="LPSection">
|
||||
<xs:sequence>
|
||||
<xs:element name="entry" type="tns:LPEntry" maxOccurs="unbounded" minOccurs="0">
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
<xs:attribute name="name" use="required">
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:minLength value="1"></xs:minLength>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:attribute>
|
||||
</xs:complexType>
|
||||
|
||||
<xs:complexType name="LPEntry">
|
||||
<xs:simpleContent>
|
||||
<xs:extension base="xs:string">
|
||||
<xs:attribute name="overwrite" type="xs:boolean"
|
||||
use="optional" default="false">
|
||||
</xs:attribute>
|
||||
<xs:attribute name="name" use="required">
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:minLength value="1"></xs:minLength>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:attribute>
|
||||
</xs:extension>
|
||||
</xs:simpleContent>
|
||||
</xs:complexType>
|
||||
</xs:schema>
|
|
@ -1 +0,0 @@
|
|||
../libs
|
|
@ -20,7 +20,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
package org.linphone.chat;
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -47,12 +50,16 @@ import org.linphone.core.Core;
|
|||
import org.linphone.core.CoreListenerStub;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static org.linphone.fragments.FragmentsAvailable.CHAT_LIST;
|
||||
|
||||
public class ChatListFragment extends Fragment implements ContactsUpdatedListener, ListSelectionHelper.DeleteListener {
|
||||
private LayoutInflater mInflater;
|
||||
private ListView mChatRoomsList;
|
||||
//public class ChatListFragment extends Fragment {
|
||||
// private LayoutInflater mInflater;
|
||||
private RecyclerView mChatRoomsList;
|
||||
private TextView mNoChatHistory;
|
||||
private ImageView mNewDiscussionButton, mBackToCallButton;
|
||||
private ChatRoomsAdapter mChatRoomsAdapter;
|
||||
|
@ -61,23 +68,31 @@ public class ChatListFragment extends Fragment implements ContactsUpdatedListene
|
|||
private RelativeLayout mWaitLayout;
|
||||
private int mChatRoomDeletionPendingCount;
|
||||
private ChatRoomListenerStub mChatRoomListener;
|
||||
private Context mContext;
|
||||
private List<ChatRoom> mRooms;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
mInflater = inflater;
|
||||
// mInflater = inflater;
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
mRooms = new ArrayList<>(Arrays.asList(LinphoneManager.getLc().getChatRooms()));
|
||||
this.mContext = getActivity().getApplicationContext();
|
||||
View view = inflater.inflate(R.layout.chatlist, container, false);
|
||||
mSelectionHelper = new ListSelectionHelper(view, this);
|
||||
mChatRoomsAdapter = new ChatRoomsAdapter(getActivity(), mSelectionHelper, mInflater);
|
||||
mSelectionHelper.setAdapter(mChatRoomsAdapter);
|
||||
mSelectionHelper.setDialogMessage(R.string.chat_room_delete_dialog);
|
||||
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(mContext);
|
||||
|
||||
mChatRoomsAdapter = new ChatRoomsAdapter(mContext, R.layout.chatlist_cell, mRooms);
|
||||
// mSelectionHelper = new ListSelectionHelper(view, this);
|
||||
// mChatRoomsAdapter = new ChatRoomsAdapter(this, mSelectionHelper, mRooms);
|
||||
// mSelectionHelper.setAdapter(mChatRoomsAdapter);
|
||||
// mSelectionHelper.setDialogMessage(R.string.chat_room_delete_dialog);
|
||||
|
||||
mWaitLayout = view.findViewById(R.id.waitScreen);
|
||||
mWaitLayout.setVisibility(View.GONE);
|
||||
|
||||
mChatRoomsList = view.findViewById(R.id.chatList);
|
||||
mChatRoomsList.setAdapter(mChatRoomsAdapter);
|
||||
|
||||
mChatRoomsList.setLayoutManager(layoutManager);
|
||||
mNoChatHistory = view.findViewById(R.id.noChatHistory);
|
||||
mNoChatHistory.setVisibility(View.GONE);
|
||||
|
||||
|
@ -135,12 +150,12 @@ public class ChatListFragment extends Fragment implements ContactsUpdatedListene
|
|||
|
||||
private void refreshChatRoomsList() {
|
||||
mChatRoomsAdapter.refresh();
|
||||
mNoChatHistory.setVisibility(mChatRoomsAdapter.getCount() == 0 ? View.VISIBLE : View.GONE);
|
||||
mNoChatHistory.setVisibility(mChatRoomsAdapter.getItemCount() == 0 ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
public void displayFirstChat() {
|
||||
ChatRoomsAdapter adapter = (ChatRoomsAdapter)mChatRoomsList.getAdapter();
|
||||
if (adapter != null && adapter.getCount() > 0) {
|
||||
if (adapter != null && adapter.getItemCount() > 0) {
|
||||
ChatRoom room = (ChatRoom) adapter.getItem(0);
|
||||
LinphoneActivity.instance().goToChat(room.getPeerAddress().asStringUriOnly());
|
||||
} else {
|
||||
|
@ -210,16 +225,15 @@ public class ChatListFragment extends Fragment implements ContactsUpdatedListene
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void onContactsUpdated() {
|
||||
if (!LinphoneActivity.isInstanciated() || LinphoneActivity.instance().getCurrentFragment() != CHAT_LIST)
|
||||
return;
|
||||
|
||||
ChatRoomsAdapter adapter = (ChatRoomsAdapter) mChatRoomsList.getAdapter();
|
||||
if (adapter != null) {
|
||||
adapter.notifyDataSetInvalidated();
|
||||
//adapter.notifyDataSetInvalidated();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -22,14 +22,18 @@ package org.linphone.chat;
|
|||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Typeface;
|
||||
import android.net.Uri;
|
||||
import android.provider.MediaStore;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
//import org.linphone.Chat;
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.LinphoneUtils;
|
||||
import org.linphone.R;
|
||||
|
@ -39,21 +43,19 @@ import org.linphone.contacts.LinphoneContact;
|
|||
import org.linphone.core.Address;
|
||||
import org.linphone.core.ChatMessage;
|
||||
import org.linphone.core.ChatRoom;
|
||||
import org.linphone.core.ChatRoomCapabilities;
|
||||
import org.linphone.core.ChatRoomListenerStub;
|
||||
import org.linphone.core.EventLog;
|
||||
import org.linphone.ui.ListSelectionAdapter;
|
||||
import org.linphone.ui.ListSelectionHelper;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
public class ChatRoomsAdapter extends ListSelectionAdapter {
|
||||
public class ChatRoomsAdapter extends RecyclerView.Adapter<ChatRoomsAdapter.ChatRoomViewHolder> {
|
||||
|
||||
private class ChatRoomViewHolder {
|
||||
public class ChatRoomViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
||||
public TextView lastMessageSenderView;
|
||||
public TextView lastMessageView;
|
||||
public TextView date;
|
||||
|
@ -61,16 +63,81 @@ public class ChatRoomsAdapter extends ListSelectionAdapter {
|
|||
public TextView unreadMessages;
|
||||
public CheckBox delete;
|
||||
public ImageView contactPicture;
|
||||
public Context mContext;
|
||||
public ChatRoom mRoom;
|
||||
|
||||
public ChatRoomViewHolder(View view) {
|
||||
lastMessageSenderView = view.findViewById(R.id.lastMessageSender);
|
||||
lastMessageView = view.findViewById(R.id.lastMessage);
|
||||
date = view.findViewById(R.id.date);
|
||||
displayName = view.findViewById(R.id.sipUri);
|
||||
unreadMessages = view.findViewById(R.id.unreadMessages);
|
||||
delete = view.findViewById(R.id.delete_chatroom);
|
||||
contactPicture = view.findViewById(R.id.contact_picture);
|
||||
public ChatRoomViewHolder(Context context,View itemView) {
|
||||
super(itemView);
|
||||
this.mContext= context;
|
||||
this.lastMessageSenderView = itemView.findViewById(R.id.lastMessageSender);
|
||||
this.lastMessageView = itemView.findViewById(R.id.lastMessage);
|
||||
this.date = itemView.findViewById(R.id.date);
|
||||
this.displayName = itemView.findViewById(R.id.sipUri);
|
||||
this.unreadMessages = itemView.findViewById(R.id.unreadMessages);
|
||||
this.delete = itemView.findViewById(R.id.delete_chatroom);
|
||||
this.contactPicture = itemView.findViewById(R.id.contact_picture);
|
||||
itemView.setOnClickListener(this);
|
||||
}
|
||||
public void bindChatRoom(ChatRoom room) {
|
||||
|
||||
// 4. Bind the data to the ViewHolder
|
||||
this.mRoom = room;
|
||||
this.lastMessageSenderView.setText(getSender(mRoom));
|
||||
this.lastMessageView.setText(mRoom.getLastMessageInHistory() != null ? mRoom.getLastMessageInHistory().getTextContent(): "");
|
||||
this.date.setText(mRoom.getLastMessageInHistory()!=null ? LinphoneUtils.timestampToHumanDate(this.mContext, mRoom.getLastUpdateTime(), R.string.messages_list_date_format) : "");
|
||||
this.displayName.setText(getContact(mRoom));
|
||||
this.unreadMessages.setText(String.valueOf(LinphoneManager.getInstance().getUnreadCountForChatRoom(mRoom)));
|
||||
this.delete.setChecked(!this.delete.isChecked());
|
||||
getAvatar(mRoom);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
// 5. Handle the onClick event for the ViewHolder
|
||||
if (this.mRoom != null) {
|
||||
LinphoneActivity.instance().goToChat(mRoom.getPeerAddress().asString());
|
||||
}
|
||||
}
|
||||
|
||||
public String getSender(ChatRoom mRoom){
|
||||
if (mRoom.getLastMessageInHistory() != null) {
|
||||
LinphoneContact contact = ContactsManager.getInstance().findContactFromAddress(mRoom.getLastMessageInHistory().getFromAddress());
|
||||
if (contact != null) {
|
||||
return (contact.getFullName() + mContext.getString(R.string.separator));
|
||||
} else {
|
||||
return (LinphoneUtils.getAddressDisplayName(mRoom.getLastMessageInHistory().getFromAddress()) + ":");
|
||||
}
|
||||
}else{
|
||||
return "" ;
|
||||
}
|
||||
}
|
||||
|
||||
public String getContact(ChatRoom mRoom) {
|
||||
LinphoneContact contact;
|
||||
contact = ContactsManager.getInstance().findContactFromAddress(mRoom.getPeerAddress());
|
||||
if (contact != null) {
|
||||
|
||||
return (contact.getFullName());
|
||||
|
||||
} else {
|
||||
return (LinphoneUtils.getAddressDisplayName(mRoom.getPeerAddress()));
|
||||
}
|
||||
}
|
||||
public void getAvatar(ChatRoom mRoom) {
|
||||
mDefaultBitmap = ContactsManager.getInstance().getDefaultAvatarBitmap();
|
||||
LinphoneContact contact = ContactsManager.getInstance().findContactFromAddress(mRoom.getPeerAddress());
|
||||
if (contact != null) {
|
||||
LinphoneUtils.setThumbnailPictureFromUri(LinphoneActivity.instance(), this.contactPicture, ContactsManager.getInstance().findContactFromAddress(mRoom.getPeerAddress()).getThumbnailUri());
|
||||
} else {
|
||||
this.contactPicture.setImageBitmap(mDefaultBitmap);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private Context mContext;
|
||||
|
@ -78,22 +145,45 @@ public class ChatRoomsAdapter extends ListSelectionAdapter {
|
|||
private LayoutInflater mLayoutInflater;
|
||||
private Bitmap mDefaultBitmap, mDefaultGroupBitmap;
|
||||
private ChatRoomListenerStub mListener;
|
||||
private int itemResource;
|
||||
|
||||
public ChatRoomsAdapter(Context context, ListSelectionHelper helper, LayoutInflater inflater) {
|
||||
super(helper);
|
||||
public ChatRoomsAdapter(Context context, int itemResource, List<ChatRoom> mRooms) {
|
||||
super();
|
||||
this.mRooms = mRooms;
|
||||
this.mContext = context;
|
||||
this.itemResource = itemResource;
|
||||
mContext = context;
|
||||
mLayoutInflater = inflater;
|
||||
mRooms = new ArrayList<>();
|
||||
//mLayoutInflater = inflater;
|
||||
mDefaultBitmap = ContactsManager.getInstance().getDefaultAvatarBitmap();
|
||||
mDefaultGroupBitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.chat_group_avatar);
|
||||
|
||||
mListener = new ChatRoomListenerStub() {
|
||||
@Override
|
||||
public void onSubjectChanged(ChatRoom cr, EventLog eventLog) {
|
||||
ChatRoomViewHolder holder = (ChatRoomViewHolder) cr.getUserData();
|
||||
holder.displayName.setText(cr.getSubject());
|
||||
}
|
||||
};
|
||||
// mListener = new ChatRoomListenerStub() {
|
||||
// @Override
|
||||
// public void onSubjectChanged(ChatRoom cr, EventLog eventLog) {
|
||||
// ChatRoomViewHolder holder = (ChatRoomViewHolder) cr.getUserData();
|
||||
// holder.displayName.setText(cr.getSubject());
|
||||
// }
|
||||
// };
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChatRoomViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
|
||||
// 3. Inflate the view and return the new ViewHolder
|
||||
View view = LayoutInflater.from(parent.getContext())
|
||||
.inflate(this.itemResource, parent, false);
|
||||
return new ChatRoomViewHolder(this.mContext, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(ChatRoomViewHolder holder, int position) {
|
||||
|
||||
// 5. Use position to access the correct Bakery object
|
||||
ChatRoom room = this.mRooms.get(position);
|
||||
|
||||
// 6. Bind the bakery object to the holder
|
||||
holder.bindChatRoom(room);
|
||||
}
|
||||
|
||||
public void refresh() {
|
||||
|
@ -120,12 +210,19 @@ public class ChatRoomsAdapter extends ListSelectionAdapter {
|
|||
* Adapter's methods
|
||||
*/
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return mRooms.size();
|
||||
}
|
||||
// @Override
|
||||
// public int getCount() {
|
||||
// return mRooms.size();
|
||||
// }
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
|
||||
return this.mRooms.size();
|
||||
}
|
||||
|
||||
|
||||
//@Override
|
||||
public Object getItem(int position) {
|
||||
return mRooms.get(position);
|
||||
}
|
||||
|
@ -135,120 +232,120 @@ public class ChatRoomsAdapter extends ListSelectionAdapter {
|
|||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(final int position, View convertView, ViewGroup viewGroup) {
|
||||
View view;
|
||||
ChatRoomViewHolder holder;
|
||||
|
||||
if (convertView != null) {
|
||||
view = convertView;
|
||||
holder = (ChatRoomViewHolder) view.getTag();
|
||||
} else {
|
||||
view = mLayoutInflater.inflate(R.layout.chatlist_cell, viewGroup, false);
|
||||
holder = new ChatRoomViewHolder(view);
|
||||
view.setTag(holder);
|
||||
}
|
||||
|
||||
ChatRoom chatRoom = mRooms.get(position);
|
||||
Address remoteAddress = chatRoom.getPeerAddress();
|
||||
Address contactAddress = remoteAddress;
|
||||
|
||||
if (chatRoom.hasCapability(ChatRoomCapabilities.OneToOne.toInt()) && chatRoom.getParticipants().length > 0) {
|
||||
contactAddress = chatRoom.getParticipants()[0].getAddress();
|
||||
}
|
||||
|
||||
if (chatRoom.hasCapability(ChatRoomCapabilities.Conference.toInt()) && chatRoom.getState() == ChatRoom.State.Created) { // Only set for state Created otherwise it will conflict with removal listener
|
||||
chatRoom.addListener(mListener);
|
||||
chatRoom.setUserData(holder);
|
||||
}
|
||||
|
||||
int unreadMessagesCount = LinphoneManager.getInstance().getUnreadCountForChatRoom(chatRoom);
|
||||
ChatMessage lastMessage = chatRoom.getLastMessageInHistory();
|
||||
holder.lastMessageView.setText("");
|
||||
holder.lastMessageSenderView.setText("");
|
||||
holder.date.setText(LinphoneUtils.timestampToHumanDate(mContext, chatRoom.getLastUpdateTime(), R.string.messages_list_date_format));
|
||||
|
||||
if (lastMessage != null) {
|
||||
if (lastMessage.getFileTransferInformation() != null || lastMessage.getExternalBodyUrl() != null || lastMessage.getAppdata() != null) {
|
||||
holder.lastMessageView.setBackgroundResource(R.drawable.chat_file_message);
|
||||
} else if (lastMessage.getTextContent() != null && lastMessage.getTextContent().length() > 0) {
|
||||
holder.lastMessageView.setBackgroundResource(0);
|
||||
holder.lastMessageView.setText(lastMessage.getTextContent());
|
||||
}
|
||||
|
||||
Address lastMessageSenderAddress = lastMessage.getFromAddress();
|
||||
LinphoneContact contact = ContactsManager.getInstance().findContactFromAddress(lastMessageSenderAddress);
|
||||
if (contact != null) {
|
||||
holder.lastMessageSenderView.setText(contact.getFullName() + mContext.getString(R.string.separator));
|
||||
} else {
|
||||
holder.lastMessageSenderView.setText(LinphoneUtils.getAddressDisplayName(lastMessageSenderAddress) + mContext.getString(R.string.separator));
|
||||
}
|
||||
}
|
||||
|
||||
holder.displayName.setSelected(true); // For animation
|
||||
holder.contactPicture.setImageBitmap(mDefaultBitmap);
|
||||
|
||||
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());
|
||||
holder.contactPicture.setImageBitmap(mDefaultGroupBitmap);
|
||||
}
|
||||
|
||||
if (unreadMessagesCount > 0) {
|
||||
holder.unreadMessages.setVisibility(View.VISIBLE);
|
||||
holder.unreadMessages.setText(String.valueOf(unreadMessagesCount));
|
||||
if (unreadMessagesCount > 99) {
|
||||
holder.unreadMessages.setTextSize(12);
|
||||
}
|
||||
holder.unreadMessages.setVisibility(View.VISIBLE);
|
||||
holder.displayName.setTypeface(null, Typeface.BOLD);
|
||||
} else {
|
||||
holder.unreadMessages.setVisibility(View.GONE);
|
||||
holder.displayName.setTypeface(null, Typeface.NORMAL);
|
||||
}
|
||||
|
||||
if (isEditionEnabled()) {
|
||||
view.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
ChatRoomViewHolder holder = (ChatRoomViewHolder)v.getTag();
|
||||
holder.delete.setChecked(!holder.delete.isChecked());
|
||||
}
|
||||
});
|
||||
holder.unreadMessages.setVisibility(View.GONE);
|
||||
holder.delete.setOnCheckedChangeListener(null);
|
||||
holder.delete.setVisibility(View.VISIBLE);
|
||||
holder.delete.setChecked(getSelectedItemsPosition().contains(position));
|
||||
holder.delete.setTag(position);
|
||||
holder.delete.setOnCheckedChangeListener(getDeleteListener());
|
||||
} else {
|
||||
view.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
ChatRoom chatRoom = mRooms.get(position);
|
||||
LinphoneActivity.instance().goToChat(chatRoom.getPeerAddress().asString());
|
||||
}
|
||||
});
|
||||
holder.delete.setVisibility(isEditionEnabled() ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
return view;
|
||||
}
|
||||
// @Override
|
||||
// public View getView(final int position, View convertView, ViewGroup viewGroup) {
|
||||
// View view;
|
||||
// ChatRoomViewHolder holder;
|
||||
//
|
||||
// if (convertView != null) {
|
||||
// view = convertView;
|
||||
// holder = (ChatRoomViewHolder) view.getTag();
|
||||
// } else {
|
||||
// view = mLayoutInflater.inflate(R.layout.chatlist_cell, viewGroup, false);
|
||||
// holder = new ChatRoomViewHolder(view);
|
||||
// view.setTag(holder);
|
||||
// }
|
||||
//
|
||||
// ChatRoom chatRoom = mRooms.get(position);
|
||||
// Address remoteAddress = chatRoom.getPeerAddress();
|
||||
// Address contactAddress = remoteAddress;
|
||||
//
|
||||
// if (chatRoom.hasCapability(ChatRoomCapabilities.OneToOne.toInt()) && chatRoom.getParticipants().length > 0) {
|
||||
// contactAddress = chatRoom.getParticipants()[0].getAddress();
|
||||
// }
|
||||
//
|
||||
// if (chatRoom.hasCapability(ChatRoomCapabilities.Conference.toInt()) && chatRoom.getState() == ChatRoom.State.Created) { // Only set for state Created otherwise it will conflict with removal listener
|
||||
// chatRoom.addListener(mListener);
|
||||
// chatRoom.setUserData(holder);
|
||||
// }
|
||||
//
|
||||
// int unreadMessagesCount = LinphoneManager.getInstance().getUnreadCountForChatRoom(chatRoom);
|
||||
// ChatMessage lastMessage = chatRoom.getLastMessageInHistory();
|
||||
// holder.lastMessageView.setText("");
|
||||
// holder.lastMessageSenderView.setText("");
|
||||
// holder.date.setText(LinphoneUtils.timestampToHumanDate(mContext, chatRoom.getLastUpdateTime(), R.string.messages_list_date_format));
|
||||
//
|
||||
// if (lastMessage != null) {
|
||||
// if (lastMessage.getFileTransferInformation() != null || lastMessage.getExternalBodyUrl() != null || lastMessage.getAppdata() != null) {
|
||||
// holder.lastMessageView.setBackgroundResource(R.drawable.chat_file_message);
|
||||
// } else if (lastMessage.getTextContent() != null && lastMessage.getTextContent().length() > 0) {
|
||||
// holder.lastMessageView.setBackgroundResource(0);
|
||||
// holder.lastMessageView.setText(lastMessage.getTextContent());
|
||||
// }
|
||||
//
|
||||
// Address lastMessageSenderAddress = lastMessage.getFromAddress();
|
||||
// LinphoneContact contact = ContactsManager.getInstance().findContactFromAddress(lastMessageSenderAddress);
|
||||
// if (contact != null) {
|
||||
// holder.lastMessageSenderView.setText(contact.getFullName() + mContext.getString(R.string.separator));
|
||||
// } else {
|
||||
// holder.lastMessageSenderView.setText(LinphoneUtils.getAddressDisplayName(lastMessageSenderAddress) + mContext.getString(R.string.separator));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// holder.displayName.setSelected(true); // For animation
|
||||
// holder.contactPicture.setImageBitmap(mDefaultBitmap);
|
||||
//
|
||||
// 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());
|
||||
// holder.contactPicture.setImageBitmap(mDefaultGroupBitmap);
|
||||
// }
|
||||
//
|
||||
// if (unreadMessagesCount > 0) {
|
||||
// holder.unreadMessages.setVisibility(View.VISIBLE);
|
||||
// holder.unreadMessages.setText(String.valueOf(unreadMessagesCount));
|
||||
// if (unreadMessagesCount > 99) {
|
||||
// holder.unreadMessages.setTextSize(12);
|
||||
// }
|
||||
// holder.unreadMessages.setVisibility(View.VISIBLE);
|
||||
// holder.displayName.setTypeface(null, Typeface.BOLD);
|
||||
// } else {
|
||||
// holder.unreadMessages.setVisibility(View.GONE);
|
||||
// holder.displayName.setTypeface(null, Typeface.NORMAL);
|
||||
// }
|
||||
//
|
||||
// if (isEditionEnabled()) {
|
||||
// view.setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View v) {
|
||||
// ChatRoomViewHolder holder = (ChatRoomViewHolder)v.getTag();
|
||||
// holder.delete.setChecked(!holder.delete.isChecked());
|
||||
// }
|
||||
// });
|
||||
// holder.unreadMessages.setVisibility(View.GONE);
|
||||
// holder.delete.setOnCheckedChangeListener(null);
|
||||
// holder.delete.setVisibility(View.VISIBLE);
|
||||
// holder.delete.setChecked(getSelectedItemsPosition().contains(position));
|
||||
// holder.delete.setTag(position);
|
||||
// holder.delete.setOnCheckedChangeListener(getDeleteListener());
|
||||
// } else {
|
||||
// view.setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View v) {
|
||||
// ChatRoom chatRoom = mRooms.get(position);
|
||||
// LinphoneActivity.instance().goToChat(chatRoom.getPeerAddress().asString());
|
||||
// }
|
||||
// });
|
||||
// holder.delete.setVisibility(isEditionEnabled() ? View.VISIBLE : View.GONE);
|
||||
// }
|
||||
// return view;
|
||||
// }
|
||||
}
|
||||
|
|
4
src/android/org/linphone/ui/SelectableAdapter.java
Normal file
4
src/android/org/linphone/ui/SelectableAdapter.java
Normal file
|
@ -0,0 +1,4 @@
|
|||
package org.linphone.ui;
|
||||
|
||||
public abstract class SelectableAdapter {
|
||||
}
|
Loading…
Reference in a new issue