Compatible Android

This commit is contained in:
Andros Fenollosa
2016-11-03 00:05:36 +01:00
parent 7cb6af1390
commit 8ec8327e5e
1793 changed files with 440698 additions and 7 deletions

View File

@@ -0,0 +1,12 @@
<?xml version="1.0"?>
<globals>
<global id="topOut" value="." />
<global id="projectOut" value="." />
<global id="manifestOut" value="." />
<global id="srcOut" value="src/${slashedPackageName(packageName)}" />
<global id="resOut" value="res" />
<global id="mavenUrl" value="mavenCentral" />
<global id="buildToolsVersion" value="${buildApi}" />
<global id="gradlePluginVersion" value="1.0.+" />
<global id="v4SupportLibraryVersion" value="13.0.+" />
</globals>

View File

@@ -0,0 +1,27 @@
<?xml version="1.0"?>
<recipe>
<instantiate from="AndroidManifest.xml.ftl"
to="${escapeXmlAttribute(manifestOut)}/AndroidManifest.xml" />
<#if copyIcons>
<copy from="res/drawable-hdpi"
to="${escapeXmlAttribute(resOut)}/drawable-hdpi" />
<copy from="res/drawable-mdpi"
to="${escapeXmlAttribute(resOut)}/drawable-mdpi" />
<copy from="res/drawable-xhdpi"
to="${escapeXmlAttribute(resOut)}/drawable-xhdpi" />
</#if>
<instantiate from="res/values/styles.xml.ftl"
to="${escapeXmlAttribute(resOut)}/values/styles.xml" />
<#if buildApi gte 11 && baseTheme != "none">
<instantiate from="res/values-v11/styles_hc.xml.ftl"
to="${escapeXmlAttribute(resOut)}/values-v11/styles.xml" />
</#if>
<#if buildApi gte 14 && baseTheme?contains("darkactionbar")>
<instantiate from="res/values-v14/styles_ics.xml.ftl"
to="${escapeXmlAttribute(resOut)}/values-v14/styles.xml" />
</#if>
<instantiate from="res/values/strings.xml.ftl"
to="${escapeXmlAttribute(resOut)}/values/strings.xml" />
</recipe>

View File

@@ -0,0 +1,15 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="${packageName}"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="${minApi}" <#if buildApi gte 4>android:targetSdkVersion="${targetApi}" </#if>/>
<application <#if minApiLevel gte 4 && buildApi gte 4>android:allowBackup="true"</#if>
android:label="@string/app_name"
android:icon="@drawable/ic_launcher"<#if baseTheme != "none">
android:theme="@style/AppTheme"</#if>>
</application>
</manifest>

View File

@@ -0,0 +1,35 @@
buildscript {
repositories {
<#if mavenUrl == "mavenCentral">
mavenCentral()
<#else>
maven { url '${mavenUrl}' }
</#if>
}
dependencies {
classpath 'com.android.tools.build:gradle:${gradlePluginVersion}'
}
}
apply plugin: 'android'
repositories {
<#if mavenUrl == "mavenCentral">
mavenCentral()
<#else>
maven { url '${mavenUrl}' }
</#if>
}
android {
compileSdkVersion ${buildApi}
buildToolsVersion "${buildToolsVersion}"
defaultConfig {
minSdkVersion ${minApi}
targetSdkVersion ${targetApi}
}
}
dependencies {
compile 'com.android.support:support-v4:${v4SupportLibraryVersion}'
}

View File

@@ -0,0 +1,13 @@
<resources>
<!--
Base application theme for API 11+. This theme completely replaces
AppBaseTheme from res/values/styles.xml on API 11+ devices.
-->
<style name="AppBaseTheme" parent="<#if
appCompat?has_content>Theme.AppCompat<#else
>android:Theme.Holo</#if><#if baseTheme?contains("light")>.Light</#if>">
<!-- API 11 theme customizations can go here. -->
</style>
</resources>

View File

@@ -0,0 +1,14 @@
<resources>
<!--
Base application theme for API 14+. This theme completely replaces
AppBaseTheme from BOTH res/values/styles.xml and
res/values-v11/styles.xml on API 14+ devices.
-->
<style name="AppBaseTheme" parent="<#if
appCompat?has_content>Theme.AppCompat<#else
>android:Theme.Holo</#if>.Light.DarkActionBar">
<!-- API 14 theme customizations can go here. -->
</style>
</resources>

View File

@@ -0,0 +1,3 @@
<resources>
<string name="app_name">${escapeXmlString(appTitle)}</string>
</resources>

View File

@@ -0,0 +1,22 @@
<resources>
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="<#if
appCompat?has_content>Theme.AppCompat<#else>android:Theme</#if><#if
baseTheme?contains("light")>.Light</#if>">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
</resources>

View File

@@ -0,0 +1,82 @@
<?xml version="1.0"?>
<template
format="1"
revision="2"
name="Android Application"
description="Creates a new Android application.">
<dependency name="android-support-v4" revision="8" />
<thumbs>
<thumb>template_new_project.png</thumb>
</thumbs>
<category value="Applications" />
<parameter
id="packageName"
name="Package name"
type="string"
constraints="package|nonempty"
default="com.mycompany.myapp" />
<parameter
id="appTitle"
name="Application title"
type="string"
constraints="nonempty"
default="My Application" />
<parameter
id="baseTheme"
name="Base Theme"
type="enum"
default="holo_light_darkactionbar"
help="The base user interface theme for the application">
<option id="none">None</option>
<option id="holo_dark" minBuildApi="11">Holo Dark</option>
<option id="holo_light" minBuildApi="11">Holo Light</option>
<option id="holo_light_darkactionbar" minBuildApi="14" default="true">Holo Light with Dark Action Bar</option>
</parameter>
<parameter
id="minApi"
name="Minimum API level"
type="string"
constraints="apilevel"
default="7" />
<!--
Usually the same as minApi, but when minApi is a code name this will be the corresponding
API level
-->
<parameter
id="minApiLevel"
name="Minimum API level"
type="string"
constraints="apilevel"
default="7" />
<parameter
id="targetApi"
name="Target API level"
type="string"
constraints="apilevel"
default="16" />
<parameter
id="buildApi"
name="Build API level"
type="string"
constraints="apilevel"
default="16" />
<parameter
id="copyIcons"
name="Include launcher icons"
type="boolean"
default="true" />
<globals file="globals.xml.ftl" />
<execute file="recipe.xml.ftl" />
</template>

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@@ -0,0 +1,12 @@
<?xml version="1.0"?>
<globals>
<global id="topOut" value="." />
<global id="projectOut" value="." />
<global id="manifestOut" value="." />
<global id="srcOut" value="src/${slashedPackageName(packageName)}" />
<global id="resOut" value="res" />
<global id="mavenUrl" value="mavenCentral" />
<global id="buildToolsVersion" value="${buildApi}" />
<global id="gradlePluginVersion" value="1.0.+" />
<global id="v4SupportLibraryVersion" value="13.0.+" />
</globals>

View File

@@ -0,0 +1,27 @@
<?xml version="1.0"?>
<recipe>
<instantiate from="AndroidManifest.xml.ftl"
to="${escapeXmlAttribute(manifestOut)}/AndroidManifest.xml" />
<#if copyIcons>
<copy from="res/drawable-hdpi"
to="${escapeXmlAttribute(resOut)}/drawable-hdpi" />
<copy from="res/drawable-mdpi"
to="${escapeXmlAttribute(resOut)}/drawable-mdpi" />
<copy from="res/drawable-xhdpi"
to="${escapeXmlAttribute(resOut)}/drawable-xhdpi" />
</#if>
<instantiate from="res/values/styles.xml.ftl"
to="${escapeXmlAttribute(resOut)}/values/styles.xml" />
<#if buildApi gte 11 && baseTheme != "none">
<instantiate from="res/values-v11/styles_hc.xml.ftl"
to="${escapeXmlAttribute(resOut)}/values-v11/styles.xml" />
</#if>
<#if buildApi gte 14 && baseTheme?contains("darkactionbar")>
<instantiate from="res/values-v14/styles_ics.xml.ftl"
to="${escapeXmlAttribute(resOut)}/values-v14/styles.xml" />
</#if>
<instantiate from="res/values/strings.xml.ftl"
to="${escapeXmlAttribute(resOut)}/values/strings.xml" />
</recipe>

View File

@@ -0,0 +1,15 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="${packageName}"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="${minApi}" <#if buildApi gte 4>android:targetSdkVersion="${targetApi}" </#if>/>
<application <#if minApiLevel gte 4 && buildApi gte 4>android:allowBackup="true"</#if>
android:label="@string/app_name"
android:icon="@drawable/ic_launcher"<#if baseTheme != "none">
android:theme="@style/AppTheme"</#if>>
</application>
</manifest>

View File

@@ -0,0 +1,35 @@
buildscript {
repositories {
<#if mavenUrl == "mavenCentral">
mavenCentral()
<#else>
maven { url '${mavenUrl}' }
</#if>
}
dependencies {
classpath 'com.android.tools.build:gradle:${gradlePluginVersion}'
}
}
apply plugin: 'android-library'
repositories {
<#if mavenUrl == "mavenCentral">
mavenCentral()
<#else>
maven { url '${mavenUrl}' }
</#if>
}
android {
compileSdkVersion ${buildApi}
buildToolsVersion "${buildToolsVersion}"
defaultConfig {
minSdkVersion ${minApi}
targetSdkVersion ${targetApi}
}
}
dependencies {
compile 'com.android.support:support-v4:${v4SupportLibraryVersion}'
}

View File

@@ -0,0 +1,13 @@
<resources>
<!--
Base application theme for API 11+. This theme completely replaces
AppBaseTheme from res/values/styles.xml on API 11+ devices.
-->
<style name="AppBaseTheme" parent="<#if
appCompat?has_content>Theme.AppCompat<#else
>android:Theme.Holo</#if><#if baseTheme?contains("light")>.Light</#if>">
<!-- API 11 theme customizations can go here. -->
</style>
</resources>

View File

@@ -0,0 +1,14 @@
<resources>
<!--
Base application theme for API 14+. This theme completely replaces
AppBaseTheme from BOTH res/values/styles.xml and
res/values-v11/styles.xml on API 14+ devices.
-->
<style name="AppBaseTheme" parent="<#if
appCompat?has_content>Theme.AppCompat<#else
>android:Theme.Holo</#if>.Light.DarkActionBar">
<!-- API 14 theme customizations can go here. -->
</style>
</resources>

View File

@@ -0,0 +1,3 @@
<resources>
<string name="app_name">${escapeXmlString(appTitle)}</string>
</resources>

View File

@@ -0,0 +1,22 @@
<resources>
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="<#if
appCompat?has_content>Theme.AppCompat<#else>android:Theme</#if><#if
baseTheme?contains("light")>.Light</#if>">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
</resources>

View File

@@ -0,0 +1,82 @@
<?xml version="1.0"?>
<template
format="1"
revision="2"
name="Android Library"
description="Creates a new Android library.">
<dependency name="android-support-v4" revision="8" />
<thumbs>
<thumb>template_new_project.png</thumb>
</thumbs>
<category value="Applications" />
<parameter
id="packageName"
name="Package name"
type="string"
constraints="package|nonempty"
default="com.mycompany.myapp" />
<parameter
id="appTitle"
name="Library title"
type="string"
constraints="nonempty"
default="My Library"/>
<parameter
id="baseTheme"
name="Base Theme"
type="enum"
default="holo_light_darkactionbar"
help="The base user interface theme for the library">
<option id="none">None</option>
<option id="holo_dark" minBuildApi="11">Holo Dark</option>
<option id="holo_light" minBuildApi="11">Holo Light</option>
<option id="holo_light_darkactionbar" minBuildApi="14" default="true">Holo Light with Dark Action Bar</option>
</parameter>
<parameter
id="minApi"
name="Minimum API level"
type="string"
constraints="apilevel"
default="7" />
<!--
Usually the same as minApi, but when minApi is a code name this will be the corresponding
API level
-->
<parameter
id="minApiLevel"
name="Minimum API level"
type="string"
constraints="apilevel"
default="7" />
<parameter
id="targetApi"
name="Target API level"
type="string"
constraints="apilevel"
default="16" />
<parameter
id="buildApi"
name="Build API level"
type="string"
constraints="apilevel"
default="16" />
<parameter
id="copyIcons"
name="Include launcher icons"
type="boolean"
default="true" />
<globals file="globals.xml.ftl" />
<execute file="recipe.xml.ftl" />
</template>

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@@ -0,0 +1,6 @@
<?xml version="1.0"?>
<globals>
<global id="topOut" value="." />
<global id="projectOut" value="." />
<global id="srcOut" value="src/${slashedPackageName(packageName)}" />
</globals>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0"?>
<recipe>
<instantiate from="/src/library_package/Placeholder.java.ftl"
to="${escapeXmlAttribute(srcOut)}/${className}.java" />
</recipe>

View File

@@ -0,0 +1 @@
include ':${projectName}'

View File

@@ -0,0 +1,4 @@
package ${packageName};
public class ${className} {
}

View File

@@ -0,0 +1,38 @@
<?xml version="1.0"?>
<template
format="1"
revision="2"
name="Java Library"
description="Creates a new Java library.">
<thumbs>
<thumb>template_new_project.png</thumb>
</thumbs>
<category value="Applications" />
<parameter
id="projectName"
name="Library name"
type="string"
constraints="nonempty"
default="MyLibrary"/>
<parameter
id="packageName"
name="Java package name"
type="string"
constraints="nonempty"
default="com.example"/>
<parameter
id="className"
name="Java class name"
type="string"
constraints="nonempty"
default="MyClass"/>
<globals file="globals.xml.ftl" />
<execute file="recipe.xml.ftl" />
</template>

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB