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
53262352
Commit
53262352
authored
Nov 18, 2019
by
皮皮蟹
Committed by
Susan Rati Lane
Nov 18, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only show preview context menu on supported file type. (#1908)
parent
a194f49a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
37 additions
and
14 deletions
+37
-14
appinventor/appengine/src/com/google/appinventor/client/explorer/commands/ChainableCommand.java
...ppinventor/client/explorer/commands/ChainableCommand.java
+9
-0
appinventor/appengine/src/com/google/appinventor/client/explorer/commands/PreviewFileCommand.java
...inventor/client/explorer/commands/PreviewFileCommand.java
+8
-2
appinventor/appengine/src/com/google/appinventor/client/explorer/commands/ProjectNodeCommand.java
...inventor/client/explorer/commands/ProjectNodeCommand.java
+4
-0
appinventor/appengine/src/com/google/appinventor/client/explorer/project/ProjectNodeContextMenu.java
...entor/client/explorer/project/ProjectNodeContextMenu.java
+10
-9
appinventor/appengine/src/com/google/appinventor/shared/storage/StorageUtil.java
...rc/com/google/appinventor/shared/storage/StorageUtil.java
+6
-3
No files found.
appinventor/appengine/src/com/google/appinventor/client/explorer/commands/ChainableCommand.java
View file @
53262352
...
...
@@ -157,6 +157,15 @@ public abstract class ChainableCommand {
*/
protected
abstract
void
execute
(
ProjectNode
node
);
/**
* Check if the command can be used for the project node.
* @param node the project node to which the command is applied
* @return
*/
protected
boolean
isSupported
(
ProjectNode
node
)
{
return
true
;
}
/**
* Executes the next command in the chain.
*
...
...
appinventor/appengine/src/com/google/appinventor/client/explorer/commands/PreviewFileCommand.java
View file @
53262352
...
...
@@ -36,6 +36,12 @@ public class PreviewFileCommand extends ChainableCommand {
return
false
;
}
@Override
public
boolean
isSupported
(
final
ProjectNode
node
)
{
return
StorageUtil
.
isImageFile
(
node
.
getFileId
())
||
StorageUtil
.
isAudioFile
(
node
.
getFileId
())
||
StorageUtil
.
isVideoFile
(
node
.
getFileId
());
}
@Override
public
void
execute
(
final
ProjectNode
node
)
{
final
DialogBox
dialogBox
=
new
DialogBox
();
...
...
@@ -95,7 +101,7 @@ public class PreviewFileCommand extends ChainableCommand {
String
fileType
=
StorageUtil
.
getContentTypeForFilePath
(
fileSuffix
);
// Support preview for file types that all major browser support
if
(
fileType
.
endsWith
(
"png"
)
||
fileType
.
endsWith
(
"jpeg"
)
||
fileType
.
endsWith
(
"gif"
)
||
fileType
.
endsWith
(
"bmp"
))
{
||
fileType
.
endsWith
(
"bmp"
)
||
fileType
.
endsWith
(
"svg+xml"
)
)
{
Image
img
=
new
Image
(
fileUrl
);
img
.
getElement
().
getStyle
().
setProperty
(
"maxWidth"
,
"600px"
);
return
img
;
...
...
@@ -108,7 +114,7 @@ public class PreviewFileCommand extends ChainableCommand {
}
}
else
if
(
StorageUtil
.
isVideoFile
(
fileSuffix
))
{
// Video Preview
String
fileType
=
StorageUtil
.
getContentTypeForFilePath
(
fileSuffix
);
if
(
fileType
.
endsWith
(
"mp4"
)
||
fileType
.
endsWith
(
"webm"
))
{
if
(
fileType
.
endsWith
(
"
avi"
)
||
fileType
.
endsWith
(
"
mp4"
)
||
fileType
.
endsWith
(
"webm"
))
{
return
new
HTML
(
"<video width='320' height='240' controls> <source src='"
+
fileUrl
+
"' type='"
+
fileType
+
"'>"
+
MESSAGES
.
filePlaybackError
()
+
"</video>"
);
}
...
...
appinventor/appengine/src/com/google/appinventor/client/explorer/commands/ProjectNodeCommand.java
View file @
53262352
...
...
@@ -53,4 +53,8 @@ public final class ProjectNodeCommand {
public
void
execute
(
ProjectNode
node
)
{
command
.
startExecuteChain
(
actionName
,
node
);
}
public
boolean
isSupported
(
ProjectNode
node
)
{
return
command
.
isSupported
(
node
);
}
}
appinventor/appengine/src/com/google/appinventor/client/explorer/project/ProjectNodeContextMenu.java
View file @
53262352
...
...
@@ -45,15 +45,16 @@ public final class ProjectNodeContextMenu {
Window
.
getScrollTop
()
+
clientY
);
for
(
final
CommandRegistry
.
Entry
entry
:
entries
)
{
final
ProjectNodeCommand
cmd
=
entry
.
getCommand
();
// Create the menu item.
menu
.
addItem
(
cmd
.
getLabel
(),
new
Command
()
{
@Override
public
void
execute
()
{
menu
.
hide
();
cmd
.
execute
(
node
);
}
});
if
(
cmd
.
isSupported
(
node
))
{
// Create the menu item.
menu
.
addItem
(
cmd
.
getLabel
(),
new
Command
()
{
@Override
public
void
execute
()
{
menu
.
hide
();
cmd
.
execute
(
node
);
}
});
}
}
menu
.
show
();
...
...
appinventor/appengine/src/com/google/appinventor/shared/storage/StorageUtil.java
View file @
53262352
...
...
@@ -124,6 +124,9 @@ public class StorageUtil {
if
(
filePath
.
endsWith
(
".webp"
))
{
return
"image/webp"
;
}
if
(
filePath
.
endsWith
(
".svg"
))
{
return
"image/svg+xml"
;
}
// Audio File Types
if
(
filePath
.
endsWith
(
".mp3"
))
{
...
...
@@ -161,6 +164,9 @@ public class StorageUtil {
}
// Video File Types
if
(
filePath
.
endsWith
(
".avi"
))
{
return
"video/avi"
;
}
if
(
filePath
.
endsWith
(
".mp4"
))
{
return
"video/mp4"
;
}
...
...
@@ -176,9 +182,6 @@ public class StorageUtil {
if
(
filePath
.
endsWith
(
".mkv"
))
{
return
"video/mkv"
;
}
if
(
filePath
.
endsWith
(
".svg"
))
{
return
"image/svg+xml"
;
}
// Other File Types
if
(
filePath
.
endsWith
(
".apk"
))
{
...
...
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