Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to set gravity for content box components . #98

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ public MaterialShowcaseSequence addSequenceItem(MaterialShowcaseView sequenceIte
}

mShowcaseQueue.add(sequenceItem);
if (mConfig != null) {
sequenceItem.setConfig(mConfig);
}
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;

import java.util.ArrayList;
Expand Down Expand Up @@ -492,6 +493,26 @@ private void setDismissTextColor(int textColour) {
}
}

private void setDismissTextGravity(int dismissTextGravity){
if (mDismissButton != null) {
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) this.mDismissButton.getLayoutParams();
layoutParams.gravity = dismissTextGravity;
this.mDismissButton.setLayoutParams(layoutParams);
}
}

private void setContentTextGravity(int contentTextGravity){
if(mContentTextView != null ) {
this.mContentTextView.setGravity(contentTextGravity);
}
}

private void setTitleTextGravity(int titleTextGravity){
if(mTitleTextView != null ) {
this.mTitleTextView.setGravity(titleTextGravity);
}
}

private void setShapePadding(int padding) {
mShapePadding = padding;
}
Expand Down Expand Up @@ -749,6 +770,22 @@ public Builder setTitleText(CharSequence text) {
}


private Builder setDismissTextGravity(int dismissTextGravity){
showcaseView.setDismissTextGravity(dismissTextGravity);
return this ;
}

private Builder setContentTextGravity(int mGravity){
showcaseView.setContentTextGravity(mGravity);
return this ;
}

private Builder setTitleTextGravity(int mGravity){
showcaseView.setTitleTextGravity(mGravity);
return this ;
}


/**
* Tooltip mode config options
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,33 @@
package uk.co.deanwild.materialshowcaseview;

import android.graphics.Color;

import android.view.Gravity;
import android.graphics.Typeface;


import uk.co.deanwild.materialshowcaseview.shape.CircleShape;
import uk.co.deanwild.materialshowcaseview.shape.Shape;


public class ShowcaseConfig {

public static final String DEFAULT_MASK_COLOUR = "#dd335075";
public static final long DEFAULT_FADE_TIME = 300;
public static final long DEFAULT_DELAY = 0;
public static final Shape DEFAULT_SHAPE = new CircleShape();
public static final int DEFAULT_SHAPE_PADDING = 10;
public static final int DEFAULT_TEXT_GRAVITY = Gravity.LEFT;

private long mDelay = -1;
private int mMaskColour;
private Typeface mDismissTextStyle;

private int mContentTextColor;
private int mDismissTextColor;
private int dismissTextGravity = DEFAULT_TEXT_GRAVITY ;
private int titleTextGravity = DEFAULT_TEXT_GRAVITY ;
private int contentTextGravity = DEFAULT_TEXT_GRAVITY ;
private long mFadeDuration = -1;
private Shape mShape = null;
private int mShapePadding = -1;
Expand Down Expand Up @@ -99,4 +110,28 @@ public Boolean getRenderOverNavigationBar() {
public void setRenderOverNavigationBar(boolean renderOverNav) {
this.renderOverNav = renderOverNav;
}

public void setDismissTextGravity(int dismissTextGravity) {
this.dismissTextGravity = dismissTextGravity;
}

public void setTitleTextGravity(int titleTextGravity) {
this.titleTextGravity = titleTextGravity;
}

public void setContentTextGravity(int contentTextGravity) {
this.contentTextGravity = contentTextGravity;
}

public int getDismissTextGravity() {
return dismissTextGravity;
}

public int getTitleTextGravity() {
return titleTextGravity;
}

public int getContentTextGravity() {
return contentTextGravity;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ private void presentShowcaseSequence() {

ShowcaseConfig config = new ShowcaseConfig();
config.setDelay(500); // half second between each showcase view

config.setTitleTextGravity(Gravity.CENTER);
config.setDismissTextGravity(Gravity.CENTER);
config.setContentTextGravity(Gravity.CENTER);

MaterialShowcaseSequence sequence = new MaterialShowcaseSequence(this, SHOWCASE_ID);

sequence.setOnItemShownListener(new MaterialShowcaseSequence.OnSequenceItemShownListener() {
Expand Down