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
ce9cb23a
Unverified
Commit
ce9cb23a
authored
Apr 17, 2020
by
Ramanathi
Committed by
GitHub
Apr 17, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Propose valid project names in creating new project (#2143)
parent
bb7c8241
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
13 deletions
+40
-13
appinventor/appengine/src/com/google/appinventor/client/widgets/LabeledTextBox.java
...com/google/appinventor/client/widgets/LabeledTextBox.java
+8
-2
appinventor/appengine/src/com/google/appinventor/client/wizards/youngandroid/NewYoungAndroidProjectWizard.java
...nt/wizards/youngandroid/NewYoungAndroidProjectWizard.java
+3
-2
appinventor/appengine/src/com/google/appinventor/client/wizards/youngandroid/RemixedYoungAndroidProjectWizard.java
...izards/youngandroid/RemixedYoungAndroidProjectWizard.java
+2
-2
appinventor/appengine/src/com/google/appinventor/client/youngandroid/TextValidators.java
...oogle/appinventor/client/youngandroid/TextValidators.java
+27
-7
No files found.
appinventor/appengine/src/com/google/appinventor/client/widgets/LabeledTextBox.java
View file @
ce9cb23a
...
...
@@ -179,8 +179,14 @@ public class LabeledTextBox extends Composite {
*/
private
void
setErrorStyles
(
boolean
validationResult
)
{
if
(
validationResult
)
{
textbox
.
getElement
().
getStyle
().
setBorderColor
(
defaultTextBoxColor
);
errorLabel
.
setText
(
""
);
if
(
errorMessage
.
length
()
>
0
)
{
// handling warnings
String
warningColor
=
"yellow"
;
textbox
.
getElement
().
getStyle
().
setBorderColor
(
warningColor
);
errorLabel
.
setText
(
errorMessage
);
}
else
{
textbox
.
getElement
().
getStyle
().
setBorderColor
(
defaultTextBoxColor
);
errorLabel
.
setText
(
""
);
}
}
else
{
String
errorColor
=
"red"
;
textbox
.
getElement
().
getStyle
().
setBorderColor
(
errorColor
);
...
...
appinventor/appengine/src/com/google/appinventor/client/wizards/youngandroid/NewYoungAndroidProjectWizard.java
View file @
ce9cb23a
...
...
@@ -60,6 +60,7 @@ public final class NewYoungAndroidProjectWizard extends NewProjectWizard {
disableOkButton
();
return
false
;
}
errorMessage
=
TextValidators
.
getWarningMessages
(
value
);
enableOkButton
();
return
true
;
}
...
...
@@ -113,8 +114,8 @@ public final class NewYoungAndroidProjectWizard extends NewProjectWizard {
initFinishCommand
(
new
Command
()
{
@Override
public
void
execute
()
{
String
projectName
=
projectNameTextBox
.
getText
();
String
projectName
=
projectNameTextBox
.
getText
()
.
trim
()
;
projectName
=
projectName
.
replaceAll
(
"( )+"
,
" "
).
replace
(
" "
,
"_"
);
if
(
TextValidators
.
checkNewProjectName
(
projectName
))
{
String
packageName
=
StringUtils
.
getProjectPackage
(
Ode
.
getInstance
().
getUser
().
getUserEmail
(),
projectName
);
...
...
appinventor/appengine/src/com/google/appinventor/client/wizards/youngandroid/RemixedYoungAndroidProjectWizard.java
View file @
ce9cb23a
...
...
@@ -68,7 +68,7 @@ public final class RemixedYoungAndroidProjectWizard extends NewProjectWizard { /
initFinishCommand
(
new
Command
()
{
@Override
public
void
execute
()
{
String
projectName
=
projectNameTextBox
.
getText
();
String
projectName
=
projectNameTextBox
.
getText
()
.
trim
()
;
final
PopupPanel
popup
=
new
PopupPanel
(
true
);
final
FlowPanel
content
=
new
FlowPanel
();
popup
.
setWidget
(
content
);
...
...
@@ -77,7 +77,7 @@ public final class RemixedYoungAndroidProjectWizard extends NewProjectWizard { /
// loading indicator will be hided or forced to be hided in gallery.loadSourceFile
content
.
add
(
loading
);
popup
.
center
();
boolean
success
=
gallery
.
loadSourceFile
(
app
,
projectNameTextBox
.
getText
(),
popup
);
boolean
success
=
gallery
.
loadSourceFile
(
app
,
projectNameTextBox
.
getText
()
.
trim
()
,
popup
);
if
(
success
){
gallery
.
appWasDownloaded
(
app
.
getGalleryAppId
(),
app
.
getDeveloperId
());
}
...
...
appinventor/appengine/src/com/google/appinventor/client/youngandroid/TextValidators.java
View file @
ce9cb23a
...
...
@@ -187,15 +187,35 @@ public final class TextValidators {
String
errorMessage
=
""
;
String
noWhitespace
=
"[\\S]+"
;
String
firstCharacterLetter
=
"[A-Za-z].*"
;
if
(!
filename
.
matches
(
"[A-Za-z][A-Za-z0-9_]*"
)
&&
filename
.
length
()
>
0
)
{
if
(!
filename
.
matches
(
noWhitespace
))
{
//Check to make sure that this project does not contain any whitespace
errorMessage
=
MESSAGES
.
whitespaceProjectNameError
();
}
else
if
(!
filename
.
matches
(
firstCharacterLetter
))
{
//Check to make sure that the first character is a letter
errorMessage
=
MESSAGES
.
firstCharProjectNameError
();
}
else
{
//The text contains a character that is not a letter, number, or underscore
errorMessage
=
MESSAGES
.
invalidCharProjectNameError
();
String
temp
=
filename
.
trim
().
replaceAll
(
"( )+"
,
" "
).
replace
(
" "
,
"_"
);
if
(
temp
.
length
()
>
0
)
{
if
(!
temp
.
matches
(
"[A-Za-z][A-Za-z0-9_]*"
))
{
if
(!
temp
.
matches
(
firstCharacterLetter
))
{
//Check to make sure that the first character is a letter
errorMessage
=
MESSAGES
.
firstCharProjectNameError
();
}
else
{
//The text contains a character that is not a letter, number, or underscore
errorMessage
=
MESSAGES
.
invalidCharProjectNameError
();
}
}
}
return
errorMessage
;
}
/**
* Determines human-readable message for specific warning if there are no errors.
* @param filename The filename (not path) of uploaded file
* @return String representing warning message, empty string if no warning and no error
*/
public
static
String
getWarningMessages
(
String
filename
)
{
String
warningMessage
=
""
;
if
(
getErrorMessage
(
filename
).
length
()
==
0
&&
filename
.
trim
().
length
()
>
0
)
{
if
(!
filename
.
matches
(
"[A-Za-z][A-Za-z0-9_]*"
))
{
// check to make sure if filename has no spaces
String
errorMessage
=
MESSAGES
.
whitespaceProjectNameError
();
filename
=
filename
.
trim
().
replaceAll
(
"( )+"
,
" "
).
replace
(
" "
,
"_"
);
warningMessage
=
errorMessage
+
". \n '"
+
filename
+
"' will be used if continued."
;
}
}
return
warningMessage
;
}
}
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