forked from mit-cml/appinventor-sources
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/ucr' into components-tinydb
Change-Id: Ic8239166d99b70f16cb54cba95d6316de8b9224b
- Loading branch information
Showing
102 changed files
with
17,423 additions
and
264 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
...ventor/AICompanionApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>IDEDidComputeMac32BitWarning</key> | ||
<true/> | ||
</dict> | ||
</plist> |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
134 changes: 134 additions & 0 deletions
134
...tor/appengine/src/com/google/appinventor/client/editor/simple/components/MockChatBot.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
// -*- mode: java; c-basic-offset: 2; -*- | ||
// Copyright 2023 MIT, All rights reserved | ||
// Released under the Apache License, Version 2.0 | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
package com.google.appinventor.client.editor.simple.components; | ||
|
||
import static com.google.appinventor.client.Ode.MESSAGES; | ||
|
||
import com.google.appinventor.client.DesignToolbar; | ||
import com.google.appinventor.client.Ode; | ||
import com.google.appinventor.client.OdeAsyncCallback; | ||
import com.google.appinventor.client.editor.simple.SimpleEditor; | ||
import com.google.appinventor.client.output.OdeLog; | ||
import com.google.appinventor.client.utils.MessageDialog; | ||
import com.google.appinventor.client.widgets.properties.EditableProperty; | ||
|
||
import com.google.gwt.user.client.ui.Image; | ||
import com.google.gwt.user.client.ui.Widget; | ||
|
||
/** | ||
* Mock for the non-visible ChatBot component. This needs a separate mock | ||
* from other non-visible components so that we can fetch the token property | ||
* from the server. | ||
* | ||
* Based on {@link MockCloudDB}. | ||
* @author [email protected] (Jeffrey I. Schiller) | ||
*/ | ||
public class MockChatBot extends MockNonVisibleComponent { | ||
|
||
public static final String TYPE = "ChatBot"; | ||
|
||
private static final String PROPERTY_NAME_TOKEN = "Token"; | ||
private static boolean warningGiven = false; // Whether or not we have given experimental warning | ||
|
||
/** | ||
* Creates a new instance of a non-visible component whose icon is | ||
* loaded dynamically (not part of the icon image bundle) | ||
* | ||
* @param editor | ||
* @param type | ||
* @param iconImage | ||
*/ | ||
public MockChatBot(SimpleEditor editor, String type, Image iconImage) { | ||
super(editor, type, iconImage); | ||
} | ||
|
||
/** | ||
* Get a ChatBot auth token from the server | ||
* | ||
* @param widget the iconImage for the MockChatBot | ||
*/ | ||
@Override | ||
public final void initComponent(Widget widget) { | ||
super.initComponent(widget); | ||
getTokenFromServer(); // Get Token from the server | ||
} | ||
|
||
@Override | ||
public boolean isPropertyforYail(String propertyName) { | ||
if (propertyName.equals(PROPERTY_NAME_TOKEN)) { | ||
return true; | ||
} | ||
return super.isPropertyforYail(propertyName); | ||
} | ||
|
||
/** | ||
* Called when the component is dropped in the Designer window | ||
* we give a warning that ChatBox is still experimental. | ||
*/ | ||
|
||
@Override | ||
public void onCreateFromPalette() { | ||
if (!warningGiven) { | ||
warningGiven = true; | ||
MessageDialog.messageDialog(MESSAGES.warningDialogTitle(), | ||
MESSAGES.chatBotExperimentalWarning(), | ||
MESSAGES.okButton(), null, null); | ||
} | ||
} | ||
|
||
/** | ||
* onPropertyChange: If the property we are changing is the token, then | ||
* check to see if it begins with a "%" in which case we alter the type | ||
* to be TYPE_NONPERSISTED. | ||
*/ | ||
@Override | ||
public void onPropertyChange(String propertyName, String newValue) { | ||
if (propertyName.equals(PROPERTY_NAME_TOKEN)) { | ||
EditableProperty token = properties.getProperty(PROPERTY_NAME_TOKEN); | ||
int tokenType = token.getType(); | ||
if (newValue == null || newValue.isEmpty()) { | ||
tokenType |= EditableProperty.TYPE_NONPERSISTED; | ||
tokenType |= EditableProperty.TYPE_DOYAIL; | ||
token.setType(tokenType); | ||
getTokenFromServer(); | ||
return; // Callback from getTokenFromServer finishes up | ||
} else if (newValue.substring(0, 1) == "%") { | ||
tokenType &= ~EditableProperty.TYPE_NONPERSISTED; | ||
} | ||
token.setType(tokenType); | ||
} | ||
super.onPropertyChange(propertyName, newValue); | ||
} | ||
|
||
private void getTokenFromServer() { | ||
OdeLog.log("getTokenFromServer Called"); | ||
Ode.getInstance().getTokenAuthService().getChatBotToken(new OdeAsyncCallback<String>() { | ||
@Override | ||
public void onSuccess(String token) { | ||
EditableProperty tokenProperty = MockChatBot.this.properties.getProperty(PROPERTY_NAME_TOKEN); | ||
if (tokenProperty != null) { | ||
String existingToken = tokenProperty.getValue(); | ||
if (!existingToken.isEmpty()) { | ||
OdeLog.log("bailing on getTokenFromServer existingToken = " + existingToken); | ||
return; // If we have a value, don't over-write it | ||
} | ||
} | ||
int tokenType = tokenProperty.getType(); | ||
tokenType |= EditableProperty.TYPE_NONPERSISTED; | ||
tokenType |= EditableProperty.TYPE_DOYAIL; | ||
tokenProperty.setType(tokenType); | ||
changeProperty(PROPERTY_NAME_TOKEN, token); | ||
} | ||
|
||
@Override | ||
public void onFailure(Throwable t) { | ||
changeProperty(PROPERTY_NAME_TOKEN, "ERROR : token not created"); | ||
super.onFailure(t); | ||
} | ||
}); | ||
} | ||
|
||
} |
Oops, something went wrong.