Skip to content

Commit

Permalink
Merge branch 'mit-cml:master' into gsoc/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
shreyashsaitwal authored Jul 21, 2024
2 parents a0abae4 + 9dfe82c commit 14871ff
Show file tree
Hide file tree
Showing 13 changed files with 110 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ public interface OdeMessages extends Messages, AutogeneratedOdeMessages {
@Description("Text on \"OK\" button.")
String okButton();

@DefaultMessage("Reset")
@Description("Text on the \"Reset\" button.")
String resetButton();

@DefaultMessage("Dismiss")
@Description("Text on \"Dismiss\" button.")
String dismissButton();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,21 @@ private String getVFromOrigin(String text) {
return text.substring(text.indexOf(",") + 2, text.length() - 1);
}

/**
* Converts a double in the range of [0.0, 1.0] to a string. If the double is an integer value,
* then the returned value will be specified to two significant figures. Otherwise, the double
* will be converted to a string using the default conversion.
*
* @param d the double to convert
* @return the string representation of the double
*/
private static String doubleToString(double d) {
return d == 0 ? "0.0" : d == 1 ? "1.0" : Double.toString(d);
}

private void setOriginProperty(double u, double v) {
// format as string of type (u, v)
String s = "(" + Double.toString(u) + ", " + Double.toString(v) + ")";
String s = "(" + doubleToString(u) + ", " + doubleToString(v) + ")";
changeProperty(PROPERTY_NAME_MARKORIGIN, s);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@
<g:DeckPanel ui:field="deckPanel" animationEnabled="true" styleName="ode-DeckPanel">
<g:FlowPanel width="100%" >
<neo:ProjectToolbarNeo ui:field="projectToolbar" />
<box:ProjectListBox ui:field="projectListbox" />
<box:ProjectListBox ui:field="projectListbox" styleName="ode-Box ode-Box-height-100" />
</g:FlowPanel>
<g:FlowPanel styleName="ode-ProjectEditor" ui:field="projectEditor">
<neo:DesignToolbarNeo ui:field="designToolbar" />
<g:FlowPanel ui:field="workColumns" styleName="ode-WorkColumns" >
<box:PaletteBox width="265px" ui:field="paletteBox"/>
<box:PaletteBox ui:field="paletteBox" styleName="ode-Designer-LeftColumn" />
<box:ViewerBox ui:field="viewerBox" />
<g:FlowPanel ui:field="structureAndAssets">
<box:SourceStructureBox ui:field="sourceStructureBox" />
<g:FlowPanel ui:field="structureAndAssets" styleName="ode-Designer-RightColumns">
<box:SourceStructureBox ui:field="sourceStructureBox" />
<box:BlockSelectorBox />
<g:FlowPanel>
<g:Label text="{messages.assetListBoxCaption}" styleName="ode-AssetsTitle" />
<box:AssetListBox ui:field="assetListBox" />
</g:FlowPanel>
</g:FlowPanel>
<box:PropertiesBox ui:field="propertiesBox" width="222px" />
<box:PropertiesBox ui:field="propertiesBox" styleName="ode-Designer-RightColumns" />
</g:FlowPanel>
</g:FlowPanel>
<g:FlowPanel width="100%">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,10 @@ they get cut off in Windows.
padding-left: unset;
}

.ode-Box {
.ode-Box-height-100 {
height: 100%;
}


.ode-Box-content {
/*all:unset;*/
background-image: unset;
Expand Down Expand Up @@ -588,6 +587,13 @@ they get cut off in Windows.
display: flex;
}

.ode-Designer-LeftColumn {
min-width: 265px;
}
.ode-Designer-RightColumns {
min-width: 222px;
}

.ode-NavArrow {
background: #C2C2C2;}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public void execute() {
updateValue();
}}));

items.add(new DropDownItem("Subset Property Editor", MESSAGES.expertToolkitButton(), new Command() {
items.add(new DropDownItem("Subset Property Editor", MESSAGES.defaultText(), new Command() {
@Override
public void execute() {
property.setValue("");
Expand Down Expand Up @@ -642,7 +642,7 @@ public void onValueChange(ValueChangeEvent<Boolean> valueChangeEvent) {
protected void updateValue() {
LOG.info(property.getValue());
if (StringUtils.isNullOrEmpty(property.getValue())) {
dropDownButton.setCaption(MESSAGES.expertToolkitButton());
dropDownButton.setCaption(MESSAGES.defaultText());
dropDownButton.setWidth("");
} else if (Objects.equals(property.getValue().replaceAll("\\s+",""), BeginnerToolkit.INSTANCE.getToolkit().getText().replaceAll("\\s+",""))){
dropDownButton.setCaption(MESSAGES.beginnerToolkitButton());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

package com.google.appinventor.client.wizards;

import static com.google.appinventor.client.Ode.MESSAGES;

import com.google.appinventor.client.Ode;
import com.google.appinventor.client.widgets.ClonedWidget;
import com.google.appinventor.client.widgets.dnd.DragSource;
Expand All @@ -15,6 +17,7 @@
import com.google.gwt.event.dom.client.LoadHandler;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Widget;
Expand Down Expand Up @@ -59,7 +62,7 @@ public interface OriginSelectedCallback {
* @param callback the callback to execute after selecting origin
*/
public MarkOriginWizard(String imageUrl, String origin, final OriginSelectedCallback callback) {
super(Ode.MESSAGES.markOriginWizardCaption(), true, false);
super(MESSAGES.markOriginWizardCaption(), true, false);

u = Double.parseDouble(getUFromOrigin(origin));
v = Double.parseDouble(getVFromOrigin(origin));
Expand Down Expand Up @@ -145,6 +148,12 @@ public void onDrop(int x, int y) {

imageContainer.add(spriteImagePanel);
imageContainer.add(marker);
Button reset = new Button(MESSAGES.resetButton());
reset.addClickHandler((event) -> {
finishApply(callback, "(0.0, 0.0)");
hide();
});
getButtonPanel().insert(reset, 1);

addPage(imageContainer);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,10 @@ protected void enableOkButton() {
okButton.setEnabled(true);
}

protected HorizontalPanel getButtonPanel() {
return buttonPanel;
}

/*
* Hides the wizard.
* Note that we are not overriding hide() because it is called by center() which can some
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1389,6 +1389,39 @@ private static int upgradeImageSpriteProperties(Map<String, JSONValue> component
// The MarkOrigin, OriginX, and OriginY properties were added.
srcCompVersion = 9;
}
if (srcCompVersion < 10) {
JSONValue value = componentProperties.get("MarkOrigin");
if (value != null) {
String origin = value.asString().getString();
if (origin.startsWith("(") && origin.endsWith(")")) {
String[] parts = origin.substring(1, origin.length() - 1).split(", ");
double x = Double.parseDouble(parts[0]);
double y = Double.parseDouble(parts[1]);
if (x == 0.0 && y == 0.0) {
// Clean up the default value
componentProperties.remove("MarkOrigin");
}
}
}
value = componentProperties.get("OriginX");
if (value != null) {
double x = Double.parseDouble(value.asString().getString());
if (x == 0.0) {
// Clean up the default value
componentProperties.remove("OriginX");
}
}
// I haven't seen this in the wild but just in case...
value = componentProperties.get("OriginY");
if (value != null) {
double y = Double.parseDouble(value.asString().getString());
if (y == 0.0) {
// Clean up the default value
componentProperties.remove("OriginY");
}
}
srcCompVersion = 10;
}
return srcCompVersion;
}

Expand Down
3 changes: 3 additions & 0 deletions appinventor/blocklyeditor/src/versioning.js
Original file line number Diff line number Diff line change
Expand Up @@ -2202,6 +2202,9 @@ Blockly.Versioning.AllUpgradeMaps =
// The MarkOrigin, OriginX, and OriginY properties were added.
9: "noUpgrade",

// A fix for the MarkOrigin, OriginX, and OriginY properties in the designer was fixed
10: "noUpgrade"

}, // End ImageSprite upgraders

"Label": {
Expand Down
11 changes: 10 additions & 1 deletion appinventor/components-ios/src/ErrorMessages.swift
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,11 @@ import Foundation

// iOS Specific OrientationSensor Errors
case ERROR_IOS_ORIENTATION_SENSOR_DATA_ERROR = 100300


// iOS Specific Texting Errors
case ERROR_IOS_GOOGLEVOICE_NOT_SUPPORTED = 101701
case ERROR_IOS_RECEIVING_NOT_SUPPORTED = 101702

var code: Int32 {
return Int32(self.rawValue)
}
Expand Down Expand Up @@ -380,6 +384,11 @@ import Foundation

case .ERROR_IOS_ORIENTATION_SENSOR_DATA_ERROR:
return "The orientation sensor is no longer recording data due to the following error %s"

case .ERROR_IOS_GOOGLEVOICE_NOT_SUPPORTED:
return "Google Voice integration is unavailable."
case .ERROR_IOS_RECEIVING_NOT_SUPPORTED:
return "Receiving text messages is unavailable."
}
}
}
14 changes: 10 additions & 4 deletions appinventor/components-ios/src/Texting.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@ open class Texting: NonvisibleComponent, MFMessageComposeViewControllerDelegate
return false // Google Voice not supported on iOS
}
set(enabled) {
// Google Voice not supported on iOS
_form?.view.makeToast("Sorry, your phone's system does not support this option.")
if _form?.isRepl ?? false {
// Google Voice not supported on iOS
_form?.dispatchErrorOccurredEvent(self, "GoogleVoiceEnabled",
.ERROR_IOS_GOOGLEVOICE_NOT_SUPPORTED)
}
}
}

Expand All @@ -48,8 +51,11 @@ open class Texting: NonvisibleComponent, MFMessageComposeViewControllerDelegate
return false // Receiving messages not supported on iOS
}
set(enabled) {
// Receiving messages not supported on iOS
_form?.view.makeToast("Sorry, your phone's system does not support this option.")
if _form?.isRepl ?? false {
// Receiving messages not supported on iOS
_form?.dispatchErrorOccurredEvent(self, "ReceivingEnabled",
.ERROR_IOS_RECEIVING_NOT_SUPPORTED)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,9 @@ private YaVersion() {
// - TRENDLINE_COMPONENT_VERSION was introduced
// For YOUNG_ANDROID_VERSION 228:
// - Renamed LineOfBestFit to Trendline
public static final int YOUNG_ANDROID_VERSION = 228;
// For YOUNG_ANDROID_VERSION 229:
// - IMAGESPRITE_COMPONENT_VERSION was incremented to 10.
public static final int YOUNG_ANDROID_VERSION = 229;

// ............................... Blocks Language Version Number ...............................

Expand Down Expand Up @@ -1120,7 +1122,9 @@ private YaVersion() {
// - Assets helper block was added.
// For IMAGESPRITE_COMPONENT_VERSION 9:
// - The MarkOrigin, OriginX, and OriginY properties were added.
public static final int IMAGESPRITE_COMPONENT_VERSION = 9;
// For IMAGESPRITE_COMPONENT_VERSION 10:
// - A fix for MarkOrigin, OriginX, and OriginY properties was added.
public static final int IMAGESPRITE_COMPONENT_VERSION = 10;

// For LABEL_COMPONENT_VERSION 2:
// - The Alignment property was renamed to TextAlignment.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ public double OriginX() {
* @param u Horizontal unit coordinate of origin with respect to left edge
*/
@DesignerProperty(editorType = PropertyTypeConstants.PROPERTY_TYPE_UNIT_COORDINATE,
defaultValue = DEFAULT_U + "")
defaultValue = "0.0")
@SimpleProperty(category = PropertyCategory.BEHAVIOR)
public void OriginX(double u) {
super.U(u);
Expand All @@ -399,7 +399,7 @@ public double OriginY() {
* @param v Vertical unit coordinate of the origin with respect to top edge
*/
@DesignerProperty(editorType = PropertyTypeConstants.PROPERTY_TYPE_UNIT_COORDINATE,
defaultValue = DEFAULT_V + "")
defaultValue = "0.0")
@SimpleProperty(category = PropertyCategory.BEHAVIOR)
public void OriginY(double v) {
super.V(v);
Expand Down

0 comments on commit 14871ff

Please sign in to comment.