diff --git a/resources/src/main/res/drawable/ic_widget_grid_view.xml b/resources/src/main/res/drawable/ic_widget_grid_view.xml new file mode 100644 index 000000000..2c060a7da --- /dev/null +++ b/resources/src/main/res/drawable/ic_widget_grid_view.xml @@ -0,0 +1,28 @@ + + + + + + diff --git a/resources/src/main/res/drawable/ic_widget_imageswitcher.xml b/resources/src/main/res/drawable/ic_widget_imageswitcher.xml new file mode 100644 index 000000000..7a3e78759 --- /dev/null +++ b/resources/src/main/res/drawable/ic_widget_imageswitcher.xml @@ -0,0 +1,32 @@ + + + + + + + diff --git a/resources/src/main/res/drawable/ic_widget_textswitcher.xml b/resources/src/main/res/drawable/ic_widget_textswitcher.xml new file mode 100644 index 000000000..9ca768bf3 --- /dev/null +++ b/resources/src/main/res/drawable/ic_widget_textswitcher.xml @@ -0,0 +1,32 @@ + + + + + + + diff --git a/resources/src/main/res/drawable/ic_widget_viewanimator.xml b/resources/src/main/res/drawable/ic_widget_viewanimator.xml new file mode 100644 index 000000000..b2e010792 --- /dev/null +++ b/resources/src/main/res/drawable/ic_widget_viewanimator.xml @@ -0,0 +1,31 @@ + + + + + + \ No newline at end of file diff --git a/resources/src/main/res/drawable/ic_widget_viewflipper.xml b/resources/src/main/res/drawable/ic_widget_viewflipper.xml new file mode 100644 index 000000000..06da21a4f --- /dev/null +++ b/resources/src/main/res/drawable/ic_widget_viewflipper.xml @@ -0,0 +1,27 @@ + + + + + \ No newline at end of file diff --git a/resources/src/main/res/drawable/ic_widget_viewswitcher.xml b/resources/src/main/res/drawable/ic_widget_viewswitcher.xml new file mode 100644 index 000000000..5fd6e7c8e --- /dev/null +++ b/resources/src/main/res/drawable/ic_widget_viewswitcher.xml @@ -0,0 +1,32 @@ + + + + + + + diff --git a/resources/src/main/res/values/strings.xml b/resources/src/main/res/values/strings.xml index 51b7c4814..13686d0dc 100644 --- a/resources/src/main/res/values/strings.xml +++ b/resources/src/main/res/values/strings.xml @@ -510,6 +510,12 @@ QuickContactBadge VideoView AnalogClock + GridView + ViewAnimator + ViewSwitcher + TextSwitcher + ImageSwitcher + ViewFlipper Clone diff --git a/xml-inflater/src/main/java/com/itsaky/androidide/inflater/internal/adapters/GridViewAdapter.kt b/xml-inflater/src/main/java/com/itsaky/androidide/inflater/internal/adapters/GridViewAdapter.kt new file mode 100644 index 000000000..8df9492b3 --- /dev/null +++ b/xml-inflater/src/main/java/com/itsaky/androidide/inflater/internal/adapters/GridViewAdapter.kt @@ -0,0 +1,65 @@ +/* + * This file is part of AndroidIDE. + * + * AndroidIDE is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AndroidIDE is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with AndroidIDE. If not, see . + */ + +package com.itsaky.androidide.inflater.internal.adapters + +import android.widget.GridView +import com.itsaky.androidide.annotations.inflater.ViewAdapter +import com.itsaky.androidide.annotations.uidesigner.IncludeInDesigner +import com.itsaky.androidide.annotations.uidesigner.IncludeInDesigner.Group.LAYOUTS +import com.itsaky.androidide.inflater.AttributeHandlerScope +import com.itsaky.androidide.inflater.models.UiWidget +import com.itsaky.androidide.resources.R.drawable +import com.itsaky.androidide.resources.R.string + +/** + * Attribute adapter for [GridView]. + * + * @author Deep Kr. Ghosh + */ +@ViewAdapter(GridView::class) +@IncludeInDesigner(group = LAYOUTS) +open class GridViewAdapter : AbsListViewAdapter() { + + override fun createAttrHandlers(create: (String, AttributeHandlerScope.() -> Unit) -> Unit) { + super.createAttrHandlers(create) + create("columnWidth") { view.columnWidth = parseDimension(context, value) } + create("gravity") { view.gravity = parseGravity(value) } + create("horizontalSpacing") { view.horizontalSpacing = parseDimension(context, value) } + create("numColumns") { + view.numColumns = if (value == "auto_fit") GridView.AUTO_FIT else parseInteger(value) + } + create("stretchMode") { view.stretchMode = parseStretchMode(value) } + create("verticalSpacing") { view.verticalSpacing = parseDimension(context, value) } + } + + override fun createUiWidgets(): List { + return listOf( + UiWidget(GridView::class.java, string.widget_grid_view, drawable.ic_widget_grid_view) + ) + } + + protected fun parseStretchMode(value: String): Int { + return when (value) { + "columnWidth" -> GridView.STRETCH_COLUMN_WIDTH + "none" -> GridView.NO_STRETCH + "spacingWidth" -> GridView.STRETCH_SPACING + "spacingWidthUniform" -> GridView.STRETCH_SPACING_UNIFORM + else -> GridView.NO_STRETCH + } + } +} diff --git a/xml-inflater/src/main/java/com/itsaky/androidide/inflater/internal/adapters/ImageSwitcherAdapter.kt b/xml-inflater/src/main/java/com/itsaky/androidide/inflater/internal/adapters/ImageSwitcherAdapter.kt new file mode 100644 index 000000000..28a55e210 --- /dev/null +++ b/xml-inflater/src/main/java/com/itsaky/androidide/inflater/internal/adapters/ImageSwitcherAdapter.kt @@ -0,0 +1,45 @@ +/* + * This file is part of AndroidIDE. + * + * AndroidIDE is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AndroidIDE is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with AndroidIDE. If not, see . + */ + +package com.itsaky.androidide.inflater.internal.adapters + +import android.widget.ImageSwitcher +import com.itsaky.androidide.annotations.inflater.ViewAdapter +import com.itsaky.androidide.annotations.uidesigner.IncludeInDesigner +import com.itsaky.androidide.annotations.uidesigner.IncludeInDesigner.Group.LAYOUTS +import com.itsaky.androidide.inflater.models.UiWidget +import com.itsaky.androidide.resources.R.drawable +import com.itsaky.androidide.resources.R.string + +/** + * Attribute adapter for [ImageSwitcher]. + * + * @author Deep Kr. Ghosh + */ +@ViewAdapter(ImageSwitcher::class) +@IncludeInDesigner(group = LAYOUTS) +open class ImageSwitcherAdapter : ViewSwitcherAdapter() { + override fun createUiWidgets(): List { + return listOf( + UiWidget( + ImageSwitcher::class.java, + string.widget_imageswitcher, + drawable.ic_widget_imageswitcher + ) + ) + } +} diff --git a/xml-inflater/src/main/java/com/itsaky/androidide/inflater/internal/adapters/TextSwitcherAdapter.kt b/xml-inflater/src/main/java/com/itsaky/androidide/inflater/internal/adapters/TextSwitcherAdapter.kt new file mode 100644 index 000000000..9af6ce264 --- /dev/null +++ b/xml-inflater/src/main/java/com/itsaky/androidide/inflater/internal/adapters/TextSwitcherAdapter.kt @@ -0,0 +1,45 @@ +/* + * This file is part of AndroidIDE. + * + * AndroidIDE is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AndroidIDE is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with AndroidIDE. If not, see . + */ + +package com.itsaky.androidide.inflater.internal.adapters + +import android.widget.TextSwitcher +import com.itsaky.androidide.annotations.inflater.ViewAdapter +import com.itsaky.androidide.annotations.uidesigner.IncludeInDesigner +import com.itsaky.androidide.annotations.uidesigner.IncludeInDesigner.Group.LAYOUTS +import com.itsaky.androidide.inflater.models.UiWidget +import com.itsaky.androidide.resources.R.drawable +import com.itsaky.androidide.resources.R.string + +/** + * Attribute adapter for [TextSwitcher]. + * + * @author Deep Kr. Ghosh + */ +@ViewAdapter(TextSwitcher::class) +@IncludeInDesigner(group = LAYOUTS) +open class TextSwitcherAdapter : ViewSwitcherAdapter() { + override fun createUiWidgets(): List { + return listOf( + UiWidget( + TextSwitcher::class.java, + string.widget_textswitcher, + drawable.ic_widget_textswitcher + ) + ) + } +} diff --git a/xml-inflater/src/main/java/com/itsaky/androidide/inflater/internal/adapters/ViewAnimatorAdapter.kt b/xml-inflater/src/main/java/com/itsaky/androidide/inflater/internal/adapters/ViewAnimatorAdapter.kt new file mode 100644 index 000000000..976969443 --- /dev/null +++ b/xml-inflater/src/main/java/com/itsaky/androidide/inflater/internal/adapters/ViewAnimatorAdapter.kt @@ -0,0 +1,51 @@ +/* + * This file is part of AndroidIDE. + * + * AndroidIDE is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AndroidIDE is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with AndroidIDE. If not, see . + */ + +package com.itsaky.androidide.inflater.internal.adapters + +import android.widget.ViewAnimator +import com.itsaky.androidide.annotations.inflater.ViewAdapter +import com.itsaky.androidide.annotations.uidesigner.IncludeInDesigner +import com.itsaky.androidide.annotations.uidesigner.IncludeInDesigner.Group.LAYOUTS +import com.itsaky.androidide.inflater.AttributeHandlerScope +import com.itsaky.androidide.inflater.models.UiWidget +import com.itsaky.androidide.resources.R + +/** + * View adapter for [ViewAnimator]. + * + * @author Deep Kr. Ghosh + */ +@ViewAdapter(ViewAnimator::class) +@IncludeInDesigner(group = LAYOUTS) +open class ViewAnimatorAdapter : FrameLayoutAdapter() { + + override fun createAttrHandlers(create: (String, AttributeHandlerScope.() -> Unit) -> Unit) { + super.createAttrHandlers(create) + create("animateFirstView") { view.animateFirstView = parseBoolean(value, false) } + } + + override fun createUiWidgets(): List { + return listOf( + UiWidget( + ViewAnimator::class.java, + R.string.widget_viewanimator, + R.drawable.ic_widget_viewanimator + ) + ) + } +} diff --git a/xml-inflater/src/main/java/com/itsaky/androidide/inflater/internal/adapters/ViewFlipperAdapter.kt b/xml-inflater/src/main/java/com/itsaky/androidide/inflater/internal/adapters/ViewFlipperAdapter.kt new file mode 100644 index 000000000..dd90a4204 --- /dev/null +++ b/xml-inflater/src/main/java/com/itsaky/androidide/inflater/internal/adapters/ViewFlipperAdapter.kt @@ -0,0 +1,48 @@ +/* + * This file is part of AndroidIDE. + * + * AndroidIDE is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AndroidIDE is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with AndroidIDE. If not, see . + */ + +package com.itsaky.androidide.inflater.internal.adapters + +import android.widget.ViewFlipper +import com.itsaky.androidide.annotations.inflater.ViewAdapter +import com.itsaky.androidide.annotations.uidesigner.IncludeInDesigner +import com.itsaky.androidide.annotations.uidesigner.IncludeInDesigner.Group.LAYOUTS +import com.itsaky.androidide.inflater.AttributeHandlerScope +import com.itsaky.androidide.inflater.models.UiWidget +import com.itsaky.androidide.resources.R.drawable +import com.itsaky.androidide.resources.R.string + +/** + * Attribute adapter for [ViewFlipper]. + * + * @author Deep Kr. Ghosh + */ +@ViewAdapter(ViewFlipper::class) +@IncludeInDesigner(group = LAYOUTS) +open class ViewFlipperAdapter : ViewAnimatorAdapter() { + override fun createAttrHandlers(create: (String, AttributeHandlerScope.() -> Unit) -> Unit) { + super.createAttrHandlers(create) + create("autoStart") { view.setAutoStart(parseBoolean(value)) } + create("flipInterval") { view.flipInterval = parseInteger(value) } + } + + override fun createUiWidgets(): List { + return listOf( + UiWidget(ViewFlipper::class.java, string.widget_viewflipper, drawable.ic_widget_viewflipper) + ) + } +} diff --git a/xml-inflater/src/main/java/com/itsaky/androidide/inflater/internal/adapters/ViewSwitcherAdapter.kt b/xml-inflater/src/main/java/com/itsaky/androidide/inflater/internal/adapters/ViewSwitcherAdapter.kt new file mode 100644 index 000000000..0990f3df6 --- /dev/null +++ b/xml-inflater/src/main/java/com/itsaky/androidide/inflater/internal/adapters/ViewSwitcherAdapter.kt @@ -0,0 +1,45 @@ +/* + * This file is part of AndroidIDE. + * + * AndroidIDE is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AndroidIDE is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with AndroidIDE. If not, see . + */ + +package com.itsaky.androidide.inflater.internal.adapters + +import android.widget.ViewSwitcher +import com.itsaky.androidide.annotations.inflater.ViewAdapter +import com.itsaky.androidide.annotations.uidesigner.IncludeInDesigner +import com.itsaky.androidide.annotations.uidesigner.IncludeInDesigner.Group.LAYOUTS +import com.itsaky.androidide.inflater.models.UiWidget +import com.itsaky.androidide.resources.R.drawable +import com.itsaky.androidide.resources.R.string + +/** + * Attribute adapter for [ViewSwitcher]. + * + * @author Deep Kr. Ghosh + */ +@ViewAdapter(ViewSwitcher::class) +@IncludeInDesigner(group = LAYOUTS) +open class ViewSwitcherAdapter : ViewAnimatorAdapter() { + override fun createUiWidgets(): List { + return listOf( + UiWidget( + ViewSwitcher::class.java, + string.widget_viewswitcher, + drawable.ic_widget_viewswitcher + ) + ) + } +}