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
822fdfdf
Commit
822fdfdf
authored
Jan 08, 2018
by
Evan W. Patton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Detect and parse colors with different radix
Fixes #1118 Change-Id: Ib08fb391529b26ca107b5e8f67acb329e70e958e
parent
ec77db59
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
6 deletions
+16
-6
appinventor/appengine/src/com/google/appinventor/client/widgets/properties/ColorChoicePropertyEditor.java
.../client/widgets/properties/ColorChoicePropertyEditor.java
+16
-6
No files found.
appinventor/appengine/src/com/google/appinventor/client/widgets/properties/ColorChoicePropertyEditor.java
View file @
822fdfdf
...
...
@@ -130,6 +130,11 @@ public abstract class ColorChoicePropertyEditor extends PropertyEditor {
*/
private
Command
showCustomPicker
;
/**
* The default color value, as a numeric value.
*/
private
long
defaultValueArgb
;
/**
* Creates a new instance of the property editor.
*
...
...
@@ -147,14 +152,20 @@ public abstract class ColorChoicePropertyEditor extends PropertyEditor {
* @param colors language specific hex number prefix
* @param hexPrefix colors to be shown in property editor - must not be
* {@code null} or empty
* @
o
aram defaultValue the color of the default value, for display in the editor only
* @
p
aram defaultValue the color of the default value, for display in the editor only
* @param advanced specify true to show a button for the advanced picker
*/
public
ColorChoicePropertyEditor
(
final
Color
[]
colors
,
final
String
hexPrefix
,
final
String
defaultValue
,
final
boolean
advanced
)
{
this
.
hexPrefix
=
hexPrefix
;
this
.
colors
=
colors
;
this
.
advanced
=
advanced
;
this
.
defaultValue
=
defaultValue
.
substring
(
4
);
if
(
defaultValue
.
startsWith
(
hexPrefix
))
{
this
.
defaultValue
=
defaultValue
.
substring
(
hexPrefix
.
length
()-
6
);
// Take last 6 digits (assumes RRGGBB format)
this
.
defaultValueArgb
=
Long
.
valueOf
(
"FF"
+
this
.
defaultValue
,
16
)
&
0xFFFFFFFF
L
;
}
else
{
this
.
defaultValue
=
defaultValue
;
this
.
defaultValueArgb
=
Long
.
valueOf
(
defaultValue
,
10
)
&
0xFFFFFFFF
L
;
}
// Initialize UI
List
<
DropDownItem
>
choices
=
Lists
.
newArrayList
();
...
...
@@ -253,12 +264,11 @@ public abstract class ColorChoicePropertyEditor extends PropertyEditor {
}
long
argbValue
=
Long
.
valueOf
(
propertyValue
,
radix
)
&
0xFFFFFFFF
L
;
long
defaultArgbValue
=
Long
.
valueOf
(
"FF"
+
defaultValue
,
radix
)
&
0xFFFFFFFF
L
;
if
(
argbValue
==
defaultArgbValue
||
argbValue
==
0
)
{
if
(
argbValue
==
this
.
defaultValueArgb
||
argbValue
==
0
)
{
selectedColorMenu
.
setHTML
(
Color
.
getHtmlDescription
(
defaultValue
,
Ode
.
MESSAGES
.
defaultColor
()));
if
(
advanced
)
{
selectedColorMenu
.
replaceLastItem
(
new
DropDownItem
(
WIDGET_NAME
,
makeCustomHTML
(
defaultArgbValue
),
showCustomPicker
));
setPickerColor
(
defaultArgbValue
);
selectedColorMenu
.
replaceLastItem
(
new
DropDownItem
(
WIDGET_NAME
,
makeCustomHTML
(
this
.
defaultValueArgb
),
showCustomPicker
));
setPickerColor
(
this
.
defaultValueArgb
);
}
return
;
}
...
...
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