[File sharing] fix second sharing in a row + display pictures

This commit is contained in:
Brieuc Viel 2017-08-28 15:18:15 +02:00
parent 430e3e7c30
commit 4e10e67506
4 changed files with 24 additions and 23 deletions

View file

@ -71,6 +71,7 @@
<activity <activity
android:name=".LinphoneLauncherActivity" android:name=".LinphoneLauncherActivity"
android:exported="true" android:exported="true"
android:launchMode="singleTask"
android:label="@string/app_name" android:label="@string/app_name"
android:theme="@style/NoTitle" android:theme="@style/NoTitle"
android:windowSoftInputMode="adjustPan|stateHidden"> android:windowSoftInputMode="adjustPan|stateHidden">
@ -103,11 +104,6 @@
<category android:name="android.intent.category.BROWSABLE"/> <category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT"/> <category android:name="android.intent.category.DEFAULT"/>
</intent-filter> </intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
<intent-filter> <intent-filter>
<action android:name="android.intent.action.SEND" /> <action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />

View file

@ -163,7 +163,6 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
if (getResources().getBoolean(R.bool.orientation_portrait_only)) { if (getResources().getBoolean(R.bool.orientation_portrait_only)) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
} }
boolean useFirstLoginActivity = getResources().getBoolean(R.bool.display_account_assistant_at_first_start); boolean useFirstLoginActivity = getResources().getBoolean(R.bool.display_account_assistant_at_first_start);
if (LinphonePreferences.instance().isProvisioningLoginViewEnabled()) { if (LinphonePreferences.instance().isProvisioningLoginViewEnabled()) {
Intent wizard = new Intent(); Intent wizard = new Intent();
@ -1349,7 +1348,6 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
if (!LinphoneService.isReady()) { if (!LinphoneService.isReady()) {
startService(new Intent(Intent.ACTION_MAIN).setClass(this, LinphoneService.class)); startService(new Intent(Intent.ACTION_MAIN).setClass(this, LinphoneService.class));
} }
@ -1452,7 +1450,6 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
@Override @Override
protected void onNewIntent(Intent intent) { protected void onNewIntent(Intent intent) {
super.onNewIntent(intent); super.onNewIntent(intent);
if (getCurrentFragment() == FragmentsAvailable.SETTINGS) { if (getCurrentFragment() == FragmentsAvailable.SETTINGS) {
if (fragment instanceof SettingsFragment) { if (fragment instanceof SettingsFragment) {
((SettingsFragment) fragment).closePreferenceScreen(); ((SettingsFragment) fragment).closePreferenceScreen();

View file

@ -49,7 +49,6 @@ public class LinphoneLauncherActivity extends Activity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
// Hack to avoid to draw twice LinphoneActivity on tablets // Hack to avoid to draw twice LinphoneActivity on tablets
if (getResources().getBoolean(R.bool.orientation_portrait_only)) { if (getResources().getBoolean(R.bool.orientation_portrait_only)) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); 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() { protected void onServiceReady() {
final Class<? extends Activity> classToStart; final Class<? extends Activity> classToStart;
if (getResources().getBoolean(R.bool.show_tutorials_instead_of_app)) { 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 newIntent = new Intent(LinphoneLauncherActivity.this, classToStart);
Intent intent = getIntent(); Intent intent = getIntent();
String stringFileShared = null; String stringFileShared = null;
String stringUriFileShared = null;
Uri fileUri = null; Uri fileUri = null;
if (intent != null) { if (intent != null) {
String action = intent.getAction(); String action = intent.getAction();
String type = intent.getType(); String type = intent.getType();
newIntent.setData(intent.getData()); newIntent.setData(intent.getData());
if (Intent.ACTION_SEND.equals(action) && type != null) { 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) { if(("text/plain").equals(type) && intent.getStringExtra(Intent.EXTRA_TEXT)!= null) {
stringFileShared = intent.getStringExtra(Intent.EXTRA_TEXT); stringFileShared = intent.getStringExtra(Intent.EXTRA_TEXT);
newIntent.putExtra("msgShared", stringFileShared); newIntent.putExtra("msgShared", stringFileShared);
} else if(((Uri) intent.getExtras().get(Intent.EXTRA_STREAM)) != null){ } 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(); stringFileShared = (LinphoneUtils.createCvsFromString(LinphoneUtils.processContactUri(getApplicationContext(), (Uri)intent.getExtras().get(Intent.EXTRA_STREAM)))).toString();
newIntent.putExtra("fileShared", stringFileShared); newIntent.putExtra("fileShared", stringFileShared);
} }
}else { }else {
if(intent.getStringExtra(Intent.EXTRA_STREAM) != null){ if(intent.getStringExtra(Intent.EXTRA_STREAM) != null){
stringFileShared = intent.getStringExtra(Intent.EXTRA_STREAM); stringUriFileShared = intent.getStringExtra(Intent.EXTRA_STREAM);
}else { }else {
fileUri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM); fileUri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM);
stringFileShared = LinphoneUtils.getRealPathFromURI(getBaseContext(), fileUri); stringUriFileShared = LinphoneUtils.getRealPathFromURI(getBaseContext(), fileUri);
if(stringFileShared == null) if(stringUriFileShared == null)
if(fileUri.getPath().contains("/0/1/mediakey:/local")) if(fileUri.getPath().contains("/0/1/mediakey:/local")) {
stringFileShared = LinphoneUtils.getFilePath(getBaseContext(), fileUri); stringUriFileShared = LinphoneUtils.getFilePath(getBaseContext(), fileUri);
else }else
stringFileShared = fileUri.getPath(); stringUriFileShared = fileUri.getPath();
} }
newIntent.putExtra("fileShared", stringFileShared); newIntent.putExtra("fileShared", stringUriFileShared);
} }
} }
} }
@ -153,12 +162,11 @@ public class LinphoneLauncherActivity extends Activity {
} }
startActivity(newIntent); startActivity(newIntent);
if (classToStart == LinphoneActivity.class && LinphoneActivity.isInstanciated() && (stringFileShared != null || fileUri != null)) { if (classToStart == LinphoneActivity.class && LinphoneActivity.isInstanciated() && (stringFileShared != null || fileUri != null)) {
if(stringFileShared != null) { if(stringFileShared != null) {
LinphoneActivity.instance().displayChat(null, stringFileShared, null); LinphoneActivity.instance().displayChat(null, stringFileShared, null);
} }
if(fileUri != null) { else if(fileUri != null) {
LinphoneActivity.instance().displayChat(null, null, fileUri.toString()); LinphoneActivity.instance().displayChat(null, null, stringUriFileShared);
} }
} }
finish(); finish();

View file

@ -500,7 +500,7 @@ public final class LinphoneUtils {
} }
public static Boolean isExtensionImage(String path){ 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).*")); return (extension != null && extension.matches(".*(png|jpg|jpeg|bmp|gif).*"));
} }