mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-12-23 03:11:30 +00:00
Added button to open folder from list (fixes #770)
This commit is contained in:
parent
e0412ec51b
commit
ea9af597a5
3 changed files with 20 additions and 15 deletions
|
@ -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);
|
||||
|
|
|
@ -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<Folder> {
|
|||
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)
|
||||
|
|
|
@ -31,6 +31,16 @@
|
|||
android:layout_alignParentRight="true"
|
||||
android:textAppearance="?textAppearanceListItemSmall" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/open_folder"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:src="@drawable/ic_folder_black_24dp"
|
||||
android:background="@null"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/directory"
|
||||
android:layout_width="wrap_content"
|
||||
|
|
Loading…
Reference in a new issue