diff --git a/src/main/java/com/nutomic/syncthingandroid/fragments/FolderListFragment.java b/src/main/java/com/nutomic/syncthingandroid/fragments/FolderListFragment.java index 30f82638..9afbd30b 100644 --- a/src/main/java/com/nutomic/syncthingandroid/fragments/FolderListFragment.java +++ b/src/main/java/com/nutomic/syncthingandroid/fragments/FolderListFragment.java @@ -1,7 +1,6 @@ package com.nutomic.syncthingandroid.fragments; import android.content.Intent; -import android.net.Uri; import android.os.Bundle; import android.support.v4.app.ListFragment; import android.view.Menu; @@ -27,7 +26,7 @@ import java.util.TimerTask; * Displays a list of all existing folders. */ public class FolderListFragment extends ListFragment implements SyncthingService.OnApiChangeListener, - AdapterView.OnItemClickListener, AdapterView.OnItemLongClickListener { + AdapterView.OnItemClickListener { /** * Compares folders by labels, uses the folder ID as fallback if the label is empty @@ -76,7 +75,6 @@ public class FolderListFragment extends ListFragment implements SyncthingService setHasOptionsMenu(true); setEmptyText(getString(R.string.folder_list_empty)); getListView().setOnItemClickListener(this); - getListView().setOnItemLongClickListener(this); } /** @@ -113,18 +111,6 @@ public class FolderListFragment extends ListFragment implements SyncthingService startActivity(intent); } - /** - * Opens the folder path with a user selected app. - */ - @Override - public boolean onItemLongClick(AdapterView adapterView, View view, int i, long l) { - Intent intent = new Intent(Intent.ACTION_VIEW); - Uri uri = Uri.parse(mAdapter.getItem(i).path); - intent.setDataAndType(uri, "*/*"); - startActivity(intent); - return true; - } - @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.folder_list, menu); diff --git a/src/main/java/com/nutomic/syncthingandroid/views/FoldersAdapter.java b/src/main/java/com/nutomic/syncthingandroid/views/FoldersAdapter.java index b3b1f7c6..58f21959 100644 --- a/src/main/java/com/nutomic/syncthingandroid/views/FoldersAdapter.java +++ b/src/main/java/com/nutomic/syncthingandroid/views/FoldersAdapter.java @@ -1,7 +1,9 @@ package com.nutomic.syncthingandroid.views; import android.content.Context; +import android.content.Intent; import android.databinding.DataBindingUtil; +import android.net.Uri; import android.support.annotation.NonNull; import android.support.v4.content.ContextCompat; import android.text.TextUtils; @@ -19,6 +21,7 @@ import com.nutomic.syncthingandroid.model.Model; import com.nutomic.syncthingandroid.service.RestApi; import com.nutomic.syncthingandroid.util.Util; +import java.io.File; import java.util.HashMap; import static android.view.View.GONE; @@ -47,6 +50,12 @@ public class FoldersAdapter extends ArrayAdapter { binding.label.setText(TextUtils.isEmpty(folder.label) ? folder.id : folder.label); binding.state.setTextColor(ContextCompat.getColor(getContext(), R.color.text_green)); binding.directory.setText(folder.path); + binding.openFolder.setOnClickListener(v -> { + Intent intent = new Intent(Intent.ACTION_VIEW); + intent.setDataAndType(Uri.fromFile(new File(folder.path)), "resource/folder"); + getContext().startActivity(intent); + }); + if (model != null) { int percentage = (model.globalBytes != 0) ? Math.round(100 * model.inSyncBytes / model.globalBytes) diff --git a/src/main/res/layout/item_folder_list.xml b/src/main/res/layout/item_folder_list.xml index 07970715..77b8a581 100644 --- a/src/main/res/layout/item_folder_list.xml +++ b/src/main/res/layout/item_folder_list.xml @@ -31,6 +31,16 @@ android:layout_alignParentRight="true" android:textAppearance="?textAppearanceListItemSmall" /> + +