mirror of
https://github.com/nextcloud/android.git
synced 2024-11-27 09:39:25 +03:00
Update error handling parsing the received uri
This commit is contained in:
parent
59002bfb24
commit
1b680c606b
2 changed files with 22 additions and 7 deletions
|
@ -69,6 +69,7 @@
|
|||
<string name="uploader_wrn_no_account_setup_btn_text">Setup</string>
|
||||
<string name="uploader_wrn_no_account_quit_btn_text">Quit</string>
|
||||
<string name="uploader_wrn_no_content_title">No file to upload</string>
|
||||
<string name="uploader_wrn_unknown_content_title">The content can not be uploaded</string>
|
||||
<string name="uploader_wrn_no_content_text">Sorry, the received data does not content any file.</string>
|
||||
<string name="uploader_error_forbidden_content">%1$s is not allowed to access the shared content</string>
|
||||
<string name="uploader_info_uploading">Uploading</string>
|
||||
|
|
|
@ -119,6 +119,7 @@ public class Uploader extends FileActivity
|
|||
private final static int DIALOG_WAITING = 1;
|
||||
private final static int DIALOG_NO_STREAM = 2;
|
||||
private final static int DIALOG_MULTIPLE_ACCOUNT = 3;
|
||||
private final static int DIALOG_STREAM_UNKNOWN = 4;
|
||||
|
||||
private final static int REQUEST_CODE__SETUP_ACCOUNT = REQUEST_CODE__LAST_SHARED + 1;
|
||||
|
||||
|
@ -331,6 +332,21 @@ public class Uploader extends FileActivity
|
|||
});
|
||||
builder.setOnKeyListener(onKeyListener);
|
||||
return builder.create();
|
||||
case DIALOG_STREAM_UNKNOWN:
|
||||
builder.setIcon(android.R.drawable.ic_dialog_alert);
|
||||
builder.setTitle(R.string.uploader_wrn_unknown_content_title);
|
||||
String message = String.format(getString(R.string.uploader_error_forbidden_content),
|
||||
getString(R.string.app_name));
|
||||
builder.setMessage(message);
|
||||
builder.setCancelable(false);
|
||||
builder.setNegativeButton(R.string.common_back, new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
builder.setOnKeyListener(onKeyListener);
|
||||
return builder.create();
|
||||
default:
|
||||
throw new IllegalArgumentException("Unknown dialog id: " + id);
|
||||
}
|
||||
|
@ -536,7 +552,7 @@ public class Uploader extends FileActivity
|
|||
|
||||
Uri uri = (Uri) mStream;
|
||||
String[] columnValues;
|
||||
String displayName;
|
||||
String displayName = null;
|
||||
String filePath = "";
|
||||
|
||||
if (uri != null) {
|
||||
|
@ -572,10 +588,11 @@ public class Uploader extends FileActivity
|
|||
}
|
||||
final File file = new File(filePath);
|
||||
displayName = file.getName();
|
||||
} else {
|
||||
throw new SecurityException();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(displayName != null) {
|
||||
filePath = mUploadPath + displayName;
|
||||
|
||||
mRemoteCacheData.add(filePath);
|
||||
|
@ -585,7 +602,6 @@ public class Uploader extends FileActivity
|
|||
mNumCacheFile++;
|
||||
showWaitingCopyDialog();
|
||||
copyTask.execute(params);
|
||||
|
||||
} else {
|
||||
throw new SecurityException();
|
||||
}
|
||||
|
@ -600,9 +616,7 @@ public class Uploader extends FileActivity
|
|||
}
|
||||
|
||||
} catch (SecurityException e) {
|
||||
String message = String.format(getString(R.string.uploader_error_forbidden_content),
|
||||
getString(R.string.app_name));
|
||||
Toast.makeText(this, message, Toast.LENGTH_LONG).show();
|
||||
showDialog(DIALOG_STREAM_UNKNOWN);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue