gradle/groovy: A simple way to check if a gradle task name has been invoked (e.g. “assembleRelease” for Android developers)

If you google for this question, you’ll find a bunch of crap answers about creating tasks and checking the task graph, bullshit.

All you need to do is check if a parameter has been passed to gradle.

Keep it simple and stupid:

[pastacode lang=”java” manual=”boolean%20isAssembleRelease%20%3D%20gradle.startParameter.taskNames.contains(%22assembleRelease%22)” message=”” highlight=”” provider=”manual”/]

(If you’re working with an android project, you can define that variable before the android { section starts)

Then, if you need to do something different somewhere else down in your script, say, ask for a key alias and key password to sign your release (because they invoked ./gradlew assembleRelease you do:

[pastacode lang=”java” manual=”signingConfigs%20%7B%0A%20%20%20%20%20%20%20%20release%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20(isAssembleRelease)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%2F%2F%20your%20code%20here%20to%20ask%20for%20the%20key%20alias%20and%20password%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%7D” message=”” highlight=”” provider=”manual”/]

[ANDROID] How to set a custom title View on a DialogPreference extending class.

So you have a FooDialogPreference class which extends DialogPreference, and one of the things you’d like to do to it, is to change the Dialog’s title.

DialogPreference happens to be a bit of a bitch, you can’t just call getDialog() and start playing with its features before it is shown because the Dialog object is only created when DialogPreference.showDialog()is called.

However, there’s ONE entry point where you can make your magic happen.

If we look at the code of
DialogPreference.showDialog()
from the geniuses at the Android project, some gentle soul added a call to
onPrepareDialogBuilder(mBuilder); which is a method you’re meant to override.

Override this method, and then with the builder object you’ve received you will be able to call:

builder.setCustomTitle(myCustomTitleView);

However, there’s a couple of things you need to do:

  1. Instantiate your myCustomTitleView object on the implementation of your onBindDialogView, and keep the reference as a private property of your FooDialogPreference class.

  2. Make sure to detach it from it’s parent ViewGroup, otherwise you will get an IllegalStateException from android.view.ViewGroup.addViewInner() letting you know this view you’re trying to add, cannot have a parent.

This is what I had to do:

[pastacode lang=”java” manual=”final%20ViewGroup%20parent%20%3D%20(ViewGroup)%20myCustomTitleView.getParent()%3B%0Aparent.removeView(myCustomTitleView)%3B%0Abuilder.setCustomTitle(myCustomTitleView)%3B” message=”” highlight=”” provider=”manual”/]

That’s all folks!

OnePlus One unboxing

Charger and phone come in separate boxes.

Charger does not come with a cable. The phone does.

I guess it must be a statement for modularity and perhaps you get to buy only the accesories you need, if you need just a cable, you just buy the cable.

It’s a pretty power adapter, but not very functional, the contacts are not retractable like on many others.

The box was of really good quality material.

Custom shipping box for the phone, had a nice tab at the end of the rope used to open the box.

A white box, containing another box, good material again, but rather wasteful in my humble opinion.

Ta-da!

hopefully people will read the fine print and not get rid of this cover as it contains the devices IMEI and Serial number.

And this is the first Android device I have which I can’t open to remove the battery, so I’ll still be using my external battery for charging, hopefully the battery life will be as good as I expect as the phone didn’t come with a bunch of pre-loaded crap apps you can’t uninstall (dear AT&T and Samsung)

this material feels awesome, and the phone is pretty light.

and has a really cool looking USB cable.

I’m happy, now let’s hope I can find a rugged cover to protect it before it breaks, I tend to go running with my phones as I need gps tracking and like taking a picture here and there while I exercise.

New FrostWire for Android 1.0.8 out

Screenshot of the new FrostWire for Android navigation menu

A new FrostWire for Android is out on Google Play.

In this release we improved our search algorithm to include relevant search results that were being hidden in previous versions.

We’ve also made use of Square’s Picasso Image loading/caching library for displaying all the images on the user interface, resulting in less crashes due to out of memory errors we kept receiving. Now when browsing your Audio files you will be able to see the cover art of the track, making music browsing a lot friendlier.

We’ve removed ad display from the player window, no more admob ads, instead we’ll rely on the support of the community and we’ve placed a donation control which you can always turn off on the application settings.

We’ve added a new navigation menu called “Watch TV” which will either launch or take you to the android market so that you try our new app “FrostWire TV   ” to watch live TV channels (and a huge library of video on demand content). This app is still in beta testing period, we’d love for you to give it a try and give us as much feedback as you can. We’ll reveal more details about our Live TV initiatives and new partnerships on an upcoming press release. As an added bonus,

this release is compatible with OUYA, however there’s still a lot of user experience details that need to be fine tuned for better feedback on non-touch screens. Here is the full changelog:

FrostWire 1.0.8 - MAY/31/2013
 - New main menu entry to launch "FrostWire TV" app.
 - Search algorithm improvement brings better quality and missing search results.
 - Local audio files now show album art making local music browsing friendlier.
 - Fixes bug where audio player would stop instead of pausing when removing headphones.
 - Updated Image caching based on Picasso, better frame rate overall, should see
   less Out of memory error reports.
 - Fixes bug where the search cache couldn't purge old entries nor it could be deleted.
 - Fix for parsing torrents with minor mistakes in trackers list.
 - Less intensive HTML detection during torrent parsing
 - Added jdk14 logging library.
 - Fixes bug where .torrent files and magnets would not open with some file/web browsers.
 - Fixes crash reported when there is no access to the image cache folder.
 - Fixes crash initializing donations Billing Service.
 - Better description for mobile network data usage and bittorrent preferences.
 - Removed Google AdMob.
 - Added donations request component instead of ads.
 - Integrates Offercast offers on installation.
 - Experimental OUYA compatibility.

New FrostWire for Android 1.0.6 – Now with access to Archive.org’s 7.3MM files

177fc79ea15011e2b19422000a1f9bc9_7

Download the APK or get it at Google Play

A new FrostWire for Android is here, this is a major update that you should not skip, specially if you’ve had issues in the past.

The biggest changes are:

Integration with Archive.org

Archive.org indexes free files from all over the internet, there’s a huge amount of Public Domain files and Creative Commons files, so keep an eye for those archive.org results if you’re looking to remix legally free available content, FrostWire will be a great tool to find it.

Archive.org also indexes torrents of these files, if you download and seed you will help make its contents more decentralized and durable, not to mention you will save archive.org some bandwidth.

The Archive holds over 7.3 million files, it’s a powerful content library that now is easily accesible from anywhere using FrostWire, we hope you find it very useful, for example, law students and attorneys can now use FrostWire to search for public transcript of court cases, among other documents. Almost every known public domain film, book, and audio recording is available and best of all we’ve integrated it with FrostWire after revamping our search architecture which now delivers results as soon as possible to your android device.

Search results coming from archive.org include basic information about the file’s license if available, make sure to check the licenses and to respect your local copyright laws, FrostWire condemns copyright infringement.

Faster Search, Reduction of CPU/Battery consumption

We’ve made search considerably faster, now results are shown as soon as they come in, in the past our algorithm would wait for a certain amount of results to come in and show them to you, the search experience should feel snappier now. Also we optimized and fixed our code and some third party libraries that weren’t meant to be used on Android so now the app consumes up to 84% less CPU which will result in your battery lasting a lot longer if you’re running FrostWire.

We’ve made a few improvements in the bittorrent core, namely the hashing algorithms are about 15% faster than before which also reduces battery consumption while downloading and checking torrent chunks.

More stable and compatible

Since our last release in november we received thousands of crash logs from users worldwide and we went through all of them fixing bug by bug, in the process we did a few updates on the user interface you will notice a nicer looking navigation menu, and more intuitive icons to share/unshare files on the Wi-Fi network.

Many fixes related to the audio player, specially an annoying double-playback bug lots of you reported, thank you.

Full Changelog

For those of you following the codebase and who know geek-speak

FrostWire 1.0.6 - APR/08/2013
 - Faster search results. Search architecture revised and improved.
 - Includes search results from archive.org, which indexes millions
   of public domain and creative commons works from all over the
   internet.
 - Reduces CPU and battery consumption up to 84%.
 - FrostWire won't disable screen locking during audio playback.
   It's now up to the user to set longer auto-locking timeouts if
   they want to use FrostWire as an audio player in their vehicles.
 - UI fix, media player screen is correctly updated if a song starts
   while the screen was locked.
 - Updated icons and graphics.
 - Improved mime type detection.
 - Supports WebM video search results.
 - Updated UPnP cling libraries for better Wi-Fi sharing discovery.
 - Multiple crashes and freezes fixed.
 - Opens .torrent files from urls and from any file browser.
 - Faster hashing and checking of ongoing and finished torrent downloads.
 - Fixes a crash when sharing files from third party apps like FileKicker
   which pass filepath uris instead of android provider uris.
 - Fixes double audio playback issue with third party media playing apps.
 - Fixes bug where the app would force close and restart on phones without SD cards.
 - Fixes bug on Android 4.x where finished document downloads wouldn't appear under
   documents.
 - Avoids crash caused by AdMobSDK and WebView's cache being null.
 - Fixes bug where sharing files from a third party app would open FrostWire
   in a way that hitting the back button would take the user to the desktop and
   not back into the third party app.
 - Replaced navigation menu for a better one that presents itself with a smooth
   brief zoom-in animation.
 - Navigation menu and transfer screen looks properly on Motorola Razor
 - More efficient use of Bitmaps should cut down on the number of Out of Memory errors on most devices.

My First Raspberry PI Project: DIY ARM Video Game Console.

I got everything on amazon, didn’t pay for shipping (Prime member):

raspberry_pi_diy_game_console_nes_snes_sega_n64

So far I bought:
Raspberry PI ($48)

Raspberry PI case ($14)

Power adapter ($2.25)

SNES-like Controller with USB jack ($10.75)

SanDisk SDHC 16GB class 6 (30mb/s) ($15)

I first intend to install Ubuntu ARM along with several video game console emulators for NES, SNES, SEGA, N64.

People at the Raspberry PI G+ Community have suggested instead to install arch linux and keep it light, I’ll go first for ubuntu since I know it well.

However I’m thinking that a more interesting option, given that it has an ARM processor is to install Android Jelly Bean on it and see if not only I can run game emulators on it, I’ll be running and testing FrostWire for Android on it.

Ever since I started developing FrostWire for Android I’ve thought that Android has everything in it to be a desktop operating system, maybe Raspberry PI’s will be the hardware I’ll use to prove my vision.

The idea is to end up with a nice tutorial on how to do this after I’m done so you can all do it. In the meantime I’ll keep posting updates.

Archive.org as a new search engine in FrostWire puts millions of free legal files in your hands.

We’re currently polishing our next release of FrostWire for Android 1.0.6.

Our last release was back in November 2012, since then we’ve received crash reports and lots of complaints that have helped us make the next FrostWire for Android much more robust and compatible for the +2,600 different supported Android devices that run FrostWire on hundreds of thousands of mobile devices every day.

We’ve taken this time to make the search experience considerably faster and we’ve finally been able to integrate our search with another great source of legally free available content, Archive.org.

Archive.org is a non profit organization that crawls and indexes the web’s free content and as of the moment of this writing by having FrostWire connect to its search api you will be able to search through an astonishing number of free and legal works, here’s how they break them down on their home page today:

1,181,452 movies
114,118 live concerts
1,567,041 audio recordings
4,386,872 texts

that’s over 7,246,483 works most of which are tagged with Public Domain and Creative Commons licenses that you’ll be able to download and share with FrostWire.

Most of this content is under the Public Domain and also under Creative Commons licenses.
If FrostWire can detect the license on the content it yields on search results you will see it on screen.

And every year that passes, more works automatically fall into the public domain so you will be able to access more and more information for free absolutely legally, literally from the palm of your hand via FrostWire. We think this goes in line with our mission, and once this update is released the world will be a little better place to be in since all of you will be empowered with free digital works and culture.

Other than that we’ve fixed many crashes, freezes, lowered cpu and memory consumption (which will make your battery last more), we’ve done upgrades on almost all of the application icons, fixed issues for older phones that didn’t have SD cards the way new phones do now, bugs on the audio player and so much more.

Archive.org as a search engine, and a revamp of the search experience is also being added to FrostWire for Desktop so stay tuned for our next desktop release as well (5.5.6)

changelog

FrostWire 1.0.6 - 03/28/2013
 - Faster search results. Search architecture revised and improved.
 - Includes search results from archive.org, which indexes millions
   of public domain and creative commons works from all over the
   internet.
 - FrostWire won't disable screen locking during audio playback.
   It's now up to the user to set longer auto-locking timeouts if
   they want to use FrostWire as an audio player in their vehicles.
 - UI fix, media player screen is correctly updated if a song starts
   while the screen was locked.
 - Updated icons and graphics.
 - Improved mime type detection.
 - Updated UPnP cling libraries for better Wi-Fi sharing discovery.
 - Multiple crashes and freezes fixed.
 - Opens .torrent files from urls and from any file browser.
 - Fixes a crash when sharing files from third party apps like FileKicker
   which pass filepath uris instead of android provider uris.
 - Fixes double audio playback issue with third party media playing apps.
 - Fixes bug where the app would force close and restart on phones without SD cards.

jar dependencies if you plan to use the cling UPnP library in your android project

This took me quite a while and lots of runtime errors, here are the minimum jars I needed to add to my project since now cling when used on android needs jetty, and damn jetty is broken into a thousand little jars for maximum modularity.

These are the one jars that I needed to not have any more runtime (class not found) errors

jetty-security-8.1.8.v20121106.jar
jetty-http-8.1.8.v20121106.jar
jetty-continuation-8.1.8.v20121106.jar
jetty-io-8.1.8.v20121106.jar
jetty-util-8.1.8.v20121106.jar
jetty-server-8.1.8.v20121106.jar
jetty-servlet-8.1.8.v20121106.jar
jetty-client-8.1.8.v20121106.jar
servlet-api-3.0.jar

How to enable adb logcat on Android 4 (debugging output)

So you got a new Nexus or another Android running Android +4.2 and there’s no “Applications” menu entry in the settings menu.

No worries.

Go to the “About phone” entry at the bottom of settings, then scroll all the way down to the “Build number” menu entry.

Tap on it SEVEN times. (You’ll see funny “toast” messages come along)

When you go back to the main “Settings” menu, you will see a “{ } Developer options” entry.

Cheers

Android: Changing TextView alpha transparency across different target SDKs

Sometimes you may need to make a TextView (label) look a little transparent to make emphasis on other parts of your UI. The .setAlpha() function on TextView is not supported after later in the SDK. Here’s a static workaround you can place on some sort of UIUtils class you may have in your project.

[java]
/**
* Android devices with SDK below target=11 do not support textView.setAlpha().
* This is a work around.
* @param v – the text view
* @param alpha – a value from 0 to 255. (0=transparent, 255=fully visible)
*/
public static void setTextViewAlpha(TextView v, int alpha) {
v.setTextColor(v.getTextColors().withAlpha(alpha));
v.setHintTextColor(v.getHintTextColors().withAlpha(alpha));
v.setLinkTextColor(v.getLinkTextColors().withAlpha(alpha));

Drawable[] compoundDrawables = v.getCompoundDrawables();
for (int i=0 ; i < compoundDrawables.length; i++) { Drawable d = compoundDrawables[i]; if (d != null) { d.setAlpha(alpha); } } } [/java] Enjoy, and above all CODE!