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:
tobiasKaminsky 2019-01-30 09:13:15 +01:00
parent 8dce69087f
commit 5d641b4e32
No known key found for this signature in database
GPG key ID: 0E00D4D47D0C5AF7
2 changed files with 20 additions and 2 deletions

View file

@ -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);
}

View file

@ -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";
}