Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
appinventor-sources
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
appinventor-sources
Commits
2d5a7d52
Commit
2d5a7d52
authored
Nov 15, 2019
by
Evan W. Patton
Committed by
Susan Rati Lane
Nov 15, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make Camera ask permission to write to external storage (#1906)
Change-Id: I44b3780a0475b66555b84a0e3ed94de2196fdb6e
parent
caa489f3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
21 deletions
+11
-21
appinventor/components/src/com/google/appinventor/components/runtime/Camera.java
...src/com/google/appinventor/components/runtime/Camera.java
+11
-21
No files found.
appinventor/components/src/com/google/appinventor/components/runtime/Camera.java
View file @
2d5a7d52
...
@@ -15,6 +15,7 @@ import com.google.appinventor.components.annotations.SimpleProperty;
...
@@ -15,6 +15,7 @@ import com.google.appinventor.components.annotations.SimpleProperty;
import
com.google.appinventor.components.annotations.UsesPermissions
;
import
com.google.appinventor.components.annotations.UsesPermissions
;
import
com.google.appinventor.components.common.ComponentCategory
;
import
com.google.appinventor.components.common.ComponentCategory
;
import
com.google.appinventor.components.common.YaVersion
;
import
com.google.appinventor.components.common.YaVersion
;
import
com.google.appinventor.components.runtime.util.BulkPermissionRequest
;
import
com.google.appinventor.components.runtime.util.ErrorMessages
;
import
com.google.appinventor.components.runtime.util.ErrorMessages
;
import
com.google.appinventor.components.runtime.util.NougatUtil
;
import
com.google.appinventor.components.runtime.util.NougatUtil
;
...
@@ -114,35 +115,24 @@ public class Camera extends AndroidNonvisibleComponent
...
@@ -114,35 +115,24 @@ public class Camera extends AndroidNonvisibleComponent
*/
*/
@SimpleFunction
@SimpleFunction
public
void
TakePicture
()
{
public
void
TakePicture
()
{
Date
date
=
new
Date
();
String
state
=
Environment
.
getExternalStorageState
();
if
(!
havePermission
)
{
if
(!
havePermission
)
{
final
Camera
me
=
this
;
final
Camera
me
=
this
;
form
.
runOnUiThread
(
new
Runnable
()
{
form
.
askPermission
(
new
BulkPermissionRequest
(
this
,
"TakePicture"
,
@Override
Manifest
.
permission
.
CAMERA
,
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
)
{
public
void
run
()
{
form
.
askPermission
(
Manifest
.
permission
.
CAMERA
,
new
PermissionResultHandler
()
{
@Override
@Override
public
void
HandlePermissionResponse
(
String
permission
,
boolean
granted
)
{
public
void
onGranted
()
{
if
(
granted
)
{
me
.
havePermission
=
true
;
me
.
havePermission
=
true
;
me
.
TakePicture
();
me
.
TakePicture
();
}
else
{
form
.
dispatchPermissionDeniedEvent
(
me
,
"TakePicture"
,
Manifest
.
permission
.
CAMERA
);
}
}
});
}
}
});
});
return
;
return
;
}
}
String
state
=
Environment
.
getExternalStorageState
();
if
(
Environment
.
MEDIA_MOUNTED
.
equals
(
state
))
{
if
(
Environment
.
MEDIA_MOUNTED
.
equals
(
state
))
{
Log
.
i
(
"CameraComponent"
,
"External storage is available and writable"
);
Log
.
i
(
"CameraComponent"
,
"External storage is available and writable"
);
imageFile
=
Uri
.
fromFile
(
new
File
(
Environment
.
getExternalStorageDirectory
(),
imageFile
=
Uri
.
fromFile
(
new
File
(
Environment
.
getExternalStorageDirectory
(),
"/Pictures/app_inventor_"
+
date
.
getTime
()
"/Pictures/app_inventor_"
+
new
Date
()
.
getTime
()
+
".jpg"
));
+
".jpg"
));
ContentValues
values
=
new
ContentValues
();
ContentValues
values
=
new
ContentValues
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment