Skip to content
This repository was archived by the owner on Dec 27, 2024. It is now read-only.

Commit 272719e

Browse files
committed
Import ConstraintLayout 2.0.1 to github
Import ConstraintLayout 2.0.1 sources
0 parents  commit 272719e

File tree

191 files changed

+65584
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

191 files changed

+65584
-0
lines changed

constraintlayout/README

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Building the ConstraintLayout library
2+
=====================================
3+
4+
Several environment variables need to be set:
5+
6+
export ANDROID_HOME=~/Android/Sdk/
7+
export ANDROID_M2REPOSITORY=$ANDROID_HOME/extras/android/m2repository
8+
9+
mkdir -p /tmp/out/dist
10+
OUT_DIR=/tmp/out
11+
DIST_DIR=/tmp/out/dist
12+
13+
export STUDIO_MASTER=~/studio-master-dev/
14+
export CL_PREBUILTS=$STUDIO_MASTER/prebuilts/tools/common/offline-m2/
15+
export DOCLAVA_PREBUILTS=$STUDIO_MASTER/external/
16+
export DOCLAVA_ROOTDIR=$STUDIO_MASTER/tools/sherpa/
17+
18+
To compile and publish to your local offline M2 repository, you need to run:
19+
./buildLocally.sh
20+
21+
To generate the maven artifact, you then need to run:
22+
23+
./gradlew dist

constraintlayout/build.gradle

+157
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
buildscript {
2+
repositories {
3+
// maven { url "$project.rootDir/../../prebuilts/tools/common/offline-m2" }
4+
//maven { url System.env.CL_PREBUILTS }
5+
google()
6+
jcenter()
7+
}
8+
dependencies {
9+
classpath 'com.android.tools.build:gradle:3.1.0'
10+
11+
// NOTE: Do not place your application dependencies here; they belong
12+
// in the individual module build.gradle files
13+
}
14+
}
15+
16+
import com.google.common.io.Files
17+
import com.google.common.base.Charsets
18+
19+
task('checkJavaVersion') doLast {
20+
def jvmVersion = System.getProperty('java.version')
21+
def requiredVersion = System.getenv('JAVA_FOR_TESTS') ?: '1.8'
22+
if (!jvmVersion.startsWith(requiredVersion)) {
23+
throw new RuntimeException("Tools need to be compiled with Java $requiredVersion, you are using Java $jvmVersion.")
24+
}
25+
}
26+
final def checkJavaVersionTask = tasks['checkJavaVersion']
27+
28+
ext.version = '2.0.1'
29+
30+
/*
31+
* With the build server you are given two env variables.
32+
* The OUT_DIR is a temporary directory you can use to put things during the build.
33+
* The DIST_DIR is where you want to save things from the build.
34+
*
35+
* The build server will copy the contents of DIST_DIR to somewhere and make it available.
36+
*/
37+
if (System.env.DIST_DIR != null && System.env.OUT_DIR != null) {
38+
ext.androidHostOut = file(System.env.OUT_DIR)
39+
ext.androidHostDist = file(System.env.DIST_DIR)
40+
ext.buildNumber = System.env.BUILD
41+
} else {
42+
// ext.androidHostOut is shared by all tools/{base,build,swt} gradle projects/
43+
ext.androidHostOut = file("$rootDir/../../out")
44+
ext.androidHostDist = new File(ext.androidHostOut, "dist")
45+
ext.buildNumber = null
46+
}
47+
48+
// rootProject.buildDir is specific to this gradle build.
49+
buildDir = new File(ext.androidHostOut, "build/root")
50+
ext.supportRepoOut = new File(buildDir, 'repo')
51+
52+
ext.localRepo = project.hasProperty('localRepo') ? localRepo : "$ext.androidHostOut/repo"
53+
54+
// basic task for custom distribution of project via the build server.
55+
task dist doLast {
56+
}
57+
58+
project(':constraintlayout') {
59+
ext.pomName = 'Android ConstraintLayout'
60+
ext.pomDesc = 'ConstraintLayout for Android'
61+
}
62+
63+
project(':solver') {
64+
ext.pomName = 'Android ConstraintLayout Solver'
65+
ext.pomDesc = 'Solver for ConstraintLayout'
66+
}
67+
68+
subprojects { Project project ->
69+
// Change buildDir first so that all plugins pick up the new value.
70+
project.buildDir = project.file("$project.parent.buildDir/../$project.name/build")
71+
72+
group = 'androidx.constraintlayout'
73+
version = rootProject.ext.version
74+
75+
apply plugin: 'maven'
76+
77+
repositories {
78+
maven { url "$rootProject.projectDir/../../prebuilts/tools/common/m2/repository" }
79+
}
80+
81+
task release(type: Upload) {
82+
configuration = configurations.archives
83+
repositories {
84+
mavenDeployer {
85+
repository(url: uri("$rootProject.ext.supportRepoOut"))
86+
if (project.getName() == 'constraintlayout' || project.getName() == 'solver') {
87+
pom.project {
88+
name project.ext.pomName
89+
description project.ext.pomDesc
90+
91+
url 'http://tools.android.com'
92+
inceptionYear '2007'
93+
94+
licenses {
95+
license {
96+
name 'The Apache Software License, Version 2.0'
97+
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
98+
distribution 'repo'
99+
}
100+
}
101+
102+
scm {
103+
url 'https://android.googlesource.com/platform/tools/sherpa'
104+
connection 'git://android.googlesource.com/platform/tools/sherpa.git'
105+
}
106+
developers {
107+
developer {
108+
name 'The Android Open Source Project'
109+
}
110+
}
111+
}
112+
}
113+
}
114+
}
115+
}
116+
117+
def versionDir = {
118+
def groupDir = new File(rootProject.ext.supportRepoOut, project.group.replace('.','/'))
119+
def artifactDir = new File(groupDir, archivesBaseName)
120+
return new File(artifactDir, version)
121+
}
122+
123+
def deployer = release.repositories.mavenDeployer
124+
task generateSourceProps(dependsOn: release) doLast {
125+
def content = "Maven.GroupId=$deployer.pom.groupId\n" +
126+
"Maven.ArtifactId=$deployer.pom.artifactId\n" +
127+
"Maven.Version=$deployer.pom.version\n" +
128+
"Pkg.Desc=$project.ext.pomDesc $deployer.pom.version\n" +
129+
"Pkg.Revision=1\n" +
130+
"Extra.VendorId=android\n" +
131+
"Extra.VendorDisplay=Android\n" +
132+
"Maven.Dependencies=" +
133+
String.join(",", project.configurations.implementation.allDependencies.collect {
134+
def p = parent.findProject(it.name)
135+
return p ? "$p.group:$p.archivesBaseName:$p.version" : null
136+
}.grep()) +
137+
"\n"
138+
Files.write(content, new File(versionDir(), 'source.properties'), Charsets.UTF_8)
139+
}
140+
141+
task createSeparateZip(type: Zip, dependsOn: generateSourceProps) {
142+
into archivesBaseName
143+
destinationDir project.parent.ext.androidHostDist
144+
baseName = project.group
145+
version = rootProject.ext.buildNumber
146+
archiveName = archivesBaseName + "-" + project.parent.ext.version + ".zip"
147+
}
148+
project.parent.dist.dependsOn createSeparateZip
149+
createSeparateZip.dependsOn release
150+
151+
project.afterEvaluate {
152+
// The archivesBaseName isn't available intially, so set it now
153+
def createZipTask = project.tasks.getByName("createSeparateZip")
154+
createZipTask.appendix = archivesBaseName
155+
createZipTask.from versionDir()
156+
}
157+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
apply plugin: 'com.android.library'
2+
apply plugin: 'maven'
3+
4+
def latestSdkVersion = 28
5+
6+
android {
7+
compileSdkVersion latestSdkVersion
8+
buildToolsVersion "28"
9+
10+
defaultConfig {
11+
minSdkVersion 14
12+
targetSdkVersion latestSdkVersion
13+
}
14+
15+
lintOptions {
16+
abortOnError false
17+
}
18+
19+
compileOptions {
20+
sourceCompatibility JavaVersion.VERSION_1_8
21+
targetCompatibility JavaVersion.VERSION_1_8
22+
}
23+
24+
// TODO replace with https://issuetracker.google.com/issues/72050365 once released.
25+
libraryVariants.all {
26+
it.generateBuildConfig.enabled = false
27+
}
28+
}
29+
30+
repositories {
31+
google()
32+
jcenter()
33+
}
34+
35+
configurations {
36+
//doclava
37+
}
38+
39+
dependencies {
40+
implementation 'androidx.appcompat:appcompat:1.2.0'
41+
implementation 'androidx.core:core:1.3.1'
42+
implementation project(':solver')
43+
// doclava project(':doclava')
44+
}
45+
46+
archivesBaseName = 'constraintlayout'
47+
48+
project.ext.pomName = 'Android ConstraintLayout'
49+
project.ext.pomDesc = 'ConstraintLayout for Android'
50+
51+
task publishLocal(type: Upload) {
52+
configuration = configurations.archives
53+
repositories {
54+
mavenDeployer {
55+
repository(url: uri("$rootProject.ext.localRepo"))
56+
pom.project {
57+
name project.ext.pomName
58+
description project.ext.pomDesc
59+
60+
url 'http://tools.android.com'
61+
inceptionYear '2007'
62+
63+
licenses {
64+
license {
65+
name 'The Apache Software License, Version 2.0'
66+
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
67+
distribution 'repo'
68+
}
69+
}
70+
71+
scm {
72+
url 'https://android.googlesource.com/platform/tools/sherpa'
73+
connection 'git://android.googlesource.com/platform/tools/sherpa.git'
74+
}
75+
developers {
76+
developer {
77+
name 'The Android Open Source Project'
78+
}
79+
}
80+
}
81+
}
82+
}
83+
}
84+
85+
// Call upon the DocLava tool to generate API reference
86+
/*
87+
task makeJavadocs(type: Javadoc, dependsOn: project.configurations.doclava) {
88+
def docDir = "javadoc-offline"
89+
if (project.hasProperty("online")) {
90+
docDir = "javadoc-online"
91+
options.addStringOption("dac_libraryroot", "android/support/constraint")
92+
options.addStringOption("dac_dataname", "CONSTRAINT_DATA")
93+
options.addStringOption("toroot", "/")
94+
options.addStringOption("hdf", "dac")
95+
options.addBooleanOption("devsite", true)
96+
options.addBooleanOption("yamlV2", true)
97+
}
98+
99+
title = null
100+
destinationDir = new File(buildDir, docDir)
101+
source = 'src/main/java'
102+
def docRootDir = "$System.env.DOCLAVA_ROOTDIR"
103+
classpath = files("${docRootDir}/../../prebuilts/sdk/${latestSdkVersion}/public/android.jar")
104+
options.addStringOption "resourcesdir", "${docRootDir}/constraintlayout/resources/"
105+
options.addStringOption "resourcesoutdir", "reference/android/support/constraint/resources/"
106+
options.addStringOption "federate Android", "http://developer.android.com"
107+
options.addStringOption "federationapi Android",
108+
"${docRootDir}/../../prebuilts/sdk/${latestSdkVersion}/public/api/android.txt"
109+
options.encoding = "UTF-8"
110+
options.doclet = "com.google.doclava.Doclava"
111+
options.docletpath = configurations.doclava.files.asType(List)
112+
options.addStringOption("templatedir", "${docRootDir}/../../external/doclava/res/assets/templates-sdk/")
113+
exclude '**/
114+
//BuildConfig.java'
115+
// exclude '**/R.java'
116+
//}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.example.android.constraintapi;
2+
3+
//BEGIN_INCLUDE(Example)
4+
import android.content.Context;
5+
import android.os.Bundle;
6+
import android.support.constraint.ConstraintLayout;
7+
import android.support.constraint.ConstraintSet;
8+
import android.support.transition.TransitionManager;
9+
import android.support.v7.app.AppCompatActivity;
10+
import android.view.View;
11+
12+
public class MainActivity extends AppCompatActivity {
13+
ConstraintSet mConstraintSet1 = new ConstraintSet(); // create a Constraint Set
14+
ConstraintSet mConstraintSet2 = new ConstraintSet(); // create a Constraint Set
15+
ConstraintLayout mConstraintLayout; // cache the ConstraintLayout
16+
boolean mOld = true;
17+
18+
@Override
19+
protected void onCreate(Bundle savedInstanceState) {
20+
super.onCreate(savedInstanceState);
21+
Context context = this;
22+
mConstraintSet2.clone(context, R.layout.state2); // get constraints from layout
23+
setContentView(R.layout.state1);
24+
mConstraintLayout = (ConstraintLayout) findViewById(R.id.activity_main);
25+
mConstraintSet1.clone(mConstraintLayout); // get constraints from ConstraintSet
26+
}
27+
28+
public void foo(View view) {
29+
TransitionManager.beginDelayedTransition(mConstraintLayout);
30+
if (mOld = !mOld) {
31+
mConstraintSet1.applyTo(mConstraintLayout); // set new constraints
32+
} else {
33+
mConstraintSet2.applyTo(mConstraintLayout); // set new constraints
34+
}
35+
}
36+
}
37+
//END_INCLUDE(Example)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- BEGIN_INCLUDE(Guideline) -->
3+
<androidx.constraintlayout.widget.ConstraintLayout
4+
xmlns:android="http://schemas.android.com/apk/res/android"
5+
xmlns:app="http://schemas.android.com/apk/res-auto"
6+
xmlns:tools="http://schemas.android.com/tools"
7+
android:layout_width="match_parent"
8+
android:layout_height="match_parent">
9+
10+
<androidx.constraintlayout.widget.Guideline
11+
android:layout_width="wrap_content"
12+
android:layout_height="wrap_content"
13+
android:id="@+id/guideline"
14+
app:layout_constraintGuide_begin="100dp"
15+
android:orientation="vertical"/>
16+
17+
<Button
18+
android:text="Button"
19+
android:layout_width="wrap_content"
20+
android:layout_height="wrap_content"
21+
android:id="@+id/button"
22+
app:layout_constraintLeft_toLeftOf="@+id/guideline"
23+
android:layout_marginTop="16dp"
24+
app:layout_constraintTop_toTopOf="parent" />
25+
26+
</androidx.constraintlayout.widget.ConstraintLayout>
27+
<!-- END_INCLUDE(Guideline) -->
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="androidx.constraintlayout.widget">
4+
5+
<application />
6+
</manifest>

0 commit comments

Comments
 (0)