diff --git a/app/build.gradle b/app/build.gradle index 1d6a5652..92616910 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -9,8 +9,8 @@ android { applicationId "jp.juggler.subwaytooter" minSdkVersion 21 targetSdkVersion 25 - versionCode 84 - versionName "0.8.4" + versionCode 85 + versionName "0.8.5" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } diff --git a/app/src/main/java/jp/juggler/subwaytooter/ActCallback.java b/app/src/main/java/jp/juggler/subwaytooter/ActCallback.java index ca045159..b5bd2438 100644 --- a/app/src/main/java/jp/juggler/subwaytooter/ActCallback.java +++ b/app/src/main/java/jp/juggler/subwaytooter/ActCallback.java @@ -7,6 +7,7 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.content.FileProvider; import android.support.v7.app.AppCompatActivity; +import android.text.TextUtils; import org.apache.commons.io.IOUtils; @@ -63,9 +64,7 @@ public class ActCallback extends AppCompatActivity { final String action = src.getAction(); final String type = src.getType(); - if( type == null ) return null; - - if( type.startsWith( "image/" ) ){ + if( type!= null && type.startsWith( "image/" ) ){ if( Intent.ACTION_VIEW.equals( action ) ){ Uri uri = src.getData(); if( uri == null ) return null; @@ -114,12 +113,19 @@ public class ActCallback extends AppCompatActivity { dst.putParcelableArrayListExtra( Intent.EXTRA_STREAM, list_dst ); return dst; } - }else if( type.startsWith( "text/" ) ){ - if( Intent.ACTION_SEND.equals( action ) ){ - String sv = src.getStringExtra( Intent.EXTRA_TEXT ); - if( sv == null ) return null; + }else if( Intent.ACTION_SEND.equals( action ) ){ + + // Swarmアプリから送られたインテントは getType()==null だが EXTRA_TEXT は含まれている + // EXTRA_TEXT の存在を確認してからtypeがnullもしくは text/plain なら受け取る + + String sv = src.getStringExtra( Intent.EXTRA_TEXT ); + if( ! TextUtils.isEmpty(sv) && ( type==null || type.startsWith( "text/" ) ) ){ + String subject = src.getStringExtra( Intent.EXTRA_SUBJECT ); + if(! TextUtils.isEmpty(subject) ){ + sv = subject + " " +sv; + } Intent dst = new Intent( action ); - dst.setType( type ); + dst.setType( "text/plain" ); dst.putExtra( Intent.EXTRA_TEXT, sv ); return dst; }