Fork me on GitHub

Thursday, October 30, 2014

Scaloid 3.6 is released

Today I released Scaloid 3.6. This version contains several feature improvements:

More concise intents

Intents often has a long list of extra attributes. Your code assigning these attributes should looks like this:
new Intent().putExtra("valueA", valueA).putExtra("valueB", valueB).putExtra("valueC", valueC)
This is a shame. Using Scala macros, I made a new function put(Any*) on Intent, that can be used like this:
new Intent().put(valueA, valueB, valueC)

Intents can be started

To start an activity from the intent above, we are writing like this:
startActivity(SIntent[MyActivity].put(valueA, valueB, valueC))
This is concise, but not really readable. From this version, we can rewrite it:
new Intent().put(valueA, valueB, valueC).start[MyActivity]
This looks more natural because it can be translated one-to-one in plain English:
Create a new Intent, and put values A, B, and C. Then, start the MyActivity.

Wrap or fill

I found that I am using layout properties wrap and fill very frequently. Because layout properties should written in <<...>> blocks, we have a lot of <<.wrap.>> and <<.fill.>> in our code. These idioms makes sense in terms of consistency, but not very pleasing. Because Scaloid is not stingy with providing shorthands, I dropped out <<...>> from it.

Now we can specify 'wrap-ness' of a TextView like this:
This looks trivial at first. However, think about how many times you are using it.

Additionally, we provide functions fw and wf, that is equivalent to <<(FILL_PARENT, WRAP_CONTENT).>> and <<(WRAP_CONTENT, FILL_PARENT).>> respectively.

Drops support Scala 2.10

Scaloid 3.6 is built on Scala 2.11.3, so you can use it with other Scala 2.11.x versions. From this version, I drops Scala 2.10 support to use full potential of recent improvements on macros.

Building Scala 2.11.3 on Android

I've found that building Android apps with Scala 2.11.3 (and 2.11.4) results more proguard warning, that prevents Android projects from being built. The error messages are:
Warning: scala.collection.SeqLike$$anon$1: can't find enclosing method 'scala.collection.mutable.Map occCounts(scala.collection.SeqLike,scala.collection.Seq)' in program class scala.collection.SeqLike
Warning: scala.collection.immutable.MapProxy$$anon$1: can't find enclosing method 'scala.collection.immutable.MapProxy newProxy(scala.collection.immutable.MapProxy,scala.collection.immutable.Map)' in program class scala.collection.immutable.MapProxy
Warning: scala.collection.immutable.SetProxy$$anon$1: can't find enclosing method 'scala.collection.immutable.SetProxy newProxy(scala.collection.immutable.SetProxy,scala.collection.immutable.Set)' in program class scala.collection.immutable.SetProxy
Warning: scala.collection.parallel.ParMapLike$$anon$3: can't find enclosing method 'scala.collection.parallel.IterableSplitter scala$collection$parallel$ParMapLike$$keysIterator(scala.collection.parallel.ParMapLike,scala.collection.parallel.IterableSplitter)' in program class scala.collection.parallel.ParMapLike
Warning: scala.collection.parallel.ParMapLike$$anon$4: can't find enclosing method 'scala.collection.parallel.IterableSplitter scala$collection$parallel$ParMapLike$$valuesIterator(scala.collection.parallel.ParMapLike,scala.collection.parallel.IterableSplitter)' in program class scala.collection.parallel.ParMapLike
Note: there were 1 references to unknown classes.
      You should check your configuration for typos.
Note: there were 2 classes trying to access generic signatures using reflection.
      You should consider keeping the signature attributes
      (using '-keepattributes Signature').
Warning: there were 5 unresolved references to program class members.
         Your input classes appear to be inconsistent.
         You may need to recompile the code.
[trace] Stack trace suppressed: run last android:proguard for the full output.
To build it successfully, add "-keepattributes Signature", "-dontwarn scala.collection.**" to your proguard options. Please refer to this commit log on hello-scaloid-git project that illustrates this patch.

Using Scaloid 3.6.1

Scaloid is released to central maven repository.

Update: Scaloid 3.6 was built on Scala 2.11.3, that has some bug on its compiler. I rebuilt Scaloid on Scala 2.11.4 and released it as 3.6.1

For a maven project:
or for an sbt project:
libraryDependencies += "org.scaloid" %% "scaloid" % "3.6.1-10"