Skip to Content

Blog

Flyin menu using offsetLeftAndRight not preserving after a layout

While making the flyout menu for the new MyPOD I encountered a little bug that I couldn’t find an answer for.

The problem ..

I was using offsetLeftAndRight to hold the flyout “open” after the animation finishes (simply using fillAfter on the animation produces and annoying flicker). This method takes a "relative" amount to move (i.e. the amount to offset the view from it’s current position). So this container hold whatever content might be in the front screen. But the problem was that whenever a child in this container called requestLayout. the offset would be wiped, and so the flyout would appear to suddenly close.

The API >10 solution

HoneyComb added the onLayoutChangeListener which makes it really easy to restore the old value, it is just provided in the method call.

if (Build.VERSION.SDK_INT>10) {
			_contentContainer.addOnLayoutChangeListener(new OnLayoutChangeListener() {
				
				@Override
				public void onLayoutChange(View v, int left, int top, int right,
						int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
					_contentContainer.offsetLeftAndRight(oldLeft);
				}
			});
		}

And for the rest … API<=10

Without the layout change listener the only way I could think of to react to layout changes was to use tried and true override of the onLayout method. So the container class (RelativeLayout) was extended. This sets the accumulated value when the reset condition is detected (left==0 && left != _accumOffset). There may still be problems for other use cases, but for me it has the desired effect of preserving the open state of the flyout on all API Levels.

import android.content.Context;
import android.util.AttributeSet;
import android.widget.RelativeLayout;

public class RelativeLayoutPreserveOffset extends RelativeLayout {
	int _accumOffset=0;
	
	public RelativeLayoutPreserveOffset(Context context, AttributeSet attrs,	int defStyle) {
		super(context, attrs, defStyle);
	}

	public RelativeLayoutPreserveOffset(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	public RelativeLayoutPreserveOffset(Context context) {
		super(context);
	}

	@Override
	public void offsetLeftAndRight(int offset) {
		_accumOffset+=offset;
		super.offsetLeftAndRight(offset);
	}

	@Override
	protected void onLayout(boolean changed, int left, int t, int r, int b) {
		if (left != _accumOffset) {
			if ( left == 0 ) {
				super.offsetLeftAndRight(_accumOffset);
				super.onLayout(changed, _accumOffset, t, r, b);
			} else {
				_accumOffset=left;
				super.onLayout(changed, left, t, r, b);
			}
		} else {
			super.onLayout(changed, left, t, r, b);
		}
		
	}
}

MyPOD re-write, vector graphics improvements & DroidCon

MYPOD re-write is on

The MyPOD re-write has started in earnest – we are working with some high caliber UX / UI specialists to make this full upgrade something special.

We have been putting out feelers with some users about the new design and the feedback has been great. So watch this space for some great news over the next couple of months. This re-write will address the usability bugs that some have complained about, as well as strengthen & make the app features easier to find and use.

Vectoroid SVG improvements

As part of the MyPOD re-write there have been a number of improvements in the Vectoroid library. Those pesky Arc’s are fully functional, and support will be in the upcoming release (0.83) in a couple of weeks.

Also coming in the next version are SVG drawables – These can be used in any android component that takes a drawables (which is anything). There are still a few kinks to iron through – but it works, and they are crisp … No more will I make 4 versions of each icon.

DroidCon London

Droidcon London, Oct 6-7

http://uk.droidcon.com/

The 2012 DroidCon is almost upon us. It is really getting bigger every year and this year looks to be no different.

Talks on Android x86, AndEngine, AI, Animations, Custom components and Google TV are the subjects that I am looking at. I may even sneak in a BarCamp talk on Vectoroid. Hope to see you there.

Patenting tap to zoom is like patenting DNA


Yes, Apple you won. I would say that a number of people told me that they bought a galaxy S2 cos it looked "a bit" like and iPhone. So there is some merit to that aspect …



But, where are we heading? Using these patents to wage war with – they are so basic if companies and patent trolls let rip with some of these then we are all in trouble…

Tech evolves quickly. In some ways there is a lot of evidence that the first mover is not always the ultimate winner. But Android AND Apple have created cultures and to subject actual users to limits on these simple functions isn’t an option – it all about getting da monay.

Weather they like to acknowledge it or not, they are creating a space together – people passionate about iPhone – people passionate about Android.


This, right here, is the danger of software patents. When obvious things (that generally come up in user testing – i.e. testing what feels *natural* to a user). Denying tap to zoom (and pinch to zoom? not sure on this) as a natural part of tech progression is in some ways like patenting DNA because they were just testing what feels natural for the user – probably other testing found the same thing – just because Apple did it a bit before shouldn’t give them global rights to it. Some of the knowledge captured in these patents should possibly be public domain as it relates to all of us.

The other patents are equally as obvious.

( source : http://www.bbc.co.uk/news/technology-19377261 )


There is definitely a moral imperative here not to hamstring each other – this will not only stifle innovation for manufacturers, but also for app developers… These patents really should have been invalidated by now – but because it takes so long to grant them, most of them have only been approved for a couple of years. Speeding up the award and invalidation cycle may be an improvement for the patent system. But the legal precedents set here are very worrying …


Mind, these patents should these never have been awarded as the usage has fallen into common use by the time the patent is awarded. Now we have to wait and hope that governments will realise the dangers of an ineffective patents system and reform it – I can’t say I’m holding my breath though …

Vectoroid 0.82 released

Vectoroid 0.82 was released last week, the big addition being the SVG parser to the open-source library. This was done to allow easy importing/use of SVG into Vectoroid apps, and represents a significant value add for the library. Now developers/designers can design in a Vector graphics editor (AI, Inkscape , …) and then export artwork to SVG and use it in apps directly. The SVG is parsed into the drawing model and can be manipulated in code.

It can be downloaded here : Vectoroid developers

Issues / Workarounds

The SVG parser works reasonably well with the exception that SVG Arc path points are not rendered properly – this is a problem common to other Android SVG parsers as the way Android processes Arcs (via the skia library) is significantly different to the SVG specification and therefore requires conversion. Should be possible to do, but I just have not had time to do it yet. If people request it then it can be done. Or it is definitely a good way to earn a free licence ;)

To work around the afforementioned Arc problem, you can convert and paths with Arcs to bezier paths. To do this in Inkscape select the object and then use Path > Object to path.

Applications

This is what the Twitter infographic app uses to parse and display it’s template which has just be redesigned by a designer (thanks Rachel).

Twitter Infographic builds easy infographic pics for a twitter tag

I am testing a new app called "Twitter Infographic". I have found myself surfing around twitter and finding a number of related tags which I can then read (using the read link in the search popup). It actually does make it easier to see what is happening on Twitter, looking at common hash-tags for Google IO (#io2012, #android, #glass, …) it is amazing to watch and see the spikes that occur. The output can be shared using Andorid sharing.

Use case

The initial use case is for people who want to monitor the tweet volumes for their event – I have been at a few events lately where I have seen organisers trying to get attendees to tweet more, but not really knowing if people are actually doing it. This app can even be left on a TV or screen somewhere and people can see what is coming though and help contribute as well hopefully. Which may in itself help motivate people to spread the word…

#Barclays twitter infographic Twitter Infographic for #Nexus7 Twitter Infographic for #euro2012

Technical info

The app was built using the Vectoroid drawing view, which will make it easy to add editing functions later. There are some instructions on the app Product page. It uses a SVG template for the artwork with IDs set for the dynamic elements in the view. The library is also available for white labelling.

Where to now …

At the moment I am just testing the idea as an MVP (Minimum viable product), it not a finished & polished product. The app can make a lot of requests for twitter data if the tag you are looking at has a lot of tweets, so be careful of your battery for the moment (It’s not too heavy, but constant use for an hour or so will likely run it down).

So if you like the idea, then leave a comment here or on the product/app page – when I get feedback I with build it out into a proper app. This is an app stub, based on Vectoroid to test the idea of using it to generate infographics on all types of data. Because it uses vectoroid it is quite easy to add editing features so people can customise the layout which would be pretty cool. There is also an HTML solution in the works …

The idea for the next few weeks is to build out some of the myriad of ideas I have had for the vectoriod API. It’s getting to the fun stage now – so expect to see some quite diverse ideas. Next up is a presentations tool, and a collaborative drawing tool to fit with it. As well as more developments to the vectoroid mockup API – to help further test out the new MyPOD interface.

… and more infographics (Facebook and G+ seem to be the logical ones).

Vectoroid 0.81 released

I released Vectoroid v0.81 yesterday. This release mainly finalises changes to the Model API and File Format as well as a safe failover for any future changes. Here is the change log. This is the firs release where I would say that the API is finally useable. Get it on vectoroid.com

  • Model API :
    • Changes Point storage to reflect SVG path. Supported PathData(a point), Cubic, QuadricArc is stored, but not renedered (due to differences in SVG and Andorid API arc models).
    • ID & className support for DrawingElement.
    • IDrawingElementCollection for Drawing, Layer and Group. Which supports findById() and flattening stroke processing.
    • Namspaced parameters for all DrawingElements – this allows custom data storage against any DrawingElement.
    • clipRect & opacity field – not supported in renderer yet.
  • Renderer API:
    • Animation HashMap: Allows better animation performance by storing canvas operations against the existing VecRenderObjects (see SuprCardsExploder).
  • File API: Some large changes to the file format – these will be the last refartoring, at least until mroe feedback is obtained. All new apps should use V3 which is the default.
    • SVG Path : All paths are stored in SVG format to improve compatibility with similar HTML API (e.g. svg-edit).
    • As a consequence, file versioning was tightened up, so that future file changes can be integrated seamlessly.
    • Support new model API fields (id, class, clipRect , opacity).
    • New methods for loading from InputStreams and Assets in DrawingFileUtil.
  • Examples: Updates to the Examples (VectoroidExample & SuprCardsExploder) to reflect other updates.

MyPOD website re-design

MyPOD has recently had a full website re-design. Thanks to wise robot for some great design work. I’ll post item as I go on the MyPOD G+ and Facebook profiles.

Home Page

The main aim was for the site to speed up their understanding the MyPOD feature set. The top section of the home page is devoted to the main activities people look for (bieng download, features, reviews and video) in a tab set.

Screen shots

The screen shots section has been turned into a “Screen Explorer” which show info about the screen and help links interactively as you select a screen, to serve as a quick reference.

Feed URL’s

see: MyPOD Feed Link Generator

The feed URL generator serves as a way for people to quickly generate links that MyPOD can understand and intercept when used on an Android device. Its an easy and simple process, the next step will be to integrate it with the feeds catalogue.

The layout was changed to two-column as the page will be displayed if a link is clicked on and the app isn’t installed – so download information needs to be prominent.

Future plans

  • Integrate the MyPOD catalogue into the site, so users can just go to my-pod.org to configure their feeds.
  • Integrate the MyPOD remote interface into the website, so users can manage thier device through the web interface.

So you don’t need me to ask you to give it a whirl – let us know what you think!

Random NoSuchMethodErrors when using proguard with GSON

I switched to GSON for JSON parsing a while back, but it has some special proguard requirements to make it work.

The code below is from the GSON WIKI (I think). But the -allowaccessmodification and -repackageclasses ” flags caused me problems. The NoSuchMethodError – it seems to affect random private methods in classes – I could not figure out the pattern.

So if you are getting seemingly random NoSuchMethodErrors when you use proguard, you should try commenting these out. For me it is OK as all the members I want to serialise are public so I don’t need access modification.

##GSON stuff
#-allowaccessmodification
-keepattributes *Annotation*
#-repackageclasses ''
-keepattributes Signature
-keep class sun.misc.Unsafe { *; }
## Preserve the special static methods that are required in all enumeration classes.
-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}
-keep public class * {
    public protected *;
}

A letter to MEPs on ACTA


This is a quick letter I sent to UK (London) MEP’s on ACTA. Following on from the ORG‘s blog post:

I am writing to voice my concern over the ACTA bill currently being considered by European Parliament. I feel that there are a number of problems which relate to the proposal and it should be dropped.

ACTA might on the surface be about intellectual property, but it has too many ramifications for free speech on the internet. While I sympathise with large companies who need to protect their content (I have software which I protect under copyright law). There are so many use cases where the right to fair use and debate will in practice be infringed because large compaines will no doubt use it as a hammer to sue and take down competitors and critics. The numerous legal cases of music/movie companies suing people for vastly inflated sums of money over the past years, can only lead us to assume that they will use ACTA to do this on a larger scale. The dangers of private policing of the internet will no doubt lead to unfair court cases where the large content companies use ACTA for frivolus cases and revenue generation rather the protect their content or offer it at a competitive price on the open market. Movie and music companies continue to sell their content at very high prices which don’t just aren’t competitive in the internet age, charging a fair price would combat illegal downloading a lot more than ACTA ever will.

The internet has changed the case for copyright law, every webpage we see, is a copy. A fair internet depends on all people being able to publish and use content that is available on the internet – Media companies will use ACTA to stiffle competition and lead to tiered internet where independent publishers can be sued out of existence by large corporations using frivolous copyright cases. Copyright law itself needs revising and ACTA binds us to existing copyright law. Works need to enter the public domain faster than the 70-80 year limit that is prevalent in a lot of countries.

There is also the issue that MEP Gallo’s report cites the European Parliament’s legal services’ opinions on ACTA. But some key elements of the legal services’ opinions on ACTA have not been made public. The EU Parliament refused to publish them in full, unredacted form, saying that it would “seriously interfere with the complex ratification process”. How can this be? we have the right to discuss this legislation, and if the report has flagged problems then WE NEED TO KNOW ABOUT THEM.

To quote MEP Rapporteur Dimitrios Droutsas:

an adoption of ACTA would prematurely strangle the debate and tip the balance on one side, would allow for Member States to experiment on laws that could potentially harm fundamental freedoms and set precedents that could be undesirable for future societies.

I also think that, the more the large content companies continue to re-engineer the copyright playing field, the less useful it will become. People will be afraid to use their content due to legal fears, content will continue to be overpriced and eventually it will kill the demand for their content. These companies need to be “shown the light” that it much better to have higher volumes than higher prices.

Society is changing, and business and government need to adapt, not stifle creativity and innovation. We are entering a period where web technologies will be ubiquitous and we all deserve a level playing field for individuals and companies big AND small.

Android dev tools (adb, aapt, …) : No such file or directory – Linux Mint & Ubuntu install

After my main hard disk corrupted recently, I changed to Linux mint – which is great. But while installing the Android environment I had a weird issue – all the platform-tools were installed, but the executables wouldn’t run with the message:
bash: /home/robert/bin/android-sdk-linux/platform-tools/aapt: No such file or directory

After a bit of head scratching I found this post: http://askubuntu.com/questions/73491/no-such-file-or-directory-for-existing-executable

Turns out the existing Android binaries are 32-bit (64-bit isnt supplied) and the error message is because the executables can load dependent libraries. Fairly simple really – it’s just that the error message is rather mis-leading.

Solution:
apt-get install ia32-libs

Another one (from here) is:
apt-get install --reinstall libc6-i386