Skip to content
This repository has been archived by the owner on Nov 10, 2024. It is now read-only.

Commit

Permalink
Change Gravity center feature - Align Center with Target
Browse files Browse the repository at this point in the history
Set Optional Title
bugfix in landscape mode
decrease IndicatorHeight
decrease Transition Time
added GuideListener included dismiss listener
  • Loading branch information
mreram committed Jan 24, 2018
1 parent 13e94ab commit cb464a7
Show file tree
Hide file tree
Showing 7 changed files with 195 additions and 61 deletions.
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ maven:
<dependency>
<groupId>com.github.mreram</groupId>
<artifactId>ShowCaseView</artifactId>
<version>1.0.3</version>
<version>1.0.4</version>
</dependency>
```
gradle:
Expand All @@ -54,7 +54,7 @@ allprojects {
```
Step 2. Add the dependency
```groovy
compile 'com.github.mreram:ShowCaseView:1.0.3'
compile 'com.github.mreram:ShowCaseView:1.0.4'
```
## Change type face

Expand Down Expand Up @@ -97,4 +97,20 @@ compile 'com.github.mreram:ShowCaseView:1.0.3'
.setContentSpan((Spannable) Html.fromHtml("<font color='red'>testing spannable</p>"))
.build()
.show();
## Set Listener

new GuideView.Builder(MainActivity.this)
.setTitle("Guide Title Text")
.setContentText("Guide Description Text\n .....Guide Description Text\n .....Guide Description Text .....")
.setGravity(GuideView.Gravity.CENTER)
.setTargetView(view1)
.setGuideListener(new GuideView.GuideListener() {
@Override
public void onDismiss(View view) {
//TODO ...
}
})
.build()
.show();

2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<activity android:windowSoftInputMode="stateHidden" android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,45 +9,60 @@

public class MainActivity extends AppCompatActivity {

private View view;
private ShowCaseTask showCaseTask;
private GuideView mGuideView;
private GuideView.Builder builder;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

view = findViewById(R.id.txt);
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(MainActivity.this, "Clicked!", Toast.LENGTH_LONG).show();
}
});
final View view1 = findViewById(R.id.view1);
final View view2 = findViewById(R.id.view2);
final View view3 = findViewById(R.id.view3);
final View view4 = findViewById(R.id.view4);
final View view5 = findViewById(R.id.view5);

showCaseTask = new ShowCaseTask();
view.postDelayed(showCaseTask, 1000);

builder = new GuideView.Builder(MainActivity.this)
.setTitle("Guide Title Text")
.setContentText("Guide Description Text\n .....Guide Description Text\n .....Guide Description Text .....")
.setGravity(GuideView.Gravity.CENTER)
.setTargetView(view1)
.setGuideListener(new GuideView.GuideListener() {
@Override
public void onDismiss(View view) {
switch (view.getId()){
case R.id.view1:
builder.setTargetView(view2).build();
break;
case R.id.view2:
builder.setTargetView(view3).build();
break;
case R.id.view3:
builder.setTargetView(view4).build();
break;
case R.id.view4:
builder.setTargetView(view5).build();
break;
case R.id.view5:
return;
}
mGuideView = builder.build();
mGuideView.show();
}
});

mGuideView = builder.build();
mGuideView.show();
}


@Override
protected void onDestroy() {
super.onDestroy();
if (showCaseTask != null)
view.removeCallbacks(showCaseTask);
}

class ShowCaseTask implements Runnable {

@Override
public void run() {
new GuideView.Builder(MainActivity.this)
.setTitle("Guide Title Text")
.setContentText("Guide Description Text\n .....Guide Description Text\n .....Guide Description Text .....")
.setGravity(GuideView.Gravity.AUTO)
.setTargetView(view)
.build()
.show();
}
}


}
82 changes: 73 additions & 9 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,77 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<Button android:layout_marginTop="204dp"
android:id="@+id/txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:padding="10dp"
android:text="Guide Test"
xmlns:android="http://schemas.android.com/apk/res/android" />

<TextView
android:id="@+id/view1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginRight="10dp"
android:layout_marginTop="20dp"
android:padding="10dp"
android:text="Guide Test 1" />

<ImageView
android:id="@+id/view2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_marginLeft="20dp"
android:layout_marginRight="10dp"
android:layout_marginTop="30dp"
android:src="@mipmap/ic_launcher"

/>

<Button
android:id="@+id/view3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginRight="80dp"
android:layout_marginTop="30dp"
android:padding="10dp"
android:text="Guide Test 3" />

<EditText
android:id="@+id/view4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center"
android:layout_marginRight="10dp"
android:layout_marginTop="20dp"
android:padding="10dp"
android:text="Guide Test 4" />

<LinearLayout
android:gravity="center"
android:id="@+id/view5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="40dp"
android:layout_marginTop="20dp"
android:orientation="horizontal">

<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="Guide Test 4" />

<ImageView
android:src="@android:drawable/ic_btn_speak_now"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp" />

</LinearLayout>

</LinearLayout>
</ScrollView>
Binary file modified demo-flatShowCaseView.apk
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class GuideMessageView extends LinearLayout {
setOrientation(VERTICAL);
setGravity(Gravity.CENTER);

final int padding = (int) (10* density);
final int padding = (int) (10 * density);
final int paddingBetween = (int) (3 * density);

mTitleTextView = new TextView(context);
Expand All @@ -66,6 +66,10 @@ class GuideMessageView extends LinearLayout {


public void setTitle(String title) {
if (title == null) {
removeView(mTitleTextView);
return;
}
mTitleTextView.setText(title);
}

Expand All @@ -78,20 +82,20 @@ public void setContentSpan(Spannable content) {
mContentTextView.setText(content);
}

public void setContentTypeFace(Typeface typeFace){
public void setContentTypeFace(Typeface typeFace) {
mContentTextView.setTypeface(typeFace);
}

public void setTitleTypeFace(Typeface typeFace){
public void setTitleTypeFace(Typeface typeFace) {
mTitleTextView.setTypeface(typeFace);
}

public void setTitleTextSize(int size){
mTitleTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP,size);
public void setTitleTextSize(int size) {
mTitleTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, size);
}

public void setContentTextSize(int size){
mContentTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP,size);
public void setContentTextSize(int size) {
mContentTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, size);
}

public void setColor(int color) {
Expand All @@ -103,6 +107,7 @@ public void setColor(int color) {
}

int location[] = new int[2];

@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
Expand All @@ -117,7 +122,6 @@ protected void onDraw(Canvas canvas) {
canvas.getHeight() - getPaddingBottom());



canvas.drawRoundRect(mRect, 15, 15, mPaint);
}
}
Loading

0 comments on commit cb464a7

Please sign in to comment.