Giter Club home page Giter Club logo

baitha's Introduction

Baiṭha: The Scala/Android Toolkit

Baitha is a library designed to make Scala development on Android easier and more fun. It leverages some of Scala’s features such as mix-ins and implicit conversions to make Android development with Scala a bit more idiomatic.

Current features

Baitha is still under heavy development. Some of its current features include:

AlertDialogBuilder

An wrapper around Android’s AlertDialog.Builder class that provides some implicit conversions and a mini-DSL.

BuildMode

A trait that makes converting between debug/production code easier.

EnhancedViews

Provides some implicit conversions to make adding listeners as functions.

Logger

A replacement logging interface inspired by RoboGuice.

SdkVersions

Offers conditional execution depending on the runtime version of the Android platform.

TypedColumn and TypedCursorWrapper

An easier way to get data out of a cursor.

Using the library

Baitha is designed to be used as an Android library project. This means that instead of including a compiled JAR file in your Android project, your project will directly make use of the source files provided by the library.

Building the SBT android-plugin

As of the time of this writing the latest release of the Android plugin for SBT (0.5.1) does not support Android libraries. However, the master branch has already integrated this support. You can build a local version of the plugin using the following steps:

% git clone git://github.com/jberkel/android-plugin.git
% cd android-plugin
% sbt update publish-local

The above steps should create a local version of the plugin with the necessary library project support. To use the library, you will need to modify your project/plugins/plugins.scala file to have the following line:

val android = "org.scala-tools.sbt" % "sbt-android-plugin" % "0.5.2-SNAPSHOT"

Getting a copy of the library

One approach is to add the Baitha library as a Git submodule in a subdirectory of your project. Otherwise, you can check it out into its own directory:

% git clone git://github.com/sattvik/baitha.git

Adding the library to your project

In order to actually use the library, you will need to make a reference to it in your SBT project definition. To accomplish this, you will need to make some modifications to your project/build/project.scala:

Example project definition that uses the Baitha library
import sbt._

trait Defaults {
  def androidPlatformName = "android-9" // (1)
}
class Parent(info: ProjectInfo) extends ParentProject(info) {
  override def shouldCheckOutputDirectories = false
  override def updateAction = task { None }

  lazy val baitha = project(Path.fromFile("../baitha"), "baitha", new BaithaProject(_)) // (2)
  lazy val main  = project(".", "My Android Project", new MainProject(_), baitha) // (3)
  lazy val tests = project("tests",  "tests", new TestProject(_), main)

  class MainProject(info: ProjectInfo) extends AndroidProject(info) with Defaults with MarketPublish with TypedResources {
    val keyalias  = "change-me"
    val scalatest = "org.scalatest" % "scalatest" % "1.3" % "test"
  }

  class TestProject(info: ProjectInfo) extends AndroidTestProject(info) with Defaults

  class BaithaProject(info: ProjectInfo) extends AndroidLibraryProject(info) with Defaults { // (4)
    val scalatest = "org.scalatest" % "scalatest" % "1.3" % "test"
    val mockito = "org.mockito" % "mockito-core" % "1.8.5" % "test"
  }
}
  1. To compile, Baitha currently requires API level 9 or higher. However, the runtime works with API level 7 and higher.

  2. Creates the project. Note that the Path.fromFile("…") is only necessary if accessing Baitha outside of your project’s directory structure. If you go for the git submodule approach, you can just use the directory name as a string.

  3. Declares the library as a dependency of the main project.

  4. Defines the library project along with test dependencies.

Once you have made the above changes, reloading and updated your SBT project should make the library available for you.

Contributing

As this project is very new, there is no process yet for contributing to the code. For now, your best bet is to open an issue or submit a pull request.

Copyright © 2011 Sattvik Software & Technology Resources, Ltd. Co. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

baitha's People

Contributors

sattvik avatar

Watchers

 avatar

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.