Skip to content

Commit 329db0a

Browse files
committed
v1.0.5
1 parent 35a7458 commit 329db0a

File tree

8 files changed

+106
-56
lines changed

8 files changed

+106
-56
lines changed

.idea/misc.xml

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ setFinishText(text); // Finish button text
4646
setCancelText(text); // Cancel button text
4747
setIndicatorSelected(int drawable); // Indicator drawable when selected
4848
setIndicator(int drawable); // Indicator drawable
49+
setGivePermissionText(String text); // Permission button text
4950

5051
```
5152

@@ -60,6 +61,16 @@ If you want to open another activity on tutorial finish
6061
```
6162

6263

64+
65+
##### If you want change design of view you need following items
66+
* 1 Container layout with id of container
67+
* 3 Text view which is for Title id of title, Content id of content, Summary id of summary
68+
* 1 Image view with id of image
69+
70+
71+
72+
73+
6374
## Download
6475

6576
### Step 1. Add the JitPack repository to your build file
@@ -81,7 +92,7 @@ Add it in your root build.gradle at the end of repositories:
8192
```groovy
8293
8394
dependencies {
84-
compile 'com.github.msayan:tutorial-view:v1.0.4'
95+
compile 'com.github.msayan:tutorial-view:v1.0.5'
8596
}
8697
8798
```

app/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
apply plugin: 'com.android.application'
22

33
android {
4-
compileSdkVersion 25
5-
buildToolsVersion "25.0.2"
4+
compileSdkVersion 27
5+
buildToolsVersion "27.0.2"
66
defaultConfig {
77
applicationId "com.hololo.tutorial.sample"
88
minSdkVersion 16
9-
targetSdkVersion 25
9+
targetSdkVersion 27
1010
versionCode 1
1111
versionName "1.0"
1212
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
@@ -24,7 +24,7 @@ dependencies {
2424
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
2525
exclude group: 'com.android.support', module: 'support-annotations'
2626
})
27-
compile 'com.android.support:appcompat-v7:25.3.1'
27+
compile 'com.android.support:appcompat-v7:27.0.2'
2828
compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4'
2929
testCompile 'junit:junit:4.12'
3030
compile project(path: ':library')

build.gradle

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
buildscript {
44
repositories {
55
jcenter()
6+
maven {
7+
url 'https://maven.google.com/'
8+
name 'Google'
9+
}
610
}
711
dependencies {
812
classpath 'com.android.tools.build:gradle:2.3.1'
@@ -15,6 +19,10 @@ buildscript {
1519
allprojects {
1620
repositories {
1721
jcenter()
22+
maven {
23+
url 'https://maven.google.com/'
24+
name 'Google'
25+
}
1826
}
1927
}
2028

library/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
apply plugin: 'com.android.library'
22

33
android {
4-
compileSdkVersion 25
5-
buildToolsVersion "25.0.2"
4+
compileSdkVersion 27
5+
buildToolsVersion "27.0.2"
66

77
defaultConfig {
88
minSdkVersion 16
9-
targetSdkVersion 25
9+
targetSdkVersion 27
1010
versionCode 1
1111
versionName "1.0"
1212

@@ -26,6 +26,6 @@ dependencies {
2626
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
2727
exclude group: 'com.android.support', module: 'support-annotations'
2828
})
29-
compile 'com.android.support:appcompat-v7:25.3.1'
29+
compile 'com.android.support:appcompat-v7:27.0.2'
3030
testCompile 'junit:junit:4.12'
3131
}

library/src/main/java/com/hololo/tutorial/library/Step.java

Lines changed: 49 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,22 @@
55

66
public class Step implements Parcelable {
77

8-
public static final Parcelable.Creator<Step> CREATOR = new Parcelable.Creator<Step>() {
9-
@Override
10-
public Step createFromParcel(Parcel source) {
11-
return new Step(source);
12-
}
13-
14-
@Override
15-
public Step[] newArray(int size) {
16-
return new Step[size];
17-
}
18-
};
198
private String title;
209
private String content;
2110
private String summary;
2211
private int drawable;
2312
private int backgroundColor;
13+
private int viewType;
2414

2515
public Step() {
2616
}
2717

28-
protected Step(Parcel in) {
29-
this.title = in.readString();
30-
this.content = in.readString();
31-
this.summary = in.readString();
32-
this.drawable = in.readInt();
33-
this.backgroundColor = in.readInt();
18+
public int getViewType() {
19+
return viewType;
20+
}
21+
22+
public void setViewType(int viewType) {
23+
this.viewType = viewType;
3424
}
3525

3626
public String getTitle() {
@@ -73,20 +63,6 @@ public void setSummary(String summary) {
7363
this.summary = summary;
7464
}
7565

76-
@Override
77-
public int describeContents() {
78-
return 0;
79-
}
80-
81-
@Override
82-
public void writeToParcel(Parcel dest, int flags) {
83-
dest.writeString(this.title);
84-
dest.writeString(this.content);
85-
dest.writeString(this.summary);
86-
dest.writeInt(this.drawable);
87-
dest.writeInt(this.backgroundColor);
88-
}
89-
9066
public static class Builder {
9167

9268
private Step step;
@@ -123,5 +99,47 @@ public Builder setBackgroundColor(int backgroundColor) {
12399
step.backgroundColor = backgroundColor;
124100
return this;
125101
}
102+
103+
public Builder setView(int view) {
104+
step.viewType = view;
105+
return this;
106+
}
126107
}
108+
109+
110+
@Override
111+
public int describeContents() {
112+
return 0;
113+
}
114+
115+
@Override
116+
public void writeToParcel(Parcel dest, int flags) {
117+
dest.writeString(this.title);
118+
dest.writeString(this.content);
119+
dest.writeString(this.summary);
120+
dest.writeInt(this.drawable);
121+
dest.writeInt(this.backgroundColor);
122+
dest.writeInt(this.viewType);
123+
}
124+
125+
protected Step(Parcel in) {
126+
this.title = in.readString();
127+
this.content = in.readString();
128+
this.summary = in.readString();
129+
this.drawable = in.readInt();
130+
this.backgroundColor = in.readInt();
131+
this.viewType = in.readInt();
132+
}
133+
134+
public static final Creator<Step> CREATOR = new Creator<Step>() {
135+
@Override
136+
public Step createFromParcel(Parcel source) {
137+
return new Step(source);
138+
}
139+
140+
@Override
141+
public Step[] newArray(int size) {
142+
return new Step[size];
143+
}
144+
};
127145
}

library/src/main/java/com/hololo/tutorial/library/StepFragment.java

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import android.view.View;
77
import android.view.ViewGroup;
88
import android.widget.ImageView;
9-
import android.widget.LinearLayout;
109
import android.widget.TextView;
1110

1211
public class StepFragment extends StepView {
@@ -15,7 +14,7 @@ public class StepFragment extends StepView {
1514
private TextView content;
1615
private TextView summary;
1716
private ImageView imageView;
18-
private LinearLayout layout;
17+
private View layout;
1918

2019

2120
static StepFragment createFragment(Step step) {
@@ -36,7 +35,9 @@ public void onCreate(@Nullable Bundle savedInstanceState) {
3635
@Nullable
3736
@Override
3837
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
39-
View view = inflater.inflate(R.layout.fragment_step, container, false);
38+
int layout = step.getViewType() > -1 ? step.getViewType() : R.layout.fragment_step;
39+
40+
View view = inflater.inflate(layout, container, false);
4041

4142
initViews(view);
4243
initData();
@@ -45,19 +46,30 @@ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
4546
}
4647

4748
private void initData() {
48-
title.setText(step.getTitle());
49-
content.setText(step.getContent());
50-
summary.setText(step.getSummary());
51-
imageView.setImageResource(step.getDrawable());
52-
layout.setBackgroundColor(step.getBackgroundColor());
49+
if (title != null) {
50+
title.setText(step.getTitle());
51+
}
52+
if (content != null) {
53+
content.setText(step.getContent());
54+
}
55+
if (summary != null) {
56+
summary.setText(step.getSummary());
57+
}
58+
if (imageView != null) {
59+
imageView.setImageResource(step.getDrawable());
60+
}
61+
62+
if (layout != null) {
63+
layout.setBackgroundColor(step.getBackgroundColor());
64+
}
5365
}
5466

5567
private void initViews(View view) {
56-
title = (TextView) view.findViewById(R.id.title);
57-
content = (TextView) view.findViewById(R.id.content);
58-
summary = (TextView) view.findViewById(R.id.summary);
59-
imageView = (ImageView) view.findViewById(R.id.image);
60-
layout = (LinearLayout) view.findViewById(R.id.container);
68+
title = view.findViewById(R.id.title);
69+
content = view.findViewById(R.id.content);
70+
summary = view.findViewById(R.id.summary);
71+
imageView = view.findViewById(R.id.image);
72+
layout = view.findViewById(R.id.container);
6173
}
6274

6375
}

library/src/main/java/com/hololo/tutorial/library/TutorialActivity.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,10 @@ public void setCancelText(String text) {
259259
cancelText = text;
260260
}
261261

262+
public void setGivePermissionText(String text) {
263+
givePermissionText = text;
264+
}
265+
262266
public void setIndicatorSelected(int drawable) {
263267
selectedIndicator = drawable;
264268
}

0 commit comments

Comments
 (0)