From 4e10e67506c1f1e0159316f5e191f436515230bb Mon Sep 17 00:00:00 2001 From: Brieuc Viel Date: Mon, 28 Aug 2017 15:18:15 +0200 Subject: [PATCH] [File sharing] fix second sharing in a row + display pictures --- AndroidManifest.xml | 6 +--- .../org/linphone/LinphoneActivity.java | 3 -- .../linphone/LinphoneLauncherActivity.java | 36 +++++++++++-------- src/android/org/linphone/LinphoneUtils.java | 2 +- 4 files changed, 24 insertions(+), 23 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 10968ef34..e4f615219 100755 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -71,6 +71,7 @@ @@ -103,11 +104,6 @@ - - - - - diff --git a/src/android/org/linphone/LinphoneActivity.java b/src/android/org/linphone/LinphoneActivity.java index c517c35a4..2686fbbcd 100644 --- a/src/android/org/linphone/LinphoneActivity.java +++ b/src/android/org/linphone/LinphoneActivity.java @@ -163,7 +163,6 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick if (getResources().getBoolean(R.bool.orientation_portrait_only)) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } - boolean useFirstLoginActivity = getResources().getBoolean(R.bool.display_account_assistant_at_first_start); if (LinphonePreferences.instance().isProvisioningLoginViewEnabled()) { Intent wizard = new Intent(); @@ -1349,7 +1348,6 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick @Override protected void onResume() { super.onResume(); - if (!LinphoneService.isReady()) { startService(new Intent(Intent.ACTION_MAIN).setClass(this, LinphoneService.class)); } @@ -1452,7 +1450,6 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick @Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); - if (getCurrentFragment() == FragmentsAvailable.SETTINGS) { if (fragment instanceof SettingsFragment) { ((SettingsFragment) fragment).closePreferenceScreen(); diff --git a/src/android/org/linphone/LinphoneLauncherActivity.java b/src/android/org/linphone/LinphoneLauncherActivity.java index 708031f15..9dd7dbd23 100644 --- a/src/android/org/linphone/LinphoneLauncherActivity.java +++ b/src/android/org/linphone/LinphoneLauncherActivity.java @@ -49,7 +49,6 @@ public class LinphoneLauncherActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - // Hack to avoid to draw twice LinphoneActivity on tablets if (getResources().getBoolean(R.bool.orientation_portrait_only)) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); @@ -89,6 +88,16 @@ public class LinphoneLauncherActivity extends Activity { } } + @Override + protected void onResume(){ + super.onResume(); + } + + @Override + protected void onNewIntent(Intent intent) { + super.onNewIntent(intent); + } + protected void onServiceReady() { final Class classToStart; if (getResources().getBoolean(R.bool.show_tutorials_instead_of_app)) { @@ -110,34 +119,34 @@ public class LinphoneLauncherActivity extends Activity { Intent newIntent = new Intent(LinphoneLauncherActivity.this, classToStart); Intent intent = getIntent(); String stringFileShared = null; + String stringUriFileShared = null; Uri fileUri = 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 (type.contains("text/")){ //&& intent.getStringExtra(Intent.EXTRA_TEXT) != null) { + if (type.contains("text/")){ if(("text/plain").equals(type) && 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){ - //stringFileShared = ((Uri) intent.getExtras().get(Intent.EXTRA_STREAM)).getPath(); stringFileShared = (LinphoneUtils.createCvsFromString(LinphoneUtils.processContactUri(getApplicationContext(), (Uri)intent.getExtras().get(Intent.EXTRA_STREAM)))).toString(); newIntent.putExtra("fileShared", stringFileShared); } }else { if(intent.getStringExtra(Intent.EXTRA_STREAM) != null){ - stringFileShared = intent.getStringExtra(Intent.EXTRA_STREAM); + stringUriFileShared = intent.getStringExtra(Intent.EXTRA_STREAM); }else { fileUri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM); - stringFileShared = LinphoneUtils.getRealPathFromURI(getBaseContext(), fileUri); - if(stringFileShared == null) - if(fileUri.getPath().contains("/0/1/mediakey:/local")) - stringFileShared = LinphoneUtils.getFilePath(getBaseContext(), fileUri); - else - stringFileShared = fileUri.getPath(); + stringUriFileShared = LinphoneUtils.getRealPathFromURI(getBaseContext(), fileUri); + if(stringUriFileShared == null) + if(fileUri.getPath().contains("/0/1/mediakey:/local")) { + stringUriFileShared = LinphoneUtils.getFilePath(getBaseContext(), fileUri); + }else + stringUriFileShared = fileUri.getPath(); } - newIntent.putExtra("fileShared", stringFileShared); + newIntent.putExtra("fileShared", stringUriFileShared); } } } @@ -153,12 +162,11 @@ public class LinphoneLauncherActivity extends Activity { } startActivity(newIntent); if (classToStart == LinphoneActivity.class && LinphoneActivity.isInstanciated() && (stringFileShared != null || fileUri != null)) { - if(stringFileShared != null) { LinphoneActivity.instance().displayChat(null, stringFileShared, null); } - if(fileUri != null) { - LinphoneActivity.instance().displayChat(null, null, fileUri.toString()); + else if(fileUri != null) { + LinphoneActivity.instance().displayChat(null, null, stringUriFileShared); } } finish(); diff --git a/src/android/org/linphone/LinphoneUtils.java b/src/android/org/linphone/LinphoneUtils.java index 56616c27e..cc66b6edc 100644 --- a/src/android/org/linphone/LinphoneUtils.java +++ b/src/android/org/linphone/LinphoneUtils.java @@ -500,7 +500,7 @@ public final class LinphoneUtils { } public static Boolean isExtensionImage(String path){ - String extension = LinphoneUtils.getExtensionFromFileName(path); + String extension = LinphoneUtils.getExtensionFromFileName(path).toLowerCase(); return (extension != null && extension.matches(".*(png|jpg|jpeg|bmp|gif).*")); }