Skip to content

Commit

Permalink
PAINTROID-624 Icon update
Browse files Browse the repository at this point in the history
  • Loading branch information
exland committed Sep 9, 2023
1 parent 947032c commit c3cd4ff
Show file tree
Hide file tree
Showing 10 changed files with 132 additions and 145 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,50 +1,29 @@
package org.catrobat.paintroid.test.espresso.tools

import android.graphics.Bitmap
import android.graphics.Color
import android.graphics.PointF
import android.widget.SeekBar
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.PerformException
import androidx.test.espresso.action.ViewActions.*
import androidx.test.espresso.assertion.ViewAssertions
import androidx.test.espresso.action.ViewActions.closeSoftKeyboard
import androidx.test.espresso.action.ViewActions.replaceText
import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers.*
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.LargeTest
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.rule.ActivityTestRule
import kotlinx.coroutines.delay
import kotlinx.coroutines.runBlocking
import org.catrobat.paintroid.MainActivity
import org.catrobat.paintroid.R
import org.catrobat.paintroid.contract.LayerContracts
import org.catrobat.paintroid.test.espresso.util.DrawingSurfaceLocationProvider
import org.catrobat.paintroid.test.espresso.util.EspressoUtils.waitForToast
import org.catrobat.paintroid.test.espresso.util.MainActivityHelper
import org.catrobat.paintroid.test.espresso.util.UiInteractions
import org.catrobat.paintroid.test.espresso.util.wrappers.DrawingSurfaceInteraction.Companion.onDrawingSurfaceView
import org.catrobat.paintroid.test.espresso.util.wrappers.LayerMenuViewInteraction
import org.catrobat.paintroid.test.espresso.util.wrappers.ToolBarViewInteraction
import org.catrobat.paintroid.test.espresso.util.wrappers.ToolBarViewInteraction.Companion.onToolBarView
import org.catrobat.paintroid.test.espresso.util.wrappers.ToolPropertiesInteraction
import org.catrobat.paintroid.test.espresso.util.wrappers.TopBarViewInteraction
import org.catrobat.paintroid.test.espresso.util.wrappers.TransformToolOptionsViewInteraction.Companion.onTransformToolOptionsView
import org.catrobat.paintroid.test.utils.ScreenshotOnFailRule
import org.catrobat.paintroid.tools.ToolReference
import org.catrobat.paintroid.tools.ToolType
import org.catrobat.paintroid.tools.implementation.*
import org.catrobat.paintroid.tools.implementation.MAXIMUM_BITMAP_SIZE_FACTOR
import org.catrobat.paintroid.tools.implementation.PixelTool
import org.catrobat.paintroid.ui.Perspective
import org.hamcrest.Matchers.equalTo
import org.hamcrest.Matchers.greaterThan
import org.hamcrest.Matchers.lessThan
import org.hamcrest.Matchers.not
import org.junit.Assert.assertEquals
import org.junit.Assert.assertThat
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith

class PixelationToolIntegrationTest {
@get:Rule
Expand All @@ -64,23 +43,8 @@ class PixelationToolIntegrationTest {
private lateinit var toolReference: ToolReference
private lateinit var mainActivity: MainActivity
private lateinit var activityHelper: MainActivityHelper
private lateinit var pixelTool : PixelTool
private lateinit var pixelTool: PixelTool

private var toolSelectionBoxHeight: Float
get() {
return (toolReference.tool as BaseToolWithRectangleShape).boxHeight
}
private set(height) {
(toolReference.tool as BaseToolWithRectangleShape).boxHeight = height
}

private var toolSelectionBoxWidth: Float
get() {
return (toolReference.tool as BaseToolWithRectangleShape).boxWidth
}
private set(width) {
(toolReference.tool as BaseToolWithRectangleShape).boxWidth = width
}
@Before
fun setUp() {
mainActivity = launchActivityRule.activity
Expand All @@ -101,9 +65,7 @@ class PixelationToolIntegrationTest {
}

@Test
fun inputeTest()
{

fun inputeTest() {
var width = 80.0f
var height = 49.0f
onView(withId(R.id.pocketpaint_pixel_width_value))
Expand Down Expand Up @@ -133,4 +95,4 @@ class PixelationToolIntegrationTest {
assertEquals(pixelTool.numPixelHeight, height)
// assertEquals(pixelTool.numCollors.toInt(),collor )
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,7 @@ enum class ToolType(
R.id.pocketpaint_tools_clipping,
INVALID_RESOURCE_ID,
true
)
,
),
PIXEL(
R.string.button_pixel,
R.string.help_content_text,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,15 @@ import org.catrobat.paintroid.tools.ToolPaint
import org.catrobat.paintroid.tools.ToolType
import org.catrobat.paintroid.tools.Workspace
import org.catrobat.paintroid.tools.options.ToolOptionsViewController
import org.catrobat.paintroid.ui.tools.*
import org.catrobat.paintroid.ui.tools.DefaultBrushToolOptionsView
import org.catrobat.paintroid.ui.tools.DefaultClipboardToolOptionsView
import org.catrobat.paintroid.ui.tools.DefaultShapeToolOptionsView
import org.catrobat.paintroid.ui.tools.DefaultFillToolOptionsView
import org.catrobat.paintroid.ui.tools.DefaultTransformToolOptionsView
import org.catrobat.paintroid.ui.tools.DefaultTextToolOptionsView
import org.catrobat.paintroid.ui.tools.DefaultSprayToolOptionsView
import org.catrobat.paintroid.ui.tools.DefaultPixelToolOptionsView
import org.catrobat.paintroid.ui.tools.DefaultSmudgeToolOptionsView

private const val DRAW_TIME_INIT: Long = 30_000_000

Expand Down Expand Up @@ -196,7 +204,7 @@ class DefaultToolFactory(mainActivity: MainActivity) : ToolFactory {
DRAW_TIME_INIT,
mainActivity
)
ToolType.PIXEL ->PixelTool(
ToolType.PIXEL -> PixelTool(
DefaultPixelToolOptionsView(toolLayout),
contextCallback,
toolOptionsViewController,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package org.catrobat.paintroid.tools.implementation

import android.graphics.Bitmap
import android.graphics.PointF
import android.widget.Toast
import androidx.annotation.VisibleForTesting
import androidx.test.espresso.idling.CountingIdlingResource
import org.catrobat.paintroid.command.CommandManager
Expand All @@ -15,16 +14,15 @@ import org.catrobat.paintroid.tools.options.ToolOptionsViewController
import org.catrobat.paintroid.ui.tools.DefaultPixelToolOptionsView

class PixelTool(
pixelToolOptionsViewParam : PixelationToolOptionsView,
contextCallback : ContextCallback,
pixelToolOptionsViewParam: PixelationToolOptionsView,
contextCallback: ContextCallback,
toolOptionsViewController: ToolOptionsViewController,
toolPaint: ToolPaint,
workspace: Workspace,
idlingResource: CountingIdlingResource,
commandManager: CommandManager,
override var drawTime: Long
) : BaseToolWithRectangleShape(contextCallback, toolOptionsViewController,toolPaint, workspace, idlingResource, commandManager)
{
) : BaseToolWithRectangleShape(contextCallback, toolOptionsViewController, toolPaint, workspace, idlingResource, commandManager) {
private val pixelToolOptionsView: PixelationToolOptionsView
@VisibleForTesting
@JvmField
Expand All @@ -46,7 +44,7 @@ class PixelTool(
this.pixelToolOptionsView = pixelToolOptionsViewParam
setBitmap(Bitmap.createBitmap(boxWidth.toInt(), boxHeight.toInt(), Bitmap.Config.ARGB_8888))
toolOptionsViewController.showDelayed()
this.pixelToolOptionsView.setPixelPreviewListener(object : PixelationToolOptionsView.OnPixelationPreviewListener {
this.pixelToolOptionsView.setPixelPreviewListener(object : PixelationToolOptionsView.OnPixelationPreviewListener {
override fun setPixelWidth(widthPixels: Float) {
this@PixelTool.numPixelWidth = widthPixels
}
Expand All @@ -58,11 +56,9 @@ class PixelTool(
override fun setNumCollor(collorNum: Float) {
this@PixelTool.numCollors = collorNum
}

})
}


override val toolType: ToolType
get() = ToolType.PIXEL

Expand All @@ -74,15 +70,12 @@ class PixelTool(
super.handleDown(coordinate)
}

override fun toolPositionCoordinates(coordinate: PointF): PointF = coordinate
override fun toolPositionCoordinates(coordinate: PointF): PointF = coordinate

// is the checkmark to run the programm
override fun onClickOnButton() {
// test if the ui works good then shoudl be enought for the 30.8
var i = 10

}

override fun resetInternalState() = Unit

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ class TransformTool(
}
}

private fun onApplyResizeClicked(resizePercentage: Int) {
private fun onApplyResizeClicked(resizePercentage: Int) {
val newWidth = (workspace.width / HUNDRED * resizePercentage).toInt()
val newHeight = (workspace.height / HUNDRED * resizePercentage).toInt()
if (newWidth == 0 || newHeight == 0) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
package org.catrobat.paintroid.tools.options

import android.view.View

interface PixelationToolOptionsView {
fun invalidate ()

fun getTopToolOptions(): View

fun getBottomToolOptions(): View

fun setPixelPreviewListener(onPixelationPreviewListener: OnPixelationPreviewListener)

interface OnPixelationPreviewListener{
fun setPixelWidth(widthPixels : Float)
interface OnPixelationPreviewListener {
fun setPixelWidth(widthPixels: Float)

fun setPixelHeight(heightPixels : Float)
fun setPixelHeight(heightPixels: Float)

fun setNumCollor(collorNum: Float)
}
}



Original file line number Diff line number Diff line change
Expand Up @@ -22,52 +22,40 @@ import java.text.NumberFormat
import java.text.ParseException
import java.util.Locale

@VisibleForTesting

private const val MIN_WIDTH = 1
private const val MAX_WIDTH = 100
private const val MIN_HEIGHT = 1
private const val MAX_HEIGHT = 200
private const val MIN_COLOR = 1
private const val MAX_COLOR = 40

// ask PO maybe nee ded the minumum but the bar is not scalable so far (API 21 is current?)

@SuppressLint("SetTextI18n")
class DefaultPixelToolOptionsView (rootView : ViewGroup): PixelationToolOptionsView{

private val pixelNumWidth : AppCompatEditText
private val pixelNumHeight : AppCompatEditText
private var colorNumText : AppCompatEditText
//private val thisLayer : Chip
private val currentView = rootView
private var pixelChangedListener : OnPixelationPreviewListener? = null
private var pixelNumWidthWatcher : PixelToolNumTextWatcher
private var pixelNumHeightWatcher : PixelToolNumTextWatcher
private var colorNumBar : AppCompatSeekBar
@SuppressLint("NotImplementedDeclaration")
class DefaultPixelToolOptionsView(rootView: ViewGroup) : PixelationToolOptionsView {

private val pixelNumWidth: AppCompatEditText
private val pixelNumHeight: AppCompatEditText
private var colorNumText: AppCompatEditText
// private val thisLayer : Chip
// private val currentView = rootView
private var pixelChangedListener: OnPixelationPreviewListener? = null
private var pixelNumWidthWatcher: PixelToolNumTextWatcher
private var pixelNumHeightWatcher: PixelToolNumTextWatcher
private var colorNumBar: AppCompatSeekBar

companion object {
private val TAG = DefaultPixelToolOptionsView::class.java.simpleName
public val defaulWidth = 40f
public val defaultHeight = 60f
public val defaultCollor = 20f
const val defaulWidth = 40f
const val defaultHeight = 60f
const val defaultCollor = 20f
}

init {
val inflater = LayoutInflater.from(rootView.context)
val inflater = LayoutInflater.from(rootView.context)
val pixelView = inflater.inflate(R.layout.dialog_pocketpaint_pixel, rootView, true)
colorNumBar = pixelView.findViewById(R.id.pocketpaint_pixel_color_seekbar)
colorNumText = pixelView.findViewById(R.id.pocketpaint_transform_pixel_color_text)
colorNumBar.progress = defaultCollor.toInt()
colorNumText.setText(String.format(Locale.getDefault(), "%d", colorNumBar.progress))
pixelNumWidth =pixelView.findViewById(R.id.pocketpaint_pixel_width_value)
pixelNumWidth = pixelView.findViewById(R.id.pocketpaint_pixel_width_value)
pixelNumHeight = pixelView.findViewById(R.id.pocketpaint_pixel_height_value)
pixelNumWidth.setText(defaulWidth.toString())
pixelNumHeight.setText(defaultHeight.toString())
// initColorText()
// initWidthText()
// initHeightText()

pixelNumWidthWatcher = object : PixelToolNumTextWatcher() {
override fun setValue(value: Float) {
Expand All @@ -81,8 +69,6 @@ class DefaultPixelToolOptionsView (rootView : ViewGroup): PixelationToolOptionsV
}
pixelNumWidth.addTextChangedListener(pixelNumWidthWatcher)
pixelNumHeight.addTextChangedListener(pixelNumHeightWatcher)
// pixelNumHeight.setText(MAX_HEIGHT)
// pixelNumWidth.setText(MAX_WIDTH)
colorNumText.filters = arrayOf<InputFilter>(DefaultNumberRangeFilter(MIN_COLOR, MAX_COLOR))
colorNumText.setText(String.format(Locale.getDefault(), "%d", colorNumBar.progress))
colorNumText.addTextChangedListener(object : TextWatcher {
Expand Down Expand Up @@ -124,40 +110,21 @@ class DefaultPixelToolOptionsView (rootView : ViewGroup): PixelationToolOptionsV

pixelChangedListener?.setNumCollor(colorNumBar.progress.toFloat())
}


}
// handle up probs error

override fun invalidate() {
TODO("Not yet implemented")
}

override fun getTopToolOptions(): View {
TODO("Not yet implemented")
} //topLayout

override fun getBottomToolOptions(): View {
TODO("Not yet implemented")
}

override fun setPixelPreviewListener(onPixelationPreviewListener: PixelationToolOptionsView.OnPixelationPreviewListener) {
this.pixelChangedListener = onPixelationPreviewListener
}


abstract class PixelToolNumTextWatcher : TextWatcher {

protected abstract fun setValue(value: Float)

override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) = Unit

override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) = Unit
override fun afterTextChanged(editable: Editable) {
var str = editable.toString()
if (str.isEmpty()) {
str = MAX_COLOR.toString()

}
try {
val value = NumberFormat.getIntegerInstance().parse(str)?.toFloat()
Expand All @@ -167,5 +134,4 @@ class DefaultPixelToolOptionsView (rootView : ViewGroup): PixelationToolOptionsV
}
}
}

}
}
Loading

0 comments on commit c3cd4ff

Please sign in to comment.