Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/ucr' into components-tinydb
Browse files Browse the repository at this point in the history
Change-Id: Ic8239166d99b70f16cb54cba95d6316de8b9224b
  • Loading branch information
ewpatton committed Aug 4, 2023
2 parents ab7c0b7 + 9fe1b0a commit 17e533a
Show file tree
Hide file tree
Showing 102 changed files with 17,423 additions and 264 deletions.
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>
46 changes: 39 additions & 7 deletions appinventor/AIComponentKit.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

219 changes: 112 additions & 107 deletions appinventor/Pods/Pods.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions appinventor/Pods/ZXingObjC/ZXingObjC/client/ZXCapture.m

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions appinventor/aicompanionapp/src/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>2.64.1</string>
<string>2.64.2</string>
<key>CFBundleVersion</key>
<string>9</string>
<string>12</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSRequiresIPhoneOS</key>
Expand Down
24 changes: 15 additions & 9 deletions appinventor/aicompanionapp/src/OnboardViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@ class OnboardViewController: UIViewController {
"Select Connect then AI Companion to start a connection",
"Scan the code to finish the connection"
]
var onCompletionHandler: (() -> Void)? = nil

override func viewDidLoad() {
super.viewDidLoad()

// Do any additional setup after loading the view.
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
configure()
}

Expand All @@ -35,11 +34,18 @@ class OnboardViewController: UIViewController {

private func configure() {
// Set up onboarding scrollview
let windowFrame = UIApplication.shared.keyWindow!.frame
var bottomAnchor = view.bottomAnchor
if #available(iOS 11, *) {
bottomAnchor = view.safeAreaLayoutGuide.bottomAnchor
var window: UIWindow? = nil
if #available(iOS 13, *) {
window = (UIApplication.shared.connectedScenes.first as? UIWindowScene)?.windows.first
} else {
window = UIApplication.shared.keyWindow
}

guard let windowFrame = window?.frame else {
// We don't have a window?
return
}
let bottomAnchor = view.safeAreaLayoutGuide.bottomAnchor

scrollView.translatesAutoresizingMaskIntoConstraints = false
holderView.addSubview(scrollView)
Expand Down Expand Up @@ -118,7 +124,7 @@ class OnboardViewController: UIViewController {
@objc func didTapButton(_ button: UIButton) {
guard button.tag < titles.count else {
SystemVariables.newUser = false
dismiss(animated: true, completion: nil)
dismiss(animated: true, completion: self.onCompletionHandler)
return
}
scrollView.setContentOffset(CGPoint(x: holderView.frame.size.width * CGFloat(button.tag), y: 0), animated: true)
Expand Down
23 changes: 21 additions & 2 deletions appinventor/aicompanionapp/src/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public class ViewController: UINavigationController, UITextFieldDelegate {
@objc var phoneStatus: PhoneStatus!
@objc var notifier1: Notifier!
private var onboardingScreen: OnboardViewController? = nil
private var didWifiCheck = false

private static var _interpreterInitialized = false

Expand Down Expand Up @@ -111,7 +112,15 @@ public class ViewController: UINavigationController, UITextFieldDelegate {
let runtime = try! String(contentsOfFile: url)
interpreter.evalForm(runtime)
if interpreter.exception != nil {
fatalError("Unable to initialize runtime: \(interpreter.exception!)")
let title = "Error"
let message = "Unable to initialize runtime: \(interpreter.exception!)"
let alertController = UIAlertController(title: title, message: message, preferredStyle: .alert)
let okAction = UIAlertAction(title: "OK", style: .default, handler: nil)
alertController.addAction(okAction)
if let topController = UIApplication.shared.keyWindow?.rootViewController {
topController.present(alertController, animated: true, completion: nil)
}
return interpreter
}
ViewController._interpreterInitialized = true
}
Expand Down Expand Up @@ -169,7 +178,6 @@ public class ViewController: UINavigationController, UITextFieldDelegate {
navigationBar.isTranslucent = false
form.updateNavbar()
form.Initialize()
checkWifi()
}
}

Expand Down Expand Up @@ -349,6 +357,11 @@ public class ViewController: UINavigationController, UITextFieldDelegate {
self.onboardingScreen = nil
})
}
if !self.didWifiCheck {
DispatchQueue.main.async {
self.checkWifi()
}
}
return
}

Expand All @@ -357,10 +370,16 @@ public class ViewController: UINavigationController, UITextFieldDelegate {
vc.modalPresentationStyle = .fullScreen
present(vc, animated: true)
onboardingScreen = vc
vc.onCompletionHandler = {
if !self.didWifiCheck {
self.checkWifi()
}
}
}

// Implemented in Swift based on aiplayapp/src/edu/mit/appinventor/aicompanion3/Screen1.yail
private func checkWifi() {
self.didWifiCheck = true
if PhoneStatus.GetWifiIpAddress().hasPrefix("Error") {
notifier1.ShowChooseDialog("Your Device does not appear to have a Wifi Connection",
"No WiFi", "Continue without WiFi", "Exit", false)
Expand Down
4 changes: 2 additions & 2 deletions appinventor/aiplayapp/youngandroidproject/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ icon=AI2Companion-Icon.png
# The Version code is an integer. Each new version of an App uploaded
# to the Play Store must have a version greater then the version in
# the store
versioncode=13126600
versioncode=13126700
# The Version Name is displayed to the user and can contain numbers
# and letters. It generally should be congruent to the Version Code
# Terms used by AI2:
# Version code XYZ turns into X.YZ. ai2 indicates a Companion for AI2
# and an optional "zx1" indicates it has internal Zebra Crossing (QR
# Code) scanning builtin.
versionname=2.66
versionname=2.67
useslocation=False
androidminsdk=7
actionbar=true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,12 @@ public interface Images extends Resources {
@Source("com/google/appinventor/images/voting.png")
ImageResource voting();

/**
* Designer palette item: ImageBot.
*/
@Source("com/google/appinventor/images/paintpalette.png")
ImageResource paintPalette();

/**
* Designer palette item: Pedometer Component
*/
Expand Down Expand Up @@ -649,6 +655,12 @@ public interface Images extends Resources {
@Source("com/google/appinventor/images/translator.png")
ImageResource translator();

/**
* Designer pallette item: ChatBot Component
*/
@Source("com/google/appinventor/images/chatbot.png")
ImageResource chatbot();

/**
* Designer palette item: YandexTranslate
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5088,6 +5088,20 @@ String newerVersionComponentException(String componentType, int srcCompVersion,
@Description("")
String firebaseExperimentalWarning();

@DefaultMessage("ChatBot is an experimental feature " +
"which may change in the future. It''s usage may be restricted, " +
"see <a href=\"https://appinv.us/chatbot\" target=\"_blank\">" +
"https://appinv.us/chatbot</a> for more information.")
@Description("")
String chatBotExperimentalWarning();

@DefaultMessage("ImageBot is an experimental feature " +
"which may change in the future. It''s usage may be restricted, " +
"see <a href=\"https://appinv.us/imagebot\" target=\"_blank\">" +
"https://appinv.us/imagebot</a> for more information.")
@Description("")
String imageBotExperimentalWarning();

@DefaultMessage("You are in Read Only Mode")
@Description("")
String readOnlyMode();
Expand Down
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);
}
});
}

}
Loading

0 comments on commit 17e533a

Please sign in to comment.