Skip to content

Commit

Permalink
Allow colour of content cover to be controlled (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
markormesher committed Jun 8, 2017
1 parent 2894540 commit 1e0456c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -251,4 +251,4 @@ protected boolean isEnabled() {
return !inClickMode;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,16 @@ public void setBackgroundColour(int colour) {
}
}

/**
* Sets the colour of the layer that opens behind the speed dial menu.
*
* @param colour the colour of the layer, in aRGB format
*/
public void setContentCoverColour(int colour) {
savedCoverColour = colour;
((GradientDrawable) coverView.getBackground()).setColor(colour);
}

/**
* Hide the FAB.
*/
Expand Down Expand Up @@ -543,14 +553,16 @@ public void onAnimationEnd(Animator animation) {
*====================*/

private int savedIconResId = -1;
private int savedBgColour = 0x3f51b5;
private int savedBgColour = 0xff3f51b5;
private int savedCoverColour = 0x99ffffff;

@Override
protected Parcelable onSaveInstanceState() {
Bundle bundle = new Bundle();
bundle.putBoolean("shown", shown);
bundle.putInt("savedIconResId", savedIconResId);
bundle.putInt("savedBgColour", savedBgColour);
bundle.putInt("savedCoverColour", savedCoverColour);
bundle.putParcelable("SUPER", super.onSaveInstanceState());
return bundle;
}
Expand All @@ -575,10 +587,15 @@ protected void onRestoreInstanceState(Parcelable state) {
// background colour
if (bundle.containsKey("savedBgColour")) {
savedBgColour = bundle.getInt("savedBgColour");
Log.d(C.LOG_TAG, "" + savedBgColour);
setBackgroundColour(savedBgColour);
}

// cover colour
if (bundle.containsKey("savedCoverColour")) {
savedCoverColour = bundle.getInt("savedCoverColour");
setContentCoverColour(savedCoverColour);
}

// super-state
state = bundle.getParcelable("SUPER");
}
Expand Down

0 comments on commit 1e0456c

Please sign in to comment.