Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added appinventor/aiplayapp/assets/myAppLibrary.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
60 changes: 60 additions & 0 deletions appinventor/aiplayapp/assets/projects.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<!-- Copyright © 2025 Massachusetts Institute of Technology

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!DOCTYPE html>
<html>
<head>
<title>Project Selector</title>
<script type="text/javascript">
function done() {
Android.finished();
};
function showprojects() {
let projects = Android.listProjects();
projects = JSON.parse(projects);
let html = "";
if (projects.length == 0) {
html += '<p>You do not have any projects saved.</p>'
} else {
html += "<table border=1>\n";
for (let i=0; i < projects.length; i++) {
html += "<tr><td>" + projects[i] + "</td><td><button onClick=\"loadproject('" + projects[i] + "');\">Run</button></td><td>&nbsp;</td><td><button onClick=\"deleteproject('" + projects[i] + "');\">Delete</button></td></tr>\n"
}
html += "</table>\n";
}
let l = document.getElementById("projects");
l.innerHTML = html;
}
function loadproject(project) {
Android.loadProject(project);
}
function deleteproject(project) {
Android.deleteProject(project);
showprojects();
}
document.addEventListener("DOMContentLoaded", function() {
showprojects();
});
</script>
</head>
<body>
<center>
<h1>Select Project to load</h1>
</center>
<p>
<div id="projects">
</div>
</p>
</body>
</html>
1,193 changes: 1 addition & 1,192 deletions appinventor/aiplayapp/src/edu/mit/appinventor/aicompanion3/Screen1.bky

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#|
$JSON
{"authURL":["*UNKNOWN*","jis.qyv.net"],"YaVersion":"213","Source":"Form","Properties":{"$Name":"Screen1","$Type":"Form","$Version":"30","AccentColor":"&HFF128BA8","ActionBar":"True","AlignHorizontal":"3","AppName":"repl","BackgroundColor":"&H00FFFFFF","BackgroundImage":"mooning.png","Icon":"AI2Companion-Icon.png","PrimaryColor":"&HFFA5CF47","PrimaryColorDark":"&HFF516623","Scrollable":"True","ShowListsAsJson":"False","Theme":"AppTheme.Light.DarkActionBar","Title":"MIT App Inventor 2","Uuid":"0","$Components":[{"$Name":"SettingsPanel","$Type":"VerticalArrangement","$Version":"4","AlignHorizontal":"3","Width":"-2","Uuid":"850149444","Visible":"False","$Components":[{"$Name":"settingsintro","$Type":"Label","$Version":"5","HasMargins":"False","Text":"App Inventor Companion Settings","Uuid":"1903510378"},{"$Name":"HorizontalArrangement4","$Type":"HorizontalArrangement","$Version":"4","Uuid":"289079952","$Components":[{"$Name":"Label12","$Type":"Label","$Version":"5","HasMargins":"False","Text":"Set Rendezvous Server: ","Uuid":"-321156745"},{"$Name":"rendezvoustextbox","$Type":"TextBox","$Version":"6","Hint":"Hint for TextBox1","Uuid":"-1218562375"}]},{"$Name":"HorizontalArrangement5","$Type":"HorizontalArrangement","$Version":"4","Uuid":"808500704","$Components":[{"$Name":"SetRenzvousServer","$Type":"Button","$Version":"7","Text":"Set Rendezvous Server","Uuid":"1282830233"},{"$Name":"ResetRendezvousServer","$Type":"Button","$Version":"7","Text":"Reset to Default","Uuid":"-2110364096"}]},{"$Name":"aidLabel","$Type":"Label","$Version":"5","Uuid":"-1496954497"}]},{"$Name":"MainPanel","$Type":"VerticalArrangement","$Version":"4","AlignHorizontal":"3","Width":"-2","Uuid":"-1725916419","$Components":[{"$Name":"EmulatorPanel","$Type":"VerticalArrangement","$Version":"4","AlignHorizontal":"3","Width":"-2","Uuid":"2041308688","$Components":[{"$Name":"Label5","$Type":"Label","$Version":"5","HasMargins":"False","Text":"Running using the emulator or USB,\nwaiting to get blocks...","Uuid":"-962295936"}]},{"$Name":"ErrorLabel","$Type":"Label","$Version":"5","HasMargins":"False","Width":"-2","TextAlignment":"1","TextColor":"&HFFFF0000","Uuid":"-799466554"},{"$Name":"PhonePanel","$Type":"VerticalArrangement","$Version":"4","AlignHorizontal":"3","Width":"-2","Uuid":"1543111896","$Components":[{"$Name":"Spacer1","$Type":"Label","$Version":"5","HasMargins":"False","Height":"8","Uuid":"-1762047873","Visible":"False"},{"$Name":"instructionContainer","$Type":"HorizontalArrangement","$Version":"4","AlignHorizontal":"3","Width":"-2","Uuid":"-775134396","$Components":[{"$Name":"Spacer2","$Type":"Label","$Version":"5","HasMargins":"False","Width":"8","Uuid":"567138142"},{"$Name":"Image2","$Type":"Image","$Version":"6","Picture":"Instructions.png","Uuid":"1124037216"},{"$Name":"Spacer3","$Type":"Label","$Version":"5","HasMargins":"False","Width":"8","Uuid":"-825438138"}]},{"$Name":"Label10","$Type":"Label","$Version":"5","HasMargins":"False","Height":"8","Uuid":"-1942717984"},{"$Name":"HorizontalArrangement2","$Type":"HorizontalArrangement","$Version":"4","AlignHorizontal":"3","Width":"-2","Uuid":"1345116128","$Components":[{"$Name":"Label7","$Type":"Label","$Version":"5","HasMargins":"False","Width":"16","Uuid":"-1172148075"},{"$Name":"CodeBox","$Type":"TextBox","$Version":"6","BackgroundColor":"&HFFFFFFFF","FontTypeface":"1","Width":"-2","Hint":"Six Character Code","TextAlignment":"1","Uuid":"933834161"},{"$Name":"Label8","$Type":"Label","$Version":"5","HasMargins":"False","Width":"16","Uuid":"-198600942"}]},{"$Name":"Label9","$Type":"Label","$Version":"5","HasMargins":"False","Height":"4","Uuid":"-2012312374"},{"$Name":"ConnectButton","$Type":"Button","$Version":"7","BackgroundColor":"&HFFFFFF00","FontSize":"18","Image":"connectwCode.png","TextColor":"&HFF000000","Uuid":"-942061234"},{"$Name":"Spacer","$Type":"Label","$Version":"5","HasMargins":"False","Height":"8","Uuid":"-882888941"},{"$Name":"ScanButton","$Type":"Button","$Version":"7","BackgroundColor":"&HFF00FF00","FontSize":"18","Image":"connectwQR.png","TextColor":"&HFFFFFFFF","Uuid":"875036558"}]},{"$Name":"IPContainer","$Type":"HorizontalArrangement","$Version":"4","AlignHorizontal":"3","Width":"-2","Uuid":"-907976471","$Components":[{"$Name":"Label4","$Type":"Label","$Version":"5","HasMargins":"False","Text":"Your IP Address is: ","Uuid":"-955739485"},{"$Name":"ipaddrlabel","$Type":"Label","$Version":"5","HasMargins":"False","Text":"Unknown","Uuid":"-1112644181"}]},{"$Name":"HorizontalArrangement3","$Type":"HorizontalArrangement","$Version":"4","AlignHorizontal":"3","Width":"-2","Uuid":"-2066763735","$Components":[{"$Name":"Label11","$Type":"Label","$Version":"5","HasMargins":"False","Text":"Version: ","Uuid":"-905541901"},{"$Name":"versionlabel","$Type":"Label","$Version":"5","HasMargins":"False","Text":"Unknown","Uuid":"1289286712"}]},{"$Name":"CheckBox1","$Type":"CheckBox","$Version":"2","Text":"Use Legacy Connection","Uuid":"-1087572524"},{"$Name":"SplashBox","$Type":"TextBox","$Version":"6","Enabled":"False","FontSize":"16.0","Height":"-2","Width":"-2","Hint":"Hint for TextBox1","MultiLine":"True","ReadOnly":"True","Text":"This App is a helper Application for MIT App Inventor. It does not do anything by itself! Go to appinventor.mit.edu for more information.","Uuid":"-666155899"},{"$Name":"PhoneStatus1","$Type":"PhoneStatus","$Version":"1","Uuid":"849809400"},{"$Name":"Web1","$Type":"Web","$Version":"8","Uuid":"-1876664126"},{"$Name":"BarcodeScanner1","$Type":"BarcodeScanner","$Version":"2","UseExternalScanner":"False","Uuid":"1874783275"},{"$Name":"Notifier1","$Type":"Notifier","$Version":"6","Uuid":"-30695151"}]},{"$Name":"TinyDB1","$Type":"TinyDB","$Version":"2","Uuid":"288495309"}]}}
|#
{"authURL":["*UNKNOWN*","jis.qyv.net"],"YaVersion":"233","Source":"Form","Properties":{"$Name":"Screen1","$Type":"Form","$Version":"31","AccentColor":"&HFF128BA8","ActionBar":"True","AlignHorizontal":"3","AppName":"repl","BackgroundColor":"&H00FFFFFF","BackgroundImage":"mooning.png","Icon":"AI2Companion-Icon.png","PrimaryColor":"&HFFA5CF47","PrimaryColorDark":"&HFF516623","Scrollable":"True","ShowListsAsJson":"False","Title":"MIT App Inventor 2","Uuid":"0","$Components":[{"$Name":"SettingsPanel","$Type":"VerticalArrangement","$Version":"4","AlignHorizontal":"3","Width":"-2","Uuid":"850149444","Visible":"False","$Components":[{"$Name":"settingsintro","$Type":"Label","$Version":"5","HasMargins":"False","Text":"App Inventor Companion Settings","Uuid":"1903510378"},{"$Name":"HorizontalArrangement4","$Type":"HorizontalArrangement","$Version":"4","Uuid":"289079952","$Components":[{"$Name":"Label12","$Type":"Label","$Version":"5","HasMargins":"False","Text":"Set Rendezvous Server: ","Uuid":"-321156745"},{"$Name":"rendezvoustextbox","$Type":"TextBox","$Version":"14","Hint":"Hint for TextBox1","Uuid":"-1218562375"}]},{"$Name":"HorizontalArrangement5","$Type":"HorizontalArrangement","$Version":"4","Uuid":"808500704","$Components":[{"$Name":"SetRenzvousServer","$Type":"Button","$Version":"7","Text":"Set Rendezvous Server","Uuid":"1282830233"},{"$Name":"ResetRendezvousServer","$Type":"Button","$Version":"7","Text":"Reset to Default","Uuid":"-2110364096"}]},{"$Name":"aidLabel","$Type":"Label","$Version":"5","Uuid":"-1496954497"}]},{"$Name":"MainPanel","$Type":"VerticalArrangement","$Version":"4","AlignHorizontal":"3","Width":"-2","Uuid":"-1725916419","$Components":[{"$Name":"EmulatorPanel","$Type":"VerticalArrangement","$Version":"4","AlignHorizontal":"3","Width":"-2","Uuid":"2041308688","$Components":[{"$Name":"Label5","$Type":"Label","$Version":"5","HasMargins":"False","Text":"Running using the emulator or USB,\nwaiting to get blocks...","Uuid":"-962295936"}]},{"$Name":"ErrorLabel","$Type":"Label","$Version":"5","HasMargins":"False","Width":"-2","TextAlignment":"1","TextColor":"&HFFFF0000","Uuid":"-799466554"},{"$Name":"PhonePanel","$Type":"VerticalArrangement","$Version":"4","AlignHorizontal":"3","Width":"-2","Uuid":"1543111896","$Components":[{"$Name":"Spacer1","$Type":"Label","$Version":"5","HasMargins":"False","Height":"8","Uuid":"-1762047873","Visible":"False"},{"$Name":"instructionContainer","$Type":"HorizontalArrangement","$Version":"4","AlignHorizontal":"3","Width":"-2","Uuid":"-775134396","$Components":[{"$Name":"Spacer2","$Type":"Label","$Version":"5","HasMargins":"False","Width":"8","Uuid":"567138142"},{"$Name":"Image2","$Type":"Image","$Version":"6","Picture":"Instructions.png","Uuid":"1124037216"},{"$Name":"Spacer3","$Type":"Label","$Version":"5","HasMargins":"False","Width":"8","Uuid":"-825438138"}]},{"$Name":"Label10","$Type":"Label","$Version":"5","HasMargins":"False","Height":"8","Uuid":"-1942717984"},{"$Name":"HorizontalArrangement2","$Type":"HorizontalArrangement","$Version":"4","AlignHorizontal":"3","Width":"-2","Uuid":"1345116128","$Components":[{"$Name":"Label7","$Type":"Label","$Version":"5","HasMargins":"False","Width":"16","Uuid":"-1172148075"},{"$Name":"CodeBox","$Type":"TextBox","$Version":"14","BackgroundColor":"&HFFFFFFFF","FontTypeface":"1","Width":"-2","Hint":"Six Character Code","TextAlignment":"1","Uuid":"933834161"},{"$Name":"Label8","$Type":"Label","$Version":"5","HasMargins":"False","Width":"16","Uuid":"-198600942"}]},{"$Name":"Label9","$Type":"Label","$Version":"5","HasMargins":"False","Height":"4","Uuid":"-2012312374"},{"$Name":"ConnectButton","$Type":"Button","$Version":"7","BackgroundColor":"&HFFFFFF00","FontSize":"18","Image":"connectwCode.png","TextColor":"&HFF000000","Uuid":"-942061234"},{"$Name":"Spacer","$Type":"Label","$Version":"5","HasMargins":"False","Height":"8","Uuid":"-882888941"},{"$Name":"ScanButton","$Type":"Button","$Version":"7","BackgroundColor":"&HFF00FF00","FontSize":"18","Image":"connectwQR.png","TextColor":"&HFFFFFFFF","Uuid":"875036558"},{"$Name":"Spacer4","$Type":"Label","$Version":"5","HasMargins":"False","Height":"8","Uuid":"-882888941"},{"$Name":"LibraryButton","$Type":"Button","$Version":"7","BackgroundColor":"&HFF00FF00","FontSize":"18","Image":"myAppLibrary.png","TextColor":"&HFFFFFFFF","Uuid":"-878893448"}]},{"$Name":"IPContainer","$Type":"HorizontalArrangement","$Version":"4","AlignHorizontal":"3","Width":"-2","Uuid":"-907976471","$Components":[{"$Name":"Label4","$Type":"Label","$Version":"5","HasMargins":"False","Text":"Your IP Address is: ","Uuid":"-955739485"},{"$Name":"ipaddrlabel","$Type":"Label","$Version":"5","HasMargins":"False","Text":"Unknown","Uuid":"-1112644181"}]},{"$Name":"HorizontalArrangement3","$Type":"HorizontalArrangement","$Version":"4","AlignHorizontal":"3","Width":"-2","Uuid":"-2066763735","$Components":[{"$Name":"Label11","$Type":"Label","$Version":"5","HasMargins":"False","Text":"Version: ","Uuid":"-905541901"},{"$Name":"versionlabel","$Type":"Label","$Version":"5","HasMargins":"False","Text":"Unknown","Uuid":"1289286712"}]},{"$Name":"CheckBox1","$Type":"CheckBox","$Version":"2","Text":"Use Legacy Connection","Uuid":"-1087572524"},{"$Name":"SplashBox","$Type":"TextBox","$Version":"14","Enabled":"False","FontSize":"16.0","Height":"-2","Width":"-2","Hint":"Hint for TextBox1","MultiLine":"True","ReadOnly":"True","Text":"This App is a helper Application for MIT App Inventor. It does not do anything by itself! Go to appinventor.mit.edu for more information.","Uuid":"-666155899"},{"$Name":"PhoneStatus1","$Type":"PhoneStatus","$Version":"1","Uuid":"849809400"},{"$Name":"Web1","$Type":"Web","$Version":"9","Uuid":"-1876664126"},{"$Name":"BarcodeScanner1","$Type":"BarcodeScanner","$Version":"2","UseExternalScanner":"False","Uuid":"1874783275"},{"$Name":"Notifier1","$Type":"Notifier","$Version":"6","Uuid":"-30695151"}]},{"$Name":"TinyDB1","$Type":"TinyDB","$Version":"3","Uuid":"288495309"}]}}
|#
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,30 @@ $Source $Yail

(define-event ScanButton Click()(set-this-form)
(call-component-method 'BarcodeScanner1 'DoScan (*list-for-runtime*) '()))
;;; Spacer4

(add-component PhonePanel com.google.appinventor.components.runtime.Label Spacer4
(set-and-coerce-property! 'Spacer4 'HasMargins #f 'boolean)

(set-and-coerce-property! 'Spacer4 'Height 8 'number)

)

;;; LibraryButton

(add-component PhonePanel com.google.appinventor.components.runtime.Button LibraryButton
(set-and-coerce-property! 'LibraryButton 'BackgroundColor #xFF00FF00 'number)

(set-and-coerce-property! 'LibraryButton 'FontSize 18 'number)

(set-and-coerce-property! 'LibraryButton 'Image "myAppLibrary.png" 'text)

(set-and-coerce-property! 'LibraryButton 'TextColor #xFFFFFFFF 'number)

)

(define-event LibraryButton Click()(set-this-form)
(call-component-method 'PhoneStatus1 'loadProjects (*list-for-runtime*) '()))
;;; IPContainer

(add-component MainPanel com.google.appinventor.components.runtime.HorizontalArrangement IPContainer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,17 +119,36 @@
(lookup-in-current-form-environment component-name)))
component-names))

(define (call-Initialize-of-components-library)
(begin
(android-log (format #f "*init-thunk-list* = ~A" *init-thunk-list*))
(apply call-Initialize-of-components *init-thunk-list*)))

(define *init-thunk-environment* (gnu.mapping.Environment:make 'init-thunk-environment))

(define *init-thunk-list* '())

(define (setup-thunk-list)
(let ((form-name *this-form-name*))
(android-log (format #f "Setting *init-thunk-list* Screen to ~A" form-name))
(if (string? form-name)
(set! *init-thunk-list* (list (string->symbol form-name)))
(set! *init-thunk-list* (list form-name))))) ;; Screen1 is a symbol

(define (add-init-thunk component-name thunk)
(gnu.mapping.Environment:put *init-thunk-environment* component-name thunk))
(begin
(set! *init-thunk-list* (append *init-thunk-list* (list component-name)))
(android-log (format #f "add-init-thunk: *init-thunk-list* = ~A" *init-thunk-list*))
(gnu.mapping.Environment:put *init-thunk-environment* component-name thunk)))

(define (get-init-thunk component-name)
(and (gnu.mapping.Environment:isBound *init-thunk-environment* component-name)
(gnu.mapping.Environment:get *init-thunk-environment* component-name)))

(define (clear-init-thunks)
(set! *init-thunk-environment* (gnu.mapping.Environment:make 'init-thunk-environment)))
(begin
(setup-thunk-list)
(set! *init-thunk-environment* (gnu.mapping.Environment:make 'init-thunk-environment))))

;;; (get-component comp1)
;;; ==> (lookup-in-current-form-environment 'comp1)
Expand Down Expand Up @@ -3591,11 +3610,16 @@ Dictionary implementation.
;; Calls on report are also generated for code from the blocks compiler
;; when a block is being watched.
;; send-to-block sends the result of the expression or an error message to the block editor
;;
;; If blockid is -2, we are running from the App Library (aka offline) and have no
;; browser to send the return value to
(define (send-to-block blockid message)
(let* ((good (car message))
(value (cadr message)))
(com.google.appinventor.components.runtime.util.RetValManager:appendReturnValue blockid good value)
))
(if (not (= blockid -2))
(let* ((good (car message))
(value (cadr message)))
(com.google.appinventor.components.runtime.util.RetValManager:appendReturnValue blockid good value)
))
)

(define (clear-current-form)
(when (not (eq? *this-form* #!null))
Expand All @@ -3606,8 +3630,10 @@ Dictionary implementation.
(*:clear *this-form*)))

;; Used by the repl to set the name of the form
(define *this-form-name* "Screen1")
(define (set-form-name form-name)
(*:setFormName *this-form* form-name))
(begin (set! *this-form-name* form-name)
(*:setFormName *this-form* form-name)))

(define (remove-component component-name)
(let* ((component-symbol (string->symbol component-name))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ public TaskResult execute(AndroidCompilerContext context) {

// Companion display a splash screen... define it's activity here
if (isMain && context.isForCompanion()) {
// Splash Activity
out.write(" <activity ");
out.write("android:name=\"com.google.appinventor.components.runtime.SplashActivity\" ");
out.write("android:exported=\"false\" ");
Expand All @@ -335,6 +336,17 @@ public TaskResult execute(AndroidCompilerContext context) {
out.write(" <action android:name=\"android.intent.action.MAIN\" />\n");
out.write(" </intent-filter>\n");
out.write(" </activity>\n");

// Projects Activity
out.write(" <activity ");
out.write("android:name=\"com.google.appinventor.components.runtime.ProjectsActivity\" ");
out.write("android:exported=\"false\" ");
out.write("android:screenOrientation=\"behind\" ");
out.write("android:configChanges=\"keyboardHidden|orientation\">\n");
out.write(" <intent-filter>\n");
out.write(" <action android:name=\"android.intent.action.MAIN\" />\n");
out.write(" </intent-filter>\n");
out.write(" </activity>\n");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,8 @@ public String Image() {
public void Image(@Asset String path) {
// If it's the same as on the prior call and the prior load was successful,
// do nothing.
Log.d(LOG_TAG, "Image: Path = " + path + " backgroundImageDrawable = " + backgroundImageDrawable);

if (path.equals(imagePath) && backgroundImageDrawable != null) {
return;
}
Expand Down
Loading