mirror of
https://github.com/nextcloud/android.git
synced 2024-11-27 17:46:37 +03:00
add permission check for direct upload
use yyyy instead of Y for date building Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
This commit is contained in:
parent
8dce69087f
commit
5d641b4e32
2 changed files with 20 additions and 2 deletions
|
@ -404,6 +404,18 @@ public class FileDisplayActivity extends HookActivity
|
|||
}
|
||||
return;
|
||||
}
|
||||
case PermissionUtil.PERMISSIONS_CAMERA: {
|
||||
// If request is cancelled, result arrays are empty.
|
||||
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
// permission was granted
|
||||
getFileOperationsHelper()
|
||||
.uploadFromCamera(this, FileDisplayActivity.REQUEST_CODE__UPLOAD_FROM_CAMERA);
|
||||
} else {
|
||||
// permission denied
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
default:
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
package com.owncloud.android.ui.helpers;
|
||||
|
||||
import android.Manifest;
|
||||
import android.accounts.Account;
|
||||
import android.app.Activity;
|
||||
import android.content.ActivityNotFoundException;
|
||||
|
@ -70,6 +71,7 @@ import com.owncloud.android.ui.events.SyncEventFinished;
|
|||
import com.owncloud.android.utils.ConnectivityUtils;
|
||||
import com.owncloud.android.utils.DisplayUtils;
|
||||
import com.owncloud.android.utils.FileStorageUtils;
|
||||
import com.owncloud.android.utils.PermissionUtil;
|
||||
import com.owncloud.android.utils.UriUtils;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
@ -988,7 +990,11 @@ public class FileOperationsHelper {
|
|||
pictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri);
|
||||
|
||||
if (pictureIntent.resolveActivity(activity.getPackageManager()) != null) {
|
||||
activity.startActivityForResult(pictureIntent, requestCode);
|
||||
if (PermissionUtil.checkSelfPermission(activity, Manifest.permission.CAMERA)) {
|
||||
activity.startActivityForResult(pictureIntent, requestCode);
|
||||
} else {
|
||||
PermissionUtil.requestCameraPermission(activity);
|
||||
}
|
||||
} else {
|
||||
DisplayUtils.showSnackMessage(activity, "No Camera found");
|
||||
}
|
||||
|
@ -1013,7 +1019,7 @@ public class FileOperationsHelper {
|
|||
}
|
||||
|
||||
public static String getCapturedImageName() {
|
||||
return new SimpleDateFormat("Y-MM-dd_HHmmss", Locale.US).format(new Date()) + ".jpg";
|
||||
return new SimpleDateFormat("yyyy-MM-dd_HHmmss", Locale.US).format(new Date()) + ".jpg";
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue