Giter Site home page Giter Site logo

scaloid's People

Contributors

atry avatar cjng96 avatar fayimora avatar fxthomas avatar guersam avatar keithpinson avatar nremond avatar pkmx avatar placrosse avatar pocorall avatar sgrif avatar taisukeoe avatar tewu avatar tvierling avatar wyverny avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

scaloid's Issues

Compatibility support

Hi,

I'm working on an Android client for my service which requires reasonable compatibility.

Scaloid-apidemos runs on my old GB machine but crashes with some higher-version features like Fragment.

Do you have any plans to support old devices? Covering from the minimum like android.support package to ActionbarSherlock or (hopefully) HoloEverywhere would be great.

I'm willing to work on this issue, but it might bring a lot of refactoring which causes breaking backward compatibility.

Convert PHP generator to SBT plugin (forked from #2)

I'm working on Scala based generator as we agreed on #2.

As StringTemplate implements strict model-view separation, it's hard to convert existing PHP code "as it is," so it's taking longer than I expected.

Fortunately I managed to get some improvement. Hope to deliver initial working code in a few days.

tooll chain

Would you please describe the tool chain configuration? I have installed eclipse + android plugin + android sdk + jdk + scala-ide.org and trying to import the default scaloid project.
Does not work, alot of syntax errors .

Subclassing SButton (or any other S... class for that matter)

This is most probably my fault again. I would like to create a subclass of SButton that takes a list of SEdit texts in its constructor.
I tried to subclass it in many different ways, but could not do it. The final problem was something about a missing implicit conversion.

What is the simplest way of creating such a subclass? Do I need to create a companion object to keep the SButton {...} syntax? Can I subclass a companion object?
It's most probably my lack of knowledge of the Scala language so I would appreciate any pointers on this!

Remove unused classes/method from WidgetFamily

I'm working on the cleanup mentioned here.

There are class ObjectSView, class ObjectSTextView, class ObjectSButton and def apply in WidgetFamily.scala but I can't find any usage or documentation of them.

What are they for? We already have similar constructors in STextView and SButton and the only difference is that the former uses deprecated Manifest which causes compile-time warning.

If it's not used anymore, I can safely remove them that helps flattening the container trait.

Android SDK 4.2 not supported

When compiling with Android SDK 4.2, Proguard gives the following warning:

[android] Warning: org.scaloid.common.TraitWebView$class: can't find referenced method 'android.view.View getZoomControls()' in class android.webkit.WebView

It seems that the method has been removed somewhere between 4.0 and 4.2 since if compiled with SDK 4.0 everything works correctly.

Not sure how to solve this. :) getZoomControls is deprecated anyway (I think it has been for a long time), so maybe you can just remove it.

For now my workaround is using SDK 4.0.

I'm using 2.1-8.

Implicit context value is shadowed by context method in TraitView

The implicit value context from SActivity or SContext is shadowed by the context method defined in TraitView, which causes an error when compiling with Scala 2.10 due to SI-4270.

new SVerticalLayout {
    += (new STextView)
}

Calling scalac with -Xlog-implicits gives:

[info] MainActivity.scala:12: context is not a valid implicit value for android.content.Context because:
[info] candidate implicit value context in trait SActivity is shadowed by method context in trait TraitView
[info]         += (new STextView)
[info]             ^
[error] MainActivity.scala:12: could not find implicit value for parameter context: android.content.Context

Removing context method from TraitView definitely gets rid of this error. I guess that one of them needs to be re-named, not sure what you think about this.

Scaloid and dex method count limit

Using the sbt android-sdk-plugin we run into the dex method limit (if we don't specify clean on every package), and scalaoid seems to count ~ 50000 to this limit (see the "[warn] 50446 org.scaloid.common" below)

/opt/sbt-0.13.2/bin/sbt android:package
[info] Loading global plugins from /home/chris/.sbt/0.13/plugins
[info] Loading project definition from /home/chris/prj/android/android-app/project
[info] Set current project to gutefrage.net Android App (in build file:/home/chris/prj/android/android-app/)
[info] Generating R.java
[info] Regenerating TR.scala because R.java has changed
[info] Compiling 1 Java source to /home/chris/prj/android/android-app/target/android-bin/classes...
[info] Packaging /home/chris/prj/android/android-app/target/android-bin/classes.jar ...
[info] Done packaging.
[info] Finding dependency references for: classes.jar
[info] [debug] cache hit, skipping proguard!
[info] [debug] Forcing clean dex
[info] Generating classes.dex
[warn] 
[warn] trouble writing output: Too many method references: 87874; max is 65536.
[warn] You may try using --multi-dex option.
[warn] References by package:
[warn]     17 android.app
[warn]      3 android.appwidget
[warn]     59 android.content
[warn]     10 android.content.res
[warn]     11 android.database
[warn]     32 android.gesture
[warn]     58 android.graphics
[warn]      1 android.graphics.drawable
[warn]     12 android.inputmethodservice
[warn]      3 android.media
[warn]      1 android.net
[warn]     12 android.opengl
[warn]      7 android.os
[warn]     59 android.preference
[warn]      2 android.telephony
[warn]      2 android.text
[warn]     12 android.util
[warn]    156 android.view
[warn]     21 android.webkit
[warn]    577 android.widget
[warn]    155 com.fasterxml.jackson.annotation
[warn]    480 com.fasterxml.jackson.core
[warn]    148 com.fasterxml.jackson.core.base
[warn]     34 com.fasterxml.jackson.core.format
[warn]    159 com.fasterxml.jackson.core.io
[warn]    425 com.fasterxml.jackson.core.json
[warn]    100 com.fasterxml.jackson.core.sym
[warn]     25 com.fasterxml.jackson.core.type
[warn]    286 com.fasterxml.jackson.core.util
[warn]   1179 com.fasterxml.jackson.databind
[warn]     39 com.fasterxml.jackson.databind.annotation
[warn]    166 com.fasterxml.jackson.databind.cfg
[warn]    514 com.fasterxml.jackson.databind.deser
[warn]    271 com.fasterxml.jackson.databind.deser.impl
[warn]    572 com.fasterxml.jackson.databind.deser.std
[warn]     18 com.fasterxml.jackson.databind.exc
[warn]     41 com.fasterxml.jackson.databind.ext
[warn]    680 com.fasterxml.jackson.databind.introspect
[warn]    100 com.fasterxml.jackson.databind.jsonFormatVisitors
[warn]     12 com.fasterxml.jackson.databind.jsonschema
[warn]     61 com.fasterxml.jackson.databind.jsontype
[warn]    196 com.fasterxml.jackson.databind.jsontype.impl
[warn]     64 com.fasterxml.jackson.databind.module
[warn]    635 com.fasterxml.jackson.databind.node
[warn]    279 com.fasterxml.jackson.databind.ser
[warn]    252 com.fasterxml.jackson.databind.ser.impl
[warn]    621 com.fasterxml.jackson.databind.ser.std
[warn]    301 com.fasterxml.jackson.databind.type
[warn]    459 com.fasterxml.jackson.databind.util
[warn]     68 com.fasterxml.jackson.module.scala
[warn]    569 com.fasterxml.jackson.module.scala.deser
[warn]    212 com.fasterxml.jackson.module.scala.experimental
[warn]    538 com.fasterxml.jackson.module.scala.introspect
[warn]    101 com.fasterxml.jackson.module.scala.modifiers
[warn]    251 com.fasterxml.jackson.module.scala.ser
[warn]    132 com.fasterxml.jackson.module.scala.util
[warn]      1 com.google.code.rome.android.repackaged.com.sun.syndication.feed
[warn]      1 com.google.code.rome.android.repackaged.com.sun.syndication.feed.synd
[warn]      9 com.google.code.rome.android.repackaged.com.sun.syndication.io
[warn]      3 com.google.common.annotations
[warn]    755 com.google.common.base
[warn]      7 com.google.common.base.internal
[warn]    845 com.google.common.cache
[warn]   8134 com.google.common.collect
[warn]     74 com.google.common.escape
[warn]     53 com.google.common.eventbus
[warn]    444 com.google.common.hash
[warn]      3 com.google.common.html
[warn]    696 com.google.common.io
[warn]    102 com.google.common.math
[warn]    152 com.google.common.net
[warn]    511 com.google.common.primitives
[warn]    483 com.google.common.reflect
[warn]   1088 com.google.common.util.concurrent
[warn]      4 com.google.common.xml
[warn]     11 com.google.gson
[warn]    103 com.thoughtworks.paranamer
[warn]      8 default
[warn]      2 java.beans
[warn]    167 java.io
[warn]    400 java.lang
[warn]      1 java.lang.annotation
[warn]     13 java.lang.ref
[warn]     92 java.lang.reflect
[warn]     63 java.math
[warn]     73 java.net
[warn]     38 java.nio
[warn]      3 java.nio.channels
[warn]      6 java.nio.charset
[warn]     15 java.security
[warn]      2 java.security.cert
[warn]      5 java.sql
[warn]     21 java.text
[warn]    439 java.util
[warn]    145 java.util.concurrent
[warn]     39 java.util.concurrent.atomic
[warn]     41 java.util.concurrent.locks
[warn]     10 java.util.jar
[warn]      7 java.util.logging
[warn]     17 java.util.regex
[warn]     15 java.util.zip
[warn]     22 javax.annotation
[warn]      1 javax.annotation.concurrent
[warn]      8 javax.annotation.meta
[warn]      1 javax.inject
[warn]      8 javax.net.ssl
[warn]      4 javax.xml.datatype
[warn]      1 javax.xml.namespace
[warn]      4 javax.xml.parsers
[warn]      3 javax.xml.transform
[warn]      3 javax.xml.transform.dom
[warn]      1 javax.xml.transform.sax
[warn]      2 javax.xml.transform.stream
[warn]    192 net.gutefrage.android
[warn]    127 net.gutefrage.android.rest
[warn]      4 net.gutefrage.android.rest.jackson
[warn]     14 net.gutefrage.android.rest.support
[warn]      9 net.gutefrage.android.util
[warn]     18 org.apache.commons.httpclient
[warn]      9 org.apache.commons.httpclient.methods
[warn]      2 org.apache.commons.httpclient.params
[warn]     10 org.apache.http
[warn]      3 org.apache.http.client
[warn]     11 org.apache.http.client.methods
[warn]      1 org.apache.http.conn
[warn]      3 org.apache.http.conn.params
[warn]      4 org.apache.http.conn.scheme
[warn]      1 org.apache.http.conn.ssl
[warn]      1 org.apache.http.entity
[warn]      1 org.apache.http.impl.client
[warn]      1 org.apache.http.impl.conn.tsccm
[warn]      3 org.apache.http.params
[warn]      4 org.codehaus.jackson
[warn]      7 org.codehaus.jackson.map
[warn]      1 org.codehaus.jackson.map.type
[warn]      1 org.scaloid
[warn]  50446 org.scaloid.common
[warn]     34 org.scaloid.util
[warn]      2 org.simpleframework.xml
[warn]      1 org.simpleframework.xml.core
[warn]     18 org.springframework.beans
[warn]      1 org.springframework.beans.factory
[warn]    106 org.springframework.core
[warn]    111 org.springframework.core.io
[warn]    202 org.springframework.http
[warn]    140 org.springframework.http.client
[warn]     14 org.springframework.http.client.support
[warn]     89 org.springframework.http.converter
[warn]     17 org.springframework.http.converter.feed
[warn]     44 org.springframework.http.converter.json
[warn]     36 org.springframework.http.converter.xml
[warn]    364 org.springframework.util
[warn]     49 org.springframework.util.support
[warn]    130 org.springframework.web.client
[warn]      4 org.springframework.web.client.support
[warn]    200 org.springframework.web.util
[warn]      2 org.w3c.dom.bootstrap
[warn]      2 org.w3c.dom.ls
[warn]      2 org.xml.sax
[warn]    377 scala
[warn]   1792 scala.collection
[warn]    333 scala.collection.convert
[warn]    171 scala.collection.generic
[warn]   2337 scala.collection.immutable
[warn]   2554 scala.collection.mutable
[warn]      2 scala.compat
[warn]     31 scala.concurrent
[warn]    140 scala.concurrent.forkjoin
[warn]     59 scala.concurrent.impl
[warn]      1 scala.concurrent.util
[warn]      1 scala.io
[warn]    678 scala.math
[warn]    210 scala.reflect
[warn]    115 scala.runtime
[warn]     75 scala.sys
[warn]    121 scala.util
[warn]     19 scala.util.control
[warn]     32 scala.util.hashing
[warn]     13 scala.util.matching
[warn]     15 sun.misc
com.android.ide.common.internal.LoggedErrorException: Failed to run command:
    /opt/android-sdk-linux/build-tools/19.0.3/dx -JXmx1024m --dex --incremental --no-strict --output /home/chris/prj/android/android-app/target/android-bin/classes.dex /home/chris/.ivy2/cache/org.scaloid/scaloid_2.11/jars/scaloid_2.11-3.3-8.jar /home/chris/.ivy2/cache/com.google.guava/guava/bundles/guava-15.0.jar /home/chris/.ivy2/cache/com.fasterxml.jackson.core/jackson-core/bundles/jackson-core-2.4.0-rc1.jar /home/chris/.ivy2/cache/com.thoughtworks.paranamer/paranamer/jars/paranamer-2.6.jar /home/chris/.ivy2/cache/com.fasterxml.jackson.core/jackson-databind/bundles/jackson-databind-2.4.0-rc1.jar /home/chris/prj/android/android-app/target/scala-2.11/cache/android-app/global/proguard_cache/proguard-cache-7da24952ee22ce2189e8a1e9e937a8b7c38a7e9a.jar /home/chris/.ivy2/cache/com.fasterxml.jackson.module/jackson-module-scala_2.11/bundles/jackson-module-scala_2.11-2.4.0-rc1.jar /home/chris/prj/android/android-app/target/android-bin/classes.jar /home/chris/.ivy2/cache/org.springframework.android/spring-android-core/jars/spring-android-core-1.0.1.RELEASE.jar /home/chris/.ivy2/cache/com.google.code.findbugs/jsr305/jars/jsr305-2.0.1.jar /home/chris/.ivy2/cache/org.springframework.android/spring-android-rest-template/jars/spring-android-rest-template-1.0.1.RELEASE.jar /home/chris/.ivy2/cache/com.fasterxml.jackson.core/jackson-annotations/bundles/jackson-annotations-2.4.0-rc1.jar
Error Code:
    2

Error compiling Maven example

Need help!

[ERROR] Failed to execute goal com.jayway.maven.plugins.android.generation2:andr
oid-maven-plugin:3.2.0:generate-sources (default-generate-sources) on project he
llo-scaloid-maven: Execution default-generate-sources of goal com.jayway.maven.p
lugins.android.generation2:android-maven-plugin:3.2.0:generate-sources failed: A
 required class was missing while executing com.jayway.maven.plugins.android.gen
eration2:android-maven-plugin:3.2.0:generate-sources: Lorg/sonatype/aether/Repos
itorySystem;
Apache Maven 3.1.0-alpha-1 (c726cdd3a9ad5c3a419e1171f8c1925e336ead18; 2013-06-01
 21:03:28+0800)
Maven home: D:\App\apache-maven-3.1.0-alpha-1\bin\..
Java version: 1.7.0_10, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.7.0_10\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"

XML-less layout with custom views.

I have made two custom Views. How do I make them compatible with the XML-less approach?

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/lockscreen_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal">
    <ViewStub
        android:id="@+id/lockscreen_stub"
        android:layout_width="match_parent"
        android:layout_height="fill_parent"
    />
    <com.menthal.nyx.view.LockScreenClock
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center|center_vertical|top"
            android:textSize="110dip"
            android:id="@+id/clock" android:textIsSelectable="false" android:textColor="@color/foreground"/>
    <com.menthal.nyx.view.LockScreenCircle
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/progress" android:layout_gravity="center_horizontal|bottom"
            android:layout_alignParentEnd="false"
            android:layout_alignParentBottom="true"
            android:layout_marginLeft="60dip"
            android:layout_marginBottom="20dip"
            android:layout_marginRight="60dip"/>
</RelativeLayout>

Is translated to this:

  override def onCreate(savedInstanceState: Bundle) {
    super.onCreate(savedInstanceState)

    contentView = new SRelativeLayout {
      SViewStub().<<.fill.>>
      Scom.menthal.nyx.view.LockScreenClock().textSize(110 dip)
      Scom.menthal.nyx.view.LockScreenCircle().<<.marginBottom(20 dip).marginLeft(60 dip).marginRight(60 dip).>>
    }
  }

Which is obviously wrong. How do I make S* versions of my custom views?

Replace noEquivalentGetterExists annotation with 'notSupported' macro

There are a lot of defaultValue[SomeType] with @noEquivalentGetterExists in Widgets.scala for non-existing getters in Android, IMHO, it might make debugging difficult as it just returns useless default value of specific type.

Maybe we can replace it with a macro that notifies unsupported operations at compile time.

Using scaloid in Android Studio

I added scaloid as a dependency in build.gradle (using Android Studio) but when I try to build the project I get the exception below. Any idea what the issue might be? Any guides out there on how to use scaloid with Andoid Studio?

Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
    /mnt/data/android-studio/sdk/build-tools/android-4.4.2/dx --dex --output /home/zoran/code/WorldCupTicker/app/build/dex/debug /home/zoran/code/WorldCupTicker/app/build/classes/debug /home/zoran/code/WorldCupTicker/app/build/dependency-cache/debug /home/zoran/code/WorldCupTicker/app/build/pre-dexed/debug/scala-library-2.11.0-b42a200cc2ebab992db04ea0a12c1512a40ca5de.jar /home/zoran/code/WorldCupTicker/app/build/pre-dexed/debug/scaloid_2.11-3.4-10-dd46ba57788b210ab3ca3c0074d58196558b9bf6.jar
  Error Code:
    2
  Output:
    UNEXPECTED TOP-LEVEL EXCEPTION:
    java.lang.IllegalArgumentException: method ID not in [0, 0xffff]: 65536
        at com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:501)
        at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:276)
        at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:490)
        at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:167)
        at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
        at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:439)
        at com.android.dx.command.dexer.Main.runMonoDex(Main.java:287)
        at com.android.dx.command.dexer.Main.run(Main.java:230)
        at com.android.dx.command.dexer.Main.main(Main.java:199)
        at com.android.dx.command.Main.main(Main.java:103)

Cannot use TraitContext in Fragments or other places where context is null in constructor

I've run into issues attempting to do the following:

class MyFragment extends ListFragment with TraitContext[Context] {
  override def basis = getActivity
  lazy val adapter = new MyAdapter

  override def onCreate(savedInstanceState: Bundle) = {
    super.onCreate(savedInstanceState)
    setListAdapter(adapter)
  }

  //Actual data is given to the adapter later, though the data itself is irrelevant
}

class MyAdapter(implicit context: Context) extends BaseAdapter {
  def layoutInflater = LayoutInflater.from(context)

  override def getView(index: Int, convertView: View, parent: ViewGroup) = {
    if (convertView == null) {
      layoutInflater.inflate(...) // Error occurs here
    }
  }
}

The issue stems from the fact that getActivity returns null at the point where implicit val ctx = basis is evaluated. This could be fixed if ctx were changed to a def or a lazy val.

Follow Scala versioning convention

Now we'll go with single API level as discussed in #43, so how about removing API level from our version number and follow Scala's major.minor.bugfix convention instead?

Unit tests

As the codebase grown, adding unit test will be helpful when adding features or changing behavior.

Examples using Robolectric with Scalatest or Specs2 are interesting but look a bit outdated.

Corresponding mailing list threads are as below:

How to build layout for BaseAdapter with Scaloid?

Until now there is a line inside my BaseAdapters that looks like this

LayoutInflater.from(context).inflate(R.layout.list_item, null);

I cannot get how I could use Scaloid to get rid of the xml file.
I tried searching inside scaloid examples but I could not find any.

Could you give a brief sample of such a usage?

I am new in Scaloid and I guess it can be used in all cases. Is that correct?

Ask me for more information if necessary

Thanks!

Upgrade default API Level to 16

I'm trying to merge support-v4 package into this repo using SBT's multiple project feature to provide consistent Scaloid API.

Unfortunately, current supported API level is 8 only which causes when extracting support-v4-r7 classes due to that it requires Android 4.0.1.2 at least.

For 2.0 release, I suggest increasing API level to 16 and providing support-v4 in this repo because most famous third-party libraries support it.

Support for multiple devices and standard resources

Hello, I've looked on scaloid layouts without xml and I have some questions:

  • How do you imagine support multiple devices, tablets?
    In standart we can create similar xml files in children resource folders
    I mean this http://developer.android.com/guide/practices/screens_support.html
  • I think we should create some features for standard resources: strings(localization), dimensions, colors, etc if we don't want to use standard xml files
  • Auto build android manifest: add activities, services, permissions?
    With sbt or some scala script

Event-listener setters should have signature onClick[U](f: View ⇒ U) instead of onClick(f: View ⇒ Unit)

I find myself adding superfluous unit literals at the end of event handlers.

Compare the following two examples:

Using Scaloid's onClick:

button.onClick {
  dir.mkdir() // ← returns Boolean, not Unit
  () // ← boilerplate required to conform with Unit result type
}

Compared to trivial usage of Scala's foreach:

dirs.foreach { dir ⇒
  dir.mkdir() // ← returns Boolean, which is discarded
}

The latter is preferable.

This is really easy to implement, as seen from foreach's definition:

def foreach[U](f: A ⇒ U): Unit

Where U clearly stands for Unit, but is actually more liberal.

Applying this to (e.g.) 'onClick', the signature would look like so:

def onClick[U](f: View ⇒ U)

Recover SContext and SService or not

As Thyphon commented at the 2.0-RC1 blog post:

SContext no more present. How to use it? I'm trying to port https://github.com/thypon/bits-widget

It's my bad not mentioned that trait SContext had become trait TraitContext[V <: Context] (SService for the same) during the refactoring.. All the other prefixed classes are concrete than the above, so I couldn't notice this change in advance.

Maybe we need to establish a policy for these kind of abstract classes. Do you have any idea?

automatic inheritance

Currently we need to specify superclass for TraitA manually.

Detecting them automatically will reduce much code duplication and prevent mistakes.

I'll try this in accordance with corresponding Android hierarchy. Manual mix-in might be supported later but not sure of it's usefulness yet.

Include implicit ExecutionContext to avoid dynamic invocation problems

I recently ran into this problem that you also discovered—and found a solution for! It works great, but perhaps to avoid confusion in the future, it would be helpful to have

implicit val exec = ExecutionContext.fromExecutor(
  new ThreadPoolExecutor(100, 100, 1000, TimeUnit.SECONDS,
    new LinkedBlockingQueue[Runnable]))

in scope whenever someone imports org.scaloid.common._.

Migrate template engine to Twirl

Although StringTemplate is simple & fast, it must be great if we can use a Scala based, type safe template engine such as Twirl.

The priority is not that high though.

Add implicit conversions to Parcelable

I frequently use Android's Parcelable interface to allow for my classes to be transported across Activity changes (e.g., screen rotations or passing via Intents). Android developers endorse Parcelable over Serializable due to its improved speed.

The downside to Parcelable is that implementing it brings a ton of boilerplate. Here is a "small" example of a Parcelable class:

import android.os.{Parcel, Parcelable}

class Foo(val bar: String) extends Parcelable {
  override def describeContents: Int = 0

  override def writeToParcel(dest: Parcel, flags: Int): Unit = dest.writeString(bar)
}

object Foo {
  val CREATOR = new Parcelable.Creator[Foo] {
    override def createFromParcel(source: Parcel): Foo = new Foo(source.readString())

    override def newArray(size: Int): Array[Foo] = new Array(size)
  }
}

This seems like a task well-suited to Scala's implicits/traits. In particular, I was hoping for a solution that incorporates some of these ideas:

  1. Implicit conversions from Java's primitive types to Parcelable. Currently, Parcel has a bazillion different methods for reading/writing primitive types (e.g., readInt()/writeString(), readString()/writeString(), etc.) plus readParcelable()/writeParcelable(). I would like to only have to use the latter, so having implicit conversions from Int, String, etc. to Parcelable would be very useful.
  2. Parcelable conversions for commonly-used collections. For example, List[P], where P has an implicit conversion to Parcelable.
  3. Some sort of simpler trait to extend that allows a class to be Parcelable. (SParcelable?)

The biggest obstacle that prevents me from doing this myself is Parcelable's unusual requirement that all classes implementing it must have a static field named CREATOR (there exists a Scala compiler hack that allows you to define CREATOR as a value in the class's companion object). There would need to be some way of retrofitting classes such as Int and String to have a static CREATOR field, and a way for classes which extend SParcelable to have a static CREATOR field.

I'm not sure what the best way of approaching this is, so I'm open to suggestions. Scala macros are the only way that I can think of accomplishing this, but I'm not very well-versed in macros.

Some rules in SRelativeLayout.LayoutParams should take an anchor

Some of the methods such as above, below, leftOf and rightOf in SRelativeLayout.LayoutParams should take another view as anchor, so that android knows how to place views relative to each other.

Since our programmatically created views do not have an id (v.id returns -1) unless explicitly assigned, and addRule(verb: Int, anchor: Int) takes id of our view, I'm not sure how to solve this elegantly without resorting back to manually assigning id's.

I guess some sort of automatic counter trait would work?

Error using TraitView:onTouch(f: => Boolean) when using scaloid as a jar

This is weird, and tests my still meager scala knowledge :)

If I knit scaloid sources into my source tree and do:

  edit.onTouch {
    // This is needed to force keyboard focus when using hw keyboards.
    edit.requestFocusFromTouch()
    false
  }

Everything's cool. OTOH, if I consume scaloid as a jar, when I touch the view, I get an error:

03-04 16:35:30.530: E/InputEventReceiver(24232): Exception dispatching input event.
03-04 16:35:30.530: E/MessageQueue-JNI(24232): Exception in MessageQueue callback: handleReceiveCallback
03-04 16:35:30.540: E/MessageQueue-JNI(24232): java.lang.NoSuchMethodError: scala.Function0.apply$mcZ$sp
03-04 16:35:30.540: E/MessageQueue-JNI(24232):  at org.scaloid.common.WidgetFamily$TraitView$$anon$17.onTouch(Widget.scala:184)
...

OTOH, If I use:

  edit.onTouch {
    (_, _) =>
    // This is needed to force keyboard focus when using hw keyboards.
    edit.requestFocusFromTouch()
    false
  }

Forcing use of onTouch(f: (View, MotionEvent) => Boolean) I don't get the error.

I don't see what you could have done wrong. I was a little suspicious of the use of @inline, but removing that didn't help. I suppose this is a scala bug?

I'm using scala 2.10 (with Eclipse and Proguard.)

I have my work around. But there's at least a trap here.

TableRows are not converted correctly

Hey! I was trying to use the library, but I am not able to create TableRows correctly.

I went to the layout converter and It does not take in account the views inside the TableRow.

Do you have a working example of STableRow?

Thanks

Add R.string support

Hi,

I am new to this lib, but so far I really appreciate how it makes my code dry.

However there is a feature I am missing.

Most of the classes doesn't support R.string reference directly.

An example is the AlerDialog class.

So we need to use getString everywhere.

Supporting R.string will drive users to better pattern, instead of hardcoding the string as many of us tends to do :-)

Moreover, in Preference, XML ref can be very powerful as IDE can check the R.string exists in both place, where the pref is saved and where the pref is read. So you avoid some typo.

Regards

Possible issue with multiple short listeners

There are many onSomethingHappend with more than 1 callback like below (from here):

@inline def onItemSelected(f:  => Unit): V = {
  basis.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener {
    def onItemSelected(p1: AdapterView[_], p2: View, p3: Int, p4: Long): Unit = { f }
    def onNothingSelected(p1: AdapterView[_]): Unit = {  }
  })
  basis
}

As it invokes basis.setSomeListener which replaces previous listener, calling onNothingSelected with onItemSelected will cancel each other.

We might solve this with internal addSomeListener implementation. Do you have any idea to improve this?

Too many methods when predexing Scaloid

I use preloading a lot to reduce my Scala on Android build times. This basically means that I run my libraries (Scala, usually) through the dx utility, and then upload them to my device.

I recently tried running the new Scaloid after a while using an old version, and, much to my dismay, the number of methods in the JAR is now a whooping 76243. Which is even bigger than scala-library and can't even be predexed! This is the output I get when I try :

trouble writing output:
com.android.dx.util.DexException: Too many methods: 76243; max is 65536. By package:
    17 android.app
     3 android.appwidget
    52 android.content
     6 android.content.res
    32 android.gesture
    12 android.inputmethodservice
     3 android.media
     1 android.net
    14 android.opengl
     5 android.os
    66 android.preference
     2 android.telephony
     2 android.text
     8 android.util
   239 android.view
   833 android.widget
    12 java.lang
     2 java.util.concurrent.atomic
     4 org.scaloid
 74888 org.scaloid.common
    16 scala
     1 scala.collection
     7 scala.collection.mutable
     1 scala.reflect
    17 scala.runtime
    at com.android.dx.dex.file.MemberIdsSection.orderItems(MemberIdsSection.java:49)
    at com.android.dx.dex.file.UniformItemSection.prepare0(UniformItemSection.java:73)
    at com.android.dx.dex.file.Section.prepare(Section.java:214)
    at com.android.dx.dex.file.DexFile.toDex0(DexFile.java:506)
    at com.android.dx.dex.file.DexFile.toDex(DexFile.java:216)
    at com.android.dx.command.dexer.Main.writeDex(Main.java:578)
    at com.android.dx.command.dexer.Main.run(Main.java:221)
    at com.android.dx.command.dexer.Main.main(Main.java:174)
    at com.android.dx.command.Main.main(Main.java:91)

I'm wondering at the cause of all this, but I haven't gone through all the changes between the version I used to have and this one. Is there a way we can reduce that method count? Any workaround?

(Note: Using Proguard works, of course, but this is not the point of my issue...)

Group into separate packages

Hi,

Thanks for these lovely helpers! I decided to use it for my first android project in Scala and looking into it.

common.scala was small at first but now it has became a beast of 3,304 lines. Placing them into mimicked android package structure will make it easier to understand I guess.

Missing getter/setter sugars for some abstract members

Some getter/setters are missed in TraitXXX. For example, TraitContextMenu for android.view.ContextMenu had some setters like headerTitle_=, but nothing in the current version.

I guess it is missed because of it is an abstract method. So I tried to comment out !isAbstract(m) && from the function getPolymorphicSetters, but it does not help.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.