elements = new ArrayList<>();
15 | FreeTimeLineElement element;
16 | element = new FreeTimeLineElement("Init FreeTimeLine", "init", "2016/01/06");
17 | elements.add(element);
18 | element = new FreeTimeLineElement("v1.0", "1.top_type \n2.line_color \n3.solid_color \n4.hollow_color \n5.toggle_color", "2016/01/08");
19 | elements.add(element);
20 | element = new FreeTimeLineElement("add type", "1:node type\n2:bottom type", "2016/01/09");
21 | elements.add(element);
22 | element = new FreeTimeLineElement("v2.0-alpha大量更新", "吸盘样式及字体大小和颜色的自定义", "2016/01/10");
23 | elements.add(element);
24 | element = new FreeTimeLineElement("v2.1", "大量重构及自定义显示隐藏折叠按钮", "2016/01/11");
25 | elements.add(element);
26 | return elements;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_custom.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_demo.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
20 |
33 |
34 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
12 |
13 |
19 |
24 |
29 |
34 |
35 |
36 |
42 |
47 |
52 |
53 |
54 |
60 |
65 |
70 |
71 |
72 |
78 |
83 |
88 |
89 |
90 |
95 |
96 |
101 |
102 |
107 |
108 |
109 |
110 |
118 |
119 |
126 |
127 |
134 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenenyu/FreeTimeLine/39bfd4dea16b5ded03982a95fe291227e2b15bd8/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenenyu/FreeTimeLine/39bfd4dea16b5ded03982a95fe291227e2b15bd8/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_github.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenenyu/FreeTimeLine/39bfd4dea16b5ded03982a95fe291227e2b15bd8/app/src/main/res/mipmap-xhdpi/ic_github.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenenyu/FreeTimeLine/39bfd4dea16b5ded03982a95fe291227e2b15bd8/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenenyu/FreeTimeLine/39bfd4dea16b5ded03982a95fe291227e2b15bd8/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenenyu/FreeTimeLine/39bfd4dea16b5ded03982a95fe291227e2b15bd8/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-en/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Support more than 15 custom attrs, more
4 | information in https://github.com/chenenyu/FreeTimeLine.
5 |
6 |
7 | Top sucker type
8 | Top solid type
9 | Top hollow type
10 | Hollow node
11 | Solid node
12 | Solid bottom
13 | Bottom hollow
14 | Line color
15 | Solid color
16 | Hollow color
17 | Show toggle btn
18 | Hide toggle btn
19 | Demo
20 | CHANGELOG
21 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | FreeTimeLine
3 | 支持超过15种自定义属性,更多信息请访问https://github.com/chenenyu/FreeTimeLine
4 |
5 | 顶部吸盘样式
6 | 顶部实心结点
7 | 顶部空心结点
8 | 中间空节点
9 | 中间实心节点
10 | 底部实心结点
11 | 底部空心结点
12 | 轴线颜色
13 | 实心圆颜色
14 | 空心圆颜色
15 | 显示折叠按钮
16 | 隐藏折叠按钮
17 | 示例样式
18 | 更新日志
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/arts/ftl-cn.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenenyu/FreeTimeLine/39bfd4dea16b5ded03982a95fe291227e2b15bd8/arts/ftl-cn.gif
--------------------------------------------------------------------------------
/arts/ftl-en.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenenyu/FreeTimeLine/39bfd4dea16b5ded03982a95fe291227e2b15bd8/arts/ftl-en.gif
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.0.0-alpha3'
9 |
10 | // classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
11 | // classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.5'
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
--------------------------------------------------------------------------------
/demo.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenenyu/FreeTimeLine/39bfd4dea16b5ded03982a95fe291227e2b15bd8/demo.apk
--------------------------------------------------------------------------------
/ftl/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "23.0.2"
6 |
7 | defaultConfig {
8 | minSdkVersion 8
9 | targetSdkVersion 23
10 | versionCode 1
11 | versionName "1.0"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | compile fileTree(dir: 'libs', include: ['*.jar'])
23 | }
24 |
25 | //apply from: 'bintray.gradle'
--------------------------------------------------------------------------------
/ftl/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/Cheney/workspace/AndroidSDK/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/ftl/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/ftl/src/main/java/com/chenenyu/freetimeline/FreeTimeLine.java:
--------------------------------------------------------------------------------
1 | package com.chenenyu.freetimeline;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.util.AttributeSet;
6 | import android.util.TypedValue;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.AdapterView;
10 | import android.widget.FrameLayout;
11 | import android.widget.ListView;
12 |
13 | import com.chenenyu.freetimeline.internal.FreeTimeLineAdapter;
14 | import com.chenenyu.freetimeline.internal.FreeTimeLineUI;
15 |
16 | import java.util.List;
17 |
18 | /**
19 | *
20 | * Custom layout that contains FreeTimeLine.
21 | *
22 | * Created by Cheney on 16/1/6.
23 | */
24 | public class FreeTimeLine extends FrameLayout {
25 |
26 | private ListView mContent;
27 | private FreeTimeLineAdapter mAdapter;
28 | private FreeTimeLineConfig mConfig;
29 |
30 | private int TOP_TYPE; // 顶部结点的样式
31 | private int NODE_TYPE; // 中间节点的样式
32 | private int BOTTOM_TYPE; // 底部结点的样式
33 |
34 | private int LINE_COLOR; // 竖线的颜色
35 | private int SOLID_COLOR; // 实心圆的颜色
36 | private int HOLLOW_COLOR; // 空心圆的颜色
37 | private int SUCKER_COLOR; // 吸盘样式的颜色
38 | private int TOGGLE_COLOR; // +/-号的颜色
39 |
40 | private int LEFT_COLOR; // 左侧text的颜色
41 | private float LEFT_SIZE; // 左侧text的大小
42 | private int PARENT_COLOR; // 中间父文本的颜色
43 | private float PARENT_SIZE; // 中间富文本的大小
44 | private int CHILD_COLOR; // 中间子文本的颜色
45 | private float CHILD_SIZE; // 中间子文本的大小
46 |
47 | private boolean SHOW_TOGGLE; // 是否显示更多按钮
48 |
49 | public FreeTimeLine(Context context) {
50 | this(context, null);
51 | }
52 |
53 | public FreeTimeLine(Context context, AttributeSet attrs) {
54 | this(context, attrs, 0);
55 | }
56 |
57 | public FreeTimeLine(Context context, AttributeSet attrs, int defStyleAttr) {
58 | super(context, attrs, defStyleAttr);
59 | TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.FreeTimeLine, defStyleAttr, 0);
60 | TOP_TYPE = a.getInt(R.styleable.FreeTimeLine_top_type, FreeTimeLineUI.TOP_HOLLOW);
61 | NODE_TYPE = a.getInt(R.styleable.FreeTimeLine_node_type, FreeTimeLineUI.NODE_HOLLOW);
62 | BOTTOM_TYPE = a.getInt(R.styleable.FreeTimeLine_bottom_type, FreeTimeLineUI.BOTTOM_HOLLOW);
63 |
64 | LINE_COLOR = a.getColor(R.styleable.FreeTimeLine_line_color, FreeTimeLineUI.DEFAULT_LINE_COLOR);
65 | SOLID_COLOR = a.getColor(R.styleable.FreeTimeLine_solid_color, FreeTimeLineUI.DEFAULT_SOLID_COLOR);
66 | HOLLOW_COLOR = a.getColor(R.styleable.FreeTimeLine_hollow_color, FreeTimeLineUI.DEFAULT_HOLLOW_COLOR);
67 | SUCKER_COLOR = a.getColor(R.styleable.FreeTimeLine_sucker_color, FreeTimeLineUI.DEFAULT_SUCKER_COLOR);
68 | TOGGLE_COLOR = a.getColor(R.styleable.FreeTimeLine_toggle_color, FreeTimeLineUI.DEFAULT_TOGGLE_COLOR);
69 |
70 | LEFT_COLOR = a.getColor(R.styleable.FreeTimeLine_left_color, FreeTimeLineUI.DEFAULT_LEFT_COLOR);
71 | LEFT_SIZE = a.getDimension(R.styleable.FreeTimeLine_left_size, TypedValue.applyDimension(
72 | TypedValue.COMPLEX_UNIT_SP, FreeTimeLineUI.DEFAULT_LEFT_SIZE, getResources().getDisplayMetrics()));
73 | LEFT_SIZE = LEFT_SIZE / getResources().getDisplayMetrics().scaledDensity;
74 |
75 | PARENT_COLOR = a.getColor(R.styleable.FreeTimeLine_parent_color, FreeTimeLineUI.DEFAULT_PARENT_COLOR);
76 | PARENT_SIZE = a.getDimension(R.styleable.FreeTimeLine_parent_size, TypedValue.applyDimension(
77 | TypedValue.COMPLEX_UNIT_SP, FreeTimeLineUI.DEFAULT_PARENT_SIZE, getResources().getDisplayMetrics()));
78 | PARENT_SIZE = PARENT_SIZE / getResources().getDisplayMetrics().scaledDensity;
79 |
80 | CHILD_COLOR = a.getColor(R.styleable.FreeTimeLine_child_color, FreeTimeLineUI.DEFAULT_CHILD_COLOR);
81 | CHILD_SIZE = a.getDimension(R.styleable.FreeTimeLine_child_size, TypedValue.applyDimension(
82 | TypedValue.COMPLEX_UNIT_SP, FreeTimeLineUI.DEFAULT_CHILD_SIZE, getResources().getDisplayMetrics()));
83 | CHILD_SIZE = CHILD_SIZE / getResources().getDisplayMetrics().scaledDensity;
84 |
85 | SHOW_TOGGLE = a.getBoolean(R.styleable.FreeTimeLine_show_toggle, FreeTimeLineUI.DEFAULT_SHOW_TOGGLE);
86 | a.recycle();
87 |
88 | mConfig = new FreeTimeLineConfig()
89 | .setTopType(TOP_TYPE)
90 | .setNodeType(NODE_TYPE)
91 | .setBottomType(BOTTOM_TYPE)
92 | .setLineColor(LINE_COLOR)
93 | .setSolidColor(SOLID_COLOR)
94 | .setHollowColor(HOLLOW_COLOR)
95 | .setSuckerColor(SUCKER_COLOR)
96 | .setToggleColor(TOGGLE_COLOR)
97 | .setLeftColor(LEFT_COLOR)
98 | .setLeftSize(LEFT_SIZE)
99 | .setParentColor(PARENT_COLOR)
100 | .setParentSize(PARENT_SIZE)
101 | .setChildColor(CHILD_COLOR)
102 | .setChildSize(CHILD_SIZE)
103 | .setShowToggle(SHOW_TOGGLE);
104 |
105 | mContent = new ListView(context);
106 | mContent.setDivider(null);
107 | mContent.setCacheColorHint(0);
108 | ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(
109 | ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
110 | this.addView(mContent, layoutParams);
111 | }
112 |
113 | @Override
114 | protected void onFinishInflate() {
115 | super.onFinishInflate();
116 | if (getChildCount() > 1) {
117 | throw new IllegalStateException("FreeTimeLine can't have any child added manually.");
118 | }
119 | }
120 |
121 | public void setElements(List elements) {
122 | if (elements != null) {
123 | if (mAdapter == null) {
124 | mAdapter = new FreeTimeLineAdapter(elements, mConfig);
125 | }
126 | }
127 | mContent.setAdapter(mAdapter);
128 | mContent.setOnItemClickListener(new AdapterView.OnItemClickListener() {
129 | @Override
130 | public void onItemClick(AdapterView> parent, View view, int position, long id) {
131 | mAdapter.toggleRow(position);
132 | }
133 | });
134 | }
135 |
136 | public FreeTimeLineConfig getConfig() {
137 | return mConfig;
138 | }
139 |
140 | public void setConfig(FreeTimeLineConfig config) {
141 | mConfig = config;
142 | if (mAdapter != null) {
143 | mAdapter.notifyDataSetChanged();
144 | }
145 | }
146 |
147 | public void setTopType(int type) {
148 | if (mAdapter != null && TOP_TYPE != type) {
149 | mConfig.setTopType(type);
150 | mAdapter.notifyDataSetChanged();
151 | }
152 | }
153 |
154 | public void setNodeType(int type) {
155 | if (mAdapter != null && NODE_TYPE != type) {
156 | mConfig.setNodeType(type);
157 | mAdapter.notifyDataSetChanged();
158 | }
159 | }
160 |
161 | public void setBottomType(int type) {
162 | if (mAdapter != null && BOTTOM_TYPE != type) {
163 | mConfig.setBottomType(type);
164 | mAdapter.notifyDataSetChanged();
165 | }
166 | }
167 |
168 | public void setLineColor(int color) {
169 | if (mAdapter != null && LINE_COLOR != color) {
170 | mConfig.setLineColor(color);
171 | mAdapter.notifyDataSetChanged();
172 | }
173 | }
174 |
175 | public void setSolidColor(int color) {
176 | if (mAdapter != null && SOLID_COLOR != color) {
177 | mConfig.setSolidColor(color);
178 | mAdapter.notifyDataSetChanged();
179 | }
180 | }
181 |
182 | public void setHollowColor(int color) {
183 | if (mAdapter != null && HOLLOW_COLOR != color) {
184 | mConfig.setHollowColor(color);
185 | mAdapter.notifyDataSetChanged();
186 | }
187 | }
188 |
189 | public void setSuckerColor(int color) {
190 | if (mAdapter != null && SUCKER_COLOR != color) {
191 | mConfig.setSuckerColor(color);
192 | mAdapter.notifyDataSetChanged();
193 | }
194 | }
195 |
196 | public void setToggleColor(int color) {
197 | if (mAdapter != null && TOGGLE_COLOR != color) {
198 | mConfig.setToggleColor(color);
199 | mAdapter.notifyDataSetChanged();
200 | }
201 | }
202 |
203 |
204 | public void setLeftColor(int color) {
205 | if (mAdapter != null && LEFT_COLOR != color) {
206 | mConfig.setLeftColor(color);
207 | mAdapter.notifyDataSetChanged();
208 | }
209 | }
210 |
211 | public void setLeftSize(float size) {
212 | if (mAdapter != null && LEFT_SIZE != size) {
213 | mConfig.setLeftSize(size);
214 | mAdapter.notifyDataSetChanged();
215 | }
216 | }
217 |
218 | public void setParentColor(int color) {
219 | if (mAdapter != null && PARENT_COLOR != color) {
220 | mConfig.setParentColor(color);
221 | mAdapter.notifyDataSetChanged();
222 | }
223 | }
224 |
225 | public void setParentSize(float size) {
226 | if (mAdapter != null && PARENT_SIZE != size) {
227 | mConfig.setParentSize(size);
228 | mAdapter.notifyDataSetChanged();
229 | }
230 | }
231 |
232 | public void setChildColor(int color) {
233 | if (mAdapter != null && CHILD_COLOR != color) {
234 | mConfig.setChildColor(color);
235 | mAdapter.notifyDataSetChanged();
236 | }
237 | }
238 |
239 | public void setChildSize(float size) {
240 | if (mAdapter != null && CHILD_SIZE != size) {
241 | mConfig.setChildSize(size);
242 | mAdapter.notifyDataSetChanged();
243 | }
244 | }
245 |
246 | public void setShowToggle(boolean show) {
247 | if (mAdapter != null && SHOW_TOGGLE != show) {
248 | mConfig.setShowToggle(show);
249 | mAdapter.notifyDataSetChanged();
250 | }
251 | }
252 |
253 | }
254 |
--------------------------------------------------------------------------------
/ftl/src/main/java/com/chenenyu/freetimeline/FreeTimeLineConfig.java:
--------------------------------------------------------------------------------
1 | package com.chenenyu.freetimeline;
2 |
3 | import com.chenenyu.freetimeline.internal.FreeTimeLineUI;
4 |
5 | import java.io.Serializable;
6 |
7 | /**
8 | *
9 | * All configurations for FreeTimeLine.
10 | *
11 | * Created by Cheney on 16/1/7.
12 | */
13 | public class FreeTimeLineConfig implements Serializable {
14 | private int top_type = FreeTimeLineUI.TOP_HOLLOW;
15 | private int node_type = FreeTimeLineUI.NODE_HOLLOW;
16 | private int bottom_type = FreeTimeLineUI.BOTTOM_SOLID;
17 |
18 | private int line_color = FreeTimeLineUI.DEFAULT_LINE_COLOR;
19 | private int solid_color = FreeTimeLineUI.DEFAULT_SOLID_COLOR;
20 | private int hollow_color = FreeTimeLineUI.DEFAULT_HOLLOW_COLOR;
21 | private int sucker_color = FreeTimeLineUI.DEFAULT_SUCKER_COLOR;
22 | private int toggle_color = FreeTimeLineUI.DEFAULT_TOGGLE_COLOR;
23 |
24 | private int left_color = FreeTimeLineUI.DEFAULT_LEFT_COLOR;
25 | private float left_size = FreeTimeLineUI.DEFAULT_LEFT_SIZE;
26 |
27 | private int parent_color = FreeTimeLineUI.DEFAULT_PARENT_COLOR;
28 | private float parent_size = FreeTimeLineUI.DEFAULT_PARENT_SIZE;
29 |
30 | private int child_color = FreeTimeLineUI.DEFAULT_CHILD_COLOR;
31 | private float child_size = FreeTimeLineUI.DEFAULT_CHILD_SIZE;
32 |
33 | private boolean show_toggle = FreeTimeLineUI.DEFAULT_SHOW_TOGGLE;
34 |
35 |
36 | public FreeTimeLineConfig setTopType(int type) {
37 | top_type = type;
38 | return this;
39 | }
40 |
41 | public FreeTimeLineConfig setNodeType(int type) {
42 | node_type = type;
43 | return this;
44 | }
45 |
46 | public FreeTimeLineConfig setBottomType(int type) {
47 | bottom_type = type;
48 | return this;
49 | }
50 |
51 | public FreeTimeLineConfig setLineColor(int color) {
52 | line_color = color;
53 | return this;
54 | }
55 |
56 | public FreeTimeLineConfig setSolidColor(int color) {
57 | solid_color = color;
58 | return this;
59 | }
60 |
61 | public FreeTimeLineConfig setHollowColor(int color) {
62 | hollow_color = color;
63 | return this;
64 | }
65 |
66 | public FreeTimeLineConfig setSuckerColor(int color) {
67 | sucker_color = color;
68 | return this;
69 | }
70 |
71 | public FreeTimeLineConfig setToggleColor(int color) {
72 | toggle_color = color;
73 | return this;
74 | }
75 |
76 |
77 | public FreeTimeLineConfig setLeftColor(int color) {
78 | this.left_color = color;
79 | return this;
80 | }
81 |
82 | public FreeTimeLineConfig setLeftSize(float size) {
83 | this.left_size = size;
84 | return this;
85 | }
86 |
87 | public FreeTimeLineConfig setParentColor(int color) {
88 | this.parent_color = color;
89 | return this;
90 | }
91 |
92 | public FreeTimeLineConfig setParentSize(float size) {
93 | this.parent_size = size;
94 | return this;
95 | }
96 |
97 | public FreeTimeLineConfig setChildColor(int color) {
98 | this.child_color = color;
99 | return this;
100 | }
101 |
102 | public FreeTimeLineConfig setChildSize(float size) {
103 | this.child_size = size;
104 | return this;
105 | }
106 |
107 | public FreeTimeLineConfig setShowToggle(boolean show) {
108 | this.show_toggle = show;
109 | return this;
110 | }
111 |
112 | public int getTopType() {
113 | return top_type;
114 | }
115 |
116 | public int getNodeType() {
117 | return node_type;
118 | }
119 |
120 | public int getBottomType() {
121 | return bottom_type;
122 | }
123 |
124 | public int getLineColor() {
125 | return line_color;
126 | }
127 |
128 | public int getSolidColor() {
129 | return solid_color;
130 | }
131 |
132 | public int getHollowColor() {
133 | return hollow_color;
134 | }
135 |
136 | public int getSuckerColor() {
137 | return sucker_color;
138 | }
139 |
140 | public int getToggleColor() {
141 | return toggle_color;
142 | }
143 |
144 | public int getLeftColor() {
145 | return left_color;
146 | }
147 |
148 | public float getLeftSize() {
149 | return left_size;
150 | }
151 |
152 | public int getParentColor() {
153 | return parent_color;
154 | }
155 |
156 | public float getParentSize() {
157 | return parent_size;
158 | }
159 |
160 | public int getChildColor() {
161 | return child_color;
162 | }
163 |
164 | public float getChildSize() {
165 | return child_size;
166 | }
167 |
168 | public boolean isShowToggle() {
169 | return show_toggle;
170 | }
171 | }
172 |
--------------------------------------------------------------------------------
/ftl/src/main/java/com/chenenyu/freetimeline/FreeTimeLineElement.java:
--------------------------------------------------------------------------------
1 | package com.chenenyu.freetimeline;
2 |
3 | import java.io.Serializable;
4 |
5 | /**
6 | * FTL element.
7 | * Created by Cheney on 16/1/6.
8 | */
9 | public class FreeTimeLineElement implements Serializable {
10 |
11 | private String parent;
12 | private String child;
13 | private String left;
14 |
15 | public FreeTimeLineElement() {
16 |
17 | }
18 |
19 | public FreeTimeLineElement(String parent, String child, String left) {
20 | this.parent = parent;
21 | this.child = child;
22 | this.left = left;
23 | }
24 |
25 | public String getParent() {
26 | return parent;
27 | }
28 |
29 | public void setParent(String parent) {
30 | this.parent = parent;
31 | }
32 |
33 | public String getChild() {
34 | return child;
35 | }
36 |
37 | public void setChild(String child) {
38 | this.child = child;
39 | }
40 |
41 | public String getLeft() {
42 | return left;
43 | }
44 |
45 | public void setLeft(String left) {
46 | this.left = left;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/ftl/src/main/java/com/chenenyu/freetimeline/internal/ConnectorView.java:
--------------------------------------------------------------------------------
1 | package com.chenenyu.freetimeline.internal;
2 |
3 | import android.content.Context;
4 | import android.graphics.Bitmap;
5 | import android.graphics.Canvas;
6 | import android.graphics.Paint;
7 | import android.util.AttributeSet;
8 | import android.view.View;
9 |
10 | /**
11 | * Connector view.
12 | * Created by Cheney on 16/1/6.
13 | */
14 | public class ConnectorView extends View {
15 |
16 | private Paint linePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
17 | private Paint solidPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
18 | private Paint hollowPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
19 | private Paint suckerPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
20 | private final Paint clearPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
21 |
22 | private Bitmap cache;
23 | private float strokeSize;
24 |
25 | private int type;
26 | private int lineColor = FreeTimeLineUI.DEFAULT_LINE_COLOR;
27 | private int solidColor = FreeTimeLineUI.DEFAULT_SOLID_COLOR;
28 | private int hollowColor = FreeTimeLineUI.DEFAULT_HOLLOW_COLOR;
29 | private int suckerColor = FreeTimeLineUI.DEFAULT_SUCKER_COLOR;
30 |
31 |
32 | public ConnectorView(Context context) {
33 | this(context, null);
34 | }
35 |
36 | public ConnectorView(Context context, AttributeSet attrs) {
37 | this(context, attrs, 0);
38 | }
39 |
40 | public ConnectorView(Context context, AttributeSet attrs, int defStyleAttr) {
41 | super(context, attrs, defStyleAttr);
42 | init();
43 | }
44 |
45 | /**
46 | * Default config.
47 | */
48 | private void init() {
49 | linePaint.setColor(lineColor);
50 | solidPaint.setColor(solidColor);
51 | hollowPaint.setColor(hollowColor);
52 | suckerPaint.setColor(suckerColor);
53 | clearPaint.setColor(0);
54 | clearPaint.setXfermode(FreeTimeLineUI.CLEAR_XFER_MODE);
55 |
56 | strokeSize = FreeTimeLineUI.dpToPixel(4.0F, this.getResources());
57 | linePaint.setStrokeWidth(strokeSize);
58 | hollowPaint.setStrokeWidth(strokeSize);
59 | suckerPaint.setStrokeWidth(strokeSize);
60 |
61 | this.type = FreeTimeLineUI.NODE_HOLLOW;
62 | }
63 |
64 | @Override
65 | protected void onDraw(Canvas canvas) {
66 | int width = this.getWidth();
67 | int height = this.getHeight();
68 | if (this.cache != null && (this.cache.getWidth() != width || this.cache.getHeight() != height)) {
69 | this.cache.recycle();
70 | this.cache = null;
71 | }
72 |
73 | if (this.cache == null) {
74 | this.cache = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
75 | Canvas cacheCanvas = new Canvas(this.cache);
76 | float halfWidth = (float) width / 2.0F;
77 | float halfHeight = (float) height / 2.0F;
78 | float thirdWidth = (float) width / 3.0F;
79 | switch (this.type) {
80 | case FreeTimeLineUI.TOP_SUCKER:
81 | float radiusClear = halfWidth - strokeSize / 2.0F;
82 | cacheCanvas.drawRect(0.0F, 0.0F, (float) width, radiusClear, suckerPaint);
83 | cacheCanvas.drawCircle(0.0F, radiusClear, radiusClear, clearPaint);
84 | cacheCanvas.drawCircle((float) width, radiusClear, radiusClear, clearPaint);
85 | cacheCanvas.drawLine(halfWidth, 0.0F, halfWidth, halfHeight, suckerPaint);
86 | cacheCanvas.drawLine(halfWidth, halfHeight, halfWidth, (float) height, linePaint);
87 | cacheCanvas.drawCircle(halfWidth, halfHeight, halfWidth, hollowPaint);
88 | cacheCanvas.drawCircle(halfWidth, halfHeight, thirdWidth, clearPaint);
89 | break;
90 | case FreeTimeLineUI.TOP_SOLID:
91 | cacheCanvas.drawLine(halfWidth, halfHeight, halfWidth, height, linePaint);
92 | cacheCanvas.drawCircle(halfWidth, halfHeight, thirdWidth, solidPaint);
93 | break;
94 | case FreeTimeLineUI.TOP_HOLLOW:
95 | cacheCanvas.drawLine(halfWidth, halfHeight, halfWidth, height, linePaint);
96 | cacheCanvas.drawCircle(halfWidth, halfHeight, halfWidth, hollowPaint);
97 | cacheCanvas.drawCircle(halfWidth, halfHeight, thirdWidth, clearPaint);
98 | break;
99 | case FreeTimeLineUI.NODE_SOLID:
100 | cacheCanvas.drawLine(halfWidth, 0.0F, halfWidth, (float) height, linePaint);
101 | cacheCanvas.drawCircle(halfWidth, halfHeight, thirdWidth, solidPaint);
102 | break;
103 | case FreeTimeLineUI.NODE_HOLLOW:
104 | cacheCanvas.drawLine(halfWidth, 0.0F, halfWidth, (float) height, linePaint);
105 | cacheCanvas.drawCircle(halfWidth, halfHeight, halfWidth, hollowPaint);
106 | cacheCanvas.drawCircle(halfWidth, halfHeight, thirdWidth, clearPaint);
107 | break;
108 | case FreeTimeLineUI.BOTTOM_SOLID:
109 | cacheCanvas.drawLine(halfWidth, 0.0F, halfWidth, halfHeight, linePaint);
110 | cacheCanvas.drawCircle(halfWidth, halfHeight, thirdWidth, solidPaint);
111 | break;
112 | case FreeTimeLineUI.BOTTOM_HOLLOW:
113 | cacheCanvas.drawLine(halfWidth, 0.0F, halfWidth, halfHeight, linePaint);
114 | cacheCanvas.drawCircle(halfWidth, halfHeight, halfWidth, hollowPaint);
115 | cacheCanvas.drawCircle(halfWidth, halfHeight, thirdWidth, clearPaint);
116 | break;
117 | }
118 | }
119 |
120 | canvas.drawBitmap(this.cache, 0.0F, 0.0F, null);
121 | }
122 |
123 | private void recycleCache() {
124 | if (this.cache != null) {
125 | this.cache.recycle();
126 | this.cache = null;
127 | }
128 | }
129 |
130 | public void setType(int type) {
131 | if (type != this.type) {
132 | this.type = type;
133 | recycleCache();
134 | this.invalidate();
135 | }
136 | }
137 |
138 | public void setLineColor(int color) {
139 | if (color != this.lineColor) {
140 | lineColor = color;
141 | linePaint.setColor(lineColor);
142 | recycleCache();
143 | this.invalidate();
144 | }
145 | }
146 |
147 | public void setSolidColor(int color) {
148 | if (color != this.solidColor) {
149 | solidColor = color;
150 | solidPaint.setColor(solidColor);
151 | recycleCache();
152 | this.invalidate();
153 | }
154 | }
155 |
156 | public void setHollowColor(int color) {
157 | if (color != this.hollowColor) {
158 | hollowColor = color;
159 | hollowPaint.setColor(hollowColor);
160 | recycleCache();
161 | this.invalidate();
162 | }
163 | }
164 |
165 | public void setSuckerColor(int color) {
166 | if (color != this.suckerColor) {
167 | suckerColor = color;
168 | suckerPaint.setColor(suckerColor);
169 | recycleCache();
170 | this.invalidate();
171 | }
172 | }
173 |
174 | }
175 |
--------------------------------------------------------------------------------
/ftl/src/main/java/com/chenenyu/freetimeline/internal/FreeTimeLineAdapter.java:
--------------------------------------------------------------------------------
1 | package com.chenenyu.freetimeline.internal;
2 |
3 | import android.content.Context;
4 | import android.text.TextUtils;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.BaseAdapter;
9 | import android.widget.TextView;
10 |
11 | import com.chenenyu.freetimeline.FreeTimeLineConfig;
12 | import com.chenenyu.freetimeline.FreeTimeLineElement;
13 | import com.chenenyu.freetimeline.R;
14 |
15 | import java.util.Collections;
16 | import java.util.List;
17 |
18 | /**
19 | *
20 | * FreeTimeLineAdapter
21 | *
22 | * Created by Cheney on 16/1/6.
23 | */
24 | public class FreeTimeLineAdapter extends BaseAdapter {
25 |
26 | private boolean[] opened;
27 | private final boolean SHOW_LEFT;
28 | private final boolean SHOW_TOGGLE;
29 | private List mElements = Collections.emptyList();
30 | private FreeTimeLineConfig mConfig;
31 |
32 | public FreeTimeLineAdapter(List elements, FreeTimeLineConfig config) {
33 | mElements = elements;
34 | mConfig = config;
35 | opened = new boolean[mElements.size()];
36 | SHOW_LEFT = showLeft();
37 | SHOW_TOGGLE = mConfig.isShowToggle();
38 | }
39 |
40 | @Override
41 | public int getCount() {
42 | return mElements.size();
43 | }
44 |
45 | @Override
46 | public Object getItem(int position) {
47 | return mElements.size() == 0 ? null : mElements.get(position);
48 | }
49 |
50 | @Override
51 | public long getItemId(int position) {
52 | return position;
53 | }
54 |
55 | @Override
56 | public View getView(int position, View convertView, ViewGroup parent) {
57 | Context context = parent.getContext();
58 | if (convertView == null) {
59 | convertView = LayoutInflater.from(context).inflate(R.layout.__ftl_node_row, parent, false);
60 | }
61 | TextView left = (TextView) convertView.findViewById(R.id.__ftl_row_left_text);
62 | left.setTextColor(mConfig.getLeftColor());
63 | left.setTextSize(mConfig.getLeftSize());
64 | ConnectorView connectorView = (ConnectorView) convertView.findViewById(R.id.__ftl_row_connector);
65 | connectorView.setLineColor(mConfig.getLineColor());
66 | connectorView.setSolidColor(mConfig.getSolidColor());
67 | connectorView.setSuckerColor(mConfig.getSuckerColor());
68 | connectorView.setHollowColor(mConfig.getHollowColor());
69 | TextView middle_parent = (TextView) convertView.findViewById(R.id.__ftl_row_middle_parent_text);
70 | middle_parent.setTextColor(mConfig.getParentColor());
71 | middle_parent.setTextSize(mConfig.getParentSize());
72 | TextView middle_child = (TextView) convertView.findViewById(R.id.__ftl_row_middle_child_text);
73 | middle_child.setTextColor(mConfig.getChildColor());
74 | middle_child.setTextSize(mConfig.getChildSize());
75 | ToggleView toggleView = (ToggleView) convertView.findViewById(R.id.__ftl_row_toggle);
76 | toggleView.setToggleColor(mConfig.getToggleColor());
77 |
78 | if (SHOW_LEFT) {
79 | left.setVisibility(View.VISIBLE);
80 | left.setText(mElements.get(position).getLeft());
81 | }
82 |
83 | if (position == 0) {
84 | connectorView.setType(mConfig.getTopType());
85 | } else if (position == mElements.size() - 1) {
86 | connectorView.setType(mConfig.getBottomType());
87 | } else {
88 | connectorView.setType(mConfig.getNodeType());
89 | }
90 |
91 | middle_parent.setText(mElements.get(position).getParent());
92 | if (SHOW_TOGGLE) {
93 | toggleView.setVisibility(View.VISIBLE);
94 | toggleView.setOpened(opened[position]);
95 | if (opened[position]) {
96 | middle_child.setVisibility(View.VISIBLE);
97 | middle_child.setText(mElements.get(position).getChild());
98 | } else {
99 | middle_child.setVisibility(View.GONE);
100 | }
101 | } else {
102 | toggleView.setVisibility(View.GONE);
103 | }
104 |
105 | return convertView;
106 | }
107 |
108 | private boolean showLeft() {
109 | for (FreeTimeLineElement element : mElements) {
110 | if (!TextUtils.isEmpty(element.getLeft()))
111 | return true;
112 | }
113 | return false;
114 | }
115 |
116 | /**
117 | * Expand or collapse row.
118 | *
119 | * @param position clicked item.
120 | */
121 | public void toggleRow(int position) {
122 | this.opened[position] = !this.opened[position];
123 | notifyDataSetChanged();
124 | }
125 |
126 | }
127 |
--------------------------------------------------------------------------------
/ftl/src/main/java/com/chenenyu/freetimeline/internal/FreeTimeLineUI.java:
--------------------------------------------------------------------------------
1 | package com.chenenyu.freetimeline.internal;
2 |
3 | import android.content.res.Resources;
4 | import android.graphics.PorterDuff;
5 | import android.graphics.PorterDuffXfermode;
6 | import android.util.DisplayMetrics;
7 |
8 | public class FreeTimeLineUI {
9 | public static final int DEFAULT_LINE_COLOR = 0xFFD3D3D3;
10 | public static final int DEFAULT_SOLID_COLOR = 0xFF7B593B;
11 | public static final int DEFAULT_HOLLOW_COLOR = 0xFFD3D3D3;
12 | public static final int DEFAULT_SUCKER_COLOR = 0xFF4EAAB2;
13 | public static final int DEFAULT_TOGGLE_COLOR = 0xFF4EAAB2;
14 |
15 | public static final int DEFAULT_LEFT_COLOR = 0xFF222222;
16 | public static final float DEFAULT_LEFT_SIZE = 13.0F;
17 | public static final int DEFAULT_PARENT_COLOR = 0xFF222222;
18 | public static final float DEFAULT_PARENT_SIZE = 14.0F;
19 | public static final int DEFAULT_CHILD_COLOR = 0xFF222222;
20 | public static final float DEFAULT_CHILD_SIZE = 12.0F;
21 |
22 | public static final boolean DEFAULT_SHOW_TOGGLE = false;
23 |
24 | static final PorterDuffXfermode CLEAR_XFER_MODE = new PorterDuffXfermode(PorterDuff.Mode.CLEAR);
25 |
26 | // Top type
27 | public static final int TOP_SUCKER = 0;
28 | public static final int TOP_SOLID = 1;
29 | public static final int TOP_HOLLOW = 2;
30 |
31 | // Node type
32 | public static final int NODE_SOLID = 10;
33 | public static final int NODE_HOLLOW = 11;
34 |
35 | // Bottom type
36 | public static final int BOTTOM_SOLID = 20;
37 | public static final int BOTTOM_HOLLOW = 21;
38 |
39 |
40 | private FreeTimeLineUI() {
41 | throw new AssertionError();
42 | }
43 |
44 | static float dpToPixel(float dp, Resources resources) {
45 | DisplayMetrics metrics = resources.getDisplayMetrics();
46 | return metrics.density * dp;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/ftl/src/main/java/com/chenenyu/freetimeline/internal/ToggleView.java:
--------------------------------------------------------------------------------
1 | package com.chenenyu.freetimeline.internal;
2 |
3 | import android.content.Context;
4 | import android.graphics.Bitmap;
5 | import android.graphics.Canvas;
6 | import android.graphics.Paint;
7 | import android.util.AttributeSet;
8 | import android.view.View;
9 |
10 | /**
11 | * Toggle View(i.e. plus sign and minus sign).
12 | * Created by Cheney on 16/1/6.
13 | */
14 | public class ToggleView extends View {
15 | private static final Paint togglePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
16 | private int toggleColor = FreeTimeLineUI.DEFAULT_TOGGLE_COLOR;
17 | private boolean opened;
18 | private Bitmap cache;
19 |
20 | public ToggleView(Context context) {
21 | this(context, null);
22 | }
23 |
24 | public ToggleView(Context context, AttributeSet attrs) {
25 | this(context, attrs, 0);
26 | }
27 |
28 | public ToggleView(Context context, AttributeSet attrs, int defStyleAttr) {
29 | super(context, attrs, defStyleAttr);
30 | init();
31 | }
32 |
33 | private void init() {
34 | float strokeSize = FreeTimeLineUI.dpToPixel(2.0F, this.getResources());
35 | togglePaint.setStrokeWidth(strokeSize);
36 | togglePaint.setColor(toggleColor);
37 | }
38 |
39 | protected void onDraw(Canvas canvas) {
40 | int width = this.getWidth();
41 | int height = this.getHeight();
42 |
43 | if (this.cache != null && (this.cache.getWidth() != width || this.cache.getHeight() != height)) {
44 | this.cache.recycle();
45 | this.cache = null;
46 | }
47 | if (cache == null) {
48 | cache = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
49 | Canvas cacheCanvas = new Canvas(cache);
50 | int halfHeight = height / 2;
51 | int halfWidth = width / 2;
52 | if (this.opened) {
53 | cacheCanvas.drawLine(0.0F, (float) halfHeight, (float) width, (float) halfHeight, togglePaint);
54 | } else {
55 | cacheCanvas.drawLine(0.0F, (float) halfHeight, (float) width, (float) halfHeight, togglePaint);
56 | cacheCanvas.drawLine((float) halfWidth, 0.0F, (float) halfWidth, (float) height, togglePaint);
57 | }
58 | }
59 |
60 | canvas.drawBitmap(this.cache, 0.0F, 0.0F, null);
61 | }
62 |
63 | private void recycleCache() {
64 | if (this.cache != null) {
65 | this.cache.recycle();
66 | this.cache = null;
67 | }
68 | }
69 |
70 | public void setOpened(boolean opened) {
71 | if (opened != this.opened) {
72 | this.opened = opened;
73 | recycleCache();
74 | this.invalidate();
75 | }
76 | }
77 |
78 | public void setToggleColor(int color) {
79 | if (color != this.toggleColor) {
80 | toggleColor = color;
81 | togglePaint.setColor(toggleColor);
82 | recycleCache();
83 | this.invalidate();
84 | }
85 | }
86 |
87 | }
88 |
--------------------------------------------------------------------------------
/ftl/src/main/res/layout/__ftl_node_row.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
25 |
26 |
31 |
32 |
40 |
41 |
46 |
47 |
54 |
55 |
56 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/ftl/src/main/res/values/ftl_attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chenenyu/FreeTimeLine/39bfd4dea16b5ded03982a95fe291227e2b15bd8/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Oct 21 11:34:03 PDT 2015
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':ftl'
2 |
--------------------------------------------------------------------------------