Skip to content

Commit

Permalink
Can set default color and default text color (#2)
Browse files Browse the repository at this point in the history
Thank
  • Loading branch information
porntipa authored and piruin committed Nov 27, 2016
1 parent a81bda9 commit b2b990a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Version 2.1
- Add small stroke for better visibility
- Can set default color and default text color

## Version 2.0 *(2016-11-6)*

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ and publish to JCenter.
## Download

### [JCenter]
k

- **Step 1** - set JCenter repository (This step not require for modern android project)
- **Step 2** - Add dependencies on app module

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
package me.piruin.quickaction.sample;

import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v4.content.res.ResourcesCompat;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
Expand All @@ -39,6 +41,10 @@ public class SampleActivity extends AppCompatActivity {
@Override public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

//Config default color
QuickAction.setDefaultColor(ResourcesCompat.getColor(getResources(), R.color.teal, null));
QuickAction.setDefaultTextColor(Color.BLACK);

setContentView(R.layout.activity_sample);

ActionItem nextItem = new ActionItem(ID_DOWN, "Next", R.drawable.ic_arrow_downward);
Expand All @@ -61,6 +67,7 @@ public class SampleActivity extends AppCompatActivity {
//add action items into QuickAction
quickAction.addActionItem(nextItem);
quickAction.addActionItem(prevItem);
quickAction.setTextColor(Color.YELLOW);
quickAction.addActionItem(searchItem);
quickAction.addActionItem(infoItem);
quickAction.addActionItem(eraseItem);
Expand Down Expand Up @@ -108,7 +115,6 @@ public class SampleActivity extends AppCompatActivity {
final QuickAction quickIntent = new QuickIntentAction(this)
.setActivityIntent(sendIntent)
.create();
quickIntent.setColorRes(R.color.teal);
quickIntent.setAnimStyle(QuickAction.Animation.REFLECT);

Button btn3 = (Button)this.findViewById(R.id.button3);
Expand Down
15 changes: 13 additions & 2 deletions quickaction/src/main/java/me/piruin/quickaction/QuickAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ public class QuickAction extends PopupWindows implements OnDismissListener {
public static final int HORIZONTAL = LinearLayout.HORIZONTAL;
public static final int VERTICAL = LinearLayout.VERTICAL;

private static int defaultColor = Color.WHITE;
private static int defaultTextColor = Color.BLACK;

public static void setDefaultTextColor(int defaultTextColor) {
QuickAction.defaultTextColor = defaultTextColor;
}

public static void setDefaultColor(int defaultColor) {
QuickAction.defaultColor = defaultColor;
}

private WindowManager windowManager;
private View rootView;
private View arrowUp;
Expand All @@ -67,7 +78,7 @@ public class QuickAction extends PopupWindows implements OnDismissListener {
private int insertPos;
private int orientation;
private int rootWidth = 0;
private int textColor = Color.BLACK;
private int textColor = defaultTextColor;

private final int stroke;
private final int shadowColor;
Expand Down Expand Up @@ -113,7 +124,7 @@ private void setRootView(@LayoutRes int id) {
scroller = (ViewGroup)rootView.findViewById(R.id.scroller);

setContentView(rootView);
setColor(Color.WHITE);
setColor(defaultColor);
}

/**
Expand Down

0 comments on commit b2b990a

Please sign in to comment.