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
897d96d3
Unverified
Commit
897d96d3
authored
May 10, 2019
by
Evan W. Patton
Committed by
Jeffrey I. Schiller
May 10, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make Image.Picture ask for read permissions if needed
Change-Id: I98a2aa0ccb8b231634b4122044e7a82ee9e801bd
parent
b730fa8d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
2 deletions
+19
-2
appinventor/components/src/com/google/appinventor/components/runtime/Image.java
.../src/com/google/appinventor/components/runtime/Image.java
+19
-2
No files found.
appinventor/components/src/com/google/appinventor/components/runtime/Image.java
View file @
897d96d3
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
package
com.google.appinventor.components.runtime
;
package
com.google.appinventor.components.runtime
;
import
android.Manifest
;
import
com.google.appinventor.components.annotations.DesignerComponent
;
import
com.google.appinventor.components.annotations.DesignerComponent
;
import
com.google.appinventor.components.annotations.DesignerProperty
;
import
com.google.appinventor.components.annotations.DesignerProperty
;
import
com.google.appinventor.components.annotations.PropertyCategory
;
import
com.google.appinventor.components.annotations.PropertyCategory
;
...
@@ -41,7 +42,8 @@ import java.io.IOException;
...
@@ -41,7 +42,8 @@ import java.io.IOException;
"and other aspects of the Image's appearance, can be specified in the "
+
"and other aspects of the Image's appearance, can be specified in the "
+
"Designer or in the Blocks Editor."
)
"Designer or in the Blocks Editor."
)
@SimpleObject
@SimpleObject
@UsesPermissions
(
permissionNames
=
"android.permission.INTERNET"
)
@UsesPermissions
(
permissionNames
=
"android.permission.INTERNET,"
+
"android.permission.READ_EXTERNAL_STORAGE"
)
public
final
class
Image
extends
AndroidViewComponent
{
public
final
class
Image
extends
AndroidViewComponent
{
private
final
ImageView
view
;
private
final
ImageView
view
;
...
@@ -101,7 +103,22 @@ public final class Image extends AndroidViewComponent {
...
@@ -101,7 +103,22 @@ public final class Image extends AndroidViewComponent {
@DesignerProperty
(
editorType
=
PropertyTypeConstants
.
PROPERTY_TYPE_ASSET
,
@DesignerProperty
(
editorType
=
PropertyTypeConstants
.
PROPERTY_TYPE_ASSET
,
defaultValue
=
""
)
defaultValue
=
""
)
@SimpleProperty
@SimpleProperty
public
void
Picture
(
String
path
)
{
public
void
Picture
(
final
String
path
)
{
if
(
MediaUtil
.
isExternalFile
(
path
)
&&
container
.
$form
().
isDeniedPermission
(
Manifest
.
permission
.
READ_EXTERNAL_STORAGE
))
{
container
.
$form
().
askPermission
(
Manifest
.
permission
.
READ_EXTERNAL_STORAGE
,
new
PermissionResultHandler
()
{
@Override
public
void
HandlePermissionResponse
(
String
permission
,
boolean
granted
)
{
if
(
granted
)
{
Picture
(
path
);
}
else
{
container
.
$form
().
dispatchPermissionDeniedEvent
(
Image
.
this
,
"Picture"
,
permission
);
}
}
});
return
;
}
picturePath
=
(
path
==
null
)
?
""
:
path
;
picturePath
=
(
path
==
null
)
?
""
:
path
;
Drawable
drawable
;
Drawable
drawable
;
...
...
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