rename color fill to bucket fill and show a toast on long press
This commit is contained in:
parent
b456013d26
commit
1456648f6d
|
@ -63,7 +63,7 @@ class MainActivity : SimpleActivity(), CanvasListener {
|
|||
private var lastSavePromptTS = 0L
|
||||
private var isEraserOn = false
|
||||
private var isEyeDropperOn = false
|
||||
private var isColorFillOn = false
|
||||
private var isBucketFillOn = false
|
||||
private var isImageCaptureIntent = false
|
||||
private var isEditIntent = false
|
||||
private var lastBitmapPath = ""
|
||||
|
@ -106,7 +106,12 @@ class MainActivity : SimpleActivity(), CanvasListener {
|
|||
true
|
||||
}
|
||||
|
||||
color_fill.setOnClickListener { colorFillClicked() }
|
||||
bucket_fill.setOnClickListener { bucketFillClicked() }
|
||||
bucket_fill.setOnLongClickListener {
|
||||
toast(R.string.bucket_fill)
|
||||
true
|
||||
}
|
||||
|
||||
checkIntents()
|
||||
if (!isImageCaptureIntent) {
|
||||
checkWhatsNewDialog()
|
||||
|
@ -395,18 +400,17 @@ class MainActivity : SimpleActivity(), CanvasListener {
|
|||
eye_dropper.setImageResource(iconId)
|
||||
}
|
||||
|
||||
private fun colorFillClicked() {
|
||||
isColorFillOn = !isColorFillOn
|
||||
private fun bucketFillClicked() {
|
||||
isBucketFillOn = !isBucketFillOn
|
||||
|
||||
val iconId = if (isColorFillOn) {
|
||||
R.drawable.ic_color_fill_off_vector
|
||||
val iconId = if (isBucketFillOn) {
|
||||
R.drawable.ic_bucket_fill_off_vector
|
||||
} else {
|
||||
R.drawable.ic_color_fill_on_vector
|
||||
R.drawable.ic_bucket_fill_on_vector
|
||||
}
|
||||
|
||||
color_fill.setImageResource(iconId)
|
||||
|
||||
my_canvas.toggleColorFill(isColorFillOn)
|
||||
bucket_fill.setImageResource(iconId)
|
||||
my_canvas.toggleBucketFill(isBucketFillOn)
|
||||
}
|
||||
|
||||
private fun confirmImage() {
|
||||
|
@ -591,7 +595,7 @@ class MainActivity : SimpleActivity(), CanvasListener {
|
|||
eraser.applyColorFilter(contrastColor)
|
||||
redo.applyColorFilter(contrastColor)
|
||||
eye_dropper.applyColorFilter(contrastColor)
|
||||
color_fill.applyColorFilter(contrastColor)
|
||||
bucket_fill.applyColorFilter(contrastColor)
|
||||
if (isBlackAndWhiteTheme()) {
|
||||
stroke_width_bar.setColors(0, contrastColor, 0)
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) {
|
|||
private var mCurrBrushSize = 0f
|
||||
private var mAllowMovingZooming = true
|
||||
private var mIsEraserOn = false
|
||||
private var mIsColorFillOn = false
|
||||
private var mIsBucketFillOn = false
|
||||
private var mWasMultitouch = false
|
||||
private var mIgnoreTouches = false
|
||||
private var mWasScalingInGesture = false
|
||||
|
@ -164,7 +164,7 @@ class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) {
|
|||
mTouchSloppedBeforeMultitouch = false
|
||||
}
|
||||
|
||||
if (!mIsColorFillOn && (!mAllowMovingZooming || (!mScaleDetector!!.isInProgress && event.pointerCount == 1 && !mWasMultitouch))) {
|
||||
if (!mIsBucketFillOn && (!mAllowMovingZooming || (!mScaleDetector!!.isInProgress && event.pointerCount == 1 && !mWasMultitouch))) {
|
||||
actionMove(newValueX, newValueY)
|
||||
}
|
||||
|
||||
|
@ -276,8 +276,8 @@ class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) {
|
|||
invalidate()
|
||||
}
|
||||
|
||||
fun toggleColorFill(isColorFillOn: Boolean) {
|
||||
mIsColorFillOn = isColorFillOn
|
||||
fun toggleBucketFill(isBucketFillOn: Boolean) {
|
||||
mIsBucketFillOn = isBucketFillOn
|
||||
}
|
||||
|
||||
fun setColor(newColor: Int) {
|
||||
|
@ -365,8 +365,8 @@ class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) {
|
|||
}
|
||||
|
||||
private fun actionUp(forceLineDraw: Boolean) {
|
||||
if (mIsColorFillOn) {
|
||||
colorFill()
|
||||
if (mIsBucketFillOn) {
|
||||
bucketFill()
|
||||
} else if (!mWasMultitouch || forceLineDraw) {
|
||||
drawADot()
|
||||
}
|
||||
|
@ -389,7 +389,7 @@ class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) {
|
|||
mListener?.toggleRedoVisibility(visible)
|
||||
}
|
||||
|
||||
private fun colorFill() {
|
||||
private fun bucketFill() {
|
||||
val touchedX = mCurX.toInt()
|
||||
val touchedY = mCurY.toInt()
|
||||
if (contains(touchedX, touchedY)) {
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24">
|
||||
<path android:fillColor="#FFFFFFFF" android:pathData="M18 14c0-4-6-10.8-6-10.8s-1.33 1.51-2.73 3.52l8.59 8.59C17.95 14.89 18 14.45 18 14zm-0.88 3.12L12.5 12.5 5.27 5.27 4 6.55l3.32 3.32C6.55 11.32 6 12.79 6 14c0 3.31 2.69 6 6 6 1.52 0 2.9-0.57 3.96-1.5l2.63 2.63 1.27-1.27-2.74-2.74z"/>
|
||||
</vector>
|
|
@ -0,0 +1,3 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="48" android:viewportHeight="48">
|
||||
<path android:fillColor="#FFFFFFFF" android:pathData="M10.561 5.804l2.513-2.725 20.337 22.057c0.896 0.972 1.344 2.166 1.344 3.581 0 1.416-0.448 2.609-1.344 3.581L23.009 43.58c-0.896 0.972-1.948 1.458-3.156 1.458-1.208 0-2.26-0.486-3.156-1.458L6.295 32.298c-0.896-0.972-1.344-2.166-1.344-3.581 0-1.416 0.448-2.609 1.344-3.581l11.046-11.979zm9.292 10.078L8.224 28.495h23.259zm19.753 30.234c-1.169 0-2.162-0.444-2.98-1.331-0.818-0.887-1.227-1.965-1.227-3.233 0-0.718 0.156-1.5 0.468-2.345 0.312-0.845 0.74-1.711 1.286-2.599 0.312-0.549 0.692-1.141 1.14-1.775 0.448-0.634 0.886-1.225 1.315-1.775 0.429 0.549 0.867 1.141 1.315 1.775 0.448 0.634 0.828 1.225 1.14 1.775 0.545 0.887 0.974 1.754 1.286 2.599 0.312 0.845 0.468 1.627 0.468 2.345 0 1.268-0.409 2.345-1.227 3.233-0.818 0.887-1.812 1.331-2.98 1.331z"/>
|
||||
</vector>
|
|
@ -1,5 +0,0 @@
|
|||
<vector android:height="24dp" android:tint="#FFFFFF"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@android:color/white" android:pathData="M18,14c0,-4 -6,-10.8 -6,-10.8s-1.33,1.51 -2.73,3.52l8.59,8.59c0.09,-0.42 0.14,-0.86 0.14,-1.31zM17.12,17.12L12.5,12.5 5.27,5.27 4,6.55l3.32,3.32C6.55,11.32 6,12.79 6,14c0,3.31 2.69,6 6,6 1.52,0 2.9,-0.57 3.96,-1.5l2.63,2.63 1.27,-1.27 -2.74,-2.74z"/>
|
||||
</vector>
|
|
@ -1,5 +0,0 @@
|
|||
<vector android:height="24dp" android:viewportHeight="48"
|
||||
android:viewportWidth="48" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#FFFFFF"
|
||||
android:pathData="M10.561,5.804 L13.074,3.079 33.411,25.136c0.896,0.972 1.344,2.166 1.344,3.581 0,1.416 -0.448,2.609 -1.344,3.581L23.009,43.58c-0.896,0.972 -1.948,1.458 -3.156,1.458 -1.208,0 -2.26,-0.486 -3.156,-1.458L6.295,32.298c-0.896,-0.972 -1.344,-2.166 -1.344,-3.581 0,-1.416 0.448,-2.609 1.344,-3.581L17.341,13.157ZM19.853,15.882 L8.224,28.495L31.483,28.495ZM39.606,46.116c-1.169,0 -2.162,-0.444 -2.98,-1.331 -0.818,-0.887 -1.227,-1.965 -1.227,-3.233 0,-0.718 0.156,-1.5 0.468,-2.345 0.312,-0.845 0.74,-1.711 1.286,-2.599 0.312,-0.549 0.692,-1.141 1.14,-1.775 0.448,-0.634 0.886,-1.225 1.315,-1.775 0.429,0.549 0.867,1.141 1.315,1.775 0.448,0.634 0.828,1.225 1.14,1.775 0.545,0.887 0.974,1.754 1.286,2.599 0.312,0.845 0.468,1.627 0.468,2.345 0,1.268 -0.409,2.345 -1.227,3.233 -0.818,0.887 -1.812,1.331 -2.98,1.331z" android:strokeWidth="1.21722"/>
|
||||
</vector>
|
|
@ -44,20 +44,20 @@
|
|||
android:id="@+id/redo"
|
||||
android:layout_width="@dimen/normal_icon_size"
|
||||
android:layout_height="@dimen/normal_icon_size"
|
||||
android:layout_toStartOf="@+id/color_fill"
|
||||
android:layout_toStartOf="@+id/bucket_fill"
|
||||
android:contentDescription="@string/redo"
|
||||
android:padding="@dimen/medium_margin"
|
||||
android:src="@drawable/ic_redo_vector"
|
||||
android:visibility="gone" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/color_fill"
|
||||
android:id="@+id/bucket_fill"
|
||||
android:layout_width="@dimen/normal_icon_size"
|
||||
android:layout_height="@dimen/normal_icon_size"
|
||||
android:layout_toStartOf="@+id/eraser"
|
||||
android:contentDescription="@string/bucket_fill"
|
||||
android:padding="@dimen/medium_margin"
|
||||
android:src="@drawable/ic_color_fill_on_vector" />
|
||||
android:src="@drawable/ic_bucket_fill_on_vector" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/eraser"
|
||||
|
|
Loading…
Reference in New Issue