Skip to content

Commit

Permalink
Force chooser on open-with
Browse files Browse the repository at this point in the history
Long-click selection --> menu --> open with, should force chooser for file handler rather than opening the default handler, which will be automatically called on short-click.
  • Loading branch information
lbdroid committed Apr 9, 2015
1 parent 5de08e1 commit 485de2c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/com/amaze/filemanager/activities/TextReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
utils.showProps(mFile, c, theme1);
return true;
} else if (item.getItemId() == R.id.openwith) {
utils.openunknown(mFile, c);
utils.openunknown(mFile, c, false);
}
return super.onOptionsItemSelected(item);
}
Expand Down Expand Up @@ -360,4 +360,4 @@ private String getStatusColor() {
};
return colors[ Arrays.asList(colors).indexOf(skin)+1];
}
}
}
6 changes: 3 additions & 3 deletions src/com/amaze/filemanager/fragments/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -1026,10 +1026,10 @@ public void onNegative(MaterialDialog materialDialog) {
return true;
case R.id.openwith:
if (results)utils.openunknown(new File(slist.get(
(plist.get(0))).getDesc()), getActivity());
(plist.get(0))).getDesc()), getActivity(), true);
else
utils.openunknown(new File(list.get(
(plist.get(0))).getDesc()), getActivity());
(plist.get(0))).getDesc()), getActivity(), true);

return true;
case R.id.permissions:
Expand Down Expand Up @@ -1545,4 +1545,4 @@ public void onClick(View view) {
});

}
}
}
13 changes: 8 additions & 5 deletions src/com/amaze/filemanager/utils/Futils.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,18 @@ public String getFileExtension(String url) {
}


public void openunknown(File f, Context c) {
public void openunknown(File f, Context c, boolean forcechooser) {
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);

String type = MimeTypes.getMimeType(f);
if(type!=null && type.trim().length()!=0 && !type.equals("*/*"))
{intent.setDataAndType(Uri.fromFile(f), type);
Intent startintent;
if (forcechooser) startintent=Intent.createChooser(intent, c.getResources().getString(R.string.openwith));
else startintent=intent;
try {
c.startActivity(intent);
c.startActivity(startintent);
} catch (ActivityNotFoundException e) {
e.printStackTrace();
Toast.makeText(c,R.string.noappfound,Toast.LENGTH_SHORT).show();
Expand Down Expand Up @@ -502,7 +505,7 @@ public void openFile(final File f, final MainActivity m) {
m.startActivity(intent);
}else {
try {
openunknown(f, m);
openunknown(f, m, false);
} catch (Exception e) {
Toast.makeText(m, getString(m, R.string.noappfound),Toast.LENGTH_LONG).show();
openWith(f, m);
Expand All @@ -514,7 +517,7 @@ public void showPackageDialog(final File f,final MainActivity m){
mat.title(R.string.packageinstaller).content(R.string.pitext).positiveText(R.string.install).negativeText(R.string.view).neutralText(R.string.cancel).callback(new MaterialDialog.Callback() {
@Override
public void onPositive(MaterialDialog materialDialog) {
openunknown(f,m);
openunknown(f,m,false);
}

@Override
Expand Down Expand Up @@ -911,4 +914,4 @@ public int parseSpecialPermissions(String permission) {

return tmp;
}
}
}

0 comments on commit 485de2c

Please sign in to comment.