Fix file sharing from SEND intent
This commit is contained in:
parent
c0058e4a5d
commit
b2b3365202
9 changed files with 106 additions and 36 deletions
|
@ -685,6 +685,7 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
|
|||
private void displayChat(String sipUri, String message, String fileUri, String pictureUri, String thumbnailUri, String displayName, Address lAddress) {
|
||||
Bundle extras = new Bundle();
|
||||
extras.putString("SipUri", sipUri);
|
||||
|
||||
if (message != null)
|
||||
extras.putString("messageDraft", message);
|
||||
if (fileUri != null)
|
||||
|
@ -694,14 +695,11 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
|
|||
extras.putString("PictureUri", pictureUri);
|
||||
extras.putString("ThumbnailUri", thumbnailUri);
|
||||
}
|
||||
if (sipUri == null && message == null && fileUri == null) {
|
||||
changeCurrentFragment(FragmentsAvailable.CREATE_CHAT, extras);
|
||||
} else {
|
||||
changeCurrentFragment(FragmentsAvailable.GROUP_CHAT, extras);
|
||||
}
|
||||
|
||||
changeCurrentFragment(FragmentsAvailable.CREATE_CHAT, extras);
|
||||
}
|
||||
|
||||
public void goToChatCreator(String address, ArrayList<ContactAddress> selectedContacts, String subject, boolean isGoBack) {
|
||||
public void goToChatCreator(String address, ArrayList<ContactAddress> selectedContacts, String subject, boolean isGoBack, Bundle shareInfos) {
|
||||
if (currentFragment == FragmentsAvailable.INFO_GROUP_CHAT && isGoBack) {
|
||||
getFragmentManager().popBackStackImmediate();
|
||||
getFragmentManager().popBackStackImmediate();
|
||||
|
@ -710,23 +708,37 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
|
|||
extras.putSerializable("selectedContacts", selectedContacts);
|
||||
extras.putString("subject", subject);
|
||||
extras.putString("groupChatRoomAddress", address);
|
||||
|
||||
if (shareInfos != null) {
|
||||
if (shareInfos.getString("fileSharedUri") != null)
|
||||
extras.putString("fileSharedUri", shareInfos.getString("fileSharedUri"));
|
||||
if (shareInfos.getString("messageDraft") != null)
|
||||
extras.putString("messageDraft", shareInfos.getString("messageDraft"));
|
||||
}
|
||||
|
||||
changeCurrentFragment(FragmentsAvailable.CREATE_CHAT, extras);
|
||||
}
|
||||
|
||||
public void goToChat(String sipUri) {
|
||||
public void goToChat(String sipUri, Bundle shareInfos) {
|
||||
Bundle extras = new Bundle();
|
||||
extras.putString("SipUri", sipUri);
|
||||
|
||||
if (shareInfos != null) {
|
||||
if (shareInfos.getString("fileSharedUri") != null)
|
||||
extras.putString("fileSharedUri", shareInfos.getString("fileSharedUri"));
|
||||
if (shareInfos.getString("messageDraft") != null)
|
||||
extras.putString("messageDraft", shareInfos.getString("messageDraft"));
|
||||
}
|
||||
|
||||
if (isTablet()) {
|
||||
Fragment fragment2 = getFragmentManager().findFragmentById(R.id.fragmentContainer2);
|
||||
if (fragment2 != null && fragment2.isVisible() && currentFragment == FragmentsAvailable.GROUP_CHAT && !emptyFragment) {
|
||||
GroupChatFragment chatFragment = (GroupChatFragment) fragment2;
|
||||
chatFragment.changeDisplayedChat(sipUri);
|
||||
} else {
|
||||
Bundle extras = new Bundle();
|
||||
extras.putString("SipUri", sipUri);
|
||||
changeCurrentFragment(FragmentsAvailable.GROUP_CHAT, extras);
|
||||
}
|
||||
} else {
|
||||
Bundle extras = new Bundle();
|
||||
extras.putString("SipUri", sipUri);
|
||||
changeCurrentFragment(FragmentsAvailable.GROUP_CHAT, extras);
|
||||
}
|
||||
|
||||
|
@ -734,7 +746,7 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
|
|||
displayMissedChats(LinphoneManager.getInstance().getUnreadMessageCount());
|
||||
}
|
||||
|
||||
public void goToChatGroupInfos(String address, ArrayList<ContactAddress> contacts, String subject, boolean isEditionEnabled, boolean isGoBack) {
|
||||
public void goToChatGroupInfos(String address, ArrayList<ContactAddress> contacts, String subject, boolean isEditionEnabled, boolean isGoBack, Bundle shareInfos) {
|
||||
if (currentFragment == FragmentsAvailable.CREATE_CHAT && isGoBack) {
|
||||
getFragmentManager().popBackStackImmediate();
|
||||
getFragmentManager().popBackStackImmediate();
|
||||
|
@ -744,6 +756,14 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
|
|||
extras.putBoolean("isEditionEnabled", isEditionEnabled);
|
||||
extras.putSerializable("ContactAddress", contacts);
|
||||
extras.putString("subject", subject);
|
||||
|
||||
if (shareInfos != null) {
|
||||
if (shareInfos.getString("fileSharedUri") != null)
|
||||
extras.putString("fileSharedUri", shareInfos.getString("fileSharedUri"));
|
||||
if (shareInfos.getString("messageDraft") != null)
|
||||
extras.putString("messageDraft", shareInfos.getString("messageDraft"));
|
||||
}
|
||||
|
||||
changeCurrentFragment(FragmentsAvailable.INFO_GROUP_CHAT, extras);
|
||||
}
|
||||
|
||||
|
|
|
@ -76,6 +76,7 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
|
|||
private String mChatRoomSubject, mChatRoomAddress;
|
||||
private ChatRoom mChatRoom;
|
||||
private ChatRoomListenerStub mChatRoomCreationListener;
|
||||
private Bundle mShareInfos;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
|
@ -177,7 +178,7 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
|
|||
public void onStateChanged(ChatRoom cr, ChatRoom.State newState) {
|
||||
if (newState == ChatRoom.State.Created) {
|
||||
mWaitLayout.setVisibility(View.GONE);
|
||||
LinphoneActivity.instance().goToChat(cr.getPeerAddress().asStringUriOnly());
|
||||
LinphoneActivity.instance().goToChat(cr.getPeerAddress().asStringUriOnly(), mShareInfos);
|
||||
} else if (newState == ChatRoom.State.CreationFailed) {
|
||||
mWaitLayout.setVisibility(View.GONE);
|
||||
LinphoneActivity.instance().displayChatRoomError();
|
||||
|
@ -186,6 +187,23 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
|
|||
}
|
||||
};
|
||||
|
||||
if (getArguments() != null) {
|
||||
String fileSharedUri = getArguments().getString("fileSharedUri");
|
||||
String messageDraft = getArguments().getString("messageDraft");
|
||||
|
||||
if (fileSharedUri != null || messageDraft != null)
|
||||
mShareInfos = new Bundle();
|
||||
|
||||
if (fileSharedUri != null) {
|
||||
LinphoneActivity.instance().checkAndRequestPermissionsToSendImage();
|
||||
mShareInfos.putString("fileSharedUri", fileSharedUri);
|
||||
}
|
||||
|
||||
if (messageDraft != null)
|
||||
mShareInfos.putString("messageDraft", messageDraft);
|
||||
}
|
||||
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
|
@ -367,17 +385,17 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
|
|||
mChatRoom.addParticipant(participant);
|
||||
} else {
|
||||
chatRoom = lc.getChatRoom(participant);
|
||||
LinphoneActivity.instance().goToChat(chatRoom.getPeerAddress().asStringUriOnly());
|
||||
LinphoneActivity.instance().goToChat(chatRoom.getPeerAddress().asStringUriOnly(), mShareInfos);
|
||||
}
|
||||
} else {
|
||||
LinphoneActivity.instance().goToChat(chatRoom.getPeerAddress().asStringUriOnly());
|
||||
LinphoneActivity.instance().goToChat(chatRoom.getPeerAddress().asStringUriOnly(), mShareInfos);
|
||||
}
|
||||
} else {
|
||||
mContactsSelectedLayout.removeAllViews();
|
||||
LinphoneActivity.instance().goToChatGroupInfos(null, mContactsSelected, null, true, false);
|
||||
LinphoneActivity.instance().goToChatGroupInfos(null, mContactsSelected, null, true, false, mShareInfos);
|
||||
}
|
||||
} else {
|
||||
LinphoneActivity.instance().goToChatGroupInfos(mChatRoomAddress, mContactsSelected, mChatRoomSubject, true, true);
|
||||
LinphoneActivity.instance().goToChatGroupInfos(mChatRoomAddress, mContactsSelected, mChatRoomSubject, true, true, mShareInfos);
|
||||
}
|
||||
} else if (id == R.id.clearSearchField) {
|
||||
mSearchField.setText("");
|
||||
|
@ -395,7 +413,7 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
|
|||
ProxyConfig lpc = lc.getDefaultProxyConfig();
|
||||
if (lpc == null || lpc.getConferenceFactoryUri() == null) {
|
||||
ChatRoom chatRoom = lc.getChatRoom(ca.getAddress());
|
||||
LinphoneActivity.instance().goToChat(chatRoom.getPeerAddress().asStringUriOnly());
|
||||
LinphoneActivity.instance().goToChat(chatRoom.getPeerAddress().asStringUriOnly(), mShareInfos);
|
||||
} else {
|
||||
removeContactFromSelection(ca);
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ public class ChatListFragment extends Fragment implements ContactsUpdatedListene
|
|||
mNewDiscussionButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
LinphoneActivity.instance().goToChatCreator(null, null, null, false);
|
||||
LinphoneActivity.instance().goToChatCreator(null, null, null, false, null);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -142,7 +142,7 @@ public class ChatListFragment extends Fragment implements ContactsUpdatedListene
|
|||
ChatRoomsAdapter adapter = (ChatRoomsAdapter)mChatRoomsList.getAdapter();
|
||||
if (adapter != null && adapter.getCount() > 0) {
|
||||
ChatRoom room = (ChatRoom) adapter.getItem(0);
|
||||
LinphoneActivity.instance().goToChat(room.getPeerAddress().asStringUriOnly());
|
||||
LinphoneActivity.instance().goToChat(room.getPeerAddress().asStringUriOnly(), null);
|
||||
} else {
|
||||
LinphoneActivity.instance().displayEmptyFragment();
|
||||
}
|
||||
|
|
|
@ -244,7 +244,7 @@ public class ChatRoomsAdapter extends ListSelectionAdapter {
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
ChatRoom chatRoom = mRooms.get(position);
|
||||
LinphoneActivity.instance().goToChat(chatRoom.getPeerAddress().asString());
|
||||
LinphoneActivity.instance().goToChat(chatRoom.getPeerAddress().asString(), null);
|
||||
}
|
||||
});
|
||||
holder.delete.setVisibility(isEditionEnabled() ? View.VISIBLE : View.GONE);
|
||||
|
|
|
@ -162,7 +162,7 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
|
|||
ContactAddress ca = new ContactAddress(c, a.asString(), "", c.isFriend(), p.isAdmin());
|
||||
participants.add(ca);
|
||||
}
|
||||
LinphoneActivity.instance().goToChatGroupInfos(mRemoteSipAddress.asString(), participants, mChatRoom.getSubject(), mChatRoom.getMe() != null ? mChatRoom.getMe().isAdmin() : false, false);
|
||||
LinphoneActivity.instance().goToChatGroupInfos(mRemoteSipAddress.asString(), participants, mChatRoom.getSubject(), mChatRoom.getMe() != null ? mChatRoom.getMe().isAdmin() : false, false, null);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -215,6 +215,25 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
|
|||
mChatEventsList = view.findViewById(R.id.chat_message_list);
|
||||
registerForContextMenu(mChatEventsList);
|
||||
|
||||
if (getArguments() != null) {
|
||||
String fileSharedUri = getArguments().getString("fileSharedUri");
|
||||
if (fileSharedUri != null) {
|
||||
if (LinphoneUtils.isExtensionImage(fileSharedUri)) {
|
||||
addImageToPendingList(fileSharedUri);
|
||||
} else {
|
||||
if (fileSharedUri.startsWith("content://") || fileSharedUri.startsWith("file://")) {
|
||||
fileSharedUri = LinphoneUtils.getFilePath(this.getActivity().getApplicationContext(), Uri.parse(fileSharedUri));
|
||||
} else if (fileSharedUri.contains("com.android.contacts/contacts/")) {
|
||||
fileSharedUri = LinphoneUtils.getCVSPathFromLookupUri(fileSharedUri).toString();
|
||||
}
|
||||
addFileToPendingList(fileSharedUri);
|
||||
}
|
||||
}
|
||||
|
||||
if (getArguments().getString("messageDraft") != null)
|
||||
mMessageTextToSend.setText(getArguments().getString("messageDraft"));
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
|
|
|
@ -72,6 +72,7 @@ public class GroupInfoFragment extends Fragment implements ChatRoomListener {
|
|||
private ChatRoom mChatRoom, mTempChatRoom;
|
||||
private Dialog mAdminStateChangedDialog;
|
||||
private ChatRoomListenerStub mChatRoomCreationListener;
|
||||
private Bundle mShareInfos;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
|
@ -118,18 +119,30 @@ public class GroupInfoFragment extends Fragment implements ChatRoomListener {
|
|||
mParticipantsList.setAdapter(mAdapter);
|
||||
mAdapter.setChatRoom(mChatRoom);
|
||||
|
||||
String fileSharedUri = getArguments().getString("fileSharedUri");
|
||||
String messageDraft = getArguments().getString("messageDraft");
|
||||
|
||||
if (fileSharedUri != null || messageDraft != null)
|
||||
mShareInfos = new Bundle();
|
||||
|
||||
if (fileSharedUri != null)
|
||||
mShareInfos.putString("fileSharedUri", fileSharedUri);
|
||||
|
||||
if (messageDraft != null)
|
||||
mShareInfos.putString("messageDraft", messageDraft);
|
||||
|
||||
mBackButton = view.findViewById(R.id.back);
|
||||
mBackButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (mIsAlreadyCreatedGroup) {
|
||||
if (LinphoneActivity.instance().isTablet()) {
|
||||
LinphoneActivity.instance().goToChat(mGroupChatRoomAddress.asStringUriOnly());
|
||||
LinphoneActivity.instance().goToChat(mGroupChatRoomAddress.asStringUriOnly(), mShareInfos);
|
||||
} else {
|
||||
getFragmentManager().popBackStack();
|
||||
}
|
||||
} else {
|
||||
LinphoneActivity.instance().goToChatCreator(null, mParticipants, null, true);
|
||||
LinphoneActivity.instance().goToChatCreator(null, mParticipants, null, true, mShareInfos);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -150,7 +163,7 @@ public class GroupInfoFragment extends Fragment implements ChatRoomListener {
|
|||
public void onClick(View view) {
|
||||
if (mChatRoom != null) {
|
||||
mChatRoom.leave();
|
||||
LinphoneActivity.instance().goToChat(mGroupChatRoomAddress.asString());
|
||||
LinphoneActivity.instance().goToChat(mGroupChatRoomAddress.asString(), null);
|
||||
} else {
|
||||
Log.e("Can't leave, chatRoom for address " + mGroupChatRoomAddress.asString() + " is null...");
|
||||
}
|
||||
|
@ -174,7 +187,7 @@ public class GroupInfoFragment extends Fragment implements ChatRoomListener {
|
|||
@Override
|
||||
public void onClick(View view) {
|
||||
if (mIsEditionEnabled) {
|
||||
LinphoneActivity.instance().goToChatCreator(mGroupChatRoomAddress != null ? mGroupChatRoomAddress.asString() : null, mParticipants, mSubject, !mIsAlreadyCreatedGroup);
|
||||
LinphoneActivity.instance().goToChatCreator(mGroupChatRoomAddress != null ? mGroupChatRoomAddress.asString() : null, mParticipants, mSubject, !mIsAlreadyCreatedGroup, null);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -182,7 +195,7 @@ public class GroupInfoFragment extends Fragment implements ChatRoomListener {
|
|||
mAddParticipantsButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
LinphoneActivity.instance().goToChatCreator(mGroupChatRoomAddress != null ? mGroupChatRoomAddress.asString() : null, mParticipants, mSubject, !mIsAlreadyCreatedGroup);
|
||||
LinphoneActivity.instance().goToChatCreator(mGroupChatRoomAddress != null ? mGroupChatRoomAddress.asString() : null, mParticipants, mSubject, !mIsAlreadyCreatedGroup, null);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -213,7 +226,7 @@ public class GroupInfoFragment extends Fragment implements ChatRoomListener {
|
|||
// This will remove both the creation fragment and the group info fragment from the back stack
|
||||
getFragmentManager().popBackStack();
|
||||
getFragmentManager().popBackStack();
|
||||
LinphoneActivity.instance().goToChat(cr.getPeerAddress().asStringUriOnly());
|
||||
LinphoneActivity.instance().goToChat(cr.getPeerAddress().asStringUriOnly(), mShareInfos);
|
||||
} else if (newState == ChatRoom.State.CreationFailed) {
|
||||
mWaitLayout.setVisibility(View.GONE);
|
||||
LinphoneActivity.instance().displayChatRoomError();
|
||||
|
@ -289,7 +302,7 @@ public class GroupInfoFragment extends Fragment implements ChatRoomListener {
|
|||
toAdd.toArray(participantsToAdd);
|
||||
mChatRoom.addParticipants(participantsToAdd);
|
||||
|
||||
LinphoneActivity.instance().goToChat(mGroupChatRoomAddress.asString());
|
||||
LinphoneActivity.instance().goToChat(mGroupChatRoomAddress.asString(), null);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -88,7 +88,7 @@ public class ImdnFragment extends Fragment {
|
|||
@Override
|
||||
public void onClick(View view) {
|
||||
if (LinphoneActivity.instance().isTablet()) {
|
||||
LinphoneActivity.instance().goToChat(mRoomUri);
|
||||
LinphoneActivity.instance().goToChat(mRoomUri, null);
|
||||
} else {
|
||||
LinphoneActivity.instance().onBackPressed();
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ public class ContactDetailsFragment extends Fragment implements OnClickListener
|
|||
Address participant = Factory.instance().createAddress(tag);
|
||||
ChatRoom room = lc.findOneToOneChatRoom(lc.getDefaultProxyConfig().getContact(), participant);
|
||||
if (room != null) {
|
||||
LinphoneActivity.instance().goToChat(room.getPeerAddress().asStringUriOnly());
|
||||
LinphoneActivity.instance().goToChat(room.getPeerAddress().asStringUriOnly(), null);
|
||||
} else {
|
||||
ProxyConfig lpc = lc.getDefaultProxyConfig();
|
||||
if (lpc != null && lpc.getConferenceFactoryUri() != null && !LinphonePreferences.instance().useBasicChatRoomFor1To1()) {
|
||||
|
@ -87,7 +87,7 @@ public class ContactDetailsFragment extends Fragment implements OnClickListener
|
|||
mChatRoom.addParticipant(participant);
|
||||
} else {
|
||||
room = lc.getChatRoom(participant);
|
||||
LinphoneActivity.instance().goToChat(room.getPeerAddress().asStringUriOnly());
|
||||
LinphoneActivity.instance().goToChat(room.getPeerAddress().asStringUriOnly(), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ public class ContactDetailsFragment extends Fragment implements OnClickListener
|
|||
public void onStateChanged(ChatRoom cr, ChatRoom.State newState) {
|
||||
if (newState == ChatRoom.State.Created) {
|
||||
mWaitLayout.setVisibility(View.GONE);
|
||||
LinphoneActivity.instance().goToChat(cr.getPeerAddress().asStringUriOnly());
|
||||
LinphoneActivity.instance().goToChat(cr.getPeerAddress().asStringUriOnly(), null);
|
||||
} else if (newState == ChatRoom.State.CreationFailed) {
|
||||
mWaitLayout.setVisibility(View.GONE);
|
||||
LinphoneActivity.instance().displayChatRoomError();
|
||||
|
|
|
@ -109,7 +109,7 @@ public class HistoryDetailFragment extends Fragment implements OnClickListener {
|
|||
public void onStateChanged(ChatRoom cr, ChatRoom.State newState) {
|
||||
if (newState == ChatRoom.State.Created) {
|
||||
mWaitLayout.setVisibility(View.GONE);
|
||||
LinphoneActivity.instance().goToChat(cr.getPeerAddress().asStringUriOnly());
|
||||
LinphoneActivity.instance().goToChat(cr.getPeerAddress().asStringUriOnly(), null);
|
||||
} else if (newState == ChatRoom.State.CreationFailed) {
|
||||
mWaitLayout.setVisibility(View.GONE);
|
||||
LinphoneActivity.instance().displayChatRoomError();
|
||||
|
@ -199,7 +199,7 @@ public class HistoryDetailFragment extends Fragment implements OnClickListener {
|
|||
Address participant = Factory.instance().createAddress(sipUri);
|
||||
ChatRoom room = lc.findOneToOneChatRoom(lc.getDefaultProxyConfig().getContact(), participant);
|
||||
if (room != null) {
|
||||
LinphoneActivity.instance().goToChat(room.getPeerAddress().asStringUriOnly());
|
||||
LinphoneActivity.instance().goToChat(room.getPeerAddress().asStringUriOnly(), null);
|
||||
} else {
|
||||
ProxyConfig lpc = lc.getDefaultProxyConfig();
|
||||
if (lpc != null && lpc.getConferenceFactoryUri() != null && !LinphonePreferences.instance().useBasicChatRoomFor1To1()) {
|
||||
|
@ -209,7 +209,7 @@ public class HistoryDetailFragment extends Fragment implements OnClickListener {
|
|||
mChatRoom.addParticipant(participant);
|
||||
} else {
|
||||
room = lc.getChatRoom(participant);
|
||||
LinphoneActivity.instance().goToChat(room.getPeerAddress().asStringUriOnly());
|
||||
LinphoneActivity.instance().goToChat(room.getPeerAddress().asStringUriOnly(), null);
|
||||
}
|
||||
}
|
||||
} else if (id == R.id.add_contact) {
|
||||
|
|
Loading…
Reference in a new issue