Home > Articles > Mobile Application Development & Programming

This chapter is from the book

App Inventor Blocks Editor

Apart from the Designer, the Blocks Editor forms the second central work window of the AI development environment. The Blocks Editor is where you will bring the individual components of your app to life and assign them specific tasks, which together will form the overall functionality of your app. As the AI Blocks Editor is implemented as Java Web Start application, starting it requires your computer to have the Java configuration described in Chapter 1. You start the AI Blocks Editor from the AI Designer from the function menu and by clicking the button labeled “Open the Blocks Editor,” as shown in Figure 2.15.

Figure 2.15.

Figure 2.15. Starting the AI Blocks Editor from the function menu of AI Designer

Once you click on this button, its label changes to “Opening the Blocks Editor ... (click to cancel),” indicating that the loading process for AI Blocks Editor has begun. The web browser then asks you in a separate window what it should do with the Java Web Start application you are about to download, or rather the underlying JNLP file AppInventorForAndroidCodeblocks.jnlp. Proceed in the same way as in the Java Web Start demos of the previous chapter: Choose Open with > Java(TM) Web Start Launcher, perhaps activate “Do this automatically for files like this from now on” so you are not asked the same question in the future, and then confirm your choice by clicking OK, as shown in Figure 2.16.

Figure 2.16.

Figure 2.16. Confirm to load and start the AI Blocks Editor

The Java Web Start application AI Blocks Editor is now being loaded, as indicated by the message appearing in a separate window (see the left side of Figure 2.17). Before the fully downloaded application is executed on your computer, your operating system may first check it for a digital signature. If none is present, you have to manually confirm that you want to run the program (see the right side of Figure 2.17). Again you have the option of enabling the check box “Always trust content from this publisher”; choosing it means you will not be asked the same question again the next time you open AI Blocks Editor.

Figure 2.17.

Figure 2.17. Loading AI Blocks Editor with a security check

The loading process for AI Blocks Editor can take a little while—according to Google, 30 seconds or more, depending on the Internet bandwidth you have available. After the loading and start time, a new window appears, presenting the user interface of AI Blocks Editor (see Figure 2.18). Again, it is quite empty when you first open it, but that will soon change.

Figure 2.18.

Figure 2.18. The AI Blocks Editor user interface on first start

Given that you started the AI Blocks Editor within a specific project from within the AI Designer, the initial representation of the user interface relates to the current project, “HelloAndroidWorld.” The project name appears both in the window title and on the left in the green bar of the function menu shown in Figure 2.18.

Developing App Functions from Blocks

The AI Blocks Editor also presents different panels below the function menu. Similar to the AI Designer, the left column—the block selection—contains a list of functional groups available for selection. These groups do not contain components, but rather functional blocks, which make up the syntax of the visual developer language AI, similar to the command set of a classic programming language.

To make it easier even for nonprogrammers to understand the role that blocks play in developing apps with AI, we can try a simple comparison of the two central work areas, Designer and Blocks Editor, plus the individual building blocks, components and blocks. Don’t worry—this approach is not required for your development work with AI. After all, AI is meant to help you intuitively use and assemble the building blocks offered in your app development, without having to think too much about the application structure. Later, you will see how easily you can switch between the working environments and manage to use the different puzzle pieces in combination.

Generic Block Groups Under the Built-In Tab

Let’s get back to selecting blocks in the AI Blocks Editor. The block selection contains two areas that you can access by clicking on the Built-In and My Blocks tabs. The Built-In tab includes seven generic block groups: Definition, Text, Lists, Math, Logic, Control, and Colors. As the term “generic” indicates, these blocks are always generically available for app development, independent of the component objects used. To open a group, simply click on the group name. This displays the individual blocks of the group in a scrollable selection to the right of the group name. Figure 2.19 shows an extract of the available colors from the Colors group.

Figure 2.19.

Figure 2.19. Color selection in the Colors block group

Component-Specific Blocks Under My Blocks

Things are slightly different with the block groups listed under the My Blocks tab. Here you can choose from component-specific blocks that allow you to influence the properties of those component objects that you use in the current app project. Accordingly, the block groups have the names of the corresponding component they represent in the Blocks Editor. As we are currently using the start component “Screen1” in our app “HelloAndroidWorld,” this group is the only one listed and selectable in Figure 2.20. The more components you later add in the Designer, the more groups you have available in the Blocks Editor under My Blocks.

Figure 2.20.

Figure 2.20. Component-specific block selection of “Screen1”

If you compare the blocks available for “Screen1” shown in Figure 2.20 with the properties of the component of the same name in AI Designer under the Properties function menu (see Figure 2.12), you will notice that they are partly identical. The Blocks Editor also contains blocks for setting the background color (Screen1.BackgroundColor) and the background image (Screen1.BackgroundImage).

Implementing and Editing Apps in the Editor

To the right of the block selection, you can see the central work area of the AI Blocks Editor—the actual editor. The editor will be your main sphere of activity for developing the program logic that’s behind the user interface of your app; it is where you will implement your app. In this now-empty area, you will combine the different blocks of your app so that the blocks of the input components transmit their data to the processing block structures, which then turn them into results and pass these data on to the blocks of the output components. You drag the required blocks—similar to the components in AI Designer—by holding the mouse button from the block selection of a group under Built-In or My Blocks into the editor and then assemble them like a puzzle into the desired functional block structures according to the AI syntax rules.

As the complexity and range of functions of an app increase, the number of blocks or block structures also increases, as does the display space the nascent app takes up in the editor. For that reason, the actual work area of the editor is far larger than you can see in the currently visible main window of the Blocks Editor. By using the scroll bars alongside the window or holding the left mouse button, you can scroll the window so that you always see the edited blocks on the screen. You can scroll even more quickly with the scroll window in the upper-right corner of the editor. This scroll window shows the main window as a small red rectangle within a gray rectangle, symbolizing the whole interface. By holding the mouse button and moving the red rectangle, you can scroll over the virtual workspace even more quickly (see Figure 2.21). The zoom slider in the function menu above the scroll window offers additional help for managing large block structures. If you slide it to the left, to a resolution of less than 100% (Zoom Out), you enlarge the section shown in the window, which makes the displayed blocks smaller but allows you to see more at once (see Figure 2.21). A value greater than 100% (Zoom In) lets you zoom into the block structure, making the section displayed smaller.

Figure 2.21.

Figure 2.21. Zooming out of the partial window

Once you have arranged all components in the Blocks Editor and want to concentrate on developing the associated block structures, you can enlarge the partial window even more by hiding the block selection completely. Click on the small top triangle on the splitter bar between the editor and block selection area to collapse the latter. If necessary, you can display it again by clicking on the bottom triangle of the splitter bar, which has now moved to the left edge of the window. If the splitter bar is collapsed, you might wonder how to add to further blocks from the Built-In groups in the Blocks Editor. AI has an efficient solution, as usual. Simply left-click into a free area of the editor; all block groups from the Built-In area then appear in horizontal orientation. Click on a group to open it. You can then select the desired block and thereby create it, as shown in Figure 2.22.

Figure 2.22.

Figure 2.22. The block selection Built-In directly in the enlarged Blocks Editor

We should not forget to mention one important element within the Blocks Editor—the graphically represented recycle bin in the lower-right corner. As expected, it is used for deleting blocks that are no longer required in the editor. To delete a block, simply drag it to the recycle bin. This process is shown in Figure 2.23 for the assignment block for the color green.

Figure 2.23.

Figure 2.23. Deleting a block with the recycle bin

If, for example, you instead want to change a color from green to blue in the Blocks Editor, you do not need to delete the assignment block for green and then drag a new one for blue from the block selection to the editor. Many of the blocks have their own property menu, with which you can directly carry out the appropriate changes or value assignments quickly and easily. In case of the assignment block for colors, you can touch a color block with the mouse to display a small inverted triangle as symbol of an expandable menu. Click on it and you can choose from all available colors directly, as shown in Figure 2.24.

Figure 2.24.

Figure 2.24. Changing a block value directly in the Blocks Editor

Touching a block with the mouse pointer also brings up a brief explanation of the function or possible settings of the block (see Figure 2.25). This is the case with both the abstract block types in the block selection and the specific block types in the editor and often provides useful additional information during your development work in the AI Blocks Editor.

Figure 2.25.

Figure 2.25. Explanatory text for blocks

Let us close out our discussion of Blocks Editor by turning back to the function menu above the editor and the block selection. Here you can see three menu items in form of the buttons Saved, Undo, and Redo, which can be used only in certain situations. For example, you can save the current block structures in Blocks Editor with the Saved button only if you have just made changes to them and these changes have not yet been automatically saved by AI on the Google servers. Only during this time does the button have the label “Save”; it is active and usable when this label is present. The Undo button enables you to undo an action—for example, inserting a new block into the editor. If you decide you do want to use the deleted block after all, you can click the Redo button to restore it.

This brings us to the last two menu items of the Blocks Editor we need to describe, as they are of decisive importance for developing apps with AI. The buttons labeled “Connect to phone” and “New Emulator” integrate the last area of the AI development environment—your Android smartphone or the emulator to simulate it, respectively. If your smartphone is not yet connected to AI, the smartphone icon next to the button shows a question mark in the display.

Before you read on, please delete any blocks you may have dragged to the Blocks Editor while experimenting and ensure that the editor is completely empty. This ensures that we avoid malfunctions on the smartphone later that could be caused by an interpretation of the randomly added and functionless blocks.

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020