|
@@ -6,6 +6,7 @@ import android.content.res.Resources;
|
|
|
import android.graphics.Canvas;
|
|
|
import android.graphics.Color;
|
|
|
import android.graphics.Paint;
|
|
|
+import android.graphics.Rect;
|
|
|
import android.graphics.drawable.Drawable;
|
|
|
import android.graphics.drawable.RippleDrawable;
|
|
|
import android.graphics.drawable.ShapeDrawable;
|
|
@@ -15,9 +16,13 @@ import android.os.Build;
|
|
|
import android.support.annotation.ColorInt;
|
|
|
import android.support.annotation.ColorRes;
|
|
|
import android.support.annotation.FloatRange;
|
|
|
+import android.support.v4.view.GravityCompat;
|
|
|
+import android.support.v4.view.ViewCompat;
|
|
|
import android.util.AttributeSet;
|
|
|
import android.util.TypedValue;
|
|
|
+import android.view.Gravity;
|
|
|
import android.widget.FrameLayout;
|
|
|
+import android.widget.Toast;
|
|
|
|
|
|
import com.afollestad.materialdialogs.util.DialogUtils;
|
|
|
|
|
@@ -141,7 +146,7 @@ public class CircleView extends FrameLayout {
|
|
|
protected void onDraw(Canvas canvas) {
|
|
|
super.onDraw(canvas);
|
|
|
final int outerRadius = getMeasuredWidth() / 2;
|
|
|
- if(mSelected) {
|
|
|
+ if (mSelected) {
|
|
|
final int whiteRadius = outerRadius - borderWidthLarge;
|
|
|
final int innerRadius = whiteRadius - borderWidthSmall;
|
|
|
canvas.drawCircle(getMeasuredWidth() / 2,
|
|
@@ -200,4 +205,30 @@ public class CircleView extends FrameLayout {
|
|
|
public static int shiftColorUp(@ColorInt int color) {
|
|
|
return shiftColor(color, 1.1f);
|
|
|
}
|
|
|
+
|
|
|
+ public void showHint(int color) {
|
|
|
+ final int[] screenPos = new int[2];
|
|
|
+ final Rect displayFrame = new Rect();
|
|
|
+ getLocationOnScreen(screenPos);
|
|
|
+ getWindowVisibleDisplayFrame(displayFrame);
|
|
|
+ final Context context = getContext();
|
|
|
+ final int width = getWidth();
|
|
|
+ final int height = getHeight();
|
|
|
+ final int midy = screenPos[1] + height / 2;
|
|
|
+ int referenceX = screenPos[0] + width / 2;
|
|
|
+ if (ViewCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_LTR) {
|
|
|
+ final int screenWidth = context.getResources().getDisplayMetrics().widthPixels;
|
|
|
+ referenceX = screenWidth - referenceX; // mirror
|
|
|
+ }
|
|
|
+ Toast cheatSheet = Toast.makeText(context, String.format("#%06X", 0xFFFFFF & color), Toast.LENGTH_SHORT);
|
|
|
+ if (midy < displayFrame.height()) {
|
|
|
+ // Show along the top; follow action buttons
|
|
|
+ cheatSheet.setGravity(Gravity.TOP | GravityCompat.END, referenceX,
|
|
|
+ screenPos[1] + height - displayFrame.top);
|
|
|
+ } else {
|
|
|
+ // Show along the bottom center
|
|
|
+ cheatSheet.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, height);
|
|
|
+ }
|
|
|
+ cheatSheet.show();
|
|
|
+ }
|
|
|
}
|