[FileSharing] FS in progress - share images
This commit is contained in:
parent
986801e6c1
commit
160e00b99c
9 changed files with 205 additions and 111 deletions
|
@ -108,6 +108,13 @@
|
|||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<data android:mimeType="text/plain" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.SEND" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.OPENABLE"/>
|
||||
<data android:mimeType="text/plain"/>
|
||||
<data android:mimeType="image/*"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".LinphoneActivity"
|
||||
|
|
|
@ -101,7 +101,7 @@ import java.util.Locale;
|
|||
import static android.content.Intent.FLAG_GRANT_READ_URI_PERMISSION;
|
||||
|
||||
|
||||
public class ChatFragment extends Fragment implements OnClickListener, LinphoneChatMessage.LinphoneChatMessageListener {
|
||||
public class ChatFragment extends Fragment implements OnClickListener, LinphoneChatMessage.LinphoneChatMessageListener, ContactsUpdatedListener{
|
||||
private static final int ADD_PHOTO = 1337;
|
||||
private static final int MENU_DELETE_MESSAGE = 0;
|
||||
private static final int MENU_PICTURE_SMALL = 2;
|
||||
|
@ -138,6 +138,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
|
||||
private LinphoneCoreListenerBase mListener;
|
||||
private boolean newChatConversation = false;
|
||||
private String fileSharedUri, fileAlreadySharedUri;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
|
@ -155,6 +156,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
} else {
|
||||
//Retrieve parameter from intent
|
||||
sipUri = getArguments().getString("SipUri");
|
||||
newChatConversation = false;
|
||||
}
|
||||
|
||||
//Initialize UI
|
||||
|
@ -195,7 +197,12 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
delete = (ImageView) view.findViewById(R.id.delete);
|
||||
delete.setOnClickListener(this);
|
||||
|
||||
if (getArguments().getString("fileSharedUri") != null && getArguments().getString("fileSharedUri") != "")
|
||||
fileSharedUri = getArguments().getString("fileSharedUri");
|
||||
else
|
||||
fileSharedUri = null;
|
||||
if (newChatConversation) {
|
||||
Log.e(" ===>>> ChatFragment : onCreateView - newChatConversation = "+newChatConversation+" - fileSharedUri = "+fileSharedUri);
|
||||
initNewChatConversation();
|
||||
}
|
||||
|
||||
|
@ -283,7 +290,16 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
if (contact != null) {
|
||||
outState.putSerializable("contactDraft",contact);
|
||||
outState.putString("sipUriDraft",sipUri);
|
||||
|
||||
}
|
||||
if (sipUri != null) {
|
||||
Log.e("====>>>> ChatFragment - onSaveInstanceState : sipUri = "+sipUri);
|
||||
outState.putString("sipUriDraft", sipUri);
|
||||
outState.putString("SipUri", sipUri);
|
||||
|
||||
}
|
||||
outState.putString("fileSharedUri", "");
|
||||
|
||||
super.onSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
|
@ -350,7 +366,6 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
|
||||
public void initChatRoom(String sipUri) {
|
||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||
|
||||
LinphoneAddress lAddress = null;
|
||||
if (sipUri == null) {
|
||||
contact = null; // Tablet rotation issue
|
||||
|
@ -410,9 +425,12 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
}
|
||||
}
|
||||
|
||||
public void changeDisplayedChat(String newSipUri, String displayName, String pictureUri, String message) {
|
||||
public void changeDisplayedChat(String newSipUri, String displayName, String pictureUri, String message, String fileUri) {
|
||||
this.sipUri = newSipUri;
|
||||
this.message.setText(message);
|
||||
if(message != null)
|
||||
this.message.setText(message);
|
||||
if(fileUri != null)
|
||||
fileSharedUri = fileUri;
|
||||
initChatRoom(sipUri);
|
||||
}
|
||||
|
||||
|
@ -446,7 +464,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
chatRoom.deleteMessage(message);
|
||||
if (getResources().getBoolean(R.bool.isTablet) && chatRoom.getHistorySize() <= 0) {
|
||||
if (LinphoneActivity.isInstanciated()) {
|
||||
LinphoneActivity.instance().displayChat("", null);
|
||||
LinphoneActivity.instance().displayChat("", null, null);
|
||||
LinphoneActivity.instance().onMessageSent("", null);
|
||||
initNewChatConversation();
|
||||
}
|
||||
|
@ -516,7 +534,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
ContactsManager.addContactsListener(this);
|
||||
message.addTextChangedListener(textWatcher);
|
||||
addVirtualKeyboardVisiblityListener();
|
||||
|
||||
|
@ -537,11 +555,26 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
String draft = getArguments().getString("messageDraft");
|
||||
message.setText(draft);
|
||||
contact = (LinphoneContact)getArguments().getSerializable("contactDraft");
|
||||
|
||||
Log.e("===>>>> ChatFragment - onResume : sipUriDraft = "+getArguments().getString("sipUriDraft")+" - sipUri = "+getArguments().getString("sipUri")+" - VS sipUri = "+sipUri);
|
||||
|
||||
if (contact != null) {
|
||||
Log.e("===>>> onResume - loop 1");
|
||||
contactName.setText(contact.getFullName());
|
||||
sipUri = getArguments().getString("sipUriDraft");
|
||||
sipUri = getArguments().getString("SipUri");
|
||||
newChatConversation = false;
|
||||
getArguments().clear();
|
||||
}else if(getArguments().getString("sipUriDraft") != null){
|
||||
Log.e("===>>> onResume - loop 2");
|
||||
sipUri = getArguments().getString("sipUriDraft");
|
||||
newChatConversation = false;
|
||||
}else if (sipUri != null) {
|
||||
Log.e("===>>> onResume - loop 3");
|
||||
newChatConversation = false;
|
||||
}else {
|
||||
Log.e("===>>> onResume - loop 4");
|
||||
sipUri = null;
|
||||
newChatConversation = true;
|
||||
}
|
||||
|
||||
if(LinphoneManager.getLc().isIncall()){
|
||||
|
@ -586,7 +619,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
}
|
||||
if (getResources().getBoolean(R.bool.isTablet) && chatRoom.getHistorySize() <= 0) {
|
||||
if (LinphoneActivity.isInstanciated()) {
|
||||
LinphoneActivity.instance().displayChat("", null);
|
||||
LinphoneActivity.instance().displayChat("", null, null);
|
||||
LinphoneActivity.instance().onMessageSent("", null);
|
||||
initNewChatConversation();
|
||||
}
|
||||
|
@ -714,9 +747,10 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
}
|
||||
|
||||
private void sendImageMessage(String path, int imageSize) {
|
||||
Log.e("====>>> ChatFragment - sendImageMessage() : path = "+path+" - imageSize = "+imageSize);
|
||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||
boolean isNetworkReachable = lc == null ? false : lc.isNetworkReachable();
|
||||
|
||||
Log.e("====>>> ChatFragment - sendImageMessage() : newChatConversation = "+ newChatConversation +" - chatRoom = "+chatRoom);
|
||||
if(newChatConversation && chatRoom == null) {
|
||||
String address = searchContactField.getText().toString();
|
||||
if (address != null && !address.equals("")) {
|
||||
|
@ -725,6 +759,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
}
|
||||
|
||||
if (chatRoom != null && path != null && path.length() > 0 && isNetworkReachable) {
|
||||
Log.e("====>>> ChatFragment - sendImageMessage() : Do something loop 2 ");
|
||||
try {
|
||||
Bitmap bm = BitmapFactory.decodeFile(path);
|
||||
if (bm != null) {
|
||||
|
@ -736,6 +771,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
} catch (RuntimeException e) {
|
||||
Log.e("Error, not enough memory to create the bitmap");
|
||||
}
|
||||
fileSharedUri = null;
|
||||
} else if (!isNetworkReachable && LinphoneActivity.isInstanciated()) {
|
||||
LinphoneActivity.instance().displayCustomToast(getString(R.string.error_network_unreachable), Toast.LENGTH_LONG);
|
||||
}
|
||||
|
@ -833,6 +869,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
|
||||
//File transfer
|
||||
private void pickImage() {
|
||||
//TODO : update to use with any file types
|
||||
List<Intent> cameraIntents = new ArrayList<Intent>();
|
||||
Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||
File file = new File(Environment.getExternalStorageDirectory(), getString(R.string.temp_photo_name_with_date).replace("%s", String.valueOf(System.currentTimeMillis())));
|
||||
|
@ -841,7 +878,8 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
cameraIntents.add(captureIntent);
|
||||
|
||||
Intent galleryIntent = new Intent();
|
||||
galleryIntent.setType("image/*");
|
||||
//galleryIntent.setType("image/*");
|
||||
galleryIntent.setType("*/*");
|
||||
galleryIntent.setAction(Intent.ACTION_PICK);
|
||||
|
||||
Intent chooserIntent = Intent.createChooser(galleryIntent, getString(R.string.image_picker_title));
|
||||
|
@ -863,6 +901,13 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContactsUpdated() {
|
||||
if(fileSharedUri != null){
|
||||
initNewChatConversation();
|
||||
}
|
||||
}
|
||||
|
||||
class FileUploadPrepareTask extends AsyncTask<Bitmap, Void, byte[]> {
|
||||
private String path;
|
||||
private ProgressDialog progressDialog;
|
||||
|
@ -974,11 +1019,9 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
fileToUploadPath = imageToUploadUri.getPath();
|
||||
}
|
||||
|
||||
if (fileToUploadPath != null) {
|
||||
//showPopupMenuAskingImageSize(fileToUploadPath);
|
||||
sendImageMessage(fileToUploadPath,0);
|
||||
}
|
||||
Log.e(" ====>>>> onActivityResult - requestCode = "+requestCode+" - resultCode = "+resultCode+" - data = "+data.toString()+" - fileToUploadPath = "+fileToUploadPath);
|
||||
} else {
|
||||
Log.e(" ====>>>> onActivityResult - requestCode = "+requestCode+" - resultCode = "+resultCode+" - data = "+data.toString());
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
}
|
||||
|
@ -1001,6 +1044,15 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
|
||||
newChatConversation = false;
|
||||
initChatRoom(sipUri);
|
||||
|
||||
//TODO :
|
||||
if(fileSharedUri != null){
|
||||
Log.e(" ===>>> exitNewConversationMode - sendImage from Uri");
|
||||
//save SipUri into bundle
|
||||
onSaveInstanceState(getArguments());
|
||||
sendImageMessage(fileSharedUri,0);
|
||||
fileSharedUri = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void initNewChatConversation(){
|
||||
|
|
|
@ -17,17 +17,6 @@ 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.
|
||||
*/
|
||||
import java.util.List;
|
||||
|
||||
import org.linphone.core.LinphoneAddress;
|
||||
import org.linphone.core.LinphoneChatMessage;
|
||||
import org.linphone.core.LinphoneChatRoom;
|
||||
import org.linphone.core.LinphoneCore;
|
||||
import org.linphone.core.LinphoneCoreException;
|
||||
import org.linphone.core.LinphoneCoreFactory;
|
||||
import org.linphone.core.LinphoneCoreListenerBase;
|
||||
import org.linphone.mediastream.Log;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.app.Fragment;
|
||||
import android.graphics.Typeface;
|
||||
|
@ -52,6 +41,17 @@ import android.widget.LinearLayout;
|
|||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.linphone.core.LinphoneAddress;
|
||||
import org.linphone.core.LinphoneChatMessage;
|
||||
import org.linphone.core.LinphoneChatRoom;
|
||||
import org.linphone.core.LinphoneCore;
|
||||
import org.linphone.core.LinphoneCoreException;
|
||||
import org.linphone.core.LinphoneCoreFactory;
|
||||
import org.linphone.core.LinphoneCoreListenerBase;
|
||||
import org.linphone.mediastream.Log;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Sylvain Berfini
|
||||
*/
|
||||
|
@ -182,14 +182,14 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
|||
public void refresh() {
|
||||
mConversations = LinphoneActivity.instance().getChatList();
|
||||
if (getResources().getBoolean(R.bool.isTablet)) {
|
||||
LinphoneActivity.instance().displayChat("", null);
|
||||
LinphoneActivity.instance().displayChat("", null, null);
|
||||
}
|
||||
hideAndDisplayMessageIfNoChat();
|
||||
}
|
||||
|
||||
public void displayFirstChat(){
|
||||
if (mConversations != null && mConversations.size() > 0) {
|
||||
LinphoneActivity.instance().displayChat(mConversations.get(0), null);
|
||||
LinphoneActivity.instance().displayChat(mConversations.get(0), null, null);
|
||||
} else {
|
||||
LinphoneActivity.instance().displayEmptyFragment();
|
||||
}
|
||||
|
@ -321,7 +321,7 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
|||
enabledDeleteButton(false);
|
||||
}
|
||||
else if (id == R.id.new_discussion) {
|
||||
LinphoneActivity.instance().displayChat(null, null);
|
||||
LinphoneActivity.instance().displayChat(null, null, null);
|
||||
/*String sipUri = fastNewChat.getText().toString();
|
||||
if (sipUri.equals("")) {
|
||||
LinphoneActivity.instance().displayContacts(true);
|
||||
|
@ -345,7 +345,7 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
|||
String sipUri = chatList.getAdapter().getItem(position).toString();
|
||||
|
||||
if (LinphoneActivity.isInstanciated() && !isEditMode) {
|
||||
LinphoneActivity.instance().displayChat(sipUri, null);
|
||||
LinphoneActivity.instance().displayChat(sipUri, null, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ public class ContactDetailsFragment extends Fragment implements OnClickListener
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
if (LinphoneActivity.isInstanciated()) {
|
||||
LinphoneActivity.instance().displayChat(v.getTag().toString(), null);
|
||||
LinphoneActivity.instance().displayChat(v.getTag().toString(), null, null);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -19,23 +19,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
|
||||
package org.linphone;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.linphone.core.LinphoneAddress;
|
||||
import org.linphone.core.LinphoneCore;
|
||||
import org.linphone.core.LinphoneFriend;
|
||||
import org.linphone.core.LinphoneFriendImpl;
|
||||
import org.linphone.core.LinphoneProxyConfig;
|
||||
import org.linphone.mediastream.Log;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.accounts.AccountManager;
|
||||
import android.content.ContentProviderOperation;
|
||||
|
@ -53,6 +36,23 @@ import android.provider.ContactsContract;
|
|||
import android.provider.ContactsContract.CommonDataKinds;
|
||||
import android.provider.ContactsContract.Data;
|
||||
|
||||
import org.linphone.core.LinphoneAddress;
|
||||
import org.linphone.core.LinphoneCore;
|
||||
import org.linphone.core.LinphoneFriend;
|
||||
import org.linphone.core.LinphoneFriendImpl;
|
||||
import org.linphone.core.LinphoneProxyConfig;
|
||||
import org.linphone.mediastream.Log;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
interface ContactsUpdatedListener {
|
||||
void onContactsUpdated();
|
||||
}
|
||||
|
@ -299,6 +299,7 @@ public class ContactsManager extends ContentObserver {
|
|||
}
|
||||
}
|
||||
}
|
||||
Log.e(" =====>>>> ContacsManager - fetchContactsSync Ended");
|
||||
}
|
||||
|
||||
long timeElapsed = (new Date()).getTime() - contactsTime.getTime();
|
||||
|
|
|
@ -17,11 +17,6 @@ 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.
|
||||
*/
|
||||
import org.linphone.core.LinphoneAddress;
|
||||
import org.linphone.core.LinphoneCoreException;
|
||||
import org.linphone.core.LinphoneCoreFactory;
|
||||
import org.linphone.mediastream.Log;
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
|
@ -32,6 +27,11 @@ import android.view.ViewGroup;
|
|||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.linphone.core.LinphoneAddress;
|
||||
import org.linphone.core.LinphoneCoreException;
|
||||
import org.linphone.core.LinphoneCoreFactory;
|
||||
import org.linphone.mediastream.Log;
|
||||
|
||||
/**
|
||||
* @author Sylvain Berfini
|
||||
*/
|
||||
|
@ -161,7 +161,7 @@ public class HistoryDetailFragment extends Fragment implements OnClickListener {
|
|||
} if (id == R.id.call) {
|
||||
LinphoneActivity.instance().setAddresGoToDialerAndCall(sipUri, displayName, pictureUri == null ? null : Uri.parse(pictureUri));
|
||||
} else if (id == R.id.chat) {
|
||||
LinphoneActivity.instance().displayChat(sipUri, null);
|
||||
LinphoneActivity.instance().displayChat(sipUri, null, null);
|
||||
} else if (id == R.id.add_contact) {
|
||||
String uri = sipUri;
|
||||
try {
|
||||
|
|
|
@ -19,44 +19,6 @@ package org.linphone;
|
|||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.linphone.SettingsFragment;
|
||||
import org.linphone.LinphoneManager.AddressType;
|
||||
import org.linphone.LinphoneService;
|
||||
import org.linphone.assistant.AssistantActivity;
|
||||
import org.linphone.assistant.RemoteProvisioningLoginActivity;
|
||||
import org.linphone.compatibility.Compatibility;
|
||||
import org.linphone.core.CallDirection;
|
||||
import org.linphone.core.LinphoneAddress;
|
||||
import org.linphone.core.LinphoneAuthInfo;
|
||||
import org.linphone.core.LinphoneCall;
|
||||
import org.linphone.core.LinphoneCall.State;
|
||||
import org.linphone.core.LinphoneCallLog;
|
||||
import org.linphone.core.LinphoneCallLog.CallStatus;
|
||||
import org.linphone.core.LinphoneChatMessage;
|
||||
import org.linphone.core.LinphoneChatRoom;
|
||||
import org.linphone.core.LinphoneCore;
|
||||
import org.linphone.core.LinphoneCore.RegistrationState;
|
||||
import org.linphone.core.LinphoneCoreException;
|
||||
import org.linphone.core.LinphoneCoreFactory;
|
||||
import org.linphone.core.LinphoneCoreListenerBase;
|
||||
import org.linphone.core.LinphoneProxyConfig;
|
||||
import org.linphone.core.Reason;
|
||||
import org.linphone.mediastream.Log;
|
||||
import org.linphone.purchase.InAppPurchaseActivity;
|
||||
import org.linphone.ui.AddressText;
|
||||
import org.linphone.xmlrpc.XmlRpcHelper;
|
||||
import org.linphone.xmlrpc.XmlRpcListenerBase;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
|
@ -99,6 +61,42 @@ import android.widget.RelativeLayout;
|
|||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.linphone.LinphoneManager.AddressType;
|
||||
import org.linphone.assistant.AssistantActivity;
|
||||
import org.linphone.assistant.RemoteProvisioningLoginActivity;
|
||||
import org.linphone.compatibility.Compatibility;
|
||||
import org.linphone.core.CallDirection;
|
||||
import org.linphone.core.LinphoneAddress;
|
||||
import org.linphone.core.LinphoneAuthInfo;
|
||||
import org.linphone.core.LinphoneCall;
|
||||
import org.linphone.core.LinphoneCall.State;
|
||||
import org.linphone.core.LinphoneCallLog;
|
||||
import org.linphone.core.LinphoneCallLog.CallStatus;
|
||||
import org.linphone.core.LinphoneChatMessage;
|
||||
import org.linphone.core.LinphoneChatRoom;
|
||||
import org.linphone.core.LinphoneCore;
|
||||
import org.linphone.core.LinphoneCore.RegistrationState;
|
||||
import org.linphone.core.LinphoneCoreException;
|
||||
import org.linphone.core.LinphoneCoreFactory;
|
||||
import org.linphone.core.LinphoneCoreListenerBase;
|
||||
import org.linphone.core.LinphoneProxyConfig;
|
||||
import org.linphone.core.Reason;
|
||||
import org.linphone.mediastream.Log;
|
||||
import org.linphone.purchase.InAppPurchaseActivity;
|
||||
import org.linphone.ui.AddressText;
|
||||
import org.linphone.xmlrpc.XmlRpcHelper;
|
||||
import org.linphone.xmlrpc.XmlRpcListenerBase;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Sylvain Berfini
|
||||
*/
|
||||
|
@ -644,17 +642,19 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
|
|||
return count;
|
||||
}
|
||||
|
||||
public void displayChat(String sipUri, String message) {
|
||||
public void displayChat(String sipUri, String message, String fileUri) {
|
||||
if (getResources().getBoolean(R.bool.disable_chat)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Log.e(" ===>>> displayChat : message = "+message+" - fileUri = "+fileUri);
|
||||
String pictureUri = null;
|
||||
String thumbnailUri = null;
|
||||
String displayName = null;
|
||||
|
||||
LinphoneAddress lAddress = null;
|
||||
if(sipUri != null) {
|
||||
Log.e(" ===>>> displayChat : sipUri = "+ sipUri);
|
||||
try {
|
||||
lAddress = LinphoneManager.getLc().interpretUrl(sipUri);
|
||||
} catch (LinphoneCoreException e) {
|
||||
|
@ -672,14 +672,18 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
|
|||
}
|
||||
|
||||
if (currentFragment == FragmentsAvailable.CHAT_LIST || currentFragment == FragmentsAvailable.CHAT) {
|
||||
Log.e(" ===>>> displayChat : currentFragment = "+ currentFragment.toString());
|
||||
Fragment fragment2 = getFragmentManager().findFragmentById(R.id.fragmentContainer2);
|
||||
if (fragment2 != null && fragment2.isVisible() && currentFragment == FragmentsAvailable.CHAT && !emptyFragment) {
|
||||
ChatFragment chatFragment = (ChatFragment) fragment2;
|
||||
chatFragment.changeDisplayedChat(sipUri, displayName, pictureUri, message);
|
||||
chatFragment.changeDisplayedChat(sipUri, displayName, pictureUri, message, fileUri);
|
||||
} else {
|
||||
Bundle extras = new Bundle();
|
||||
extras.putString("SipUri", sipUri);
|
||||
extras.putString("messageDraft", message);
|
||||
if(message != null)
|
||||
extras.putString("messageDraft", message);
|
||||
if(fileUri != null)
|
||||
extras.putString("fileSharedUri", fileUri);
|
||||
if (sipUri != null && lAddress.getDisplayName() != null) {
|
||||
extras.putString("DisplayName", displayName);
|
||||
extras.putString("PictureUri", pictureUri);
|
||||
|
@ -688,13 +692,18 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
|
|||
changeCurrentFragment(FragmentsAvailable.CHAT, extras);
|
||||
}
|
||||
} else {
|
||||
Log.e(" ===>>> displayChat : currentFragment != Chat");
|
||||
if(isTablet()){
|
||||
changeCurrentFragment(FragmentsAvailable.CHAT_LIST, null);
|
||||
displayChat(sipUri, message);
|
||||
//displayChat(sipUri, message, fileUri);
|
||||
} else {
|
||||
Bundle extras = new Bundle();
|
||||
extras.putString("SipUri", sipUri);
|
||||
extras.putString("messageDraft", message);
|
||||
if(sipUri != null || sipUri != "")
|
||||
extras.putString("SipUri", sipUri);
|
||||
if(message != null)
|
||||
extras.putString("messageDraft", message);
|
||||
if(fileUri != null)
|
||||
extras.putString("fileSharedUri", fileUri);
|
||||
if (sipUri != null && lAddress.getDisplayName() != null) {
|
||||
extras.putString("DisplayName", displayName);
|
||||
extras.putString("PictureUri", pictureUri);
|
||||
|
@ -1276,6 +1285,8 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
|
|||
ContactsManager.getInstance().enableContactsAccess();
|
||||
if (!ContactsManager.getInstance().contactsFetchedOnce()) {
|
||||
ContactsManager.getInstance().enableContactsAccess();
|
||||
|
||||
Log.e(" ====>>>> LinphoneActivity - ContactsManager.getInstance().fetchContactsAsync() 1 !!!");
|
||||
ContactsManager.getInstance().fetchContactsAsync();
|
||||
}
|
||||
}
|
||||
|
@ -1315,6 +1326,7 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
|
|||
} else {
|
||||
if (!ContactsManager.getInstance().contactsFetchedOnce()) {
|
||||
ContactsManager.getInstance().enableContactsAccess();
|
||||
Log.e(" ====>>>> LinphoneActivity - ContactsManager.getInstance().fetchContactsAsync() 2 !!!");
|
||||
ContactsManager.getInstance().fetchContactsAsync();
|
||||
}
|
||||
}
|
||||
|
@ -1393,9 +1405,14 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
|
|||
|
||||
Intent intent = getIntent();
|
||||
|
||||
if (intent.getStringExtra("msgShared") != null)
|
||||
displayChat(null, intent.getStringExtra("msgShared"));
|
||||
|
||||
if (intent.getStringExtra("msgShared") != null) {
|
||||
displayChat(null, intent.getStringExtra("msgShared"), null);
|
||||
intent.putExtra("msgShared", "");
|
||||
}
|
||||
if (intent.getStringExtra("fileShared") != null && intent.getStringExtra("fileShared") != "") {
|
||||
displayChat(null, null, intent.getStringExtra("fileShared"));
|
||||
intent.putExtra("fileShared", "");
|
||||
}
|
||||
doNotGoToCallActivity = false;
|
||||
isOnBackground = false;
|
||||
|
||||
|
@ -1450,7 +1467,7 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
|
|||
LinphoneService.instance().removeMessageNotification();
|
||||
String sipUri = extras.getString("ChatContactSipUri");
|
||||
doNotGoToCallActivity = true;
|
||||
displayChat(sipUri, null);
|
||||
displayChat(sipUri, null, null);
|
||||
} else if (extras != null && extras.getBoolean("GoToHistory", false)) {
|
||||
doNotGoToCallActivity = true;
|
||||
changeCurrentFragment(FragmentsAvailable.HISTORY_LIST, null);
|
||||
|
|
|
@ -18,13 +18,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
*/
|
||||
package org.linphone;
|
||||
|
||||
import static android.content.Intent.ACTION_MAIN;
|
||||
|
||||
import org.linphone.assistant.RemoteProvisioningActivity;
|
||||
import org.linphone.mediastream.Log;
|
||||
import org.linphone.mediastream.Version;
|
||||
import org.linphone.tutorials.TutorialLauncherActivity;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
|
@ -32,6 +25,13 @@ import android.net.Uri;
|
|||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
|
||||
import org.linphone.assistant.RemoteProvisioningActivity;
|
||||
import org.linphone.mediastream.Log;
|
||||
import org.linphone.mediastream.Version;
|
||||
import org.linphone.tutorials.TutorialLauncherActivity;
|
||||
|
||||
import static android.content.Intent.ACTION_MAIN;
|
||||
|
||||
/**
|
||||
*
|
||||
* Launch Linphone main activity when Service is ready.
|
||||
|
@ -104,20 +104,30 @@ public class LinphoneLauncherActivity extends Activity {
|
|||
BluetoothManager.getInstance().initBluetooth();
|
||||
}
|
||||
|
||||
//TODO :
|
||||
mHandler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Intent newIntent = new Intent(LinphoneLauncherActivity.this, classToStart);
|
||||
Intent intent = getIntent();
|
||||
String msgShared = null;
|
||||
Uri imageUri = null;
|
||||
if (intent != null) {
|
||||
String action = intent.getAction();
|
||||
String type = intent.getType();
|
||||
newIntent.setData(intent.getData());
|
||||
if (Intent.ACTION_SEND.equals(action) && type != null) {
|
||||
if ("text/plain".equals(type) && intent.getStringExtra(Intent.EXTRA_TEXT) != null) {
|
||||
Log.e(" ====>>> type = "+type+" share msg");
|
||||
msgShared = intent.getStringExtra(Intent.EXTRA_TEXT);
|
||||
newIntent.putExtra("msgShared", msgShared);
|
||||
}else if ( type.contains("image") ){
|
||||
msgShared = intent.getStringExtra(Intent.EXTRA_STREAM);
|
||||
imageUri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM);
|
||||
Log.e(" ====>>> type = "+type+" share images msgShared = "+msgShared +" VS toPath() = "+imageUri.getPath());
|
||||
newIntent.putExtra("fileShared", imageUri.getPath());
|
||||
}else{
|
||||
Log.e(" ====>>> type = "+type+" share something else");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -132,8 +142,14 @@ public class LinphoneLauncherActivity extends Activity {
|
|||
addressToCall = null;
|
||||
}
|
||||
startActivity(newIntent);
|
||||
if (classToStart == LinphoneActivity.class && LinphoneActivity.isInstanciated() && msgShared != null) {
|
||||
LinphoneActivity.instance().displayChat(null, msgShared);
|
||||
if (classToStart == LinphoneActivity.class && LinphoneActivity.isInstanciated() && (msgShared != null || imageUri != null)) {
|
||||
|
||||
if(msgShared != null) {
|
||||
LinphoneActivity.instance().displayChat(null, msgShared, null);
|
||||
}
|
||||
if(imageUri != null) {
|
||||
LinphoneActivity.instance().displayChat(null, null, imageUri.toString());
|
||||
}
|
||||
}
|
||||
finish();
|
||||
}
|
||||
|
@ -159,6 +175,7 @@ public class LinphoneLauncherActivity extends Activity {
|
|||
mServiceThread = null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 1b8f7dfbd8e5452800d79f0fc0b1e84ae8945a42
|
||||
Subproject commit 475eb67b5cb8d82f6636e69c3bde8b18daeb824e
|
Loading…
Reference in a new issue