Starter devices view
This commit is contained in:
parent
494d451d13
commit
8d7f49ea5c
6 changed files with 199 additions and 1 deletions
61
res/layout/chat_devices.xml
Normal file
61
res/layout/chat_devices.xml
Normal file
|
@ -0,0 +1,61 @@
|
|||
<?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="match_parent"
|
||||
android:background="@color/colorH" >
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/top"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/top_bar"
|
||||
android:orientation="horizontal"
|
||||
android:background="@color/colorF"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/back"
|
||||
android:src="@drawable/back"
|
||||
android:background="@drawable/toolbar_button"
|
||||
android:contentDescription="@string/content_description_back"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.2"
|
||||
android:padding="18dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:text="@string/group_chat_room_devices"
|
||||
style="@style/font6"
|
||||
android:gravity="center"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.6"
|
||||
android:padding="15dp"/>
|
||||
|
||||
<ImageView
|
||||
android:visibility="invisible"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.2"
|
||||
android:padding="15dp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center_horizontal"
|
||||
android:layout_below="@id/top">
|
||||
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
|
@ -221,6 +221,8 @@
|
|||
<string name="chat_room_delete_dialog">Do you really want to delete and leave the selected conversations?</string>
|
||||
<string name="separator">: </string>
|
||||
<string name="imdn_info">Delivery status</string>
|
||||
<string name="chat_room_devices">%s\'s devices</string>
|
||||
<string name="group_chat_room_devices">Conversation\'s devices</string>
|
||||
|
||||
<!-- Status Bar -->
|
||||
<string name="status_connected">Registered</string>
|
||||
|
|
|
@ -73,6 +73,7 @@ import org.linphone.call.CallIncomingActivity;
|
|||
import org.linphone.call.CallOutgoingActivity;
|
||||
import org.linphone.chat.ChatCreationFragment;
|
||||
import org.linphone.chat.ChatListFragment;
|
||||
import org.linphone.chat.DevicesFragment;
|
||||
import org.linphone.chat.GroupChatFragment;
|
||||
import org.linphone.chat.GroupInfoFragment;
|
||||
import org.linphone.chat.ImdnFragment;
|
||||
|
@ -429,6 +430,9 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
|
|||
case MESSAGE_IMDN:
|
||||
fragment = new ImdnFragment();
|
||||
break;
|
||||
case CONTACT_DEVICES:
|
||||
fragment = new DevicesFragment();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -752,6 +756,12 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
|
|||
changeCurrentFragment(FragmentsAvailable.INFO_GROUP_CHAT, extras);
|
||||
}
|
||||
|
||||
public void goToContactDevicesInfos(String sipUri) {
|
||||
Bundle extras = new Bundle();
|
||||
extras.putSerializable("SipUri", sipUri);
|
||||
changeCurrentFragment(FragmentsAvailable.CONTACT_DEVICES, extras);
|
||||
}
|
||||
|
||||
public void goToChatMessageImdnInfos(String sipUri, String messageId) {
|
||||
Bundle extras = new Bundle();
|
||||
extras.putSerializable("SipUri", sipUri);
|
||||
|
@ -880,6 +890,7 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
|
|||
case GROUP_CHAT:
|
||||
case INFO_GROUP_CHAT:
|
||||
case MESSAGE_IMDN:
|
||||
case CONTACT_DEVICES:
|
||||
case CHAT:
|
||||
chat_selected.setVisibility(View.VISIBLE);
|
||||
break;
|
||||
|
|
111
src/android/org/linphone/chat/DevicesFragment.java
Normal file
111
src/android/org/linphone/chat/DevicesFragment.java
Normal file
|
@ -0,0 +1,111 @@
|
|||
/*
|
||||
DevicesFragment.java
|
||||
Copyright (C) 2010-2018 Belledonne Communications, Grenoble, France
|
||||
|
||||
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 2
|
||||
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, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
package org.linphone.chat;
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.LinphoneUtils;
|
||||
import org.linphone.R;
|
||||
import org.linphone.activities.LinphoneActivity;
|
||||
import org.linphone.contacts.ContactsManager;
|
||||
import org.linphone.contacts.LinphoneContact;
|
||||
import org.linphone.core.Address;
|
||||
import org.linphone.core.ChatRoom;
|
||||
import org.linphone.core.ChatRoomCapabilities;
|
||||
import org.linphone.core.Core;
|
||||
|
||||
public class DevicesFragment extends Fragment {
|
||||
private LayoutInflater mInflater;
|
||||
private ImageView mBackButton;
|
||||
private TextView mTitle;
|
||||
|
||||
private String mRoomUri;
|
||||
private Address mRoomAddr;
|
||||
private ChatRoom mRoom;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
if (getArguments() != null) {
|
||||
mRoomUri = getArguments().getString("SipUri");
|
||||
mRoomAddr = LinphoneManager.getLc().createAddress(mRoomUri);
|
||||
}
|
||||
|
||||
mInflater = inflater;
|
||||
View view = mInflater.inflate(R.layout.chat_devices, container, false);
|
||||
|
||||
initChatRoom();
|
||||
|
||||
mTitle = view.findViewById(R.id.title);
|
||||
initHeader();
|
||||
|
||||
mBackButton = view.findViewById(R.id.back);
|
||||
mBackButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (LinphoneActivity.instance().isTablet()) {
|
||||
LinphoneActivity.instance().goToChat(mRoomUri, null);
|
||||
} else {
|
||||
LinphoneActivity.instance().onBackPressed();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
private void initChatRoom() {
|
||||
Core core = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||
Address proxyConfigContact = core.getDefaultProxyConfig().getContact();
|
||||
if (proxyConfigContact != null) {
|
||||
mRoom = core.findOneToOneChatRoom(proxyConfigContact, mRoomAddr);
|
||||
}
|
||||
if (mRoom == null) {
|
||||
mRoom = core.getChatRoomFromUri(mRoomAddr.asStringUriOnly());
|
||||
}
|
||||
}
|
||||
|
||||
private void initHeader() {
|
||||
if (mRoom.hasCapability(ChatRoomCapabilities.OneToOne.toInt())) {
|
||||
Address remoteParticipantAddr = mRoomAddr;
|
||||
if (mRoom.getParticipants().length > 0) {
|
||||
remoteParticipantAddr = mRoom.getParticipants()[0].getAddress();
|
||||
}
|
||||
LinphoneContact c = ContactsManager.getInstance().findContactFromAddress(remoteParticipantAddr);
|
||||
String displayName;
|
||||
if (c != null) {
|
||||
displayName = c.getFullName();
|
||||
} else {
|
||||
displayName = LinphoneUtils.getAddressDisplayName(remoteParticipantAddr);
|
||||
}
|
||||
mTitle.setText(getString(R.string.chat_room_devices).replace("%s", displayName));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -112,6 +112,7 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
|
|||
private int mContextMenuMessagePosition;
|
||||
private ChatScrollListener mChatScrollListener;
|
||||
private LinearLayout mTopBar;
|
||||
private ImageView mChatRoomSecurityLevel;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
|
@ -130,6 +131,14 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
|
|||
|
||||
mTopBar = view.findViewById(R.id.top_bar);
|
||||
|
||||
mChatRoomSecurityLevel = view.findViewById(R.id.room_security_level);
|
||||
mChatRoomSecurityLevel.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
LinphoneActivity.instance().goToContactDevicesInfos(getRemoteSipUri());
|
||||
}
|
||||
});
|
||||
|
||||
mBackButton = view.findViewById(R.id.back);
|
||||
mBackButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
|
|
@ -36,7 +36,8 @@ public enum FragmentsAvailable {
|
|||
CREATE_CHAT,
|
||||
INFO_GROUP_CHAT,
|
||||
GROUP_CHAT,
|
||||
MESSAGE_IMDN;
|
||||
MESSAGE_IMDN,
|
||||
CONTACT_DEVICES;
|
||||
|
||||
public boolean shouldAddItselfToTheRightOf(FragmentsAvailable fragment) {
|
||||
switch (this) {
|
||||
|
@ -58,6 +59,9 @@ public enum FragmentsAvailable {
|
|||
case MESSAGE_IMDN:
|
||||
return fragment == GROUP_CHAT || fragment == MESSAGE_IMDN;
|
||||
|
||||
case CONTACT_DEVICES:
|
||||
return fragment == GROUP_CHAT || fragment == CONTACT_DEVICES;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue