Added confirm dialog before downloading movies/episodes/albums, to prevent the user from starting a download by mistake (which can't be stopped afterwards)
This commit is contained in:
parent
db2e7a4672
commit
b0ada58bc5
|
@ -300,6 +300,12 @@ public class AlbumDetailsFragment extends Fragment
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DialogInterface.OnClickListener noopClickListener =
|
||||||
|
new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) { }
|
||||||
|
};
|
||||||
|
|
||||||
// Check if the directory exists and whether to overwrite it
|
// Check if the directory exists and whether to overwrite it
|
||||||
File file = new File(songInfoList.get(0).getAbsoluteDirectoryPath());
|
File file = new File(songInfoList.get(0).getAbsoluteDirectoryPath());
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
|
@ -324,18 +330,23 @@ public class AlbumDetailsFragment extends Fragment
|
||||||
callbackHandler);
|
callbackHandler);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.setNegativeButton(android.R.string.cancel,
|
.setNegativeButton(android.R.string.cancel, noopClickListener)
|
||||||
|
.show();
|
||||||
|
} else {
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||||
|
builder.setTitle(R.string.download)
|
||||||
|
.setMessage(R.string.confirm_album_download)
|
||||||
|
.setPositiveButton(android.R.string.ok,
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
// Nothing to do
|
FileDownloadHelper.downloadFiles(getActivity(), hostInfo,
|
||||||
|
songInfoList, FileDownloadHelper.OVERWRITE_FILES,
|
||||||
|
callbackHandler);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
.setNegativeButton(android.R.string.cancel, noopClickListener)
|
||||||
.show();
|
.show();
|
||||||
} else {
|
|
||||||
FileDownloadHelper.downloadFiles(getActivity(), hostInfo,
|
|
||||||
songInfoList, FileDownloadHelper.DOWNLOAD_WITH_NEW_NAME,
|
|
||||||
callbackHandler);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -460,6 +460,12 @@ public class MovieDetailsFragment extends Fragment
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DialogInterface.OnClickListener noopClickListener =
|
||||||
|
new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) { }
|
||||||
|
};
|
||||||
|
|
||||||
// Check if the directory exists and whether to overwrite it
|
// Check if the directory exists and whether to overwrite it
|
||||||
File file = new File(movieDownloadInfo.getAbsoluteFilePath());
|
File file = new File(movieDownloadInfo.getAbsoluteFilePath());
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
|
@ -484,18 +490,24 @@ public class MovieDetailsFragment extends Fragment
|
||||||
callbackHandler);
|
callbackHandler);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.setNegativeButton(android.R.string.cancel,
|
.setNegativeButton(android.R.string.cancel, noopClickListener)
|
||||||
new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
// Nothing to do
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.show();
|
.show();
|
||||||
} else {
|
} else {
|
||||||
FileDownloadHelper.downloadFiles(getActivity(), hostInfo,
|
// Confirm that the user really wants to download the file
|
||||||
movieDownloadInfo, FileDownloadHelper.DOWNLOAD_WITH_NEW_NAME,
|
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||||
callbackHandler);
|
builder.setTitle(R.string.download)
|
||||||
|
.setMessage(R.string.confirm_movie_download)
|
||||||
|
.setPositiveButton(android.R.string.ok,
|
||||||
|
new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
FileDownloadHelper.downloadFiles(getActivity(), hostInfo,
|
||||||
|
movieDownloadInfo, FileDownloadHelper.OVERWRITE_FILES,
|
||||||
|
callbackHandler);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setNegativeButton(android.R.string.cancel, noopClickListener)
|
||||||
|
.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -444,6 +444,12 @@ public class TVShowEpisodeDetailsFragment extends Fragment
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DialogInterface.OnClickListener noopClickListener =
|
||||||
|
new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) { }
|
||||||
|
};
|
||||||
|
|
||||||
// Check if the directory exists and whether to overwrite it
|
// Check if the directory exists and whether to overwrite it
|
||||||
File file = new File(tvshowDownloadInfo.getAbsoluteFilePath());
|
File file = new File(tvshowDownloadInfo.getAbsoluteFilePath());
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
|
@ -468,18 +474,24 @@ public class TVShowEpisodeDetailsFragment extends Fragment
|
||||||
callbackHandler);
|
callbackHandler);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.setNegativeButton(android.R.string.cancel,
|
.setNegativeButton(android.R.string.cancel, noopClickListener)
|
||||||
new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
// Nothing to do
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.show();
|
.show();
|
||||||
} else {
|
} else {
|
||||||
FileDownloadHelper.downloadFiles(getActivity(), hostInfo,
|
// Confirm that the user really wants to download the file
|
||||||
tvshowDownloadInfo, FileDownloadHelper.DOWNLOAD_WITH_NEW_NAME,
|
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||||
callbackHandler);
|
builder.setTitle(R.string.download)
|
||||||
|
.setMessage(R.string.confirm_episode_download)
|
||||||
|
.setPositiveButton(android.R.string.ok,
|
||||||
|
new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
FileDownloadHelper.downloadFiles(getActivity(), hostInfo,
|
||||||
|
tvshowDownloadInfo, FileDownloadHelper.OVERWRITE_FILES,
|
||||||
|
callbackHandler);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setNegativeButton(android.R.string.cancel, noopClickListener)
|
||||||
|
.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -234,6 +234,10 @@
|
||||||
<string name="seen">Seen</string>
|
<string name="seen">Seen</string>
|
||||||
<string name="download">Download</string>
|
<string name="download">Download</string>
|
||||||
|
|
||||||
|
<string name="confirm_movie_download">Are you sure you want to download this movie?\nThe movie will be downloaded in the background, but it can take a while to finish.</string>
|
||||||
|
<string name="confirm_episode_download">Are you sure you want to download this episode?\nThe episode will be downloaded in the background, but it can take a while to finish.</string>
|
||||||
|
<string name="confirm_album_download">Are you sure you want to download this album?\nThe album will be downloaded in the background, but it can take a while to finish.</string>
|
||||||
|
|
||||||
<string name="download_file_exists">File already exists.\nDo you want to overwrite it or download with a new name?</string>
|
<string name="download_file_exists">File already exists.\nDo you want to overwrite it or download with a new name?</string>
|
||||||
<string name="download_dir_exists">Download directory already exists.\nIf any files have the same name, do you want to overwrite them or download them with a new name?</string>
|
<string name="download_dir_exists">Download directory already exists.\nIf any files have the same name, do you want to overwrite them or download them with a new name?</string>
|
||||||
<string name="overwrite">Overwrite</string>
|
<string name="overwrite">Overwrite</string>
|
||||||
|
|
Loading…
Reference in New Issue