Dont crash if no file manager installed (fixes #822)

This commit is contained in:
Felix Ableitner 2016-12-26 09:33:28 +09:00
parent e6527ff16a
commit f2498920f0
2 changed files with 9 additions and 1 deletions

View File

@ -1,5 +1,6 @@
package com.nutomic.syncthingandroid.views;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.databinding.DataBindingUtil;
@ -12,6 +13,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import android.widget.Toast;
import com.nutomic.syncthingandroid.BuildConfig;
import com.nutomic.syncthingandroid.R;
@ -53,7 +55,11 @@ public class FoldersAdapter extends ArrayAdapter<Folder> {
binding.openFolder.setOnClickListener(v -> {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(folder.path)), "resource/folder");
getContext().startActivity(intent);
try {
getContext().startActivity(intent);
} catch (ActivityNotFoundException e) {
Toast.makeText(getContext(), R.string.toast_no_file_manager, Toast.LENGTH_SHORT).show();
}
});
if (model != null) {

View File

@ -74,6 +74,8 @@ Please report any problems you encounter via Github.</string>
<!-- Format string for folder file count -->
<string name="files">%1$d / %2$d Files</string>
<string name="toast_no_file_manager">No compatible file manager found</string>
<!-- DevicesFragment -->