X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/f7fb16963b2fba0b65245f0d5eed6ccc98c7952c..49c1f9e3180099dff1ba1d8880a95314e47480a4:/src/eu/alefzero/owncloud/ui/fragment/FileDetailFragment.java diff --git a/src/eu/alefzero/owncloud/ui/fragment/FileDetailFragment.java b/src/eu/alefzero/owncloud/ui/fragment/FileDetailFragment.java index ee695553..6b2aa86a 100644 --- a/src/eu/alefzero/owncloud/ui/fragment/FileDetailFragment.java +++ b/src/eu/alefzero/owncloud/ui/fragment/FileDetailFragment.java @@ -22,6 +22,7 @@ import java.util.List; import android.accounts.Account; import android.accounts.AccountManager; import android.app.ActionBar.LayoutParams; +import android.content.ActivityNotFoundException; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; @@ -203,9 +204,13 @@ public class FileDetailFragment extends SherlockFragment implements if (mFile.getMimetype().startsWith("image/")) { BitmapFactory.Options options = new Options(); options.inScaled = true; - options.inMutable = false; - options.inPreferQualityOverSpeed = false; options.inPurgeable = true; + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.GINGERBREAD_MR1) { + options.inPreferQualityOverSpeed = false; + } + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) { + options.inMutable = false; + } Bitmap bmp = BitmapFactory.decodeFile(mFile.getStoragePath(), options); @@ -224,6 +229,14 @@ public class FileDetailFragment extends SherlockFragment implements } catch (OutOfMemoryError e) { preview.setVisibility(View.INVISIBLE); Log.e(TAG, "Out of memory occured for file with size " + mFile.getFileLength()); + + } catch (NoSuchFieldError e) { + preview.setVisibility(View.INVISIBLE); + Log.e(TAG, "Error from access to unexisting field despite protection " + mFile.getFileLength()); + + } catch (Throwable t) { + preview.setVisibility(View.INVISIBLE); + Log.e(TAG, "Unexpected error while creating image preview " + mFile.getFileLength()); } downloadButton.setText(R.string.filedetails_open); downloadButton.setOnClickListener(new OnClickListener() { @@ -231,10 +244,11 @@ public class FileDetailFragment extends SherlockFragment implements public void onClick(View v) { Intent i = new Intent(Intent.ACTION_VIEW); i.setDataAndType(Uri.parse("file://"+mFile.getStoragePath()), mFile.getMimetype()); - List list = getActivity().getPackageManager().queryIntentActivities(i, PackageManager.MATCH_DEFAULT_ONLY); - if (list.size() > 0) { + i.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); + try { startActivity(i); - } else { + + } catch (ActivityNotFoundException e) { Toast.makeText(getActivity(), "There is no application to handle file " + mFile.getFileName(), Toast.LENGTH_SHORT).show(); } }