1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-12-03 17:51:17 +00:00

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

View file

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