Skip to content

Commit

Permalink
add permission check for direct upload
Browse files Browse the repository at this point in the history
use yyyy instead of Y for date building

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
  • Loading branch information
tobiasKaminsky committed Jan 30, 2019
1 parent 8dce690 commit 5d641b4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,18 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String permissi
}
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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -70,6 +71,7 @@
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;
Expand Down Expand Up @@ -988,7 +990,11 @@ public void uploadFromCamera(Activity activity, int requestCode) {
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");
}
Expand All @@ -1013,7 +1019,7 @@ public static File createImageFile(Activity activity) {
}

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


Expand Down

0 comments on commit 5d641b4

Please sign in to comment.