mirror of
				https://github.com/SimpleMobileTools/Simple-File-Manager.git
				synced 2025-06-05 22:09:15 +02:00 
			
		
		
		
	try a more generic mime type if a file cannot be open by anything
This commit is contained in:
		| @@ -113,10 +113,23 @@ public class ItemsFragment extends android.support.v4.app.Fragment | ||||
|             try { | ||||
|                 startActivity(intent); | ||||
|             } catch (ActivityNotFoundException e) { | ||||
|                 if (!tryGenericMimeType(intent, mimeType, file)) { | ||||
|                     Utils.showToast(getContext(), R.string.no_app_found); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private boolean tryGenericMimeType(Intent intent, String mimeType, File file) { | ||||
|         final String genericMimeType = getGenericMimeType(mimeType); | ||||
|         intent.setDataAndType(Uri.fromFile(file), genericMimeType); | ||||
|         try { | ||||
|             startActivity(intent); | ||||
|             return true; | ||||
|         } catch (ActivityNotFoundException e) { | ||||
|             return false; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void onRefresh() { | ||||
| @@ -124,6 +137,14 @@ public class ItemsFragment extends android.support.v4.app.Fragment | ||||
|         mSwipeRefreshLayout.setRefreshing(false); | ||||
|     } | ||||
|  | ||||
|     private String getGenericMimeType(String mimeType) { | ||||
|         if (!mimeType.contains("/")) | ||||
|             return mimeType; | ||||
|  | ||||
|         final String type = mimeType.substring(0, mimeType.indexOf("/")); | ||||
|         return type + "/*"; | ||||
|     } | ||||
|  | ||||
|     public interface ItemInteractionListener { | ||||
|         void itemClicked(String path); | ||||
|     } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user