import android.accounts.Account;\r
import android.accounts.AccountManager;\r
import android.app.ActionBar.LayoutParams;\r
+import android.content.ActivityNotFoundException;\r
import android.content.BroadcastReceiver;\r
import android.content.Context;\r
import android.content.Intent;\r
if (mFile.getMimetype().startsWith("image/")) {\r
BitmapFactory.Options options = new Options();\r
options.inScaled = true;\r
- options.inMutable = false;\r
- options.inPreferQualityOverSpeed = false;\r
options.inPurgeable = true;\r
+ if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.GINGERBREAD_MR1) {\r
+ options.inPreferQualityOverSpeed = false;\r
+ }\r
+ if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {\r
+ options.inMutable = false;\r
+ }\r
\r
Bitmap bmp = BitmapFactory.decodeFile(mFile.getStoragePath(), options);\r
\r
} catch (OutOfMemoryError e) {\r
preview.setVisibility(View.INVISIBLE);\r
Log.e(TAG, "Out of memory occured for file with size " + mFile.getFileLength());\r
+ \r
+ } catch (NoSuchFieldError e) {\r
+ preview.setVisibility(View.INVISIBLE);\r
+ Log.e(TAG, "Error from access to unexisting field despite protection " + mFile.getFileLength());\r
+ \r
+ } catch (Throwable t) {\r
+ preview.setVisibility(View.INVISIBLE);\r
+ Log.e(TAG, "Unexpected error while creating image preview " + mFile.getFileLength());\r
}\r
downloadButton.setText(R.string.filedetails_open);\r
downloadButton.setOnClickListener(new OnClickListener() {\r
public void onClick(View v) {\r
Intent i = new Intent(Intent.ACTION_VIEW);\r
i.setDataAndType(Uri.parse("file://"+mFile.getStoragePath()), mFile.getMimetype());\r
- List list = getActivity().getPackageManager().queryIntentActivities(i, PackageManager.MATCH_DEFAULT_ONLY);\r
- if (list.size() > 0) {\r
+ i.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);\r
+ try {\r
startActivity(i);\r
- } else {\r
+ \r
+ } catch (ActivityNotFoundException e) {\r
Toast.makeText(getActivity(), "There is no application to handle file " + mFile.getFileName(), Toast.LENGTH_SHORT).show();\r
}\r
}\r