Copy the component

It’s posible copy component of screen in the same screen?

i put the text_box and i modify the properties. Now i wont to copy this component with modify properties in the same screen. It’s posible?

You can copy blocks for the components by duplicating it in block section. But you have to redesign the component in designer.

3 Likes

I did a little experiment. i made a project with just two buttons.

Selectie_999(215)

i exported the project to a aia file and opened it. Structure of an aia file is like this.

I went to the Screen1. scm file. it looked like this.

Instead of the Uuid 01 and 02 there were random numbers but i changed those to 01 and 02. Don’t know if you can do that.

Then i copied and paste one button and changed the Uuid to 03

I saved everything imported the aia back in and i had 3 buttons on my screen. Didn’t test it any further.

Selectie_999(218)

11 Likes

I added a vertical arrangement it looks like this:

Selectie_999(220)

Then i exported the aia-file again opened up the scm file inside and found the vertical arrangement. Copy and pasted that and changed all the Uuid so they would be unique.

Saved it and imported it again. Now it looks like this.

Selectie_999(222)

10 Likes

It may look easy but an aia can be very complex. See this one. I made the font really small to show how large it is.

8 Likes

I dug a little deeper to get an idea of what you see in a scm file.

This an empty file made by App Inventor version nb168b build june 19th.

Look at the YaVersion in the text.

Selectie_999(381)

So in this case the YaVersion is 167.

The latest change was that the Form_component was incremented to 23.

You can see that in the empty file. Form Version = 23. You should be able to find it.

The change that was made to the form was that the action bar property was deprecated.

Selectie_999(382)

You can look at all the changes ever made here: appinventor-sources/YaVersion.java at master · mit-cml/appinventor-sources · GitHub

The authURL is empty. It is filled when you add components to the Screen/Form. Then it says

Selectie_999(385) in the case of App Inventor.

The YaVersions for all builders (Makeroid, App Inventor and AppyBuilder) are different. The Form versions for App Inventor and AppyBuilder are the same but for Makeroid it is different.

So all the builders make aia files and build apk files but internally they are all very different. Keep that in mind next time when you are surprised you can not import your aia in another builder and get errors.

8 Likes

I am not a developer but i programmed a bit in my early years and now with AI and it’s clones. So i can read code.

I found the file where the string is made for the initial aia. appinventor-sources/YoungAndroidProjectService.java at 6ff1bfb9be7d3dfd00db97a3462a12190412735a · mit-cml/appinventor-sources · GitHub

Maybe you can recognize some things in the routine and how it comes back in the aia file.

6 Likes

Very good job, @Peter!!! It shows clearly that each platform has its own characteristics. Before some of you say: "it is working in Platform A, B or C but does not work in Makeroid ", keep in mind that there are internal and external differences.

7 Likes

@Peter great job

Amazing explanation @Peter! :+1:

Hi, Sir in which software you open the source code of aia file?
when I opened aia file in notead++ it looks like this

The AIA file is a zip compressed archive. You have to unzip it first.

3 Likes

@Kodular i think it might be useful. im tired designing custom listview. if i can clone components with same properties than it will save a lot of time :relaxed:

Peter already explained here.

2 Likes

@Peter AMAZING! :+1:

1 Like

@yusufcihan don’t u think its for advance users like peter?

No, everything is easy after you learned. Also, Peter explained well with images. So I’m sure everyone can make easily. At least you can use this solution until Kodular adds this feature.

2 Likes

There are two things to think of when implementing this -

  1. If you copy a visible component, where should it be placed? Should it be like Ctrl-C & Ctrl-V? (i.e., you explicitly have to select the region where you want to clone the component to)

  2. If you clone an arrangement, do you want to clone all of it children also (and children of children) i.e., deep cloning?

2 Likes

Maybe we can have an extra category and component called “Panels” and when we copy a component, it will save as panel in components palette, so we can drag that from components palette and drop anywhere we want (like other components). So I think it will become easier to add this option.

This can be like internal-extensions.

4 Likes

yes, we have to select the area where we want to clone.