Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 96 additions & 0 deletions layouteditor/src/main/assets/attributes/attributes.json
Original file line number Diff line number Diff line change
Expand Up @@ -638,5 +638,101 @@
"attributeName": "android:measureAllChildren",
"argumentType": "boolean"
}
],
"com.google.android.material.textfield.TextInputEditText": [
{
"name": "android:hint",
"methodName": "setHint",
"className": "text.TextInputEditTextCaller",
"attributeName": "android:hint",
"argumentType": "text|string"
},
{
"name": "android:inputType",
"methodName": "setInputType",
"className": "text.TextInputEditTextCaller",
"attributeName": "android:inputType",
"argumentType": "flag",
"arguments": [
"date",
"datetime",
"none",
"number",
"numberDecimal",
"numberSigned",
"numberPassword",
"phone",
"text",
"textAutoComplete",
"textAutoCorrect",
"textCapCharacters",
"textCapSentences",
"textCapWords",
"textEmailAddress",
"textEmailSubject",
"textEnableTextConversionSuggestions",
"textFilter",
"textImeMultiLine",
"textLongMessage",
"textMultiLine",
"textNoSuggestions",
"textPassword",
"textPersonName",
"textPhonetic",
"textPostalAddress",
"textShortMessage",
"textUri",
"textVisiblePassword",
"textWebEditText",
"textWebEmailAddress",
"textWebPassword",
"time"
],
"defaultValue": "-1"
},
{
"name": "android:textColorHint",
"methodName": "setHintTextColor",
"className": "text.TextInputEditTextCaller",
"attributeName": "android:textColorHint",
"argumentType": "color"
},
{
"name": "android:singleLine",
"methodName": "setSingleLine",
"className": "text.TextInputEditTextCaller",
"attributeName": "android:singleLine",
"argumentType": "boolean"
}
],
"com.google.android.material.textfield.TextInputLayout": [
{
"name": "android:hint",
"methodName": "setHint",
"className": "text.TextInputLayoutCaller",
"attributeName": "android:hint",
"argumentType": "text|string"
},
{
"name": "app:hintEnabled",
"methodName": "setHintEnabled",
"className": "text.TextInputLayoutCaller",
"attributeName": "app:hintEnabled",
"argumentType": "boolean"
},
{
"name": "app:errorEnabled",
"methodName": "setErrorEnabled",
"className": "text.TextInputLayoutCaller",
"attributeName": "app:errorEnabled",
"argumentType": "boolean"
},
{
"name": "app:counterEnabled",
"methodName": "setCounterEnabled",
"className": "text.TextInputLayoutCaller",
"attributeName": "app:counterEnabled",
"argumentType": "boolean"
}
]
}
19 changes: 19 additions & 0 deletions layouteditor/src/main/assets/palette/text.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,5 +138,24 @@
"defaultAttributes": {
"android:text": "CheckedTextView"
}
},
{
"name": "TextInputLayout",
"className": "org.appdevforall.codeonthego.layouteditor.editor.palette.text.TextInputLayoutDesign",
"iconName": "ic_palette_linear_layout_vert",
"defaultAttributes": {
"android:layout_width": "match_parent",
"android:layout_height": "wrap_content"
}
},
{
"name": "TextInputEditText",
"className": "org.appdevforall.codeonthego.layouteditor.editor.palette.text.TextInputEditTextDesign",
"iconName": "ic_palette_edit_text",
"defaultAttributes": {
"android:layout_width": "match_parent",
"android:layout_height": "wrap_content",
"android:inputType": "text"
}
}
]
4 changes: 3 additions & 1 deletion layouteditor/src/main/assets/widgetclasses.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,7 @@
"RatingBar": "org.appdevforall.codeonthego.layouteditor.editor.palette.widgets.RatingBarDesign",
"SearchView": "org.appdevforall.codeonthego.layouteditor.editor.palette.widgets.SearchViewDesign",
"TextureView": "org.appdevforall.codeonthego.layouteditor.editor.palette.widgets.TextureViewDesign",
"SurfaceView": "org.appdevforall.codeonthego.layouteditor.editor.palette.widgets.SurfaceViewDesign"
"SurfaceView": "org.appdevforall.codeonthego.layouteditor.editor.palette.widgets.SurfaceViewDesign",
"TextInputEditText": "org.appdevforall.codeonthego.layouteditor.editor.palette.text.TextInputEditTextDesign",
"TextInputLayout": "org.appdevforall.codeonthego.layouteditor.editor.palette.text.TextInputLayoutDesign"
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import android.view.ViewGroup
import android.widget.AdapterView
import android.widget.ArrayAdapter
import android.widget.EditText
import android.widget.FrameLayout
import android.widget.LinearLayout
import android.widget.Spinner
import android.widget.TextView
Expand Down Expand Up @@ -363,11 +364,28 @@ class DesignEditor : LinearLayout {
context,
) as View

newView.layoutParams =
ViewGroup.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT,
)
newView.layoutParams = when (parent) {
is LinearLayout -> {
LayoutParams(
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT,
)
}

is FrameLayout -> {
FrameLayout.LayoutParams(
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT,
)
}

else -> {
ViewGroup.LayoutParams(
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT,
)
}
}
rearrangeListeners(newView)

if (newView is ViewGroup) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.appdevforall.codeonthego.layouteditor.editor.callers.text

open class TextInputEditTextCaller : EditTextCaller() {
// Inherits typical EditText attributes
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package org.appdevforall.codeonthego.layouteditor.editor.callers.text

import android.content.Context
import android.view.View
import com.google.android.material.textfield.TextInputLayout
import org.appdevforall.codeonthego.layouteditor.managers.ProjectManager
import org.appdevforall.codeonthego.layouteditor.managers.ValuesManager
import org.appdevforall.codeonthego.layouteditor.tools.ValuesResourceParser

object TextInputLayoutCaller {

@JvmStatic
fun setHint(target: View, value: String, context: Context) {
var finalValue = value
if (finalValue.startsWith("@string/")) {
val project = ProjectManager.instance.openedProject ?: return
finalValue = ValuesManager.getValueFromResources(
ValuesResourceParser.TAG_STRING, finalValue, project.stringsPath
)
}
(target as TextInputLayout).hint = finalValue
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.

@JvmStatic
fun setHintEnabled(target: View, value: String, context: Context) {
(target as TextInputLayout).isHintEnabled = value.toBoolean()
}

@JvmStatic
fun setErrorEnabled(target: View, value: String, context: Context) {
(target as TextInputLayout).isErrorEnabled = value.toBoolean()
}

@JvmStatic
fun setCounterEnabled(target: View, value: String, context: Context) {
(target as TextInputLayout).isCounterEnabled = value.toBoolean()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package org.appdevforall.codeonthego.layouteditor.editor.palette.text

import android.content.Context
import android.graphics.Canvas
import com.google.android.material.textfield.TextInputEditText
import org.appdevforall.codeonthego.layouteditor.utils.Constants
import org.appdevforall.codeonthego.layouteditor.utils.Utils

open class TextInputEditTextDesign(context: Context) : TextInputEditText(context) {

private var drawStrokeEnabled: Boolean = false
private var isBlueprint: Boolean = false

override fun dispatchDraw(canvas: Canvas) {
super.dispatchDraw(canvas)

if (drawStrokeEnabled) {
Utils.drawDashPathStroke(
this,
canvas,
if (isBlueprint) Constants.BLUEPRINT_DASH_COLOR else Constants.DESIGN_DASH_COLOR
)
}
}

fun setStrokeEnabled(enabled: Boolean) {
drawStrokeEnabled = enabled
invalidate()
}

override fun draw(canvas: Canvas) {
if (isBlueprint) {
Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR)
} else {
super.draw(canvas)
}
}
Comment thread
dara-abijo-adfa marked this conversation as resolved.

fun setBlueprint(isBlueprint: Boolean) {
this.isBlueprint = isBlueprint
invalidate()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package org.appdevforall.codeonthego.layouteditor.editor.palette.text

import android.content.Context
import android.graphics.Canvas
import com.google.android.material.textfield.TextInputLayout
import org.appdevforall.codeonthego.layouteditor.utils.Constants
import org.appdevforall.codeonthego.layouteditor.utils.Utils

open class TextInputLayoutDesign(context: Context) : TextInputLayout(context) {

private var drawStrokeEnabled: Boolean = false
private var isBlueprint: Boolean = false

override fun dispatchDraw(canvas: Canvas) {
super.dispatchDraw(canvas)

if (drawStrokeEnabled) {
Utils.drawDashPathStroke(
this,
canvas,
if (isBlueprint) Constants.BLUEPRINT_DASH_COLOR else Constants.DESIGN_DASH_COLOR
)
}
}

fun setStrokeEnabled(enabled: Boolean) {
drawStrokeEnabled = enabled
invalidate()
}

override fun draw(canvas: Canvas) {
if (isBlueprint) {
Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR)
} else {
super.draw(canvas)
}
}

fun setBlueprint(isBlueprint: Boolean) {
this.isBlueprint = isBlueprint
invalidate()
}
}
Loading
Loading