mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-22 12:03:09 -04:00
Increment: Improve flow of LocalFileTransfer activity
- File receiver device can not initiate connection anymore - Activity closes on both devices once transfer is complete
This commit is contained in:
parent
459a087728
commit
2066db6bd9
@ -77,6 +77,7 @@ public class DeviceListFragment extends ListFragment implements WifiP2pManager.P
|
||||
private boolean fileSender = false;
|
||||
private ArrayList<Uri> fileUriList;
|
||||
private int totalFiles = -1;
|
||||
private int totalFilesSent = 0;
|
||||
private ArrayList<String> fileNames;
|
||||
|
||||
@Override
|
||||
@ -141,6 +142,9 @@ public class DeviceListFragment extends ListFragment implements WifiP2pManager.P
|
||||
|
||||
@Override
|
||||
public void onListItemClick(ListView l, View v, int position, long id) {
|
||||
if(!isFileSender())
|
||||
return;
|
||||
|
||||
selectedPeerDevice = (WifiP2pDevice) getListAdapter().getItem(position);
|
||||
Toast.makeText(getActivity(), selectedPeerDevice.deviceName, Toast.LENGTH_SHORT).show();
|
||||
|
||||
@ -232,6 +236,14 @@ public class DeviceListFragment extends ListFragment implements WifiP2pManager.P
|
||||
return fileUriList;
|
||||
}
|
||||
|
||||
public void incrementTotalFilesSent() {
|
||||
this.totalFilesSent++;
|
||||
}
|
||||
|
||||
public boolean allFilesSent() {
|
||||
return (totalFilesSent == totalFiles);
|
||||
}
|
||||
|
||||
private void startFileTransfer() {
|
||||
if(groupInfo.groupFormed && !fileSender) {
|
||||
new FileServerAsyncTask(getActivity(), this).execute();
|
||||
@ -553,6 +565,16 @@ public class DeviceListFragment extends ListFragment implements WifiP2pManager.P
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(String s) {
|
||||
//
|
||||
deviceListFragment.incrementTotalFilesSent();
|
||||
|
||||
if(deviceListFragment.allFilesSent()) {
|
||||
deviceListFragment.getActivity().finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class FileServerAsyncTask extends AsyncTask<Void, Void, String> {
|
||||
@ -612,6 +634,7 @@ public class DeviceListFragment extends ListFragment implements WifiP2pManager.P
|
||||
super.onPostExecute(s);
|
||||
Toast.makeText(context, "File transfer complete", Toast.LENGTH_LONG).show();
|
||||
Log.d(LocalFileTransferActivity.TAG, "File transfer complete");
|
||||
deviceListFragment.getActivity().finish();
|
||||
|
||||
/*File recvFile = new File(filePath);
|
||||
Uri fileUri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID+".fileprovider",recvFile);
|
||||
|
Loading…
x
Reference in New Issue
Block a user