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 Set Finish button background color #30

Open
wants to merge 1 commit 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
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ setActiveIndicatorColor(R.color.white);
//Set finish button text
setFinishButtonTitle("Get Started");

//Set finish button color
setFinishButtonBackground(R.color.black);

//Set the finish button style
setFinishButtonDrawableStyle(ContextCompat.getDrawable(this, R.drawable.rounded_button));
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ protected void onCreate(Bundle savedInstanceState) {
}

setFinishButtonTitle("Finish");
setFinishButtonBackground(R.color.black);
showNavigationControls(true);
setGradientBackground();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.DecelerateInterpolator;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.RelativeLayout;
Expand All @@ -33,7 +34,7 @@ public abstract class AhoyOnboarderActivity extends AppCompatActivity implements
private CircleIndicatorView circleIndicatorView;
private ViewPager vpOnboarderPager;
private AhoyOnboarderAdapter ahoyOnboarderAdapter;
private TextView btnSkip;
private Button btnSkip;
private ImageView ivNext, ivPrev;
private FrameLayout navigationControls;
private FrameLayout buttonsLayout;
Expand All @@ -56,7 +57,7 @@ protected void onCreate(Bundle savedInstanceState) {

parentLayout = (RelativeLayout) findViewById(R.id.parent_layout);
circleIndicatorView = (CircleIndicatorView) findViewById(R.id.circle_indicator_view);
btnSkip = (TextView) findViewById(R.id.btn_skip);
btnSkip = (Button) findViewById(R.id.btn_skip);
buttonsLayout = (FrameLayout) findViewById(R.id.buttons_layout);
navigationControls = (FrameLayout) findViewById(R.id.navigation_layout);
ivNext = (ImageView) findViewById(R.id.ivNext);
Expand Down Expand Up @@ -106,9 +107,11 @@ public void onClick(View v) {

if (i == R.id.btn_skip && isInLastPage) {
onFinishButtonPressed();
} else if (i == R.id.ivPrev && !isInFirstPage) {
}
else if (i == R.id.ivPrev && !isInFirstPage) {
vpOnboarderPager.setCurrentItem(vpOnboarderPager.getCurrentItem() - 1);
} else if (i == R.id.ivNext && !isInLastPage) {
}
else if (i == R.id.ivNext && !isInLastPage) {
vpOnboarderPager.setCurrentItem(vpOnboarderPager.getCurrentItem() + 1);
}
}
Expand All @@ -131,12 +134,14 @@ public void onPageSelected(int position) {
showFinish();
fadeOut(ivNext);
fadeIn(ivPrev);
} else if (position == firstPagePosition) {
}
else if (position == firstPagePosition) {
fadeOut(ivPrev);
fadeIn(ivNext);
hideFinish();
fadeIn(circleIndicatorView);
} else {
}
else {
fadeIn(circleIndicatorView);
hideFinish();
fadeIn(ivPrev);
Expand Down Expand Up @@ -267,7 +272,8 @@ private void hideActionBar() {
public void showNavigationControls(boolean navigation) {
if (navigation) {
navigationControls.setVisibility(View.VISIBLE);
} else {
}
else {
navigationControls.setVisibility(View.GONE);
}
}
Expand Down Expand Up @@ -334,6 +340,20 @@ public void setFinishButtonTitle(@StringRes int titleResId) {
btnSkip.setText(titleResId);
}

/**
* <br/><br/>
* <b>N.B. Builds before LOLLIPOP will use the default style</b>
* <br/><br/>
* Set the color of the skip/done button, <br/>
*
* @param colorResId A color res representing your button color
*/
public void setFinishButtonBackground(@ColorRes int colorResId) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
btnSkip.setBackgroundTintList(ContextCompat.getColorStateList(this, colorResId));
}
}

public void setFont(Typeface typeface) {
this.btnSkip.setTypeface(typeface);
this.typeface = typeface;
Expand Down
2 changes: 1 addition & 1 deletion onboarder/src/main/res/layout-v21/activity_ahoy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
android:layout_marginBottom="25dp"
android:layout_marginTop="20dp" />

<TextView
<Button
android:id="@+id/btn_skip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand Down
2 changes: 1 addition & 1 deletion onboarder/src/main/res/layout/activity_ahoy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
android:layout_marginBottom="25dp"
android:layout_marginTop="20dp" />

<TextView
<Button
android:id="@+id/btn_skip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand Down