소스 검색

Added an api check, since multiselect only works on api level 18+

Pro9 10 년 전
부모
커밋
0ba228c064
1개의 변경된 파일10개의 추가작업 그리고 2개의 파일을 삭제
  1. 10 2
      src/com/owncloud/android/ui/activity/FileDisplayActivity.java

+ 10 - 2
src/com/owncloud/android/ui/activity/FileDisplayActivity.java

@@ -26,6 +26,7 @@ import android.accounts.AccountManager;
 import android.accounts.AuthenticatorException;
 import android.accounts.AuthenticatorException;
 import android.accounts.OperationCanceledException;
 import android.accounts.OperationCanceledException;
 import android.annotation.SuppressLint;
 import android.annotation.SuppressLint;
+import android.annotation.TargetApi;
 import android.app.AlertDialog;
 import android.app.AlertDialog;
 import android.app.Dialog;
 import android.app.Dialog;
 import android.app.ProgressDialog;
 import android.app.ProgressDialog;
@@ -42,6 +43,7 @@ import android.content.SyncRequest;
 import android.content.res.Resources.NotFoundException;
 import android.content.res.Resources.NotFoundException;
 import android.database.Cursor;
 import android.database.Cursor;
 import android.net.Uri;
 import android.net.Uri;
+import android.os.Build;
 import android.os.Bundle;
 import android.os.Bundle;
 import android.os.IBinder;
 import android.os.IBinder;
 import android.preference.PreferenceManager;
 import android.preference.PreferenceManager;
@@ -594,12 +596,15 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener {
 
 
     /**
     /**
      * Called, when the user selected something for uploading
      * Called, when the user selected something for uploading
+     *
      */
      */
+    @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
     protected void onActivityResult(int requestCode, int resultCode, Intent data) {
     protected void onActivityResult(int requestCode, int resultCode, Intent data) {
         super.onActivityResult(requestCode, resultCode, data);
         super.onActivityResult(requestCode, resultCode, data);
 
 
         if (requestCode == ACTION_SELECT_CONTENT_FROM_APPS && (resultCode == RESULT_OK || resultCode == UploadFilesActivity.RESULT_OK_AND_MOVE)) {
         if (requestCode == ACTION_SELECT_CONTENT_FROM_APPS && (resultCode == RESULT_OK || resultCode == UploadFilesActivity.RESULT_OK_AND_MOVE)) {
-            if (data.getData() == null){
+            //getClipData is only supported on api level 16+
+            if (data.getData() == null && Build.VERSION.SDK_INT >= 16){
                 for( int i = 0; i < data.getClipData().getItemCount(); i++){
                 for( int i = 0; i < data.getClipData().getItemCount(); i++){
                     Intent intent = new Intent();
                     Intent intent = new Intent();
                     intent.setData(data.getClipData().getItemAt(i).getUri());
                     intent.setData(data.getClipData().getItemAt(i).getUri());
@@ -846,7 +851,10 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener {
                     } else if (item == 1) {
                     } else if (item == 1) {
                         Intent action = new Intent(Intent.ACTION_GET_CONTENT);
                         Intent action = new Intent(Intent.ACTION_GET_CONTENT);
                         action = action.setType("*/*").addCategory(Intent.CATEGORY_OPENABLE);
                         action = action.setType("*/*").addCategory(Intent.CATEGORY_OPENABLE);
-                        action.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
+                        //putExtra is only supported on api level 18+
+                        if(Build.VERSION.SDK_INT >= 18) {
+                            action.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
+                        }
                         startActivityForResult(Intent.createChooser(action, getString(R.string.upload_chooser_title)),
                         startActivityForResult(Intent.createChooser(action, getString(R.string.upload_chooser_title)),
                                 ACTION_SELECT_CONTENT_FROM_APPS);
                                 ACTION_SELECT_CONTENT_FROM_APPS);
                     }
                     }