Posts

Publish an aar file to Maven Central with Gradle

Image
In the last days I tried to publish ChangeLog Lib as aar (Android Archive) to Maven Central . First of all, I am a newbie in Gradle and Maven.I always used repo as a final user, so there could be better solutions. My first step was to find an approved repository . I decided to use the Sonatype OSS Repository , which is an approved repository provided by Sonatype. 1. Register your project at Sonatype It is easy. You can use the official guide . You have to follow the 2nd and 3th section. In this way you can create your user, and your project. When you create your project, pay attention to groupId . It is very important. Here you can find a some tips about it. If you don't own a domain, you can choose a groupId that reflects your project hosting, something like com.github.gabrielemariotti. You can't use it immediately; Sonatype have to prepare repo and normally it takes 1-2 business days. Then you can write your gradle scripts to upload aar file. 2. Grad...

A Card Library

Image
In the last weeks I tried to collect my code and build a Card library. I wanted something that could realize many types of Card (not all, of course), with some built-in features without having to rewrite each time a lot of code. I am still developing but a first version is presentable Card Library provides a custom tag CardView to display a UI Card. It provides different parts as a Header, a Thumbnail, a Shadow, a MainContentArea where you can inflate your custom layout You can customize the global layout as you like You can have some built-in features as OnClickListener, OnSwipeListener , OnLongClickListener CardHeader` provides an overflow button with a PopupMenuListener, a button to expand/collapse an area, or a customizable button with its listener. CardThumbnail` load a Bitmap with a resource ID or with a URL using `LRUCache` and an `AsyncTask` Create a `Card` is is pretty simple. First, you need an XML layout that will display the `Card`. Th...

Expand and collapse animation

Image
If you search a simple code to expand and collpse a View with an animation you'll find a lot of example. Almost all of the examples extend Animation class. Instead I would like to use an Animator and its listeners. Where I come from they say I'm discovering the hot water. I know, but it might be useful to someone. Here you can see a short video: The code is very simple: We'll use two LinearLayout . .... ..... ..... In our Activity we simply add a OnClickListener to our Header View. public class MainActivity extends Activity { LinearLayout mLinearLayout; LinearLayout mLinearLayoutHeader; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mLinearLayout = (LinearLayout) findViewById(R.id.expandable); //set visibility to GONE mLinearLayout.setVisibili...

An android library to display your changelog

Image
I've published a small library to display your changelog. You can find sources, docs and examples in github . ChangeLog Library provides an easy way to display a change log in your Android app. It provides a custom ListView to display a change log through a xml file. it supports multi language you can use it in Activities, Fragments, Dialogs it supports html text markup as bold and italics you can customize layout and behaviour Implementing this library in your own apps is pretty simple. First, you need an XML layout that will contain the ChangeLogListView that displays your changelog. Then, you need a XML file with change log in res/raw folder . It automatically searches for res/raw/changelog.xml but you can customize filename. Initial release. [b]New![/b] Add new attrs to customize header and row layout Fixed log while parsing Add support for html markup Add bulle...

Color Pickers from Google

Image
There are a lot of Color Pickers available, some very nice. The most difficult thing is to know that there are and where they are. Here a first collection, written by Google. Checkout in github repository last version and last document about usage. Google Stock Calendar You can find source in Color Picker repository . You can download and use it It is very simple to use. You have just to provide an array of colors. ColorPickerDialog colorcalendar = ColorPickerDialog.newInstance( R.string.color_picker_default_title, mColor, 0, 5, Utils.isTablet(this)? ColorPickerDialog.SIZE_LARGE : ColorPickerDialog.SIZE_SMALL); colorcalendar.show(getFragmentManager(),"cal"); mColor is an array of Color. public static int[] colorChoice(Context context){ int[] mColorChoices=null; String[] color_array = context.getResources(). getStringArray(R.array.default_color_choice_values); if (color_array!=null &...

Notification History in 4.3+

Image
Android 4.3 has a new hidden feature: Notification History . Currently there is no action. You can see it in Manifest.xml: https://github.com/android/platform_packages_apps_settings/blob/master/AndroidManifest.xml#L785 A simple way could be this: Intent intent = new Intent("android.settings.SETTINGS"); intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT, "com.android.settings.NotificationStation" ); Otherwise you can use: Widgets->Setting shortcuts->Notifications and put a shortcut in your home launcher.

NotificationListenerService and a Whatsapp extension for Dashclock

Image
Android 4.3 (API 18) introduced NotificationListenerService . In this post I'll talk how to use this API, and I'll show how an app can observe the stream of notifications with the user's permission. It is very easy to use a NotificationListenerService. First of all you have to extend NotificationListenerService and implement onNotificationPosted() and onNotificationRemoved() methods public class WhtsNotificationListener extends NotificationListenerService { @Override public void onNotificationPosted(StatusBarNotification sbn) { //.............. } @Override public void onNotificationRemoved(StatusBarNotification sbn) { //.............. } } Then you must declare the service in your manifest file with the BIND_NOTIFICATION_LISTENER_SERVICE permission and include an intent filter with the SERVICE_INTERFACE action Finally user must enable your service. Without t...