[FileSharing] update files sharing to fix some issues + add new String error
This commit is contained in:
parent
f34db59d07
commit
3580f770e9
3 changed files with 51 additions and 28 deletions
|
@ -189,6 +189,7 @@
|
|||
<string name="displayed">Read</string>
|
||||
<string name="delivered">Delivered</string>
|
||||
<string name="resend">Resend</string>
|
||||
<string name="error_opening_file">An error occurs when opening this file.</string>
|
||||
|
||||
<!-- Status Bar -->
|
||||
<string name="status_connected">Registered</string>
|
||||
|
|
|
@ -782,7 +782,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
|
||||
private void sendImageMessage(String path, int imageSize) {
|
||||
if(path.contains("file://")) {
|
||||
path = path.substring(7);
|
||||
path = path.split("file:///", 2)[1];
|
||||
}
|
||||
if(path.contains("%20")) {
|
||||
path = path.replace("%20", "-");
|
||||
|
@ -815,7 +815,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
|
||||
private void sendFileSharingMessage(String path, int size ) {
|
||||
if (path.contains("file://")) {
|
||||
path = path.substring(7);
|
||||
path = path.split("file:///", 2)[1];
|
||||
} else if (path.contains("com.android.contacts/contacts/")) {
|
||||
path = getCVSPathFromLookupUri(path).toString();
|
||||
} else if (path.contains("vcard") || path.contains("vcf")) {
|
||||
|
@ -1676,20 +1676,29 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
contentUri = Uri.parse(imageUri);
|
||||
} else {
|
||||
file = new File(imageUri);
|
||||
contentUri = FileProvider.getUriForFile(getActivity(), "org.linphone.provider", file);
|
||||
try {
|
||||
contentUri = FileProvider.getUriForFile(getActivity(), "org.linphone.provider", file);
|
||||
}catch(java.lang.IllegalArgumentException e){
|
||||
Log.e("Something wrong happend : "+e);
|
||||
contentUri = null;
|
||||
}
|
||||
}
|
||||
String type = null;
|
||||
String extension = MimeTypeMap.getFileExtensionFromUrl(contentUri.toString());
|
||||
if (extension != null) {
|
||||
type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
|
||||
if(contentUri != null) {
|
||||
String extension = MimeTypeMap.getFileExtensionFromUrl(contentUri.toString());
|
||||
if (extension != null) {
|
||||
type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
|
||||
}
|
||||
if (type != null) {
|
||||
intent.setDataAndType(contentUri, type);
|
||||
} else {
|
||||
intent.setDataAndType(contentUri, "*/*");
|
||||
}
|
||||
intent.addFlags(FLAG_GRANT_READ_URI_PERMISSION);
|
||||
context.startActivity(intent);
|
||||
}else{
|
||||
LinphoneActivity.instance().displayCustomToast(getString(R.string.error_opening_file), Toast.LENGTH_LONG);
|
||||
}
|
||||
if(type != null) {
|
||||
intent.setDataAndType(contentUri, type);
|
||||
}else {
|
||||
intent.setDataAndType(contentUri, "*/*");
|
||||
}
|
||||
intent.addFlags(FLAG_GRANT_READ_URI_PERMISSION);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1901,20 +1910,29 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
contentUri = Uri.parse(imageUri);
|
||||
} else {
|
||||
file = new File(imageUri);
|
||||
contentUri = FileProvider.getUriForFile(getActivity(), "org.linphone.provider", file);
|
||||
try {
|
||||
contentUri = FileProvider.getUriForFile(getActivity(), "org.linphone.provider", file);
|
||||
}catch(java.lang.IllegalArgumentException e){
|
||||
Log.e("Something wrong happend : "+e);
|
||||
contentUri = null;
|
||||
}
|
||||
}
|
||||
String type = null;
|
||||
String extension = MimeTypeMap.getFileExtensionFromUrl(contentUri.toString());
|
||||
if (extension != null) {
|
||||
type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
|
||||
}
|
||||
if(type != null) {
|
||||
intent.setDataAndType(contentUri, type);
|
||||
}else {
|
||||
intent.setDataAndType(contentUri, "*/*");
|
||||
}
|
||||
intent.addFlags(FLAG_GRANT_READ_URI_PERMISSION);
|
||||
context.startActivity(intent);
|
||||
if(contentUri != null) {
|
||||
String extension = MimeTypeMap.getFileExtensionFromUrl(contentUri.toString());
|
||||
if (extension != null) {
|
||||
type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
|
||||
}
|
||||
if (type != null) {
|
||||
intent.setDataAndType(contentUri, type);
|
||||
} else {
|
||||
intent.setDataAndType(contentUri, "*/*");
|
||||
}
|
||||
intent.addFlags(FLAG_GRANT_READ_URI_PERMISSION);
|
||||
context.startActivity(intent);
|
||||
}else{
|
||||
LinphoneActivity.instance().displayCustomToast(getString(R.string.error_opening_file), Toast.LENGTH_LONG);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -126,7 +126,7 @@ public class LinphoneLauncherActivity extends Activity {
|
|||
newIntent.setData(intent.getData());
|
||||
if (Intent.ACTION_SEND.equals(action) && type != null) {
|
||||
if (type.contains("text/")){
|
||||
if(("text/plain").equals(type) && intent.getStringExtra(Intent.EXTRA_TEXT)!= null) {
|
||||
if(("text/plain").equals(type) && (String)intent.getStringExtra(Intent.EXTRA_TEXT)!= null) {
|
||||
stringFileShared = intent.getStringExtra(Intent.EXTRA_TEXT);
|
||||
newIntent.putExtra("msgShared", stringFileShared);
|
||||
} else if(((Uri) intent.getExtras().get(Intent.EXTRA_STREAM)) != null){
|
||||
|
@ -134,19 +134,23 @@ public class LinphoneLauncherActivity extends Activity {
|
|||
newIntent.putExtra("fileShared", stringFileShared);
|
||||
}
|
||||
}else {
|
||||
if(intent.getStringExtra(Intent.EXTRA_STREAM) != null){
|
||||
if(((String) intent.getStringExtra(Intent.EXTRA_STREAM)) != null){
|
||||
stringUriFileShared = intent.getStringExtra(Intent.EXTRA_STREAM);
|
||||
}else {
|
||||
fileUri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM);
|
||||
stringUriFileShared = LinphoneUtils.getRealPathFromURI(getBaseContext(), fileUri);
|
||||
if(stringUriFileShared == null)
|
||||
if(fileUri.getPath().contains("/0/1/mediakey:/local")) {
|
||||
if(fileUri.getPath().contains("/0/1/mediakey:/local") || fileUri.getPath().contains("/ORIGINAL/NONE/")) {
|
||||
stringUriFileShared = LinphoneUtils.getFilePath(getBaseContext(), fileUri);
|
||||
}else
|
||||
stringUriFileShared = fileUri.getPath();
|
||||
}
|
||||
newIntent.putExtra("fileShared", stringUriFileShared);
|
||||
}
|
||||
}else if (Intent.ACTION_SEND_MULTIPLE.equals(action) && type != null) {
|
||||
if (type.startsWith("image/")) {
|
||||
//TODO : Manage multiple files sharing
|
||||
}
|
||||
}else if( ACTION_CALL_LINPHONE.equals(action) && (intent.getStringExtra("NumberToCall") != null)) {
|
||||
String numberToCall = intent.getStringExtra("NumberToCall");
|
||||
if (CallActivity.isInstanciated()) {
|
||||
|
|
Loading…
Reference in a new issue