Skip to content
This repository has been archived by the owner on Oct 26, 2022. It is now read-only.

Commit

Permalink
Rename TypedResources2 to TypedLayouts
Browse files Browse the repository at this point in the history
  • Loading branch information
appamatto committed Aug 13, 2013
1 parent 9448411 commit 05f1388
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/main/scala/AndroidBase.scala
Expand Up @@ -386,8 +386,8 @@ object AndroidBase {
// Use typed resources by default
useTypedResources := true,

// Use typed resources 2 by default
useTypedResources2 := true,
// Use typed layouts by default
useTypedLayouts := true,

// Gradle uses libs/ as the unmanaged JAR directory!
unmanagedBase <<= (baseDirectory) (_ / "libs"),
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/AndroidJavaLayout.scala
Expand Up @@ -10,7 +10,7 @@ object AndroidJavaLayout {
autoScalaLibrary in GlobalScope := false,
useProguard in Compile := false,
useTypedResources in Compile := false,
useTypedResources2 in Compile := false,
useTypedLayouts in Compile := false,
manifestPath in Compile <<= (baseDirectory, manifestName) map((s,m) => Seq(s / m)) map (x=>x),
mainResPath in Compile <<= (baseDirectory, resDirectoryName) (_ / _) map (x=>x),
mainAssetsPath in Compile <<= (baseDirectory, assetsDirectoryName) (_ / _),
Expand Down
6 changes: 3 additions & 3 deletions src/main/scala/AndroidPlugin.scala
Expand Up @@ -76,7 +76,7 @@ object AndroidPlugin extends Plugin {
val usePreloaded = SettingKey[Boolean]("use-preloaded", "Use preloaded libraries for development")
val useDebug = SettingKey[Boolean]("use-debug", "Use debug settings when building an APK")
val useTypedResources = SettingKey[Boolean]("use-typed-resources", "Use typed resources")
val useTypedResources2 = SettingKey[Boolean]("use-typed-resources2", "Use typed resources 2")
val useTypedLayouts = SettingKey[Boolean]("use-typed-layouts", "Use typed layouts")

/** ApkLib dependencies */
case class LibraryProject(pkgName: String, manifest: File, sources: Set[File], resDir: Option[File], assetsDir: Option[File])
Expand Down Expand Up @@ -195,7 +195,7 @@ object AndroidPlugin extends Plugin {
val typedResource = TaskKey[File]("typed-resource",
"""Typed resource file to be generated, also includes
interfaces to access these resources.""")
val typedResource2 = TaskKey[File]("typed-resource2",
val typedLayouts = TaskKey[File]("typed-layouts",
"""Typed resource file to be generated, also includes
interfaces to access these resources.""")
val layoutResources = TaskKey[Seq[File]]("layout-resources",
Expand All @@ -220,7 +220,7 @@ object AndroidPlugin extends Plugin {
val generateTypedResources = TaskKey[Seq[File]]("generate-typed-resources",
"""Produce a file TR.scala that contains typed
references to layout resources.""")
val generateTypedResources2 = TaskKey[Seq[File]]("generate-typed-resources2",
val generateTypedLayouts = TaskKey[Seq[File]]("generate-typed-layouts",
"""Produce a file typed_resource.scala that contains typed
references to layout resources.""")
val generateManifest = TaskKey[Seq[File]]("generate-manifest",
Expand Down
6 changes: 3 additions & 3 deletions src/main/scala/AndroidProjects.scala
Expand Up @@ -24,7 +24,7 @@ object AndroidProjects {
AndroidTest.settings ++
AndroidNdk.settings ++
TypedResources.settings ++
TypedResources2.settings ++
TypedLayouts.settings ++
Seq(
// Test projects are Debug projects by default
useDebug := true,
Expand All @@ -39,7 +39,7 @@ object AndroidProjects {
// projects, but you can enable it afterwards anyway, if you really
// need it.
useTypedResources := false,
useTypedResources2 := false
useTypedLayouts := false
)
)

Expand Down Expand Up @@ -94,7 +94,7 @@ object AndroidProjects {
AndroidLaunch.settings ++
AndroidNdk.settings ++
TypedResources.settings ++
TypedResources2.settings
TypedLayouts.settings
}

// Development settings
Expand Down
Expand Up @@ -8,7 +8,7 @@ import Keys._
import AndroidPlugin._

// FIXME more appropriate name
object TypedResources2 {
object TypedLayouts {
/** Views with android:id. */
private case class NamedView(id: String,
className: String,
Expand Down Expand Up @@ -224,10 +224,10 @@ object TypedResources2 {
"def %1$s = `this`.views.%1$s".format(quoteReserved(view.id))
}

private def generateTypedResources2Task =
(useTypedResources2, typedResource2, layoutResources, libraryJarPath, manifestPackage, streams) map {
(useTypedResources2, typedResource2, layoutResources, libraryJarPath, manifestPackage, s) =>
if (useTypedResources2) {
private def generateTypedLayoutsTask =
(useTypedLayouts, typedLayouts, layoutResources, libraryJarPath, manifestPackage, streams) map {
(useTypedLayouts, typedLayouts, layoutResources, libraryJarPath, manifestPackage, s) =>
if (useTypedLayouts) {
// e.g. main_activity.xml -> main_activity
def baseName(path: File) = {
val name = path.getName
Expand All @@ -241,7 +241,7 @@ object TypedResources2 {
)
)

IO.write(typedResource2,
IO.write(typedLayouts,
"""|package %s
|
|package typed_resource {
Expand All @@ -263,22 +263,22 @@ object TypedResources2 {
.mkString("\n ")
)
)
s.log.info("Wrote %s".format(typedResource2))
Seq(typedResource2)
s.log.info("Wrote %s".format(typedLayouts))
Seq(typedLayouts)
} else {
Seq.empty
}
}

lazy val settings: Seq[Setting[_]] = (Seq (
typedResource2 <<= (manifestPackage, managedScalaPath) map {
_.split('.').foldLeft(_) ((p, s) => p / s) / "typed_resource.scala"
typedLayouts <<= (manifestPackage, managedScalaPath) map {
_.split('.').foldLeft(_) ((p, s) => p / s) / "typed_layouts.scala"
},
layoutResources <<= (mainResPath) map { x => (x * "layout*" * "*.xml" get) },

generateTypedResources2 <<= generateTypedResources2Task,
generateTypedLayouts <<= generateTypedLayoutsTask,

sourceGenerators <+= generateTypedResources2,
sourceGenerators <+= generateTypedLayouts,

watchSources <++= (layoutResources) map (ls => ls)
))
Expand Down

0 comments on commit 05f1388

Please sign in to comment.