summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Brabham <optedoblivion@gmail.com>2016-05-11 17:24:29 (GMT)
committerJoey Rizzoli <joey@cyanogenmoditalia.it>2016-06-05 08:56:23 (GMT)
commitd6d2be2535ab9dfc254b356e10d2374b6950a5ab (patch)
treea90d50017029a67b644d37626f1e51633a742cc3
parent6359b692d4f50bfbf916e4c578ed2c827c3f7a37 (diff)
downloadandroid_packages_apps_Gello-d6d2be2535ab9dfc254b356e10d2374b6950a5ab.zip
android_packages_apps_Gello-d6d2be2535ab9dfc254b356e10d2374b6950a5ab.tar.gz
android_packages_apps_Gello-d6d2be2535ab9dfc254b356e10d2374b6950a5ab.tar.bz2
Alter download flow to request permissions before anything else.
Change-Id: I6ccbdbcc39a631035b4f8a8d6edae0f5a4dc8e36 Ticket-Id: CYNGNOS-2266 Ticket-Id: FEIJ-368
-rw-r--r--src/com/android/browser/DownloadSettings.java90
1 files changed, 49 insertions, 41 deletions
diff --git a/src/com/android/browser/DownloadSettings.java b/src/com/android/browser/DownloadSettings.java
index aa528d2..ee60210 100644
--- a/src/com/android/browser/DownloadSettings.java
+++ b/src/com/android/browser/DownloadSettings.java
@@ -212,54 +212,62 @@ public class DownloadSettings extends Activity {
};
private OnClickListener downloadStartListener = new OnClickListener() {
-
@Override
public void onClick(View v) {
- filenameBase = getFilenameBaseFromUserEnter();
- // check the filename user enter is null or not
- if (TextUtils.isEmpty(filenameBase) || TextUtils.isEmpty(downloadPath)) {
- DownloadHandler.showFilenameEmptyDialog(DownloadSettings.this);
- return;
- }
+ onHandleDownload();
+ }
+ };
- filenameExtension = DownloadHandler.getFilenameExtension(filename);
- filename = filenameBase + "." + filenameExtension;
+ private void onHandleDownload() {
- // check the storage status
- if (!DownloadHandler.isStorageStatusOK(DownloadSettings.this, filename, downloadPath)) {
- return;
- }
+ filenameBase = getFilenameBaseFromUserEnter();
- // check the storage memory enough or not
- try {
- DownloadHandler.setAppointedFolder(downloadPath);
- } catch (Exception e) {
- DownloadHandler.showNoEnoughMemoryDialog(DownloadSettings.this);
- return;
- }
- boolean isNoEnoughMemory = DownloadHandler.manageNoEnoughMemory(contentLength,
- downloadPath);
- if (isNoEnoughMemory) {
- DownloadHandler.showNoEnoughMemoryDialog(DownloadSettings.this);
- return;
- }
+ // check the filename user enter is null or not
+ if (TextUtils.isEmpty(filenameBase) || TextUtils.isEmpty(downloadPath)) {
+ DownloadHandler.showFilenameEmptyDialog(DownloadSettings.this);
+ return;
+ }
- // check the download file is exist or not
- String fullFilename = downloadPath + "/" + filename;
- if (mimetype != null && new File(fullFilename).exists()) {
- DownloadHandler.fileExistQueryDialog(DownloadSettings.this);
- return;
- }
+ // check for permission
+ if (!hasPermission(permission.WRITE_EXTERNAL_STORAGE)) {
+ requestPermissions(new String[] {permission.WRITE_EXTERNAL_STORAGE},
+ ++nextRequestCode);
+ return;
+ }
- // check for permission
- if (!hasPermission(permission.WRITE_EXTERNAL_STORAGE)) {
- requestPermissions(new String[] {permission.WRITE_EXTERNAL_STORAGE},
- ++nextRequestCode);
- } else {
- download();
- }
+ filenameExtension = DownloadHandler.getFilenameExtension(filename);
+ filename = filenameBase + "." + filenameExtension;
+
+ // check the storage status
+ if (!DownloadHandler.isStorageStatusOK(DownloadSettings.this, filename, downloadPath)) {
+ return;
}
- };
+
+ // check the storage memory enough or not
+ try {
+ DownloadHandler.setAppointedFolder(downloadPath);
+ } catch (Exception e) {
+ DownloadHandler.showNoEnoughMemoryDialog(DownloadSettings.this);
+ return;
+ }
+ boolean isNoEnoughMemory = DownloadHandler.manageNoEnoughMemory(contentLength,
+ downloadPath);
+ if (isNoEnoughMemory) {
+ DownloadHandler.showNoEnoughMemoryDialog(DownloadSettings.this);
+ return;
+ }
+
+ // check the download file is exist or not
+ String fullFilename = downloadPath + "/" + filename;
+ if (mimetype != null && new File(fullFilename).exists()) {
+ DownloadHandler.fileExistQueryDialog(DownloadSettings.this);
+ return;
+ }
+
+ download();
+
+ }
+
@Override
public void onRequestPermissionsResult(int requestCode,
@@ -267,7 +275,7 @@ public class DownloadSettings extends Activity {
if (nextRequestCode == requestCode) {
if (grantResults.length > 0
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
- download();
+ onHandleDownload();
} else {
finish();
}