Catrobat/Catroid — pull request #669 by aried3r (2013-09-03 21:52:37+00:00)
Title: Optimized Layouts & emptyView implementation

This pull request covers quite a few issues within the code base. I began working on it and before I realised it, a lot came together. So, sorry for so many things within one pull request, bear with me as I try to explain what I did.

First things first: [Successful Testrun](https://jenkins.catrob.at/view/Catroid/job/Catroid-Multi-Job-Custom-Branch/340/). :green_heart:

GPU Overdraw
======
Following the [excellent article](http://www.curious-creature.org/2012/12/01/android-performance-case-study/) by Romain Guy, I decided to take a look at Catroid wrt GPU Overdraw.

Surely enough, there was enough to do. I am quite satisfied with the end result, although there are still things left to do. To better explain what the changed code does, I will post a "few" images. Left is **before**, right **after** the changes.

I'm sure not every change will be self explanatory, so if you have any questions, feel free to ask. We can also meet in person if necessary.

> It is easy to interpret the results if you remember the meaning of each color:
>
> * No color means there is no overdraw. The pixel was painted only once. In this example, you can see that the background is intact.
> * Blue indicates an overdraw of 1x. The pixel was painted twice. Large blue areas are acceptable (if the entire window is blue, you can get rid of one layer.)
> * Green indicates an overdraw of 2x. The pixel was painted three times. Medium-sized green areas are acceptable but you should try to optimize them away.
> * Light red indicates an overdraw of 3x. The pixel was painted four times. Small light red areas are acceptable.
> * Dark red indicates an overdraw of 4x or more. The pixel was painted 5 times or more. This is wrong. Fix it.

*[Android Performance Case Study](http://www.curious-creature.org/2012/12/01/android-performance-case-study/)* – Romain Guy

### Main
![main-merged](https://f.cloud.github.com/assets/1301152/1076267/8e3d99ee-14df-11e3-9eb0-5a3bc2f7d3a2.png)

### Programs
![programs-merged](https://f.cloud.github.com/assets/1301152/1076271/9567052a-14df-11e3-840c-c1c882645c55.png)

### Sprites
![sprites-merged](https://f.cloud.github.com/assets/1301152/1076274/a2d82040-14df-11e3-9c42-f5282649746c.png)

### Program Menu
![program-menu-merged](https://f.cloud.github.com/assets/1301152/1076283/bf4a59b4-14df-11e3-968c-1f791b413d40.png)

### Scripts
![scripts-merged](https://f.cloud.github.com/assets/1301152/1076289/cdd129fe-14df-11e3-9297-3e9d49438b53.png)

### Looks
![looks-merged](https://f.cloud.github.com/assets/1301152/1076295/de2e169a-14df-11e3-8f7d-6ee23f837712.png)

### Sounds
![sounds-merged](https://f.cloud.github.com/assets/1301152/1076290/d2e05fe6-14df-11e3-82a4-62ce808799e2.png)

### Formula Editor
![formulaedtior-merged](https://f.cloud.github.com/assets/1301152/1076297/e7e19900-14df-11e3-9135-4254c058fac6.png)

### Formula Editor – Logic
![logic-merged](https://f.cloud.github.com/assets/1301152/1076299/efc738be-14df-11e3-94f5-b318c1b8694e.png)

### Formula Editor – Variables
![variables-merged](https://f.cloud.github.com/assets/1301152/1076301/fdbd5a7a-14df-11e3-966e-da4bfa4a3b92.png)

### Soundrecorder
![soundrecorder-merged](https://f.cloud.github.com/assets/1301152/1076302/07c842be-14e0-11e3-998b-2250a4af5277.png)

## TODO

Now for a few things I am not quite satisfied with. In the `ScriptFragment`, we overlay the fragment first with the `BrickCategoryFragment`, followed by the bricks themselves, as can be shown here:

### Categories
![categories-merged](https://f.cloud.github.com/assets/1301152/1076309/389920f2-14e0-11e3-87a3-4ddba12b181c.png)
You can see how the `ScriptFragment` "shines" through.

### Category – Control
![control-merged](https://f.cloud.github.com/assets/1301152/1076313/450d28e2-14e0-11e3-8954-248d5ce08969.png)
Here, you can't even see the `ScriptFragment` anymore, the pixels get overdrawn so much, the whole screen is dark red. I think these last two screenshots are part of a deeper issue which we'll have to address separately.

Empty Views
==========

This pull request also fixes #664. [Here](https://github.com/Catrobat/Catroid/blob/099bf4e22e607a4074b2d235d6a691754c429fd5/catroid/res/layout/fragment_look.xml#L29-L54) is an example of how this issue was fixed. It is enough to give the `View` you want to display when the `ListView` is empty the ID `android:id/empty` if the `ListView` has the ID `android:id/list`.

I added test cases to verify this behaviour. Please see the commit for details and the screenshots of Looks, Sounds, Scripts above.

@sebheid This one might be interesting for your issue #665.

Remove unused ListView
==================

I was able to [remove one](https://github.com/Catrobat/Catroid/compare/layout_optimization?expand=1#L19L64) `ListView` completely, which was unused. I fixed the tests that failed afterwards which relied on this ninjaesque `ListView`. Mainly the index had to be changed from 1 to 0 and further, a method in `UiTestUtils` (which handled drag and drop) had to be altered.

Further Changes
============
Deleted `FtpProgressInputStream` as it was unused.