diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 363b5d9720..da78e6b1c0 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -321,7 +321,6 @@ dependencies { implementation(projects.pluginApi) implementation(projects.pluginManager) - implementation(projects.layouteditor) implementation(projects.idetooltips) implementation(projects.floatingWindow) implementation(projects.gitCore) diff --git a/app/src/main/java/com/itsaky/androidide/actions/etc/PreviewLayoutAction.kt b/app/src/main/java/com/itsaky/androidide/actions/etc/PreviewLayoutAction.kt deleted file mode 100644 index ef102ad0e1..0000000000 --- a/app/src/main/java/com/itsaky/androidide/actions/etc/PreviewLayoutAction.kt +++ /dev/null @@ -1,167 +0,0 @@ -/* - * 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.actions.etc - -import android.content.Context -import android.content.Intent -import android.view.MenuItem -import androidx.core.content.ContextCompat -import com.android.aaptcompiler.AaptResourceType.LAYOUT -import com.android.aaptcompiler.extractPathData -import com.blankj.utilcode.util.KeyboardUtils -import com.google.android.material.dialog.MaterialAlertDialogBuilder -import com.itsaky.androidide.actions.ActionData -import com.itsaky.androidide.actions.EditorRelatedAction -import com.itsaky.androidide.actions.markInvisible -import com.itsaky.androidide.activities.editor.EditorHandlerActivity -import com.itsaky.androidide.idetooltips.TooltipTag -import com.itsaky.androidide.resources.R -import org.appdevforall.codeonthego.layouteditor.activities.EditorActivity -import org.appdevforall.codeonthego.layouteditor.editor.convert.ConvertImportedXml -import org.appdevforall.codeonthego.layouteditor.utils.Constants -import org.appdevforall.codeonthego.layouteditor.tools.ValidationResult -import org.appdevforall.codeonthego.layouteditor.tools.XmlLayoutParser -import org.slf4j.LoggerFactory -import java.io.File - -/** @author Akash Yadav */ -class PreviewLayoutAction(context: Context, override val order: Int) : EditorRelatedAction() { - - override val id: String = ID - override fun retrieveTooltipTag(isReadOnlyContext: Boolean): String = - TooltipTag.EDITOR_TOOLBAR_PREVIEW_LAYOUT - override var requiresUIThread: Boolean = false - - private var previewType: PreviewType = PreviewType.NONE - - private enum class PreviewType { - NONE, - XML_LAYOUT - } - - companion object { - const val ID = "ide.editor.previewLayout" - private val LOG = LoggerFactory.getLogger(PreviewLayoutAction::class.java) - } - - init { - label = context.getString(R.string.title_preview_layout) - icon = ContextCompat.getDrawable(context, R.drawable.ic_preview_layout) - } - - override fun prepare(data: ActionData) { - super.prepare(data) - - previewType = PreviewType.NONE - - if (data.getActivity() == null) { - markInvisible() - return - } - - val viewModel = data.requireActivity().editorViewModel - val editor = data.getEditor() - val file = editor?.file - - if (file != null && !viewModel.isInitializing && file.name.endsWith(".xml")) { - val type = try { - extractPathData(file).type - } catch (err: Exception) { - LOG.warn("Failed to parse resource path for '{}'; hiding preview action", file.name, err) - markInvisible() - return - } - - if (type == LAYOUT) { - previewType = PreviewType.XML_LAYOUT - visible = true - enabled = true - } else { - markInvisible() - } - } else { - markInvisible() - } - } - - override fun getShowAsActionFlags(data: ActionData): Int { - val activity = data.getActivity() ?: return super.getShowAsActionFlags(data) - return if (KeyboardUtils.isSoftInputVisible(activity)) { - MenuItem.SHOW_AS_ACTION_IF_ROOM - } else { - MenuItem.SHOW_AS_ACTION_ALWAYS - } - } - - override suspend fun execAction(data: ActionData): Boolean { - val activity = data.requireActivity() - activity.saveAll() - return true - } - - override fun postExec(data: ActionData, result: Any) { - val activity = data.requireActivity() - - when (previewType) { - PreviewType.XML_LAYOUT -> { - val editor = data.getEditor() ?: return - val file = editor.file ?: return - val sourceCode = editor.text.toString() - - try { - val converted = ConvertImportedXml(sourceCode).getXmlConverted(activity) - if (converted == null) { - showXmlValidationError(activity, activity.getString(R.string.xml_validation_error_invalid_file)) - return - } - - val validator = XmlLayoutParser(activity) - - val result = validator.validateXml(converted, activity) - when (result) { - is ValidationResult.Success -> activity.previewXmlLayout(file) - is ValidationResult.Error -> showXmlValidationError(activity, result.formattedMessage) - } - } catch (e: Exception) { - showXmlValidationError(activity, activity.getString(R.string.xml_error_generic, e.message ?: "")) - } - } - PreviewType.NONE -> {} - } - } - - private fun EditorHandlerActivity.previewXmlLayout(file: File) { - val intent = Intent(this, EditorActivity::class.java) - intent.putExtra(Constants.EXTRA_KEY_FILE_PATH, file.absolutePath.substringBeforeLast("layout${File.separator}")) - intent.putExtra(Constants.EXTRA_KEY_LAYOUT_FILE_NAME, file.name.substringBefore(".")) - uiDesignerResultLauncher?.launch(intent) - } - - private fun showXmlValidationError(activity: Context, message: String?) { - val safeMessage = - message?.takeIf { it.isNotBlank() } - ?: activity.getString(R.string.xml_validation_error_generic) - (activity as? EditorHandlerActivity)?.runOnUiThread { - MaterialAlertDialogBuilder(activity) - .setTitle(R.string.xml_validation_error_title) - .setMessage(safeMessage) - .setPositiveButton(android.R.string.ok, null) - .show() - } - } -} diff --git a/app/src/main/java/com/itsaky/androidide/adapters/DeleteProjectListAdapter.kt b/app/src/main/java/com/itsaky/androidide/adapters/DeleteProjectListAdapter.kt index 48488a09be..aedcc2b2e0 100644 --- a/app/src/main/java/com/itsaky/androidide/adapters/DeleteProjectListAdapter.kt +++ b/app/src/main/java/com/itsaky/androidide/adapters/DeleteProjectListAdapter.kt @@ -6,7 +6,7 @@ import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView import com.itsaky.androidide.databinding.DeleteProjectsItemBinding import com.itsaky.androidide.models.Checkable -import org.appdevforall.codeonthego.layouteditor.ProjectFile +import com.itsaky.androidide.models.ProjectFile class DeleteProjectListAdapter( private var projects: List>, diff --git a/app/src/main/java/com/itsaky/androidide/adapters/RecentProjectsAdapter.kt b/app/src/main/java/com/itsaky/androidide/adapters/RecentProjectsAdapter.kt index 33a75387a3..b92b323678 100644 --- a/app/src/main/java/com/itsaky/androidide/adapters/RecentProjectsAdapter.kt +++ b/app/src/main/java/com/itsaky/androidide/adapters/RecentProjectsAdapter.kt @@ -28,8 +28,8 @@ import com.itsaky.androidide.tasks.executeAsync import com.itsaky.androidide.utils.applyLongPressRecursively import com.itsaky.androidide.utils.flashError import com.itsaky.androidide.utils.flashSuccess -import org.appdevforall.codeonthego.layouteditor.ProjectFile -import org.appdevforall.codeonthego.layouteditor.databinding.TextinputlayoutBinding +import com.itsaky.androidide.databinding.RenameProjectTextinputBinding +import com.itsaky.androidide.models.ProjectFile import org.slf4j.LoggerFactory import java.io.File @@ -219,7 +219,7 @@ class RecentProjectsAdapter( val oldName = project.name val builder = MaterialAlertDialogBuilder(context).setTitle(R.string.rename_project) - val binding = TextinputlayoutBinding.inflate(LayoutInflater.from(context)) + val binding = RenameProjectTextinputBinding.inflate(LayoutInflater.from(context)) binding.textinputEdittext.setText(project.name) binding.textinputLayout.hint = context.getString(R.string.msg_new_project_name) val padding = (16 * context.resources.displayMetrics.density).toInt() diff --git a/app/src/main/java/com/itsaky/androidide/fragments/MainFragment.kt b/app/src/main/java/com/itsaky/androidide/fragments/MainFragment.kt index 62134c9148..0e89e65f2e 100644 --- a/app/src/main/java/com/itsaky/androidide/fragments/MainFragment.kt +++ b/app/src/main/java/com/itsaky/androidide/fragments/MainFragment.kt @@ -19,7 +19,6 @@ import com.itsaky.androidide.idetooltips.TooltipTag.MAIN_GET_STARTED import com.itsaky.androidide.viewmodel.MainViewModel import org.adfa.constants.CONTENT_KEY import org.adfa.constants.CONTENT_TITLE_KEY -import org.appdevforall.codeonthego.layouteditor.managers.ProjectManager import org.koin.androidx.viewmodel.ext.android.activityViewModel class MainFragment : BaseFragment() { @@ -87,8 +86,7 @@ class MainFragment : BaseFragment() { handleGitUrlDrop( shouldAcceptDrop = { isVisible && - viewModel.currentScreen.value == MainViewModel.SCREEN_MAIN && - ProjectManager.instance.openedProject == null + viewModel.currentScreen.value == MainViewModel.SCREEN_MAIN }, onDropped = viewModel::requestCloneRepository ) diff --git a/app/src/main/java/com/itsaky/androidide/fragments/RecentProjectsFragment.kt b/app/src/main/java/com/itsaky/androidide/fragments/RecentProjectsFragment.kt index 4956190a51..129fa28462 100644 --- a/app/src/main/java/com/itsaky/androidide/fragments/RecentProjectsFragment.kt +++ b/app/src/main/java/com/itsaky/androidide/fragments/RecentProjectsFragment.kt @@ -44,7 +44,7 @@ import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.debounce import kotlinx.coroutines.joinAll import kotlinx.coroutines.launch -import org.appdevforall.codeonthego.layouteditor.ProjectFile +import com.itsaky.androidide.models.ProjectFile import com.itsaky.androidide.utils.flashSuccess import com.itsaky.androidide.utils.findValidProjects import com.itsaky.androidide.utils.isProjectCandidateDir diff --git a/app/src/main/java/com/itsaky/androidide/models/ProjectFile.kt b/app/src/main/java/com/itsaky/androidide/models/ProjectFile.kt new file mode 100644 index 0000000000..9805b40c98 --- /dev/null +++ b/app/src/main/java/com/itsaky/androidide/models/ProjectFile.kt @@ -0,0 +1,41 @@ +package com.itsaky.androidide.models + +import android.content.Context +import com.itsaky.androidide.resources.R +import com.itsaky.androidide.utils.formatDate +import java.io.File + +class ProjectFile( + path: String, + val createdAt: String?, + val lastModified: String?, +) { + + var path: String = path + private set + + var name: String = lastSegment(path) + private set + + fun rename(newPath: String) { + File(path).renameTo(File(newPath)) + path = newPath + name = lastSegment(newPath) + } + + fun renderDateText(context: Context): String { + val showModified = createdAt != lastModified + val renderDate = if (showModified) lastModified else createdAt + val label = + if (showModified) { + context.getString(R.string.date_modified_label) + } else { + context.getString(R.string.date_created_label) + } + return context.getString(R.string.date, label, formatDate(renderDate ?: "")) + } + + private companion object { + fun lastSegment(path: String): String = path.substring(path.lastIndexOf("/") + 1) + } +} diff --git a/app/src/main/java/com/itsaky/androidide/ui/ProjectInfoBottomSheet.kt b/app/src/main/java/com/itsaky/androidide/ui/ProjectInfoBottomSheet.kt index 6801923286..2040193810 100644 --- a/app/src/main/java/com/itsaky/androidide/ui/ProjectInfoBottomSheet.kt +++ b/app/src/main/java/com/itsaky/androidide/ui/ProjectInfoBottomSheet.kt @@ -15,7 +15,7 @@ import com.itsaky.androidide.utils.loadProjectDetails import com.itsaky.androidide.utils.viewLifecycleScope import com.termux.shared.interact.ShareUtils.copyTextToClipboard import kotlinx.coroutines.launch -import org.appdevforall.codeonthego.layouteditor.ProjectFile +import com.itsaky.androidide.models.ProjectFile class ProjectInfoBottomSheet : BottomSheetDialogFragment() { companion object { diff --git a/app/src/main/java/com/itsaky/androidide/utils/EditorActivityActions.kt b/app/src/main/java/com/itsaky/androidide/utils/EditorActivityActions.kt index 797c38027a..1cc51fee1d 100644 --- a/app/src/main/java/com/itsaky/androidide/utils/EditorActivityActions.kt +++ b/app/src/main/java/com/itsaky/androidide/utils/EditorActivityActions.kt @@ -39,7 +39,6 @@ import com.itsaky.androidide.actions.etc.FindAction import com.itsaky.androidide.actions.etc.FindInFileAction import com.itsaky.androidide.actions.etc.FindInProjectAction import com.itsaky.androidide.actions.etc.LaunchAppAction -import com.itsaky.androidide.actions.etc.PreviewLayoutAction import com.itsaky.androidide.actions.file.CloseAllFilesAction import com.itsaky.androidide.actions.file.CloseFileAction import com.itsaky.androidide.actions.file.CloseOtherFilesAction @@ -95,7 +94,6 @@ class EditorActivityActions { registry.registerAction(UndoAction(context, order++)) registry.registerAction(RedoAction(context, order++)) registry.registerAction(SaveFileAction(context, order++)) - registry.registerAction(PreviewLayoutAction(context, order++)) registry.registerAction(FindAction(context, order++)) registry.registerAction(FindInFileAction(context, order++)) registry.registerAction(FindInProjectAction(context, order++)) diff --git a/app/src/main/java/com/itsaky/androidide/viewmodel/RecentProjectsViewModel.kt b/app/src/main/java/com/itsaky/androidide/viewmodel/RecentProjectsViewModel.kt index d7631f77a2..4c545f01ca 100644 --- a/app/src/main/java/com/itsaky/androidide/viewmodel/RecentProjectsViewModel.kt +++ b/app/src/main/java/com/itsaky/androidide/viewmodel/RecentProjectsViewModel.kt @@ -14,7 +14,7 @@ import com.itsaky.androidide.roomData.recentproject.RecentProjectDao import com.itsaky.androidide.roomData.recentproject.RecentProjectRoomDatabase import com.itsaky.androidide.utils.getCreatedTime import com.itsaky.androidide.utils.getLastModifiedTime -import org.appdevforall.codeonthego.layouteditor.ProjectFile +import com.itsaky.androidide.models.ProjectFile import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job import kotlinx.coroutines.flow.MutableSharedFlow @@ -80,9 +80,7 @@ class RecentProjectsViewModel(application: Application) : AndroidViewModel(appli fun loadProjects(): Job { return viewModelScope.launch(Dispatchers.IO) { val projectsFromDb = recentProjectDao.dumpAll() ?: emptyList() - val context = getApplication().applicationContext - - allProjects = projectsFromDb.map { ProjectFile(it.location, it.createdAt, it.lastModified, context) } + allProjects = projectsFromDb.map { ProjectFile(it.location, it.createdAt, it.lastModified) } applyFilters() } } diff --git a/layouteditor/src/main/res/layout/textinputlayout.xml b/app/src/main/res/layout/rename_project_textinput.xml similarity index 65% rename from layouteditor/src/main/res/layout/textinputlayout.xml rename to app/src/main/res/layout/rename_project_textinput.xml index d31b1db9ab..1b5904d3e1 100644 --- a/layouteditor/src/main/res/layout/textinputlayout.xml +++ b/app/src/main/res/layout/rename_project_textinput.xml @@ -2,24 +2,22 @@ - + app:boxCornerRadiusBottomEnd="8dp" + app:boxCornerRadiusBottomStart="8dp" + app:boxCornerRadiusTopEnd="8dp" + app:boxCornerRadiusTopStart="8dp" + app:hintAnimationEnabled="true"> + - - - \ No newline at end of file + android:maxLines="1" + android:textSize="16sp" /> + diff --git a/layouteditor/.gitignore b/layouteditor/.gitignore deleted file mode 100644 index 9ea5a9cf85..0000000000 --- a/layouteditor/.gitignore +++ /dev/null @@ -1,88 +0,0 @@ -# Built application files -*.apk -*.aar -*.ap_ -*.aab - -# Files for the ART/Dalvik VM -*.dex - -# Java class files -*.class - -# Generated files -bin/ -gen/ -out/ -# Uncomment the following line in case you need and you don't have the release build type files in your app -# release/ - -# Gradle files -.gradle/ -build/ - -# Local configuration file (sdk path, etc) -local.properties - -# Proguard folder generated by Eclipse -proguard/ - -# Log Files -*.log - -# Android Studio Navigation editor temp files -.navigation/ - -# Android Studio captures folder -captures/ - -# IntelliJ -*.iml -.idea/workspace.xml -.idea/tasks.xml -.idea/gradle.xml -.idea/assetWizardSettings.xml -.idea/dictionaries -.idea/libraries -# Android Studio 3 in .gitignore file. -.idea/caches -.idea/modules.xml -# Comment next line if keeping position of elements in Navigation Editor is relevant for you -.idea/navEditor.xml - -# Keystore files -# Uncomment the following lines if you do not want to check your keystore files in. -#*.jks -#*.keystore - -# External native build folder generated in Android Studio 2.2 and later -.externalNativeBuild -.cxx/ - -# Google Services (e.g. APIs or Firebase) -# google-services.json - -# Freeline -freeline.py -freeline/ -freeline_project_description.json - -# fastlane -fastlane/report.xml -fastlane/Preview.html -fastlane/screenshots -fastlane/test_output -fastlane/readme.md - -# Version control -vcs.xml - -# lint -lint/intermediates/ -lint/generated/ -lint/outputs/ -lint/tmp/ -# lint/reports/ - - -.cg/ \ No newline at end of file diff --git a/layouteditor/build.gradle.kts b/layouteditor/build.gradle.kts deleted file mode 100644 index 10521e87f9..0000000000 --- a/layouteditor/build.gradle.kts +++ /dev/null @@ -1,49 +0,0 @@ -plugins { - id("com.android.library") - id("org.jetbrains.kotlin.android") -} - -android { - namespace = "org.appdevforall.codeonthego.layouteditor" - - buildFeatures { - viewBinding = true - buildConfig = true - } -} - -dependencies { - implementation(projects.vectormaster) - implementation(projects.common) - implementation(projects.commonUi) - implementation(projects.uidesigner) - implementation(projects.idetooltips) - - implementation (libs.androidx.lifecycle.viewmodel.ktx) - implementation (libs.androidx.activity.ktx) - implementation (libs.androidx.appcompat) - implementation (libs.androidx.constraintlayout) - implementation (libs.androidx.core.ktx) - implementation (libs.androidx.preference.ktx) - implementation (libs.androidx.recyclerview) - implementation (libs.androidx.viewpager2) - implementation (libs.androidx.palette.ktx) - implementation (libs.google.material) - implementation (libs.google.material) - implementation (libs.google.gson) - implementation (libs.common.glide) - - implementation(libs.zoomage) - implementation(libs.utilcodex) - implementation(libs.zoomage) - implementation(libs.utilcodex) - implementation(libs.colorpickerview) - implementation(platform(libs.sora.bom)) - implementation(libs.common.editor) - implementation(libs.sora.language.textmate) - - implementation(libs.commons.text) - implementation(libs.common.io) - implementation(projects.idetooltips) - -} diff --git a/layouteditor/src/main/AndroidManifest.xml b/layouteditor/src/main/AndroidManifest.xml deleted file mode 100644 index 6768018fea..0000000000 --- a/layouteditor/src/main/AndroidManifest.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/layouteditor/src/main/assets/attributes/attributes.json b/layouteditor/src/main/assets/attributes/attributes.json deleted file mode 100644 index f72c8db266..0000000000 --- a/layouteditor/src/main/assets/attributes/attributes.json +++ /dev/null @@ -1,738 +0,0 @@ -{ - "android.view.View": [ - { - "name": "android:id", - "methodName": "setId", - "className": "ViewCaller", - "attributeName": "android:id", - "argumentType": "id" - }, - { - "name": "android:layout_width", - "methodName": "setLayoutWidth", - "className": "ViewCaller", - "attributeName": "android:layout_width", - "argumentType": "size", - "canDelete": "false" - }, - { - "name": "android:layout_height", - "methodName": "setLayoutHeight", - "className": "ViewCaller", - "attributeName": "android:layout_height", - "argumentType": "size", - "canDelete": "false" - }, - { - "name": "android:alpha", - "methodName": "setAlpha", - "className": "ViewCaller", - "attributeName": "android:alpha", - "argumentType": "float" - }, - { - "name": "android:background", - "methodName": "setBackground", - "className": "ViewCaller", - "attributeName": "android:background", - "argumentType": "color|drawable" - }, - { - "name": "android:foreground", - "methodName": "setForeground", - "className": "ViewCaller", - "attributeName": "android:foreground", - "argumentType": "color|drawable" - }, - { - "name": "android:elevation", - "methodName": "setElevation", - "className": "ViewCaller", - "attributeName": "android:elevation", - "argumentType": "dimension", - "dimensionUnit": "dp" - }, - { - "name": "android:padding", - "methodName": "setPadding", - "className": "ViewCaller", - "attributeName": "android:padding", - "argumentType": "dimension", - "dimensionUnit": "dp" - }, - { - "name": "android:paddingLeft", - "methodName": "setPaddingLeft", - "className": "ViewCaller", - "attributeName": "android:paddingLeft", - "argumentType": "dimension", - "dimensionUnit": "dp" - }, - { - "name": "android:paddingRight", - "methodName": "setPaddingRight", - "className": "ViewCaller", - "attributeName": "android:paddingRight", - "argumentType": "dimension", - "dimensionUnit": "dp" - }, - { - "name": "android:paddingTop", - "methodName": "setPaddingTop", - "className": "ViewCaller", - "attributeName": "android:paddingTop", - "argumentType": "dimension", - "dimensionUnit": "dp" - }, - { - "name": "android:paddingBottom", - "methodName": "setPaddingBottom", - "className": "ViewCaller", - "attributeName": "android:paddingBottom", - "argumentType": "dimension", - "dimensionUnit": "dp" - }, - { - "name": "android:rotation", - "methodName": "setRotation", - "className": "ViewCaller", - "attributeName": "android:rotation", - "argumentType": "float" - }, - { - "name": "android:rotationX", - "methodName": "setRotationX", - "className": "ViewCaller", - "attributeName": "android:rotationX", - "argumentType": "float" - }, - { - "name": "android:rotationY", - "methodName": "setRotationY", - "className": "ViewCaller", - "attributeName": "android:rotationY", - "argumentType": "float" - }, - { - "name": "android:translationX", - "methodName": "setTranslationX", - "className": "ViewCaller", - "attributeName": "android:translationX", - "argumentType": "dimension", - "dimensionUnit": "dp" - }, - { - "name": "android:translationY", - "methodName": "setTranslationY", - "className": "ViewCaller", - "attributeName": "android:translationY", - "argumentType": "dimension", - "dimensionUnit": "dp" - }, - { - "name": "android:translationZ", - "methodName": "setTranslationZ", - "className": "ViewCaller", - "attributeName": "android:translationZ", - "argumentType": "dimension", - "dimensionUnit": "dp" - }, - { - "name": "android:scaleX", - "methodName": "setScaleX", - "className": "ViewCaller", - "attributeName": "android:scaleX", - "argumentType": "float" - }, - { - "name": "android:scaleY", - "methodName": "setScaleY", - "className": "ViewCaller", - "attributeName": "android:scaleY", - "argumentType": "float" - }, - { - "name": "android:enabled", - "methodName": "setEnabled", - "className": "ViewCaller", - "attributeName": "android:enabled", - "argumentType": "boolean" - }, - { - "name": "android:visibility", - "methodName": "setVisibility", - "className": "ViewCaller", - "attributeName": "android:visibility", - "argumentType": "enum", - "arguments": [ - "visible", - "invisible", - "gone" - ], - "defaultValue": "-1" - } - ], - "android.widget.LinearLayout": [ - { - "name": "android:gravity", - "methodName": "setGravity", - "className": "LinearLayoutCaller", - "attributeName": "android:gravity", - "argumentType": "flag", - "arguments": [ - "left", - "right", - "top", - "bottom", - "center", - "center_horizontal", - "center_vertical", - "fill", - "fill_horizontal", - "fill_vertical", - "clip_horizontal", - "clip_vertical", - "start", - "end" - ], - "defaultValue": "-1" - }, - { - "name": "android:orientation", - "methodName": "setOrientation", - "className": "LinearLayoutCaller", - "attributeName": "android:orientation", - "argumentType": "enum", - "arguments": [ - "horizontal", - "vertical" - ], - "defaultValue": "-1" - }, - { - "name": "android:weightSum", - "methodName": "setWeightSum", - "className": "layouts.LinearLayoutCaller", - "attributeName": "android:weightSum", - "argumentType": "float" - } - ], - "androidx.cardview.widget.CardView": [ - { - "name": "app:cardElevation", - "methodName": "setCardElevation", - "className": "CardViewCaller", - "attributeName": "app:cardElevation", - "argumentType": "dimension", - "dimensionUnit": "dp" - }, - { - "name": "app:cardCornerRadius", - "methodName": "setCardCornerRadius", - "className": "CardViewCaller", - "attributeName": "app:cardCornerRadius", - "argumentType": "dimension", - "dimensionUnit": "dp" - }, - { - "name": "app:cardBackgroundColor", - "methodName": "setCardBackgroundColor", - "className": "CardViewCaller", - "attributeName": "app:cardBackgroundColor", - "argumentType": "color" - }, - { - "name": "app:cardUseCompatPadding", - "methodName": "setCardUseCompatPadding", - "className": "CardViewCaller", - "attributeName": "app:cardUseCompatPadding", - "argumentType": "boolean", - "defaultValue": "false" - } - ], - "android.widget.TextView": [ - { - "name": "android:text", - "methodName": "setText", - "className": "text.TextViewCaller", - "attributeName": "android:text", - "argumentType": "text|string" - }, - { - "name": "android:textSize", - "methodName": "setTextSize", - "className": "text.TextViewCaller", - "attributeName": "android:textSize", - "argumentType": "dimension", - "dimensionUnit": "sp" - }, - { - "name": "android:textColor", - "methodName": "setTextColor", - "className": "text.TextViewCaller", - "attributeName": "android:textColor", - "argumentType": "color" - }, - { - "name": "android:textStyle", - "methodName": "setTextStyle", - "className": "text.TextViewCaller", - "attributeName": "android:textStyle", - "argumentType": "enum", - "arguments": [ - "normal", - "bold", - "italic", - "bold|italic" - ], - "defaultValue": "-1" - }, - { - "name": "android:gravity", - "methodName": "setGravity", - "className": "text.TextViewCaller", - "attributeName": "android:gravity", - "argumentType": "flag", - "arguments": [ - "left", - "right", - "top", - "bottom", - "center", - "center_horizontal", - "center_vertical", - "fill", - "fill_horizontal", - "fill_vertical", - "clip_horizontal", - "clip_vertical", - "start", - "end" - ], - "defaultValue": "-1" - } - ], - "android.widget.CheckedTextView": [ - { - "name": "android:checkMark", - "methodName": "setCheckMark", - "className": "text.TextViewCaller", - "attributeName": "android:checkMark", - "argumentType": "drawable" - }, - { - "name": "android:checked", - "methodName": "setChecked", - "className": "text.TextViewCaller", - "attributeName": "android:checked", - "argumentType": "boolean" - } - ], - "android.widget.AutoCompleteTextView": [ - { - "name": "android:completionHint", - "methodName": "setCompletionHint", - "className": "text.AutoCompleteTextViewCaller", - "attributeName": "android:completionHint", - "argumentType": "string|text" - }, - { - "name": "android:dropDownHeight", - "methodName": "setDropDownHeight", - "className": "text.AutoCompleteTextViewCaller", - "attributeName": "android:dropDownHeight", - "argumentType": "size" - }, - { - "name": "android:dropDownHorizontalOffset", - "methodName": "setDropDownHorizontalOffset", - "className": "text.AutoCompleteTextViewCaller", - "attributeName": "android:dropDownHorizontalOffset", - "argumentType": "float" - }, - { - "name": "android:dropDownVerticalOffset", - "methodName": "setDropDownVerticalOffset", - "className": "text.AutoCompleteTextViewCaller", - "attributeName": "android:dropDownVerticalOffset", - "argumentType": "float" - }, - { - "name": "android:dropDownWidth", - "methodName": "setDropDownWidth", - "className": "text.AutoCompleteTextViewCaller", - "attributeName": "android:dropDownWidth", - "argumentType": "size" - }, - { - "name": "android:popupBackground", - "methodName": "setDropDownBackgroundResource", - "className": "text.AutoCompleteTextViewCaller", - "attributeName": "android:popupBackground", - "argumentType": "color" - }, - { - "name": "android:completionThreshold", - "methodName": "setThreshold", - "className": "text.AutoCompleteTextViewCaller", - "attributeName": "android:completionThreshold", - "argumentType": "int" - } - ], - "android.widget.EditText": [ - { - "name": "android:hint", - "methodName": "setHint", - "className": "text.EditTextCaller", - "attributeName": "android:hint", - "argumentType": "text|string" - }, - { - "name": "android:inputType", - "methodName": "setInputType", - "className": "text.EditTextCaller", - "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.EditTextCaller", - "attributeName": "android:textColorHint", - "argumentType": "color" - }, - { - "name": "android:singleLine", - "methodName": "setSingleLine", - "className": "text.EditTextCaller", - "attributeName": "android:singleLine", - "argumentType": "boolean" - } - ], - "android.widget.ImageView": [ - { - "name": "android:src", - "methodName": "setImage", - "className": "ImageViewCaller", - "attributeName": "android:src", - "argumentType": "drawable" - }, - { - "name": "android:scaleType", - "methodName": "setScaleType", - "className": "ImageViewCaller", - "attributeName": "android:scaleType", - "argumentType": "enum", - "arguments": [ - "fitXY", - "fitStart", - "fitCenter", - "fitEnd", - "center", - "centerCrop", - "centerInside" - ], - "defaultValue": "-1" - }, - { - "name": "android:tint", - "methodName": "setTint", - "className": "ImageViewCaller", - "attributeName": "android:tint", - "argumentType": "color" - } - ], - "androidx.appcompat.widget.AppCompatImageView": [ - { - "name": "android:src", - "methodName": "setImage", - "className": "ImageViewCaller", - "attributeName": "android:src", - "argumentType": "drawable" - }, - { - "name": "app:srcCompat", - "methodName": "setImage", - "className": "ImageViewCaller", - "attributeName": "app:srcCompat", - "argumentType": "drawable" - }, - { - "name": "android:scaleType", - "methodName": "setScaleType", - "className": "ImageViewCaller", - "attributeName": "android:scaleType", - "argumentType": "enum", - "arguments": [ - "fitXY", - "fitStart", - "fitCenter", - "fitEnd", - "center", - "centerCrop", - "centerInside" - ], - "defaultValue": "-1" - }, - { - "name": "android:tint", - "methodName": "setTint", - "className": "ImageViewCaller", - "attributeName": "android:tint", - "argumentType": "color" - } - ], - "com.google.android.material.floatingactionbutton.FloatingActionButton": [ - { - "name": "app:background", - "methodName": "setBackgroundColor", - "className": "FABCaller", - "attributeName": "app:background", - "argumentType": "color" - }, - { - "name": "app:fabSize", - "methodName": "setSize", - "className": "FABCaller", - "attributeName": "app:fabSize", - "argumentType": "enum", - "arguments": [ - "auto", - "mini", - "normal" - ], - "defaultValue": "-1" - }, - { - "name": "app:fabCustomSize", - "methodName": "setCustomSize", - "className": "FABCaller", - "attributeName": "app:fabCustomSize", - "argumentType": "dimension", - "dimensionUnit": "dp" - }, - { - "name": "app:elevation", - "methodName": "setCompatElevation", - "className": "FABCaller", - "attributeName": "app:elevation", - "argumentType": "dimension", - "dimensionUnit": "dp" - } - ], - "android.widget.Switch": [ - { - "name": "android:checked", - "methodName": "setChecked", - "className": "SwitchCaller", - "attributeName": "android:checked", - "argumentType": "boolean" - } - ], - "androidx.appcompat.widget.SwitchCompat": [ - { - "name": "android:checked", - "methodName": "setChecked", - "className": "SwitchCaller", - "attributeName": "android:checked", - "argumentType": "boolean" - } - ], - "android.widget.ProgressBar": [ - { - "name": "android:progress", - "methodName": "setProgress", - "className": "ProgressBarCaller", - "attributeName": "android:progress", - "argumentType": "int" - }, - { - "name": "android:max", - "methodName": "setMax", - "className": "ProgressBarCaller", - "attributeName": "android:max", - "argumentType": "int" - }, - { - "name": "android:indeterminate", - "methodName": "setIndeterminate", - "className": "ProgressBarCaller", - "attributeName": "android:indeterminate", - "argumentType": "boolean" - } - ], - "android.widget.ScrollView": [ - { - "name": "android:fillViewport", - "methodName": "setFillViewport", - "className": "containers.ScrollViewCaller", - "attributeName": "android:fillViewport", - "argumentType": "boolean" - } - ], - "android.widget.FrameLayout": [ - { - "name": "android:foregroundGravity", - "methodName": "setForegroundGravity", - "className": "layouts.FrameLayoutCaller", - "attributeName": "android:foregroundGravity", - "argumentType": "flag", - "arguments": [ - "left", - "right", - "top", - "bottom", - "center", - "center_horizontal", - "center_vertical", - "fill", - "fill_horizontal", - "fill_vertical", - "clip_horizontal", - "clip_vertical", - "start", - "end" - ], - "defaultValue": "-1" - }, - { - "name": "android:measureAllChildren", - "methodName": "setMeasureAllChildren", - "className": "layouts.FrameLayoutCaller", - "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" - } - ] -} \ No newline at end of file diff --git a/layouteditor/src/main/assets/attributes/parent_attributes.json b/layouteditor/src/main/assets/attributes/parent_attributes.json deleted file mode 100644 index 5a7deb6799..0000000000 --- a/layouteditor/src/main/assets/attributes/parent_attributes.json +++ /dev/null @@ -1,532 +0,0 @@ -{ - "android.widget.LinearLayout": [ - { - "name": "android:layout_weight", - "methodName": "setLayoutWeight", - "className": "parentcallers.LinearLayoutCaller", - "attributeName": "android:layout_weight", - "argumentType": "float" - }, - { - "name": "android:layout_margin", - "methodName": "setLayoutMargin", - "className": "parentcallers.LinearLayoutCaller", - "attributeName": "android:layout_margin", - "argumentType": "dimension", - "dimensionUnit": "dp" - }, - { - "name": "android:layout_marginLeft", - "methodName": "setLayoutMarginLeft", - "className": "parentcallers.LinearLayoutCaller", - "attributeName": "android:layout_marginLeft", - "argumentType": "dimension", - "dimensionUnit": "dp" - }, - { - "name": "android:layout_marginRight", - "methodName": "setLayoutMarginRight", - "className": "parentcallers.LinearLayoutCaller", - "attributeName": "android:layout_marginRight", - "argumentType": "dimension", - "dimensionUnit": "dp" - }, - { - "name": "android:layout_marginTop", - "methodName": "setLayoutMarginTop", - "className": "parentcallers.LinearLayoutCaller", - "attributeName": "android:layout_marginTop", - "argumentType": "dimension", - "dimensionUnit": "dp" - }, - { - "name": "android:layout_marginBottom", - "methodName": "setLayoutMarginBottom", - "className": "parentcallers.LinearLayoutCaller", - "attributeName": "android:layout_marginBottom", - "argumentType": "dimension", - "dimensionUnit": "dp" - } - ], - "android.widget.FrameLayout": [ - { - "name": "android:layout_gravity", - "methodName": "setLayoutGravity", - "className": "parentcallers.FrameLayoutCaller", - "attributeName": "android:layout_gravity", - "argumentType": "flag", - "arguments": [ - "left", - "right", - "top", - "bottom", - "center", - "center_horizontal", - "center_vertical", - "fill", - "fill_horizontal", - "fill_vertical", - "clip_horizontal", - "clip_vertical", - "start", - "end" - ], - "defaultValue": "-1" - }, - { - "name": "android:layout_margin", - "methodName": "setLayoutMargin", - "className": "parentcallers.FrameLayoutCaller", - "attributeName": "android:layout_margin", - "argumentType": "dimension", - "dimensionUnit": "dp" - }, - { - "name": "android:layout_marginLeft", - "methodName": "setLayoutMarginLeft", - "className": "parentcallers.FrameLayoutCaller", - "attributeName": "android:layout_marginLeft", - "argumentType": "dimension", - "dimensionUnit": "dp" - }, - { - "name": "android:layout_marginRight", - "methodName": "setLayoutMarginRight", - "className": "parentcallers.FrameLayoutCaller", - "attributeName": "android:layout_marginRight", - "argumentType": "dimension", - "dimensionUnit": "dp" - }, - { - "name": "android:layout_marginTop", - "methodName": "setLayoutMarginTop", - "className": "parentcallers.FrameLayoutCaller", - "attributeName": "android:layout_marginTop", - "argumentType": "dimension", - "dimensionUnit": "dp" - }, - { - "name": "android:layout_marginBottom", - "methodName": "setLayoutMarginBottom", - "className": "parentcallers.FrameLayoutCaller", - "attributeName": "android:layout_marginBottom", - "argumentType": "dimension", - "dimensionUnit": "dp" - } - ], - "android.widget.RelativeLayout": [ - { - "name": "android:layout_centerHorizontal", - "methodName": "setLayoutCenterHorizontal", - "className": "parentcallers.RelativeLayoutCaller", - "attributeName": "android:layout_centerHorizontal", - "argumentType": "boolean", - "defaultValue": "false" - }, - { - "name": "android:layout_centerVertical", - "methodName": "setLayoutCenterVertical", - "className": "parentcallers.RelativeLayoutCaller", - "attributeName": "android:layout_centerVertical", - "argumentType": "boolean", - "defaultValue": "false" - }, - { - "name": "android:layout_centerInParent", - "methodName": "setLayoutCenterInParent", - "className": "parentcallers.RelativeLayoutCaller", - "attributeName": "android:layout_centerInParent", - "argumentType": "boolean", - "defaultValue": "false" - }, - { - "name": "android:layout_below", - "methodName": "setLayoutBelow", - "className": "parentcallers.RelativeLayoutCaller", - "attributeName": "android:layout_below", - "argumentType": "view", - "defaultValue": "-1" - }, - { - "name": "android:layout_above", - "methodName": "setLayoutAbove", - "className": "parentcallers.RelativeLayoutCaller", - "attributeName": "android:layout_above", - "argumentType": "view", - "defaultValue": "-1" - }, - { - "name": "android:layout_toLeftOf", - "methodName": "setLayoutToLeftOf", - "className": "parentcallers.RelativeLayoutCaller", - "attributeName": "android:layout_toLeftOf", - "argumentType": "view", - "defaultValue": "-1" - }, - { - "name": "android:layout_toRightOf", - "methodName": "setLayoutToRightOf", - "className": "parentcallers.RelativeLayoutCaller", - "attributeName": "android:layout_toRightOf", - "argumentType": "view", - "defaultValue": "-1" - }, - { - "name": "android:layout_alignLeft", - "methodName": "setLayoutAlignLeft", - "className": "parentcallers.RelativeLayoutCaller", - "attributeName": "android:layout_alignLeft", - "argumentType": "view", - "defaultValue": "-1" - }, - { - "name": "android:layout_alignRight", - "methodName": "setLayoutAlignRight", - "className": "parentcallers.RelativeLayoutCaller", - "attributeName": "android:layout_alignRight", - "argumentType": "view", - "defaultValue": "-1" - }, - { - "name": "android:layout_alignTop", - "methodName": "setLayoutAlignTop", - "className": "parentcallers.RelativeLayoutCaller", - "attributeName": "android:layout_alignTop", - "argumentType": "view", - "defaultValue": "-1" - }, - { - "name": "android:layout_alignBottom", - "methodName": "setLayoutAlignBottom", - "className": "parentcallers.RelativeLayoutCaller", - "attributeName": "android:layout_alignBottom", - "argumentType": "view", - "defaultValue": "-1" - }, - { - "name": "android:layout_alignParentLeft", - "methodName": "setLayoutAlignParentLeft", - "className": "parentcallers.RelativeLayoutCaller", - "attributeName": "android:layout_alignParentLeft", - "argumentType": "boolean", - "defaultValue": "false" - }, - { - "name": "android:layout_alignParentRight", - "methodName": "setLayoutAlignParentRight", - "className": "parentcallers.RelativeLayoutCaller", - "attributeName": "android:layout_alignParentRight", - "argumentType": "boolean", - "defaultValue": "false" - }, - { - "name": "android:layout_alignParentTop", - "methodName": "setLayoutAlignParentTop", - "className": "parentcallers.RelativeLayoutCaller", - "attributeName": "android:layout_alignParentTop", - "argumentType": "boolean", - "defaultValue": "false" - }, - { - "name": "android:layout_alignParentBottom", - "methodName": "setLayoutAlignParentBottom", - "className": "parentcallers.RelativeLayoutCaller", - "attributeName": "android:layout_alignParentBottom", - "argumentType": "boolean", - "defaultValue": "false" - }, - { - "name": "android:layout_alignBaseline", - "methodName": "setLayoutAlignBaseline", - "className": "parentcallers.RelativeLayoutCaller", - "attributeName": "android:layout_alignBaseline", - "argumentType": "view", - "defaultValue": "-1" - }, - { - "name": "android:layout_margin", - "methodName": "setLayoutMargin", - "className": "parentcallers.RelativeLayoutCaller", - "attributeName": "android:layout_margin", - "argumentType": "dimension", - "dimensionUnit": "dp" - }, - { - "name": "android:layout_marginLeft", - "methodName": "setLayoutMarginLeft", - "className": "parentcallers.RelativeLayoutCaller", - "attributeName": "android:layout_marginLeft", - "argumentType": "dimension", - "dimensionUnit": "dp" - }, - { - "name": "android:layout_marginRight", - "methodName": "setLayoutMarginRight", - "className": "parentcallers.RelativeLayoutCaller", - "attributeName": "android:layout_marginRight", - "argumentType": "dimension", - "dimensionUnit": "dp" - }, - { - "name": "android:layout_marginTop", - "methodName": "setLayoutMarginTop", - "className": "parentcallers.RelativeLayoutCaller", - "attributeName": "android:layout_marginTop", - "argumentType": "dimension", - "dimensionUnit": "dp" - }, - { - "name": "android:layout_marginBottom", - "methodName": "setLayoutMarginBottom", - "className": "parentcallers.RelativeLayoutCaller", - "attributeName": "android:layout_marginBottom", - "argumentType": "dimension", - "dimensionUnit": "dp" - } - ], - "androidx.constraintlayout.widget.ConstraintLayout": [ - { - "name": "app:layout_constraintLeft_toLeftOf", - "methodName": "setLeftToLeft", - "className": "layouts.ConstraintLayoutCaller", - "attributeName": "app:layout_constraintLeft_toLeftOf", - "argumentType": "view", - "constant": "parent", - "defaultValue": "-1" - }, - { - "name": "app:layout_constraintLeft_toRightOf", - "methodName": "setLeftToRight", - "className": "layouts.ConstraintLayoutCaller", - "attributeName": "app:layout_constraintLeft_toRightOf", - "argumentType": "view", - "constant": "parent", - "defaultValue": "-1" - }, - { - "name": "app:layout_constraintRight_toLeftOf", - "methodName": "setRightToLeft", - "className": "layouts.ConstraintLayoutCaller", - "attributeName": "app:layout_constraintRight_toLeftOf", - "argumentType": "view", - "constant": "parent", - "defaultValue": "-1" - }, - { - "name": "app:layout_constraintRight_toRightOf", - "methodName": "setRightToRight", - "className": "layouts.ConstraintLayoutCaller", - "attributeName": "app:layout_constraintRight_toRightOf", - "argumentType": "view", - "constant": "parent", - "defaultValue": "-1" - }, - { - "name": "app:layout_constraintTop_toTopOf", - "methodName": "setTopToTop", - "className": "layouts.ConstraintLayoutCaller", - "attributeName": "app:layout_constraintTop_toTopOf", - "argumentType": "view", - "constant": "parent", - "defaultValue": "-1" - }, - { - "name": "app:layout_constraintTop_toBottomOf", - "methodName": "setTopToBottom", - "className": "layouts.ConstraintLayoutCaller", - "attributeName": "app:layout_constraintTop_toBottomOf", - "argumentType": "view", - "constant": "parent", - "defaultValue": "-1" - }, - { - "name": "app:layout_constraintBottom_toTopOf", - "methodName": "setBottomToTop", - "className": "layouts.ConstraintLayoutCaller", - "attributeName": "app:layout_constraintBottom_toTopOf", - "argumentType": "view", - "constant": "parent", - "defaultValue": "-1" - }, - { - "name": "app:layout_constraintBottom_toBottomOf", - "methodName": "setBottomToBottom", - "className": "layouts.ConstraintLayoutCaller", - "attributeName": "app:layout_constraintBottom_toBottomOf", - "argumentType": "view", - "constant": "parent", - "defaultValue": "-1" - }, - { - "name": "app:layout_constraintBaseline_toBaselineOf", - "methodName": "setBaselineToBaseline", - "className": "layouts.ConstraintLayoutCaller", - "attributeName": "app:layout_constraintBaseline_toBaselineOf", - "argumentType": "view", - "constant": "parent", - "defaultValue": "-1" - }, - { - "name": "app:layout_constraintStart_toStartOf", - "methodName": "setStartToStart", - "className": "layouts.ConstraintLayoutCaller", - "attributeName": "app:layout_constraintStart_toStartOf", - "argumentType": "view", - "constant": "parent", - "defaultValue": "-1" - }, - { - "name": "app:layout_constraintStart_toEndOf", - "methodName": "setStartToEnd", - "className": "layouts.ConstraintLayoutCaller", - "attributeName": "app:layout_constraintStart_toEndOf", - "argumentType": "view", - "constant": "parent", - "defaultValue": "-1" - }, - { - "name": "app:layout_constraintEnd_toStartOf", - "methodName": "setEndToStart", - "className": "layouts.ConstraintLayoutCaller", - "attributeName": "app:layout_constraintEnd_toStartOf", - "argumentType": "view", - "constant": "parent", - "defaultValue": "-1" - }, - { - "name": "app:layout_constraintEnd_toEndOf", - "methodName": "setEndToEnd", - "className": "layouts.ConstraintLayoutCaller", - "attributeName": "app:layout_constraintEnd_toEndOf", - "argumentType": "view", - "constant": "parent", - "defaultValue": "-1" - }, - { - "name": "android:layout_marginLeft", - "methodName": "setLayoutMarginLeft", - "className": "layouts.ConstraintLayoutCaller", - "attributeName": "android:layout_marginLeft", - "argumentType": "dimension", - "dimensionUnit": "dp" - }, - { - "name": "android:layout_marginRight", - "methodName": "setLayoutMarginRight", - "className": "layouts.ConstraintLayoutCaller", - "attributeName": "android:layout_marginRight", - "argumentType": "dimension", - "dimensionUnit": "dp" - }, - { - "name": "android:layout_marginTop", - "methodName": "setLayoutMarginTop", - "className": "layouts.ConstraintLayoutCaller", - "attributeName": "android:layout_marginTop", - "argumentType": "dimension", - "dimensionUnit": "dp" - }, - { - "name": "android:layout_marginBottom", - "methodName": "setLayoutMarginBottom", - "className": "layouts.ConstraintLayoutCaller", - "attributeName": "android:layout_marginBottom", - "argumentType": "dimension", - "dimensionUnit": "dp" - }, - { - "name": "android:layout_marginStart", - "methodName": "setLayoutMarginStart", - "className": "layouts.ConstraintLayoutCaller", - "attributeName": "android:layout_marginStart", - "argumentType": "dimension", - "dimensionUnit": "dp" - }, - { - "name": "android:layout_marginEnd", - "methodName": "setLayoutMarginEnd", - "className": "layouts.ConstraintLayoutCaller", - "attributeName": "android:layout_marginEnd", - "argumentType": "dimension", - "dimensionUnit": "dp" - }, - { - "name": "app:layout_marginBaseline", - "methodName": "setLayoutMarginBaseline", - "className": "layouts.ConstraintLayoutCaller", - "attributeName": "app:layout_marginBaseline", - "argumentType": "dimension", - "dimensionUnit": "dp" - }, - { - "name": "app:layout_goneMarginLeft", - "methodName": "setLayoutGoneMarginLeft", - "className": "layouts.ConstraintLayoutCaller", - "attributeName": "app:layout_goneMarginLeft", - "argumentType": "dimension", - "dimensionUnit": "dp" - }, - { - "name": "app:layout_goneMarginRight", - "methodName": "setLayoutGoneMarginRight", - "className": "layouts.ConstraintLayoutCaller", - "attributeName": "app:layout_goneMarginRight", - "argumentType": "dimension", - "dimensionUnit": "dp" - }, - { - "name": "app:layout_goneMarginTop", - "methodName": "setLayoutGoneMarginTop", - "className": "layouts.ConstraintLayoutCaller", - "attributeName": "app:layout_goneMarginTop", - "argumentType": "dimension", - "dimensionUnit": "dp" - }, - { - "name": "app:layout_goneMarginBottom", - "methodName": "setLayoutGoneMarginBottom", - "className": "layouts.ConstraintLayoutCaller", - "attributeName": "app:layout_goneMarginBottom", - "argumentType": "dimension", - "dimensionUnit": "dp" - }, - { - "name": "app:layout_goneMarginStart", - "methodName": "setLayoutGoneMarginStart", - "className": "layouts.ConstraintLayoutCaller", - "attributeName": "app:layout_goneMarginStart", - "argumentType": "dimension", - "dimensionUnit": "dp" - }, - { - "name": "app:layout_goneMarginEnd", - "methodName": "setLayoutGoneMarginEnd", - "className": "layouts.ConstraintLayoutCaller", - "attributeName": "app:layout_goneMarginEnd", - "argumentType": "dimension", - "dimensionUnit": "dp" - }, - { - "name": "app:layout_goneMarginBaseline", - "methodName": "setLayoutGoneMarginBaseline", - "className": "layouts.ConstraintLayoutCaller", - "attributeName": "app:layout_goneMarginBaseline", - "argumentType": "dimension", - "dimensionUnit": "dp" - }, - { - "name": "app:layout_constraintHorizontal_bias", - "methodName": "setHorizontalBias", - "className": "layouts.ConstraintLayoutCaller", - "attributeName": "app:layout_constraintHorizontal_bias", - "argumentType": "float" - }, - { - "name": "app:layout_constraintVertical_bias", - "methodName": "setVerticalBias", - "className": "layouts.ConstraintLayoutCaller", - "attributeName": "app:layout_constraintVertical_bias", - "argumentType": "float" - } - ] -} \ No newline at end of file diff --git a/layouteditor/src/main/assets/colors.xml b/layouteditor/src/main/assets/colors.xml deleted file mode 100644 index fc802bd78a..0000000000 --- a/layouteditor/src/main/assets/colors.xml +++ /dev/null @@ -1,3 +0,0 @@ - - #4CAF50 - \ No newline at end of file diff --git a/layouteditor/src/main/assets/default_font.ttf b/layouteditor/src/main/assets/default_font.ttf deleted file mode 100644 index 973e658ea1..0000000000 Binary files a/layouteditor/src/main/assets/default_font.ttf and /dev/null differ diff --git a/layouteditor/src/main/assets/default_image.png b/layouteditor/src/main/assets/default_image.png deleted file mode 100644 index aa0f4681e4..0000000000 Binary files a/layouteditor/src/main/assets/default_image.png and /dev/null differ diff --git a/layouteditor/src/main/assets/editor/textmate/abyss.json b/layouteditor/src/main/assets/editor/textmate/abyss.json deleted file mode 100644 index 24ae2408ef..0000000000 --- a/layouteditor/src/main/assets/editor/textmate/abyss.json +++ /dev/null @@ -1,223 +0,0 @@ -{ - "name": "Abyss", - "settings": [{ - "settings": { - "background": "#000c18", - "caret": "#ddbb88", - "foreground": "#6688cc", - "invisibles": "#002040", - "lineHighlight": "#082050", - "selection": "#770811", - "guide": "#002952" - } - }, { - "scope": ["meta.embedded", "source.groovy.embedded"], - "settings": { - "foreground": "#6688cc" - } - }, { - "name": "Comment", - "scope": "comment", - "settings": { - "foreground": "#384887" - } - }, { - "name": "String", - "scope": "string", - "settings": { - "foreground": "#22aa44" - } - }, { - "name": "Number", - "scope": "constant.numeric", - "settings": { - "foreground": "#f280d0" - } - }, { - "name": "Built-in constant", - "scope": "constant.language", - "settings": { - "foreground": "#f280d0" - } - }, { - "name": "User-defined constant", - "scope": ["constant.character", "constant.other"], - "settings": { - "foreground": "#f280d0" - } - }, { - "name": "Variable", - "scope": "variable", - "settings": { - "fontStyle": "" - } - }, { - "name": "Keyword", - "scope": "keyword", - "settings": { - "foreground": "#225588" - } - }, { - "name": "Storage", - "scope": "storage", - "settings": { - "fontStyle": "", - "foreground": "#225588" - } - }, { - "name": "Storage type", - "scope": "storage.type", - "settings": { - "fontStyle": "italic", - "foreground": "#9966b8" - } - }, { - "name": "Class name", - "scope": ["entity.name.class", "entity.name.type", "entity.name.namespace", "entity.name.scope-resolution"], - "settings": { - "fontStyle": "underline", - "foreground": "#ffeebb" - } - }, { - "name": "Inherited class", - "scope": "entity.other.inherited-class", - "settings": { - "fontStyle": "italic underline", - "foreground": "#ddbb88" - } - }, { - "name": "Function name", - "scope": "entity.name.function", - "settings": { - "fontStyle": "", - "foreground": "#ddbb88" - } - }, { - "name": "Function argument", - "scope": "variable.parameter", - "settings": { - "fontStyle": "italic", - "foreground": "#2277ff" - } - }, { - "name": "Tag name", - "scope": "entity.name.tag", - "settings": { - "fontStyle": "", - "foreground": "#225588" - } - }, { - "name": "Tag attribute", - "scope": "entity.other.attribute-name", - "settings": { - "fontStyle": "", - "foreground": "#ddbb88" - } - }, { - "name": "Library function", - "scope": "support.function", - "settings": { - "fontStyle": "", - "foreground": "#9966b8" - } - }, { - "name": "Library constant", - "scope": "support.constant", - "settings": { - "fontStyle": "", - "foreground": "#9966b8" - } - }, { - "name": "Library class/type", - "scope": ["support.type", "support.class"], - "settings": { - "fontStyle": "italic", - "foreground": "#9966b8" - } - }, { - "name": "Library variable", - "scope": "support.other.variable", - "settings": { - "fontStyle": "" - } - }, { - "name": "Invalid", - "scope": "invalid", - "settings": { - "fontStyle": "", - "foreground": "#A22D44" - } - }, { - "name": "Invalid deprecated", - "scope": "invalid.deprecated", - "settings": { - "foreground": "#A22D44" - } - }, { - "name": "diff: header", - "scope": ["meta.diff", "meta.diff.header"], - "settings": { - "fontStyle": "italic", - "foreground": "#E0EDDD" - } - }, { - "name": "diff: deleted", - "scope": "markup.deleted", - "settings": { - "fontStyle": "", - "foreground": "#dc322f" - } - }, { - "name": "diff: changed", - "scope": "markup.changed", - "settings": { - "fontStyle": "", - "foreground": "#cb4b16" - } - }, { - "name": "diff: inserted", - "scope": "markup.inserted", - "settings": { - "foreground": "#219186" - } - }, { - "name": "Markup Quote", - "scope": "markup.quote", - "settings": { - "foreground": "#22aa44" - } - }, { - "name": "Markup Styling", - "scope": ["markup.bold", "markup.italic"], - "settings": { - "foreground": "#22aa44" - } - }, { - "name": "Markup: Strong", - "scope": "markup.bold", - "settings": { - "fontStyle": "bold" - } - }, { - "name": "Markup: Emphasis", - "scope": "markup.italic", - "settings": { - "fontStyle": "italic" - } - }, { - "name": "Markup Inline", - "scope": "markup.inline.raw", - "settings": { - "fontStyle": "", - "foreground": "#9966b8" - } - }, { - "name": "Markup Headings", - "scope": ["markup.heading", "markup.heading.setext"], - "settings": { - "fontStyle": "bold", - "foreground": "#6688cc" - } - }] - -} \ No newline at end of file diff --git a/layouteditor/src/main/assets/editor/textmate/darcula.json b/layouteditor/src/main/assets/editor/textmate/darcula.json deleted file mode 100644 index 7c07f8d1dc..0000000000 --- a/layouteditor/src/main/assets/editor/textmate/darcula.json +++ /dev/null @@ -1,465 +0,0 @@ -{ - "name": "darcula", - "settings": [{ - "settings": { - "background": "#242424", - "foreground": "#cccccc", - "lineHighlight": "#2B2B2B", - "selection": "#214283", - "highlightedDelimetersForeground": "#57f6c0" - } - }, - { - "name": "Comment", - "scope": "comment", - "settings": { - "foreground": "#707070" - } - }, - { - "name": "Operator Keywords", - "scope": "keyword.operator,keyword.operator.logical,keyword.operator.relational,keyword.operator.assignment,keyword.operator.comparison,keyword.operator.ternary,keyword.operator.arithmetic,keyword.operator.spread", - "settings": { - "foreground": "#CCCCCC" - } - }, - { - "name": "Strings", - "scope": "string,string.character.escape,string.template.quoted,string.template.quoted.punctuation,string.template.quoted.punctuation.single,string.template.quoted.punctuation.double,string.type.declaration.annotation,string.template.quoted.punctuation.tag", - "settings": { - "foreground": "#6A8759" - } - }, - { - "name": "String Interpolation Begin and End", - "scope": "punctuation.definition.template-expression.begin,punctuation.definition.template-expression.end", - "settings": { - "foreground": "#CC8242" - } - }, - { - "name": "String Interpolation Body", - "scope": "expression.string,meta.template.expression", - "settings": { - "foreground": "#CCCCCC" - } - }, - { - "name": "Number", - "scope": "constant.numeric", - "settings": { - "foreground": "#7A9EC2" - } - }, - { - "name": "Built-in constant", - "scope": "constant.language,variable.language", - "settings": { - "foreground": "#CC8242" - } - }, - { - "name": "User-defined constant", - "scope": "constant.character, constant.other", - "settings": { - "foreground": "#9E7BB0" - } - }, - { - "name": "Keyword", - "scope": "keyword,keyword.operator.new,keyword.operator.delete,keyword.operator.static,keyword.operator.this,keyword.operator.expression", - "settings": { - "foreground": "#CC8242" - } - }, - { - "name": "Types, Class Types", - "scope": "entity.name.type,meta.return.type,meta.type.annotation,meta.type.parameters,support.type.primitive", - "settings": { - "foreground": "#7A9EC2" - } - }, - { - "name": "Storage type", - "scope": "storage,storage.type,storage.modifier,storage.arrow", - "settings": { - "foreground": "#CC8242" - } - }, - { - "name": "Class constructor", - "scope": "class.instance.constructor,new.expr entity.name.type", - "settings": { - "foreground": "#FFC66D" - } - }, - { - "name": "Function", - "scope": "support.function, entity.name.function", - "settings": { - "foreground": "#FFC66D" - } - }, - { - "name": "Function Types", - "scope": "annotation.meta.ts, annotation.meta.tsx", - "settings": { - "foreground": "#CCCCCC" - } - }, - { - "name": "Function Argument", - "scope": "variable.parameter, operator.rest.parameters", - "settings": { - "foreground": "#CCCCCC" - } - }, - { - "name": "Variable, Property", - "scope": "variable.property,variable.other.property,variable.other.object.property,variable.object.property,support.variable.property", - "settings": { - "foreground": "#9E7BB0" - } - }, - { - "name": "Module Name", - "scope": "quote.module", - "settings": { - "foreground": "#6A8759" - } - }, - { - "name": "Markup Headings", - "scope": "markup.heading", - "settings": { - "foreground": "#CC8242" - } - }, - { - "name": "Tag name", - "scope": "punctuation.definition.tag.html, punctuation.definition.tag.begin, punctuation.definition.tag.end, entity.name.tag", - "settings": { - "foreground": "#FFC66D" - } - }, - { - "name": "Tag attribute", - "scope": "entity.other.attribute-name", - "settings": { - "foreground": "#CCCCCC" - } - }, - { - "name": "Object Keys", - "scope": "meta.object-literal.key", - "settings": { - "foreground": "#9E7BB0" - } - }, - { - "name": "TypeScript Class Modifiers", - "scope": "storage.modifier.ts", - "settings": { - "foreground": "#CC8242" - } - }, - { - "name": "TypeScript Type Casting", - "scope": "ts.cast.expr,ts.meta.entity.class.method.new.expr.cast,ts.meta.entity.type.name.new.expr.cast,ts.meta.entity.type.name.var-single-variable.annotation,tsx.cast.expr,tsx.meta.entity.class.method.new.expr.cast,tsx.meta.entity.type.name.new.expr.cast,tsx.meta.entity.type.name.var-single-variable.annotation", - "settings": { - "foreground": "#7A9EC2" - } - }, - { - "name": "TypeScript Type Declaration", - "scope": "ts.meta.type.support,ts.meta.type.entity.name,ts.meta.class.inherited-class,tsx.meta.type.support,tsx.meta.type.entity.name,tsx.meta.class.inherited-class,type-declaration,enum-declaration", - "settings": { - "foreground": "#7A9EC2" - } - }, - { - "name": "TypeScript Method Declaration", - "scope": "function-declaration,method-declaration,method-overload-declaration,type-fn-type-parameters", - "settings": { - "foreground": "#FFC66D" - } - }, - { - "name": "Documentation Block", - "scope": "comment.block.documentation", - "settings": { - "foreground": "#6A8759" - } - }, - { - "name": "Documentation Highlight (JSDoc)", - "scope": "storage.type.class.jsdoc", - "settings": { - "foreground": "#CC8242" - } - }, - { - "name": "Import-Export-All (*) Keyword", - "scope": "constant.language.import-export-all", - "settings": { - "foreground": "#CCCCCC" - } - }, - { - "name": "Object Key Seperator", - "scope": "objectliteral.key.separator, punctuation.separator.key-value", - "settings": { - "foreground": "#CCCCCC" - } - }, - { - "name": "Regex", - "scope": "regex", - "settings": { - "fontStyle": " italic" - } - }, - { - "name": "Typescript Namespace", - "scope": "ts.meta.entity.name.namespace,tsx.meta.entity.name.namespace", - "settings": { - "foreground": "#CCCCCC" - } - }, - { - "name": "Regex Character-class", - "scope": "regex.character-class", - "settings": { - "foreground": "#CCCCCC" - } - }, - { - "name": "Class Name", - "scope": "entity.name.type.class", - "settings": { - "foreground": "#CCCCCC" - } - }, - { - "name": "Class Inheritances", - "scope": "entity.other.inherited-class", - "settings": { - "foreground": "#7A9EC2" - } - }, - { - "name": "Documentation Entity", - "scope": "entity.name.type.instance.jsdoc", - "settings": { - "foreground": "#FFC66D" - } - }, - { - "name": "YAML entity", - "scope": "yaml.entity.name,yaml.string.entity.name", - "settings": { - "foreground": "#CC8242" - } - }, - { - "name": "YAML string value", - "scope": "yaml.string.out", - "settings": { - "foreground": "#CCCCCC" - } - }, - { - "name": "Ignored (Exceptions Rules)", - "scope": "meta.brace.square.ts,block.support.module,block.support.type.module,block.support.function.variable,punctuation.definition.typeparameters.begin,punctuation.definition.typeparameters.end", - "settings": { - "foreground": "#CCCCCC" - } - }, - { - "name": "Regex", - "scope": "string.regexp", - "settings": { - "foreground": "#CC8242" - } - }, - { - "name": "Regex Group/Set", - "scope": "punctuation.definition.group.regexp,punctuation.definition.character-class.regexp", - "settings": { - "foreground": "#FFC66D" - } - }, - { - "name": "Regex Character Class", - "scope": "constant.other.character-class.regexp, constant.character.escape.ts", - "settings": { - "foreground": "#CCCCCC" - } - }, - { - "name": "Regex Or Operator", - "scope": "expr.regex.or.operator", - "settings": { - "foreground": "#CCCCCC" - } - }, - { - "name": "Tag string", - "scope": "string.template.tag,string.template.punctuation.tag,string.quoted.punctuation.tag,string.quoted.embedded.tag, string.quoted.double.tag", - "settings": { - "foreground": "#6A8759" - } - }, - { - "name": "Tag function parenthesis", - "scope": "tag.punctuation.begin.arrow.parameters.embedded,tag.punctuation.end.arrow.parameters.embedded", - "settings": { - "foreground": "#CCCCCC" - } - }, - { - "name": "Object-literal key class", - "scope": "object-literal.object.member.key.field.other,object-literal.object.member.key.accessor,object-literal.object.member.key.array.brace.square", - "settings": { - "foreground": "#CCCCCC" - } - }, - { - "name": "CSS Property-value", - "scope": "property-list.property-value,property-list.constant", - "settings": { - "foreground": "#A5C261" - } - }, - { - "name": "CSS Property variable", - "scope": "support.type.property-name.variable.css,support.type.property-name.variable.scss,variable.scss", - "settings": { - "foreground": "#7A9EC2" - } - }, - { - "name": "CSS Property entity", - "scope": "entity.other.attribute-name.class.css,entity.other.attribute-name.class.scss,entity.other.attribute-name.parent-selector-suffix.css,entity.other.attribute-name.parent-selector-suffix.scss", - "settings": { - "foreground": "#FFC66D" - } - }, - { - "name": "CSS Property-value", - "scope": "property-list.property-value.rgb-value, keyword.other.unit.css,keyword.other.unit.scss", - "settings": { - "foreground": "#7A9EC2" - } - }, - { - "name": "CSS Property-value function", - "scope": "property-list.property-value.function", - "settings": { - "foreground": "#FFC66D" - } - }, - { - "name": "CSS constant variables", - "scope": "support.constant.property-value.css,support.constant.property-value.scss", - "settings": { - "foreground": "#A5C261" - } - }, - { - "name": "CSS Tag", - "scope": "css.entity.name.tag,scss.entity.name.tag", - "settings": { - "foreground": "#CC8242" - } - }, - { - "name": "CSS ID, Selector", - "scope": "meta.selector.css, entity.attribute-name.id, entity.other.attribute-name.pseudo-class.css,entity.other.attribute-name.pseudo-element.css", - "settings": { - "foreground": "#FFC66D" - } - }, - { - "name": "CSS Keyword", - "scope": "keyword.scss,keyword.css", - "settings": { - "foreground": "#CC8242" - } - }, - { - "name": "Triple-slash Directive Tag", - "scope": "triple-slash.tag", - "settings": { - "foreground": "#CCCCCC", - "fontStyle": "italic" - } - }, - { - "scope": "token.info-token", - "settings": { - "foreground": "#6796e6" - } - }, - { - "scope": "token.warn-token", - "settings": { - "foreground": "#cd9731" - } - }, - { - "scope": "token.error-token", - "settings": { - "foreground": "#f44747" - } - }, - { - "scope": "token.debug-token", - "settings": { - "foreground": "#b267e6" - } - }, - { - "name": "Python operators", - "scope": "keyword.operator.logical.python", - "settings": { - "foreground": "#CC8242" - } - }, - { - "name": "Dart class type", - "scope": "support.class.dart", - "settings": { - "foreground": "#CC8242" - } - }, - { - "name": "PHP variables", - "scope": ["variable.language.php", "variable.other.php"], - "settings": { - "foreground": "#9E7BB0" - } - }, - { - "name": "Perl specific", - "scope": ["variable.other.readwrite.perl"], - "settings": { - "foreground": "#9E7BB0" - } - }, - { - "name": "PHP variables", - "scope": ["variable.other.property.php"], - "settings": { - "foreground": "#CC8242" - } - }, - { - "name": "PHP variables", - "scope": ["support.variable.property.php"], - "settings": { - "foreground": "#FFC66D" - } - } - ] -} diff --git a/layouteditor/src/main/assets/editor/textmate/default.json b/layouteditor/src/main/assets/editor/textmate/default.json deleted file mode 100644 index 73eb60e266..0000000000 --- a/layouteditor/src/main/assets/editor/textmate/default.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "name": "Tomorrow-Night-XML", - "author": "Vivek", - "version": "1.0", - "settings": [ - { - "name": "Tag", - "scope": "entity.name.tag", - "settings": { - "fontStyle": "bold", - "foreground": "#F92672" - } - }, - { - "name": "Attribute names", - "scope": "entity.other.attribute-name", - "settings": { - "foreground": "#A6E22E" - } - }, - { - "name": "Attribute values", - "scope": "string.quoted", - "settings": { - "fontStyle": "italic", - "foreground": "#E6DB74" - } - }, - { - "name": "Comments", - "scope": "comment.block", - "settings": { - "fontStyle": "italic", - "foreground": "#75715E" - } - }, - { - "name": "CDATA", - "scope": "string.unquoted.cdata.xml", - "settings": { - "foreground": "#66D9EF" - } - }, - { - "name": "Namespace Tag", - "scope": "entity.name.namespace.xml", - "settings": { - "fontStyle": "bold", - "foreground": "#AE81FF" - } - }, - { - "name": "Default Text", - "scope": "text.xml", - "settings": { - "foreground": "#F8F8F2" - } - } - ] -} \ No newline at end of file diff --git a/layouteditor/src/main/assets/editor/textmate/languages.json b/layouteditor/src/main/assets/editor/textmate/languages.json deleted file mode 100644 index 50770b0f07..0000000000 --- a/layouteditor/src/main/assets/editor/textmate/languages.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "languages": [ - { - "grammar": "editor/textmate/xml/syntaxes/xml.tmLanguage.json", - "name": "xml", - "scopeName": "text.xml", - "languageConfiguration": "editor/textmate/xml/language-configuration.json" - } - ] -} \ No newline at end of file diff --git a/layouteditor/src/main/assets/editor/textmate/quietlight.json b/layouteditor/src/main/assets/editor/textmate/quietlight.json deleted file mode 100644 index 9b8bec1802..0000000000 --- a/layouteditor/src/main/assets/editor/textmate/quietlight.json +++ /dev/null @@ -1,542 +0,0 @@ -{ - "name": "Quiet Light", - "tokenColors": [ - { - "settings": { - "foreground": "#333333" - } - }, - { - "scope": [ - "meta.embedded", - "source.groovy.embedded" - ], - "settings": { - "foreground": "#333333" - } - }, - { - "name": "Comments", - "scope": [ - "comment", - "punctuation.definition.comment" - ], - "settings": { - "fontStyle": "italic", - "foreground": "#AAAAAA" - } - }, - { - "name": "Comments: Preprocessor", - "scope": "comment.block.preprocessor", - "settings": { - "fontStyle": "", - "foreground": "#AAAAAA" - } - }, - { - "name": "Comments: Documentation", - "scope": [ - "comment.documentation", - "comment.block.documentation", - "comment.block.documentation punctuation.definition.comment " - ], - "settings": { - "foreground": "#448C27" - } - }, - { - "name": "Invalid", - "scope": "invalid", - "settings": { - "foreground": "#cd3131" - } - }, - { - "name": "Invalid - Illegal", - "scope": "invalid.illegal", - "settings": { - "foreground": "#660000" - } - }, - { - "name": "Operators", - "scope": "keyword.operator", - "settings": { - "foreground": "#777777" - } - }, - { - "name": "Keywords", - "scope": [ - "keyword", - "storage" - ], - "settings": { - "foreground": "#4B69C6" - } - }, - { - "name": "Types", - "scope": [ - "storage.type", - "support.type" - ], - "settings": { - "foreground": "#7A3E9D" - } - }, - { - "name": "Language Constants", - "scope": [ - "constant.language", - "support.constant", - "variable.language" - ], - "settings": { - "foreground": "#9C5D27" - } - }, - { - "name": "Variables", - "scope": [ - "variable", - "support.variable" - ], - "settings": { - "foreground": "#7A3E9D" - } - }, - { - "name": "Functions", - "scope": [ - "entity.name.function", - "support.function" - ], - "settings": { - "fontStyle": "bold", - "foreground": "#AA3731" - } - }, - { - "name": "Classes", - "scope": [ - "entity.name.type", - "entity.name.namespace", - "entity.name.scope-resolution", - "entity.other.inherited-class", - "support.class" - ], - "settings": { - "fontStyle": "bold", - "foreground": "#7A3E9D" - } - }, - { - "name": "Exceptions", - "scope": "entity.name.exception", - "settings": { - "foreground": "#660000" - } - }, - { - "name": "Sections", - "scope": "entity.name.section", - "settings": { - "fontStyle": "bold" - } - }, - { - "name": "Numbers, Characters", - "scope": [ - "constant.numeric", - "constant.character", - "constant" - ], - "settings": { - "foreground": "#9C5D27" - } - }, - { - "name": "Strings", - "scope": "string", - "settings": { - "foreground": "#448C27" - } - }, - { - "name": "Strings: Escape Sequences", - "scope": "constant.character.escape", - "settings": { - "foreground": "#777777" - } - }, - { - "name": "Strings: Regular Expressions", - "scope": "string.regexp", - "settings": { - "foreground": "#4B69C6" - } - }, - { - "name": "Strings: Symbols", - "scope": "constant.other.symbol", - "settings": { - "foreground": "#9C5D27" - } - }, - { - "name": "Punctuation", - "scope": "punctuation", - "settings": { - "foreground": "#777777" - } - }, - { - "name": "HTML: Doctype Declaration", - "scope": [ - "meta.tag.sgml.doctype", - "meta.tag.sgml.doctype string", - "meta.tag.sgml.doctype entity.name.tag", - "meta.tag.sgml punctuation.definition.tag.html" - ], - "settings": { - "foreground": "#AAAAAA" - } - }, - { - "name": "HTML: Tags", - "scope": [ - "meta.tag", - "punctuation.definition.tag.html", - "punctuation.definition.tag.begin.html", - "punctuation.definition.tag.end.html" - ], - "settings": { - "foreground": "#91B3E0" - } - }, - { - "name": "HTML: Tag Names", - "scope": "entity.name.tag", - "settings": { - "foreground": "#4B69C6" - } - }, - { - "name": "HTML: Attribute Names", - "scope": [ - "meta.tag entity.other.attribute-name", - "entity.other.attribute-name.html" - ], - "settings": { - "fontStyle": "italic", - "foreground": "#8190A0" - } - }, - { - "name": "HTML: Entities", - "scope": [ - "constant.character.entity", - "punctuation.definition.entity" - ], - "settings": { - "foreground": "#9C5D27" - } - }, - { - "name": "CSS: Selectors", - "scope": [ - "meta.selector", - "meta.selector entity", - "meta.selector entity punctuation", - "entity.name.tag.css" - ], - "settings": { - "foreground": "#7A3E9D" - } - }, - { - "name": "CSS: Property Names", - "scope": [ - "meta.property-name", - "support.type.property-name" - ], - "settings": { - "foreground": "#9C5D27" - } - }, - { - "name": "CSS: Property Values", - "scope": [ - "meta.property-value", - "meta.property-value constant.other", - "support.constant.property-value" - ], - "settings": { - "foreground": "#448C27" - } - }, - { - "name": "CSS: Important Keyword", - "scope": "keyword.other.important", - "settings": { - "fontStyle": "bold" - } - }, - { - "name": "Markup: Changed", - "scope": "markup.changed", - "settings": { - "foreground": "#000000" - } - }, - { - "name": "Markup: Deletion", - "scope": "markup.deleted", - "settings": { - "foreground": "#000000" - } - }, - { - "name": "Markup: Emphasis", - "scope": "markup.italic", - "settings": { - "fontStyle": "italic" - } - }, - { - "scope": "markup.strikethrough", - "settings": { - "fontStyle": "strikethrough" - } - }, - { - "name": "Markup: Error", - "scope": "markup.error", - "settings": { - "foreground": "#660000" - } - }, - { - "name": "Markup: Insertion", - "scope": "markup.inserted", - "settings": { - "foreground": "#000000" - } - }, - { - "name": "Markup: Link", - "scope": "meta.link", - "settings": { - "foreground": "#4B69C6" - } - }, - { - "name": "Markup: Output", - "scope": [ - "markup.output", - "markup.raw" - ], - "settings": { - "foreground": "#777777" - } - }, - { - "name": "Markup: Prompt", - "scope": "markup.prompt", - "settings": { - "foreground": "#777777" - } - }, - { - "name": "Markup: Heading", - "scope": "markup.heading", - "settings": { - "foreground": "#AA3731" - } - }, - { - "name": "Markup: Strong", - "scope": "markup.bold", - "settings": { - "fontStyle": "bold" - } - }, - { - "name": "Markup: Traceback", - "scope": "markup.traceback", - "settings": { - "foreground": "#660000" - } - }, - { - "name": "Markup: Underline", - "scope": "markup.underline", - "settings": { - "fontStyle": "underline" - } - }, - { - "name": "Markup Quote", - "scope": "markup.quote", - "settings": { - "foreground": "#7A3E9D" - } - }, - { - "name": "Markup Lists", - "scope": "markup.list", - "settings": { - "foreground": "#4B69C6" - } - }, - { - "name": "Markup Styling", - "scope": [ - "markup.bold", - "markup.italic" - ], - "settings": { - "foreground": "#448C27" - } - }, - { - "name": "Markup Inline", - "scope": "markup.inline.raw", - "settings": { - "fontStyle": "", - "foreground": "#9C5D27" - } - }, - { - "name": "Extra: Diff Range", - "scope": [ - "meta.diff.range", - "meta.diff.index", - "meta.separator" - ], - "settings": { - "foreground": "#434343" - } - }, - { - "name": "Extra: Diff From", - "scope": [ - "meta.diff.header.from-file", - "punctuation.definition.from-file.diff" - ], - "settings": { - "foreground": "#4B69C6" - } - }, - { - "name": "Extra: Diff To", - "scope": [ - "meta.diff.header.to-file", - "punctuation.definition.to-file.diff" - ], - "settings": { - "foreground": "#4B69C6" - } - }, - { - "name": "diff: deleted", - "scope": "markup.deleted.diff", - "settings": { - "foreground": "#C73D20" - } - }, - { - "name": "diff: changed", - "scope": "markup.changed.diff", - "settings": { - "foreground": "#9C5D27" - } - }, - { - "name": "diff: inserted", - "scope": "markup.inserted.diff", - "settings": { - "foreground": "#448C27" - } - }, - { - "name": "JSX: Tags", - "scope": [ - "punctuation.definition.tag.js", - "punctuation.definition.tag.begin.js", - "punctuation.definition.tag.end.js" - ], - "settings": { - "foreground": "#91B3E0" - } - }, - { - "name": "JSX: InnerText", - "scope": "meta.jsx.children.js", - "settings": { - "foreground": "#333333ff" - } - } - ], - "colors": { - "focusBorder": "#A6B39B", - "pickerGroup.foreground": "#A6B39B", - "pickerGroup.border": "#749351", - "list.activeSelectionForeground": "#6c6c6c", - "quickInputList.focusBackground": "#CADEB9", - "list.hoverBackground": "#e0e0e0", - "list.activeSelectionBackground": "#c4d9b1", - "list.inactiveSelectionBackground": "#d3dbcd", - "list.highlightForeground": "#9769dc", - "selection.background": "#C9D0D9", - "editor.background": "#F5F5F5", - "editorWhitespace.foreground": "#AAAAAA", - "editor.lineHighlightBackground": "#E4F6D4", - "editorLineNumber.activeForeground": "#9769dc", - "editor.selectionBackground": "#C9D0D9", - "minimap.selectionHighlight": "#C9D0D9", - "panel.background": "#F5F5F5", - "sideBar.background": "#F2F2F2", - "sideBarSectionHeader.background": "#ede8ef", - "editorLineNumber.foreground": "#6D705B", - "editorCursor.foreground": "#54494B", - "inputOption.activeBorder": "#adafb7", - "dropdown.background": "#F5F5F5", - "editor.findMatchBackground": "#BF9CAC", - "editor.findMatchHighlightBackground": "#edc9d8", - "peekViewEditor.matchHighlightBackground": "#C2DFE3", - "peekViewTitle.background": "#F2F8FC", - "peekViewEditor.background": "#F2F8FC", - "peekViewResult.background": "#F2F8FC", - "peekView.border": "#705697", - "peekViewResult.matchHighlightBackground": "#93C6D6", - "tab.lastPinnedBorder": "#c9d0d9", - "statusBar.background": "#705697", - "welcomePage.tileBackground": "#f0f0f7", - "statusBar.noFolderBackground": "#705697", - "statusBar.debuggingBackground": "#705697", - "statusBarItem.remoteBackground": "#4e3c69", - "ports.iconRunningProcessForeground": "#749351", - "activityBar.background": "#EDEDF5", - "activityBar.foreground": "#705697", - "activityBarBadge.background": "#705697", - "titleBar.activeBackground": "#c4b7d7", - "button.background": "#705697", - "editorGroup.dropBackground": "#C9D0D988", - "inputValidation.infoBorder": "#4ec1e5", - "inputValidation.infoBackground": "#f2fcff", - "inputValidation.warningBackground": "#fffee2", - "inputValidation.warningBorder": "#ffe055", - "inputValidation.errorBackground": "#ffeaea", - "inputValidation.errorBorder": "#f1897f", - "errorForeground": "#f1897f", - "badge.background": "#705697AA", - "progressBar.background": "#705697", - "walkThrough.embeddedEditorBackground": "#00000014", - "editorIndentGuide.background": "#aaaaaa60", - "editorIndentGuide.activeBackground": "#777777b0" - }, - "semanticHighlighting": true -} \ No newline at end of file diff --git a/layouteditor/src/main/assets/editor/textmate/solarized_drak.json b/layouteditor/src/main/assets/editor/textmate/solarized_drak.json deleted file mode 100644 index b0de1a5da8..0000000000 --- a/layouteditor/src/main/assets/editor/textmate/solarized_drak.json +++ /dev/null @@ -1,421 +0,0 @@ -{ - "name": "Solarized (dark)", - "tokenColors": [ - { - "settings": { - "foreground": "#839496" - } - }, - { - "scope": [ - "meta.embedded", - "source.groovy.embedded" - ], - "settings": { - "foreground": "#839496" - } - }, - { - "name": "Comment", - "scope": "comment", - "settings": { - "fontStyle": "italic", - "foreground": "#586E75" - } - }, - { - "name": "String", - "scope": "string", - "settings": { - "foreground": "#2AA198" - } - }, - { - "name": "Regexp", - "scope": "string.regexp", - "settings": { - "foreground": "#DC322F" - } - }, - { - "name": "Number", - "scope": "constant.numeric", - "settings": { - "foreground": "#D33682" - } - }, - { - "name": "Variable", - "scope": [ - "variable.language", - "variable.other" - ], - "settings": { - "foreground": "#268BD2" - } - }, - { - "name": "Keyword", - "scope": "keyword", - "settings": { - "foreground": "#859900" - } - }, - { - "name": "Storage", - "scope": "storage", - "settings": { - "fontStyle": "bold", - "foreground": "#93A1A1" - } - }, - { - "name": "Class name", - "scope": [ - "entity.name.class", - "entity.name.type", - "entity.name.namespace", - "entity.name.scope-resolution" - ], - "settings": { - "fontStyle": "", - "foreground": "#CB4B16" - } - }, - { - "name": "Function name", - "scope": "entity.name.function", - "settings": { - "foreground": "#268BD2" - } - }, - { - "name": "Variable start", - "scope": "punctuation.definition.variable", - "settings": { - "foreground": "#859900" - } - }, - { - "name": "Embedded code markers", - "scope": [ - "punctuation.section.embedded.begin", - "punctuation.section.embedded.end" - ], - "settings": { - "foreground": "#DC322F" - } - }, - { - "name": "Built-in constant", - "scope": [ - "constant.language", - "meta.preprocessor" - ], - "settings": { - "foreground": "#B58900" - } - }, - { - "name": "Support.construct", - "scope": [ - "support.function.construct", - "keyword.other.new" - ], - "settings": { - "foreground": "#CB4B16" - } - }, - { - "name": "User-defined constant", - "scope": [ - "constant.character", - "constant.other" - ], - "settings": { - "foreground": "#CB4B16" - } - }, - { - "name": "Inherited class", - "scope": "entity.other.inherited-class", - "settings": { - "foreground": "#6C71C4" - } - }, - { - "name": "Function argument", - "scope": "variable.parameter", - "settings": {} - }, - { - "name": "Tag name", - "scope": "entity.name.tag", - "settings": { - "foreground": "#268BD2" - } - }, - { - "name": "Tag start/end", - "scope": "punctuation.definition.tag", - "settings": { - "foreground": "#586E75" - } - }, - { - "name": "Tag attribute", - "scope": "entity.other.attribute-name", - "settings": { - "foreground": "#93A1A1" - } - }, - { - "name": "Library function", - "scope": "support.function", - "settings": { - "foreground": "#268BD2" - } - }, - { - "name": "Continuation", - "scope": "punctuation.separator.continuation", - "settings": { - "foreground": "#DC322F" - } - }, - { - "name": "Library constant", - "scope": [ - "support.constant", - "support.variable" - ], - "settings": {} - }, - { - "name": "Library class/type", - "scope": [ - "support.type", - "support.class" - ], - "settings": { - "foreground": "#859900" - } - }, - { - "name": "Library Exception", - "scope": "support.type.exception", - "settings": { - "foreground": "#CB4B16" - } - }, - { - "name": "Library variable", - "scope": "support.other.variable", - "settings": {} - }, - { - "name": "Invalid", - "scope": "invalid", - "settings": { - "foreground": "#DC322F" - } - }, - { - "name": "diff: header", - "scope": [ - "meta.diff", - "meta.diff.header" - ], - "settings": { - "fontStyle": "italic", - "foreground": "#268BD2" - } - }, - { - "name": "diff: deleted", - "scope": "markup.deleted", - "settings": { - "fontStyle": "", - "foreground": "#DC322F" - } - }, - { - "name": "diff: changed", - "scope": "markup.changed", - "settings": { - "fontStyle": "", - "foreground": "#CB4B16" - } - }, - { - "name": "diff: inserted", - "scope": "markup.inserted", - "settings": { - "foreground": "#859900" - } - }, - { - "name": "Markup Quote", - "scope": "markup.quote", - "settings": { - "foreground": "#859900" - } - }, - { - "name": "Markup Lists", - "scope": "markup.list", - "settings": { - "foreground": "#B58900" - } - }, - { - "name": "Markup Styling", - "scope": [ - "markup.bold", - "markup.italic" - ], - "settings": { - "foreground": "#D33682" - } - }, - { - "name": "Markup: Strong", - "scope": "markup.bold", - "settings": { - "fontStyle": "bold" - } - }, - { - "name": "Markup: Emphasis", - "scope": "markup.italic", - "settings": { - "fontStyle": "italic" - } - }, - { - "scope": "markup.strikethrough", - "settings": { - "fontStyle": "strikethrough" - } - }, - { - "name": "Markup Inline", - "scope": "markup.inline.raw", - "settings": { - "fontStyle": "", - "foreground": "#2AA198" - } - }, - { - "name": "Markup Headings", - "scope": "markup.heading", - "settings": { - "fontStyle": "bold", - "foreground": "#268BD2" - } - }, - { - "name": "Markup Setext Header", - "scope": "markup.heading.setext", - "settings": { - "fontStyle": "", - "foreground": "#268BD2" - } - } - ], - "colors": { - "focusBorder": "#2AA19899", - "selection.background": "#2AA19899", - "input.background": "#003847", - "input.foreground": "#93A1A1", - "input.placeholderForeground": "#93A1A1AA", - "inputOption.activeBorder": "#2AA19899", - "inputValidation.infoBorder": "#363b5f", - "inputValidation.infoBackground": "#052730", - "inputValidation.warningBackground": "#5d5938", - "inputValidation.warningBorder": "#9d8a5e", - "inputValidation.errorBackground": "#571b26", - "inputValidation.errorBorder": "#a92049", - "errorForeground": "#ffeaea", - "badge.background": "#047aa6", - "progressBar.background": "#047aa6", - "dropdown.background": "#00212B", - "dropdown.border": "#2AA19899", - "button.background": "#2AA19899", - "list.activeSelectionBackground": "#005A6F", - "quickInputList.focusBackground": "#005A6F", - "list.hoverBackground": "#004454AA", - "list.inactiveSelectionBackground": "#00445488", - "list.dropBackground": "#00445488", - "list.highlightForeground": "#1ebcc5", - "editor.background": "#002B36", - "editor.foreground": "#839496", - "editorWidget.background": "#00212B", - "editorCursor.foreground": "#D30102", - "editorWhitespace.foreground": "#93A1A180", - "editor.lineHighlightBackground": "#073642", - "editorLineNumber.activeForeground": "#949494", - "editor.selectionBackground": "#274642", - "minimap.selectionHighlight": "#274642", - "editorIndentGuide.background": "#93A1A180", - "editorIndentGuide.activeBackground": "#C3E1E180", - "editorHoverWidget.background": "#004052", - "editorMarkerNavigationError.background": "#AB395B", - "editorMarkerNavigationWarning.background": "#5B7E7A", - "editor.selectionHighlightBackground": "#005A6FAA", - "editor.wordHighlightBackground": "#004454AA", - "editor.wordHighlightStrongBackground": "#005A6FAA", - "editorBracketHighlight.foreground1": "#cdcdcdff", - "editorBracketHighlight.foreground2": "#b58900ff", - "editorBracketHighlight.foreground3": "#d33682ff", - "peekViewResult.background": "#00212B", - "peekViewEditor.background": "#10192c", - "peekViewTitle.background": "#00212B", - "peekView.border": "#2b2b4a", - "peekViewEditor.matchHighlightBackground": "#7744AA40", - "titleBar.activeBackground": "#002C39", - "editorGroup.border": "#00212B", - "editorGroup.dropBackground": "#2AA19844", - "editorGroupHeader.tabsBackground": "#004052", - "tab.activeForeground": "#d6dbdb", - "tab.activeBackground": "#002B37", - "tab.inactiveForeground": "#93A1A1", - "tab.inactiveBackground": "#004052", - "tab.border": "#003847", - "tab.lastPinnedBorder": "#2AA19844", - "activityBar.background": "#003847", - "panel.border": "#2b2b4a", - "sideBar.background": "#00212B", - "sideBarTitle.foreground": "#93A1A1", - "statusBar.foreground": "#93A1A1", - "statusBar.background": "#00212B", - "statusBar.debuggingBackground": "#00212B", - "statusBar.noFolderBackground": "#00212B", - "statusBarItem.remoteBackground": "#2AA19899", - "ports.iconRunningProcessForeground": "#369432", - "statusBarItem.prominentBackground": "#003847", - "statusBarItem.prominentHoverBackground": "#003847", - "debugToolBar.background": "#00212B", - "debugExceptionWidget.background": "#00212B", - "debugExceptionWidget.border": "#AB395B", - "pickerGroup.foreground": "#2AA19899", - "pickerGroup.border": "#2AA19899", - "terminal.ansiBlack": "#073642", - "terminal.ansiRed": "#dc322f", - "terminal.ansiGreen": "#859900", - "terminal.ansiYellow": "#b58900", - "terminal.ansiBlue": "#268bd2", - "terminal.ansiMagenta": "#d33682", - "terminal.ansiCyan": "#2aa198", - "terminal.ansiWhite": "#eee8d5", - "terminal.ansiBrightBlack": "#002b36", - "terminal.ansiBrightRed": "#cb4b16", - "terminal.ansiBrightGreen": "#586e75", - "terminal.ansiBrightYellow": "#657b83", - "terminal.ansiBrightBlue": "#839496", - "terminal.ansiBrightMagenta": "#6c71c4", - "terminal.ansiBrightCyan": "#93a1a1", - "terminal.ansiBrightWhite": "#fdf6e3" - }, - "semanticHighlighting": true -} \ No newline at end of file diff --git a/layouteditor/src/main/assets/editor/textmate/xml/language-configuration.json b/layouteditor/src/main/assets/editor/textmate/xml/language-configuration.json deleted file mode 100644 index 934eb6b5f5..0000000000 --- a/layouteditor/src/main/assets/editor/textmate/xml/language-configuration.json +++ /dev/null @@ -1,104 +0,0 @@ -{ - "comments": { - "blockComment": [ - "" - ] - }, - "brackets": [ - [ - "" - ], - [ - "<", - ">" - ], - [ - "{", - "}" - ], - [ - "(", - ")" - ] - ], - "autoClosingPairs": [ - { - "open": "{", - "close": "}" - }, - { - "open": "[", - "close": "]" - }, - { - "open": "(", - "close": ")" - }, - { - "open": "\"", - "close": "\"", - "notIn": [ - "string" - ] - }, - { - "open": "'", - "close": "'", - "notIn": [ - "string" - ] - }, - { - "open": "", - "notIn": [ - "comment", - "string" - ] - }, - { - "open": "", - "notIn": [ - "comment", - "string" - ] - } - ], - "surroundingPairs": [ - { - "open": "'", - "close": "'" - }, - { - "open": "\"", - "close": "\"" - }, - { - "open": "{", - "close": "}" - }, - { - "open": "[", - "close": "]" - }, - { - "open": "(", - "close": ")" - }, - { - "open": "<", - "close": ">" - } - ], - "colorizedBracketPairs": [], - "folding": { - "markers": { - "start": "^\\s*", - "end": "^\\s*" - } - }, - "wordPattern": "(-?\\d*\\.\\d\\w*)|([^\\`\\~\\!\\@\\#\\$\\%\\^\\&\\*\\(\\)\\=\\+\\[\\{\\]\\}\\\\\\|\\;\\:\\'\\\"\\,\\.\\<\\>\\/\\?\\s]+)" -} \ No newline at end of file diff --git a/layouteditor/src/main/assets/editor/textmate/xml/syntaxes/xml.tmLanguage.json b/layouteditor/src/main/assets/editor/textmate/xml/syntaxes/xml.tmLanguage.json deleted file mode 100644 index 181a982272..0000000000 --- a/layouteditor/src/main/assets/editor/textmate/xml/syntaxes/xml.tmLanguage.json +++ /dev/null @@ -1,389 +0,0 @@ -{ - "information_for_contributors": [ - "This file has been converted from https://github.com/atom/language-xml/blob/master/grammars/xml.cson", - "If you want to provide a fix or improvement, please create a pull request against the original repository.", - "Once accepted there, we are happy to receive an update request." - ], - "version": "https://github.com/atom/language-xml/commit/7bc75dfe779ad5b35d9bf4013d9181864358cb49", - "name": "XML", - "scopeName": "text.xml", - "patterns": [ - { - "begin": "(<\\?)\\s*([-_a-zA-Z0-9]+)", - "captures": { - "1": { - "name": "punctuation.definition.tag.xml" - }, - "2": { - "name": "entity.name.tag.xml" - } - }, - "end": "(\\?>)", - "name": "meta.tag.preprocessor.xml", - "patterns": [ - { - "match": " ([a-zA-Z-]+)", - "name": "entity.other.attribute-name.xml" - }, - { - "include": "#doublequotedString" - }, - { - "include": "#singlequotedString" - } - ] - }, - { - "begin": "()", - "name": "meta.tag.sgml.doctype.xml", - "patterns": [ - { - "include": "#internalSubset" - } - ] - }, - { - "include": "#comments" - }, - { - "begin": "(<)((?:([-_a-zA-Z0-9]+)(:))?([-_a-zA-Z0-9:]+))(?=(\\s[^>]*)?>)", - "beginCaptures": { - "1": { - "name": "punctuation.definition.tag.xml" - }, - "2": { - "name": "entity.name.tag.xml" - }, - "3": { - "name": "entity.name.tag.namespace.xml" - }, - "4": { - "name": "punctuation.separator.namespace.xml" - }, - "5": { - "name": "entity.name.tag.localname.xml" - } - }, - "end": "(>)()", - "endCaptures": { - "1": { - "name": "punctuation.definition.tag.xml" - }, - "2": { - "name": "punctuation.definition.tag.xml" - }, - "3": { - "name": "entity.name.tag.xml" - }, - "4": { - "name": "entity.name.tag.namespace.xml" - }, - "5": { - "name": "punctuation.separator.namespace.xml" - }, - "6": { - "name": "entity.name.tag.localname.xml" - }, - "7": { - "name": "punctuation.definition.tag.xml" - } - }, - "name": "meta.tag.no-content.xml", - "patterns": [ - { - "include": "#tagStuff" - } - ] - }, - { - "begin": "()", - "name": "meta.tag.xml", - "patterns": [ - { - "include": "#tagStuff" - } - ] - }, - { - "include": "#entity" - }, - { - "include": "#bare-ampersand" - }, - { - "begin": "<%@", - "beginCaptures": { - "0": { - "name": "punctuation.section.embedded.begin.xml" - } - }, - "end": "%>", - "endCaptures": { - "0": { - "name": "punctuation.section.embedded.end.xml" - } - }, - "name": "source.java-props.embedded.xml", - "patterns": [ - { - "match": "page|include|taglib", - "name": "keyword.other.page-props.xml" - } - ] - }, - { - "begin": "<%[!=]?(?!--)", - "beginCaptures": { - "0": { - "name": "punctuation.section.embedded.begin.xml" - } - }, - "end": "(?!--)%>", - "endCaptures": { - "0": { - "name": "punctuation.section.embedded.end.xml" - } - }, - "name": "source.java.embedded.xml", - "patterns": [ - { - "include": "source.java" - } - ] - }, - { - "begin": "", - "endCaptures": { - "0": { - "name": "punctuation.definition.string.end.xml" - } - }, - "name": "string.unquoted.cdata.xml" - } - ], - "repository": { - "EntityDecl": { - "begin": "()", - "patterns": [ - { - "include": "#doublequotedString" - }, - { - "include": "#singlequotedString" - } - ] - }, - "bare-ampersand": { - "match": "&", - "name": "invalid.illegal.bad-ampersand.xml" - }, - "doublequotedString": { - "begin": "\"", - "beginCaptures": { - "0": { - "name": "punctuation.definition.string.begin.xml" - } - }, - "end": "\"", - "endCaptures": { - "0": { - "name": "punctuation.definition.string.end.xml" - } - }, - "name": "string.quoted.double.xml", - "patterns": [ - { - "include": "#entity" - }, - { - "include": "#bare-ampersand" - } - ] - }, - "entity": { - "captures": { - "1": { - "name": "punctuation.definition.constant.xml" - }, - "3": { - "name": "punctuation.definition.constant.xml" - } - }, - "match": "(&)([:a-zA-Z_][:a-zA-Z0-9_.-]*|#[0-9]+|#x[0-9a-fA-F]+)(;)", - "name": "constant.character.entity.xml" - }, - "internalSubset": { - "begin": "(\\[)", - "captures": { - "1": { - "name": "punctuation.definition.constant.xml" - } - }, - "end": "(\\])", - "name": "meta.internalsubset.xml", - "patterns": [ - { - "include": "#EntityDecl" - }, - { - "include": "#parameterEntity" - }, - { - "include": "#comments" - } - ] - }, - "parameterEntity": { - "captures": { - "1": { - "name": "punctuation.definition.constant.xml" - }, - "3": { - "name": "punctuation.definition.constant.xml" - } - }, - "match": "(%)([:a-zA-Z_][:a-zA-Z0-9_.-]*)(;)", - "name": "constant.character.parameter-entity.xml" - }, - "singlequotedString": { - "begin": "'", - "beginCaptures": { - "0": { - "name": "punctuation.definition.string.begin.xml" - } - }, - "end": "'", - "endCaptures": { - "0": { - "name": "punctuation.definition.string.end.xml" - } - }, - "name": "string.quoted.single.xml", - "patterns": [ - { - "include": "#entity" - }, - { - "include": "#bare-ampersand" - } - ] - }, - "tagStuff": { - "patterns": [ - { - "captures": { - "1": { - "name": "entity.other.attribute-name.namespace.xml" - }, - "2": { - "name": "entity.other.attribute-name.xml" - }, - "3": { - "name": "punctuation.separator.namespace.xml" - }, - "4": { - "name": "entity.other.attribute-name.localname.xml" - } - }, - "match": "(?:^|\\s+)(?:([-\\w.]+)((:)))?([-\\w.:]+)\\s*=" - }, - { - "include": "#doublequotedString" - }, - { - "include": "#singlequotedString" - } - ] - }, - "comments": { - "patterns": [ - { - "begin": "<%--", - "captures": { - "0": { - "name": "punctuation.definition.comment.xml" - } - }, - "end": "--%>", - "name": "comment.block.xml" - }, - { - "begin": "", - "name": "comment.block.xml", - "patterns": [ - { - "begin": "--(?!>)", - "captures": { - "0": { - "name": "invalid.illegal.bad-comments-or-CDATA.xml" - } - }, - "end": "", - "name": "comment.block.xml" - } - ] - } - ] - } - } -} \ No newline at end of file diff --git a/layouteditor/src/main/assets/palette/buttons.json b/layouteditor/src/main/assets/palette/buttons.json deleted file mode 100644 index 5ad9420f2b..0000000000 --- a/layouteditor/src/main/assets/palette/buttons.json +++ /dev/null @@ -1,81 +0,0 @@ -[ - { - "name": "Button", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.buttons.ButtonDesign", - "iconName": "ic_palette_button", - "defaultAttributes": { - "android:text": "Button" - } - }, - { - "name": "ImageButton", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.buttons.ImageButtonDesign", - "iconName": "ic_palette_image_button", - "defaultAttributes": { - "android:src": "@drawable/ic_launcher_round" - } - }, - { - "name": "ChipGroup", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.buttons.ChipGroupDesign", - "iconName": "ic_palette_chip_group", - "defaultAttributes": { - "android:layout_width": "match_parent", - "android:padding": "8dp" - } - }, - { - "name": "Chip", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.buttons.ChipDesign", - "iconName": "ic_palette_chip", - "defaultAttributes": { - "android:text": "Chip" - } - }, - { - "name": "CheckBox", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.buttons.CheckBoxDesign", - "iconName": "ic_palette_check_box", - "defaultAttributes": { - "android:text": "CheckBox" - } - }, - { - "name": "RadioGroup", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.buttons.RadioGroupDesign", - "iconName": "ic_palette_radio_group", - "defaultAttributes": { - "android:layout_width": "match_parent", - "android:padding": "8dp" - } - }, - { - "name": "RadioButton", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.buttons.RadioButtonDesign", - "iconName": "ic_palette_radio_button", - "defaultAttributes": { - "android:text": "RadioButton" - } - }, - { - "name": "ToggleButton", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.buttons.ToggleButtonDesign", - "iconName": "ic_palette_toggle_button", - "defaultAttributes": { - "android:text": "ToggleButton" - } - }, - { - "name": "Switch", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.buttons.SwitchDesign", - "iconName": "ic_palette_switch", - "defaultAttributes": { - "android:text": "Switch" - } - }, - { - "name": "FloatingActionButton", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.buttons.FloatingActionButtonDesign", - "iconName": "ic_palette_floating_action_button" - } -] \ No newline at end of file diff --git a/layouteditor/src/main/assets/palette/common.json b/layouteditor/src/main/assets/palette/common.json deleted file mode 100644 index 46f546aad8..0000000000 --- a/layouteditor/src/main/assets/palette/common.json +++ /dev/null @@ -1,85 +0,0 @@ -[ - { - "name": "LinearLayout (H)", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.layouts.LinearLayoutDesign", - "iconName": "ic_palette_linear_layout_horz", - "defaultAttributes": { - "android:layout_width": "match_parent", - "android:orientation": "horizontal", - "android:padding": "8dp" - } - }, - { - "name": "LinearLayout (V)", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.layouts.LinearLayoutDesign", - "iconName": "ic_palette_linear_layout_vert", - "defaultAttributes": { - "android:layout_height": "match_parent", - "android:orientation": "vertical", - "android:padding": "8dp" - } - }, - { - "name": "ScrollView (unable to scroll in the editor)", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.containers.ScrollViewDesign", - "iconName": "ic_palette_scroll_view", - "defaultAttributes": { - "android:layout_height": "match_parent", - "android:layout_width": "match_parent", - "android:padding": "8dp" - } - }, - { - "name": "HorizontalScrollView (unable to scroll in the editor)", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.containers.HorizontalScrollViewDesign", - "iconName": "ic_palette_scroll_view", - "defaultAttributes": { - "android:layout_height": "match_parent", - "android:layout_width": "match_parent", - "android:padding": "8dp" - } - }, - { - "name": "TextView", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.text.TextViewDesign", - "iconName": "ic_palette_text_view", - "defaultAttributes": { - "android:text": "TextView" - } - }, - { - "name": "Button", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.buttons.ButtonDesign", - "iconName": "ic_palette_button", - "defaultAttributes": { - "android:text": "Button" - } - }, - { - "name": "ImageView", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.widgets.ImageViewDesign", - "iconName": "ic_palette_image_view", - "defaultAttributes": { - "android:layout_width": "48dp", - "android:layout_height": "48dp", - "android:src": "@drawable/ic_launcher_round" - } - }, - { - "name": "Switch", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.buttons.SwitchDesign", - "iconName": "ic_palette_switch", - "defaultAttributes": { - "android:text": "Switch" - } - }, - { - "name": "RecyclerView", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.containers.RecyclerViewDesign", - "iconName": "ic_palette_recycler_view", - "defaultAttributes": { - "android:layout_width":"match_parent", - "android:layout_height":"100dp" - } - } -] \ No newline at end of file diff --git a/layouteditor/src/main/assets/palette/containers.json b/layouteditor/src/main/assets/palette/containers.json deleted file mode 100644 index 6b8e863028..0000000000 --- a/layouteditor/src/main/assets/palette/containers.json +++ /dev/null @@ -1,155 +0,0 @@ -[ - { - "name": "Spinner", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.containers.SpinnerDesign", - "iconName": "ic_palette_spinner" - }, - { - "name": "RecyclerView", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.containers.RecyclerViewDesign", - "iconName": "ic_palette_recycler_view", - "defaultAttributes": { - "android:layout_width":"match_parent", - "android:layout_height":"100dp" - } - }, - { - "name": "ScrollView (unable to scroll in the editor)", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.containers.ScrollViewDesign", - "iconName": "ic_palette_scroll_view", - "defaultAttributes": { - "android:layout_width":"match_parent", - "android:layout_height":"match_parent", - "android:padding": "8dp" - } - }, - { - "name": "HorizontalScrollView (unable to scroll in the editor)", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.containers.HorizontalScrollViewDesign", - "iconName": "ic_palette_horizontal_scroll_view", - "defaultAttributes": { - "android:layout_width":"match_parent", - "android:layout_height":"match_parent", - "android:padding": "8dp" - } - }, - { - "name": "NestedScrollView (unable to scroll in the editor)", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.containers.NestedScrollViewDesign", - "iconName": "ic_palette_nested_scroll_view", - "defaultAttributes": { - "android:layout_width":"match_parent", - "android:layout_height":"match_parent", - "android:padding": "8dp" - } - }, - { - "name": "ViewPager", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.containers.ViewPagerDesign", - "iconName": "ic_palette_view_pager", - "defaultAttributes": { - "android:layout_width":"match_parent", - "android:layout_height":"match_parent" - } - }, - { - "name": "CardView", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.containers.CardViewDesign", - "iconName": "ic_palette_card_view", - "defaultAttributes": { - "android:layout_width":"match_parent" - } - }, - { - "name": "AppBarLayout", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.containers.AppBarLayoutDesign", - "iconName": "ic_palette_app_bar_layout", - "defaultAttributes": { - "android:layout_width":"match_parent" - } - }, - { - "name": "BottomAppBar", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.containers.BottomAppBarDesign", - "iconName": "ic_palette_bottom_app_bar", - "defaultAttributes": { - "android:layout_width":"match_parent", - "android:gravity":"bottom" - } - }, - { - "name": "NavigationView", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.containers.NavigationViewDesign", - "iconName": "ic_palette_navigation_view", - "defaultAttributes": { - "android:layout_width":"100dp" - } - }, - { - "name": "BottomNavigationView", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.containers.BottomNavigationViewDesign", - "iconName": "ic_palette_bottom_navigation_view", - "defaultAttributes": { - "android:layout_width":"match_parent", - "android:gravity":"bottom" - } - }, - { - "name": "Toolbar", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.containers.ToolbarDesign", - "iconName": "ic_palette_toolbar", - "defaultAttributes": { - "android:layout_width":"match_parent" - } - }, - { - "name": "MaterialToolbar", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.containers.MaterialToolbarDesign", - "iconName": "ic_palette_toolbar", - "defaultAttributes": { - "android:layout_width":"match_parent" - } - }, - { - "name": "TabLayout", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.containers.TabLayoutDesign", - "iconName": "ic_palette_tab_layout", - "defaultAttributes": { - "android:layout_width":"match_parent" - } - }, - { - "name": "TabItem", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.containers.TabItemDesign", - "iconName": "ic_palette_tab_item", - "defaultAttributes": { - "android:layout_height":"match_parent" - } - }, - { - "name": "ListView (old, use RecyclerView instead)", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.legacy.ListViewDesign", - "iconName": "ic_palette_list_view", - "defaultAttributes": { - "android:layout_width":"match_parent", - "android:layout_height":"100dp" - } - }, - { - "name": "TabHost (old, use TabLayout + ViewPager2 instead)", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.legacy.TabHostDesign", - "iconName": "ic_palette_tab_host", - "defaultAttributes": { - "android:layout_width":"match_parent" - } - }, - { - "name": "GridView (old, use RecyclerView + GridLayoutManager instead)", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.legacy.GridViewDesign", - "iconName": "ic_palette_grid_view", - "defaultAttributes": { - "android:layout_width":"match_parent", - "android:layout_height":"100dp" - } - } -] \ No newline at end of file diff --git a/layouteditor/src/main/assets/palette/layouts.json b/layouteditor/src/main/assets/palette/layouts.json deleted file mode 100644 index 857631761e..0000000000 --- a/layouteditor/src/main/assets/palette/layouts.json +++ /dev/null @@ -1,103 +0,0 @@ -[ - { - "name": "RelativeLayout", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.layouts.RelativeLayoutDesign", - "iconName": "ic_palette_relative_layout", - "defaultAttributes": { - "android:layout_width": "match_parent", - "android:padding": "8dp" - } - }, - { - "name": "ConstraintLayout", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.layouts.ConstraintLayoutDesign", - "iconName": "ic_palette_constraint_layout", - "defaultAttributes": { - "android:layout_width": "match_parent", - "android:padding": "8dp" - } - }, - { - "name": "LinearLayout (H)", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.layouts.LinearLayoutDesign", - "iconName": "ic_palette_linear_layout_horz", - "defaultAttributes": { - "android:layout_width": "match_parent", - "android:orientation": "horizontal", - "android:padding": "8dp" - } - }, - { - "name": "LinearLayout (V)", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.layouts.LinearLayoutDesign", - "iconName": "ic_palette_linear_layout_vert", - "defaultAttributes": { - "android:layout_height": "match_parent", - "android:orientation": "vertical", - "android:padding": "8dp" - } - }, - { - "name": "FrameLayout", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.layouts.FrameLayoutDesign", - "iconName": "ic_palette_frame_layout", - "defaultAttributes": { - "android:layout_width": "match_parent", - "android:padding": "8dp" - } - }, - { - "name": "TableLayout", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.layouts.TableLayoutDesign", - "iconName": "ic_palette_table_layout", - "defaultAttributes": { - "android:layout_width": "match_parent", - "android:padding": "8dp" - } - }, - { - "name": "TableRow", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.layouts.TableRowDesign", - "iconName": "ic_palette_table_row", - "defaultAttributes": { - "android:layout_width": "match_parent", - "android:padding": "8dp" - } - }, - { - "name": "Space", - "className": "android.widget.Space", - "iconName": "ic_palette_space", - "defaultAttributes": { - "android:layout_width": "match_parent", - "android:padding": "8dp" - } - }, - { - "name": "GridLayout (old, use ConstraintLayout instead)", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.legacy.GridLayoutDesign", - "iconName": "ic_palette_grid_layout", - "defaultAttributes": { - "android:layout_width":"match_parent" - } - }, - { - "name": "CoordinatorLayout", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.layouts.CoordinatorLayoutDesign", - "iconName": "ic_palette_coordinator_layout", - "defaultAttributes": { - "android:layout_width": "match_parent", - "android:padding": "8dp" - } - }, - { - "name": "DrawerLayout", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.layouts.DrawerLayoutDesign", - "iconName": "ic_palette_drawer_layout", - "defaultAttributes": { - "android:layout_width": "match_parent", - "android:layout_height": "match_parent", - "android:padding": "8dp" - } - } -] \ No newline at end of file diff --git a/layouteditor/src/main/assets/palette/text.json b/layouteditor/src/main/assets/palette/text.json deleted file mode 100644 index 370e177b48..0000000000 --- a/layouteditor/src/main/assets/palette/text.json +++ /dev/null @@ -1,161 +0,0 @@ -[ - { - "name": "TextView", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.text.TextViewDesign", - "iconName": "ic_palette_text_view", - "defaultAttributes": { - "android:text": "@string/default_string" - } - }, - { - "name": "Plain Text", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.text.EditTextDesign", - "iconName": "ic_palette_edit_text", - "defaultAttributes": { - "android:hint": "Plain Text", - "android:inputType":"text" - } - }, - { - "name": "Password", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.text.EditTextDesign", - "iconName": "ic_palette_password_textfield", - "defaultAttributes": { - "android:hint": "Password", - "android:inputType":"textPassword" - } - }, - { - "name": "Password (Numeric)", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.text.EditTextDesign", - "iconName": "ic_palette_password_numeric_textfield", - "defaultAttributes": { - "android:hint": "Password (Numeric)", - "android:inputType":"numberPassword" - } - }, - { - "name": "E-mail", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.text.EditTextDesign", - "iconName": "ic_palette_email_textfield", - "defaultAttributes": { - "android:hint": "E-mail", - "android:inputType":"textEmailAddress" - } - }, - { - "name": "Phone", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.text.EditTextDesign", - "iconName": "ic_palette_phone_textfield", - "defaultAttributes": { - "android:hint": "Phone", - "android:inputType":"phone" - } - }, - { - "name": "Postal Address", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.text.EditTextDesign", - "iconName": "ic_palette_postal_address_textfield", - "defaultAttributes": { - "android:hint": "Postal Address", - "android:inputType":"textPostalAddress" - } - }, - { - "name": "Multiline Text", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.text.EditTextDesign", - "iconName": "ic_palette_textfield_multiline", - "defaultAttributes": { - "android:hint": "Multiline Text", - "android:inputType":"textMultiLine" - } - }, - { - "name": "Time", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.text.EditTextDesign", - "iconName": "ic_palette_time_textfield", - "defaultAttributes": { - "android:hint": "Time", - "android:inputType":"time" - } - }, - { - "name": "Date", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.text.EditTextDesign", - "iconName": "ic_palette_date_textfield", - "defaultAttributes": { - "android:hint": "Date", - "android:inputType":"date" - } - }, - { - "name": "Number", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.text.EditTextDesign", - "iconName": "ic_palette_number_textfield", - "defaultAttributes": { - "android:hint": "Number", - "android:inputType":"number" - } - }, - { - "name": "Number (Signed)", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.text.EditTextDesign", - "iconName": "ic_palette_number_signed_textfield", - "defaultAttributes": { - "android:hint": "Number (Signed)", - "android:inputType":"numberSigned" - } - }, - { - "name": "Number (Decimal)", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.text.EditTextDesign", - "iconName": "ic_palette_number_decimal_textfield", - "defaultAttributes": { - "android:hint": "Number (Decimal)", - "android:inputType":"numberDecimal" - } - }, - { - "name": "AutoCompleteTextView", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.text.AutoCompleteTextViewDesign", - "iconName": "ic_palette_auto_complete_text_view", - "defaultAttributes": { - "android:hint": "AutoCompleteTextView" - } - }, - { - "name": "MultiAutoCompleteTextView", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.text.MultiAutoCompleteTextViewDesign", - "iconName": "ic_palette_multi_auto_complete_text_view", - "defaultAttributes": { - "android:hint": "MultiAutoCompleteTextView" - } - }, - { - "name": "CheckedTextView", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.text.CheckedTextViewDesign", - "iconName": "ic_palette_checked_text_view", - "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" - } - } -] \ No newline at end of file diff --git a/layouteditor/src/main/assets/palette/widgets.json b/layouteditor/src/main/assets/palette/widgets.json deleted file mode 100644 index a15b4070a4..0000000000 --- a/layouteditor/src/main/assets/palette/widgets.json +++ /dev/null @@ -1,118 +0,0 @@ -[ - { - "name": "View", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.widgets.ViewDesign", - "iconName": "ic_palette_view", - "defaultAttributes": { - "android:layout_width": "match_parent", - "android:layout_height": "30dp", - "android:padding": "8dp" - } - }, - { - "name": "ImageView", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.widgets.ImageViewDesign", - "iconName": "ic_palette_image_view", - "defaultAttributes": { - "android:layout_width": "48dp", - "android:layout_height": "48dp", - "android:src": "@drawable/ic_launcher_round" - } - }, - { - "name": "WebView", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.widgets.WebViewDesign", - "iconName": "ic_palette_web_view", - "defaultAttributes": { - "android:layout_width": "match_parent", - "android:layout_height": "200dp" - } - }, - { - "name": "VideoView", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.widgets.VideoViewDesign", - "iconName": "ic_palette_video_view", - "defaultAttributes": { - "android:layout_width": "match_parent", - "android:layout_height": "200dp" - } - }, - { - "name": "CalendarView", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.widgets.CalendarViewDesign", - "iconName": "ic_palette_calendar_view", - "defaultAttributes": { - "android:layout_width": "match_parent" - } - }, - { - "name": "Text Clock", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.widgets.TextClockDesign", - "iconName": "ic_palette_text_clock", - "defaultAttributes": { - "android:textSize": "20sp" - } - }, - { - "name": "ProgressBar", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.widgets.ProgressBarDesign", - "iconName": "ic_palette_progress_bar", - "defaultAttributes": { - "android:layout_width": "match_parent" - } - }, - { - "name": "ProgressBar (Horizontal)", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.widgets.ProgressBarDesign", - "iconName": "ic_palette_progress_bar_horizontal", - "defaultAttributes": { - "android:layout_width": "match_parent" - } - }, - { - "name": "SeekBar", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.widgets.SeekBarDesign", - "iconName": "ic_palette_seek_bar", - "defaultAttributes": { - "android:layout_width": "match_parent" - } - }, - { - "name": "SeekBar (Discrete)", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.widgets.SeekBarDesign", - "iconName": "ic_palette_seek_bar_discrete", - "defaultAttributes": { - "android:layout_width": "match_parent" - } - }, - { - "name": "RatingBar", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.widgets.RatingBarDesign", - "iconName": "ic_palette_rating_bar" - }, - { - "name": "SearchView", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.widgets.SearchViewDesign", - "iconName": "ic_palette_search_view", - "defaultAttributes": { - "android:layout_width": "match_parent" - } - }, - { - "name": "TextureView", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.widgets.TextureViewDesign", - "iconName": "ic_palette_texture_view", - "defaultAttributes": { - "android:layout_width": "match_parent" - } - }, - { - "name": "SurfaceView", - "className": "org.appdevforall.codeonthego.layouteditor.editor.palette.widgets.SurfaceViewDesign", - "iconName": "ic_palette_surface_view", - "defaultAttributes": { - "android:layout_width": "match_parent", - "android:layout_height": "200dp" - } - } -] \ No newline at end of file diff --git a/layouteditor/src/main/assets/strings.xml b/layouteditor/src/main/assets/strings.xml deleted file mode 100644 index 3dc9e61394..0000000000 --- a/layouteditor/src/main/assets/strings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - Hello World! - \ No newline at end of file diff --git a/layouteditor/src/main/assets/widgetclasses.json b/layouteditor/src/main/assets/widgetclasses.json deleted file mode 100644 index 133eefd57f..0000000000 --- a/layouteditor/src/main/assets/widgetclasses.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "Button": "org.appdevforall.codeonthego.layouteditor.editor.palette.buttons.ButtonDesign", - "ImageButton": "org.appdevforall.codeonthego.layouteditor.editor.palette.buttons.ImageButtonDesign", - "ChipGroup": "org.appdevforall.codeonthego.layouteditor.editor.palette.buttons.ChipGroupDesign", - "Chip": "org.appdevforall.codeonthego.layouteditor.editor.palette.buttons.ChipDesign", - "CheckBox": "org.appdevforall.codeonthego.layouteditor.editor.palette.buttons.CheckBoxDesign", - "RadioGroup": "org.appdevforall.codeonthego.layouteditor.editor.palette.buttons.RadioGroupDesign", - "RadioButton": "org.appdevforall.codeonthego.layouteditor.editor.palette.buttons.RadioButtonDesign", - "ToggleButton": "org.appdevforall.codeonthego.layouteditor.editor.palette.buttons.ToggleButtonDesign", - "Switch": "org.appdevforall.codeonthego.layouteditor.editor.palette.buttons.SwitchDesign", - "FloatingActionButton": "org.appdevforall.codeonthego.layouteditor.editor.palette.buttons.FloatingActionButtonDesign", - "Spinner": "org.appdevforall.codeonthego.layouteditor.editor.palette.containers.SpinnerDesign", - "RecyclerView":"org.appdevforall.codeonthego.layouteditor.editor.palette.containers.RecyclerViewDesign", - "ScrollView": "org.appdevforall.codeonthego.layouteditor.editor.palette.containers.ScrollViewDesign", - "HorizontalScrollView": "org.appdevforall.codeonthego.layouteditor.editor.palette.containers.HorizontalScrollViewDesign", - "NestedScrollView": "org.appdevforall.codeonthego.layouteditor.editor.palette.containers.NestedScrollViewDesign", - "ViewPager": "org.appdevforall.codeonthego.layouteditor.editor.palette.containers.ViewPagerDesign", - "CardView": "org.appdevforall.codeonthego.layouteditor.editor.palette.containers.CardViewDesign", - "AppBarLayout": "org.appdevforall.codeonthego.layouteditor.editor.palette.containers.AppBarLayoutDesign", - "BottomAppBar": "org.appdevforall.codeonthego.layouteditor.editor.palette.containers.BottomAppBarDesign", - "NavigationView": "org.appdevforall.codeonthego.layouteditor.editor.palette.containers.NavigationViewDesign", - "BottomNavigationView": "org.appdevforall.codeonthego.layouteditor.editor.palette.containers.BottomNavigationViewDesign", - "Toolbar": "org.appdevforall.codeonthego.layouteditor.editor.palette.containers.ToolbarDesign", - "MaterialToolbar": "org.appdevforall.codeonthego.layouteditor.editor.palette.containers.MaterialToolbarDesign", - "TabLayoutDesign":"org.appdevforall.codeonthego.layouteditor.editor.palette.containers.TabLayoutDesign", - "TabItem": "org.appdevforall.codeonthego.layouteditor.editor.palette.containers.TabItemDesign", - "RelativeLayout": "org.appdevforall.codeonthego.layouteditor.editor.palette.layouts.RelativeLayoutDesign", - "LinearLayout": "org.appdevforall.codeonthego.layouteditor.editor.palette.layouts.LinearLayoutDesign", - "ConstraintLayout":"org.appdevforall.codeonthego.layouteditor.editor.palette.layouts.ConstraintLayoutDesign", - "CoordinatorLayout":"org.appdevforall.codeonthego.layouteditor.editor.palette.layouts.CoordinatorLayoutDesign", - "FrameLayout": "org.appdevforall.codeonthego.layouteditor.editor.palette.layouts.FrameLayoutDesign", - "TableLayout": "org.appdevforall.codeonthego.layouteditor.editor.palette.layouts.TableLayoutDesign", - "TableRow": "org.appdevforall.codeonthego.layouteditor.editor.palette.layouts.TableRowDesign", - "DrawerLayout":"org.appdevforall.codeonthego.layouteditor.editor.palette.layouts.DrawerLayoutDesign", - "Space": "android.widget.Space", - "GridLayout": "org.appdevforall.codeonthego.layouteditor.editor.palette.legacy.GridLayoutDesign", - "TabHost": "org.appdevforall.codeonthego.layouteditor.editor.palette.legacy.TabHostDesign", - "GridView": "org.appdevforall.codeonthego.layouteditor.editor.palette.legacy.GridViewDesign", - "ListView":"org.appdevforall.codeonthego.layouteditor.editor.palette.legacy.ListViewDesign", - "TextView": "org.appdevforall.codeonthego.layouteditor.editor.palette.text.TextViewDesign", - "EditText": "org.appdevforall.codeonthego.layouteditor.editor.palette.text.EditTextDesign", - "AutoCompleteTextView": "org.appdevforall.codeonthego.layouteditor.editor.palette.text.AutoCompleteTextViewDesign", - "MultiAutoCompleteTextView": "org.appdevforall.codeonthego.layouteditor.editor.palette.text.MultiAutoCompleteTextViewDesign", - "CheckedTextView": "org.appdevforall.codeonthego.layouteditor.editor.palette.text.CheckedTextViewDesign", - "View": "org.appdevforall.codeonthego.layouteditor.editor.palette.widgets.ViewDesign", - "ImageView": "org.appdevforall.codeonthego.layouteditor.editor.palette.widgets.ImageViewDesign", - "WebView": "org.appdevforall.codeonthego.layouteditor.editor.palette.widgets.WebViewDesign", - "VideoView": "org.appdevforall.codeonthego.layouteditor.editor.palette.widgets.VideoViewDesign", - "CalendarView": "org.appdevforall.codeonthego.layouteditor.editor.palette.widgets.CalendarViewDesign", - "TextClock": "org.appdevforall.codeonthego.layouteditor.editor.palette.widgets.TextClockDesign", - "ProgressBar": "org.appdevforall.codeonthego.layouteditor.editor.palette.widgets.ProgressBarDesign", - "SeekBar": "org.appdevforall.codeonthego.layouteditor.editor.palette.widgets.SeekBarDesign", - "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", - "TextInputEditText": "org.appdevforall.codeonthego.layouteditor.editor.palette.text.TextInputEditTextDesign", - "TextInputLayout": "org.appdevforall.codeonthego.layouteditor.editor.palette.text.TextInputLayoutDesign" -} \ No newline at end of file diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/BaseActivity.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/BaseActivity.kt deleted file mode 100644 index a1878e901c..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/BaseActivity.kt +++ /dev/null @@ -1,45 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor - -import android.annotation.SuppressLint -import android.content.Context -import android.os.Bundle -import androidx.appcompat.app.AppCompatActivity -import androidx.core.view.WindowCompat -import com.google.android.material.elevation.SurfaceColors -import com.itsaky.androidide.utils.OrientationUtilities -import com.itsaky.androidide.utils.isSystemInDarkMode -import java.lang.ref.WeakReference - -open class BaseActivity : AppCompatActivity() { - var app: LayoutEditor? = null - private lateinit var ctx: WeakReference - - @SuppressLint("SourceLockedOrientationActivity") - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - instance = this - ctx = WeakReference(this) - app = LayoutEditor.instance - window.statusBarColor = SurfaceColors.SURFACE_0.getColor(this) - OrientationUtilities.setOrientation { - OrientationUtilities.setAdaptiveOrientation { requestedOrientation = it } - } - - // Set status bar icons to be dark in light mode and light in dark mode - WindowCompat.getInsetsController(this.window, this.window.decorView).apply { - isAppearanceLightStatusBars = !isSystemInDarkMode() - isAppearanceLightNavigationBars = !isSystemInDarkMode() - } - } - - - override fun onDestroy() { - ctx.clear() - super.onDestroy() - } - - companion object { - var instance: BaseActivity? = null - private set - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/LayoutEditor.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/LayoutEditor.kt deleted file mode 100644 index c91e7f739f..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/LayoutEditor.kt +++ /dev/null @@ -1,55 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor - -import android.app.Activity -import android.app.Application -import android.content.Context -import android.os.Build -import androidx.appcompat.app.AppCompatDelegate -import com.google.android.material.color.DynamicColors -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.SupervisorJob -import kotlinx.coroutines.cancelChildren -import kotlinx.coroutines.launch -import org.appdevforall.codeonthego.layouteditor.editor.DesignEditor -import org.appdevforall.codeonthego.layouteditor.managers.PreferencesManager - -class LayoutEditor : Application() { - - private val applicationScope = CoroutineScope(SupervisorJob() + Dispatchers.IO) - private lateinit var prefManager: PreferencesManager - - override fun onCreate() { - super.onCreate() - instance = this - prefManager = PreferencesManager(this.context) - AppCompatDelegate.setDefaultNightMode(prefManager.currentTheme) - if (prefManager.isApplyDynamicColors && DynamicColors.isDynamicColorAvailable()) { - DynamicColors.applyToActivitiesIfAvailable(this) - } - - applicationScope.launch { - DesignEditor.preload(context) - } - } - - override fun onTerminate() { - super.onTerminate() - applicationScope.coroutineContext.cancelChildren() - } - - val context: Context - get() = instance!!.applicationContext - val isAtLeastTiramisu: Boolean - get() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU - - fun updateTheme(nightMode: Int, activity: Activity) { - AppCompatDelegate.setDefaultNightMode(nightMode) - activity.recreate() - } - - companion object { - var instance: LayoutEditor? = null - private set - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/LayoutFile.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/LayoutFile.java deleted file mode 100644 index b0768f4984..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/LayoutFile.java +++ /dev/null @@ -1,100 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor; - -import android.os.Parcel; -import android.os.Parcelable; - -import androidx.annotation.NonNull; - -import org.appdevforall.codeonthego.layouteditor.utils.FileUtil; -import org.jetbrains.annotations.Contract; - -import java.io.File; - -public class LayoutFile implements Parcelable { - - private String path; - private String designPath; - public String name; - - public LayoutFile(String path, String designPath) { - this.path = path; - this.designPath = designPath; - this.name = FileUtil.getLastSegmentFromPath(path); - } - - public void rename(String newPath, String newDesignPath) { - File oldFile = new File(path); - File newFile = new File(newPath); - oldFile.renameTo(newFile); - - File oldDesignFile = new File(designPath); - File newDesignFile = new File(newDesignPath); - oldDesignFile.renameTo(newDesignFile); - - this.path = newPath; - this.designPath = newDesignPath; - this.name = FileUtil.getLastSegmentFromPath(newPath); - } - - public void saveLayout(String content) { - FileUtil.writeFile(path, content); - } - - // Saves the internal design-time XML - public void saveDesignFile(String content) { - FileUtil.writeFile(designPath, content); - } - - public String getPath() { - return path; - } - - public String getDesignPath() { - return designPath; - } - - public String getName() { - return name; - } - - public String readDesignFile() { - return FileUtil.readFile(designPath); - } - - public String readLayoutFile() { - return FileUtil.readFile(path); - } - - @Override - public int describeContents() { - return 0; - } - - @Override - public void writeToParcel(@NonNull Parcel parcel, int flags) { - parcel.writeString(path); - parcel.writeString(designPath); - parcel.writeString(name); - } - - public static final Parcelable.Creator CREATOR = - new Parcelable.Creator<>() { - @NonNull - @Contract("_ -> new") - public LayoutFile createFromParcel(Parcel in) { - return new LayoutFile(in); - } - - @NonNull - @Contract(value = "_ -> new", pure = true) - public LayoutFile[] newArray(int size) { - return new LayoutFile[size]; - } - }; - - private LayoutFile(@NonNull Parcel parcel) { - path = parcel.readString(); - designPath = parcel.readString(); - name = parcel.readString(); - } -} \ No newline at end of file diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/ProjectFile.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/ProjectFile.kt deleted file mode 100644 index a6992def75..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/ProjectFile.kt +++ /dev/null @@ -1,199 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor - -import android.content.Context -import android.os.Parcel -import android.os.Parcelable -import android.os.Parcelable.Creator -import org.appdevforall.codeonthego.layouteditor.managers.PreferencesManager -import org.appdevforall.codeonthego.layouteditor.utils.Constants -import org.appdevforall.codeonthego.layouteditor.utils.FileUtil -import com.itsaky.androidide.utils.formatDate -import org.jetbrains.annotations.Contract -import java.io.File -import java.nio.file.Files -import java.nio.file.Paths - -class ProjectFile : Parcelable { - - var path: String - private set - - @JvmField - var name: String - - @JvmField - var createdAt: String? = null - - @JvmField - var lastModified: String? = null - - private val mainLayoutName: String - private lateinit var preferencesManager: PreferencesManager - - constructor(path: String, createdAt: String?, lastModified: String?, context: Context, - mainLayoutName: String = "layout_main") { - - this.path = path - this.createdAt = createdAt - this.lastModified = lastModified - this.name = FileUtil.getLastSegmentFromPath(path) - this.mainLayoutName = mainLayoutName - this.preferencesManager = PreferencesManager(context = context) - } - - fun rename(newPath: String) { - val newFile = File(newPath) - val oldFile = File(path) - oldFile.renameTo(newFile) - - path = newPath - name = FileUtil.getLastSegmentFromPath(path) - } - - val drawablePath: String - get() = "$path/drawable/" - - val fontPath: String - get() = "$path/font/" - - val colorsPath: String - get() = "$path/values/colors.xml" - - val stringsPath: String - get() = "$path/values/strings.xml" - - val layoutPath: String - get() = "$path/layout/" - val layoutDesignPath: String - get() = "$path/layout/design/" - - val drawables: Array - get() { - val file = File("$path/drawable") - - if (!file.exists()) { - file.mkdirs() - return emptyArray() - } - - return file.listFiles() ?: emptyArray() - } - - val fonts: Array? - get() { - val file = File("$path/font/") - - if (!file.exists()) { - FileUtil.makeDir("$path/font/") - } - - return file.listFiles() - } - - val layouts: Array? - get() { - val file = File(layoutPath) - if (!file.exists()) { - FileUtil.makeDir(layoutPath) - } - return file.listFiles() - } - - val layoutDesigns: Array? - get() { - val file = File(layoutDesignPath) - if (!file.exists()) { - FileUtil.makeDir(layoutDesignPath) - } - return file.listFiles() - } - - val allLayouts: MutableList - get() { - val list: MutableList = mutableListOf() - layouts?.forEach { file -> - val designFile = File(layoutDesignPath, file.name) - list.add(LayoutFile(file.absolutePath, designFile.absolutePath)) - } - return list - } - - - val mainLayout: LayoutFile - get() = LayoutFile("$layoutPath$mainLayoutName.xml", "$layoutDesignPath$mainLayoutName.xml") - - val mainLayoutDesign: LayoutFile - get() { - Files.createDirectories(Paths.get(layoutDesignPath)) - val file = File("$layoutPath$mainLayoutName.xml", "$layoutDesignPath$mainLayoutName.xml") - file.createNewFile() - return LayoutFile("$layoutPath$mainLayoutName.xml", "$layoutDesignPath$mainLayoutName.xml") - } - - var currentLayout: LayoutFile - get() { - val currentLayoutPath = - preferencesManager.prefs.getString(Constants.CURRENT_LAYOUT, "") ?: "" - val currentLayoutDesignPath = - preferencesManager.prefs.getString(Constants.CURRENT_LAYOUT_DESIGN, "") ?: "" - return LayoutFile(currentLayoutPath, currentLayoutDesignPath) - } - set(value) { - preferencesManager.prefs.edit().apply { - putString(Constants.CURRENT_LAYOUT, value.path) - putString(Constants.CURRENT_LAYOUT_DESIGN, value.designPath) - apply() - } - } - - fun createDefaultLayout() { - FileUtil.writeFile(layoutPath + "layout_main.xml", "") - } - - override fun describeContents(): Int { - return 0 - } - - override fun writeToParcel(parcel: Parcel, flags: Int) { - parcel.writeString(path) - parcel.writeString(name) - } - - private constructor(parcel: Parcel, mainLayoutName: String) { - path = parcel.readString().toString() - name = parcel.readString().toString() - this.mainLayoutName = mainLayoutName - } - - fun renderDateText(context: Context): String { - val showModified = createdAt != lastModified - val renderDate = if (showModified) lastModified else createdAt - - val label = if (showModified) - context.getString(R.string.date_modified_label) - else - context.getString(R.string.date_created_label) - - return context.getString( - R.string.date, - label, - formatDate(renderDate ?: "") - ) - } - - companion object { - - @JvmField - val CREATOR: Creator = object : Creator { - @Contract("_ -> new") - override fun createFromParcel(`in`: Parcel): ProjectFile { - return ProjectFile(`in`, "") - } - - @Contract(value = "_ -> new", pure = true) - override fun newArray(size: Int): Array { - return arrayOfNulls(size) - } - } - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/activities/EditorActivity.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/activities/EditorActivity.kt deleted file mode 100644 index a9c49acbea..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/activities/EditorActivity.kt +++ /dev/null @@ -1,867 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.activities - -import android.annotation.SuppressLint -import android.content.Intent -import android.content.res.Configuration -import android.net.Uri -import android.os.Bundle -import android.os.Handler -import android.os.Looper -import android.util.Log -import android.view.Menu -import android.view.MenuItem -import android.view.View -import android.widget.Toast -import androidx.activity.OnBackPressedCallback -import androidx.appcompat.app.ActionBarDrawerToggle -import androidx.appcompat.view.menu.MenuBuilder -import androidx.appcompat.widget.PopupMenu -import androidx.appcompat.widget.TooltipCompat -import androidx.core.view.GravityCompat -import androidx.core.view.isEmpty -import androidx.drawerlayout.widget.DrawerLayout -import androidx.lifecycle.lifecycleScope -import androidx.recyclerview.widget.LinearLayoutManager -import androidx.recyclerview.widget.RecyclerView -import com.blankj.utilcode.util.ToastUtils -import com.google.android.material.dialog.MaterialAlertDialogBuilder -import com.google.android.material.floatingactionbutton.FloatingActionButton -import com.itsaky.androidide.FeedbackButtonManager -import com.itsaky.androidide.activities.editor.HelpActivity -import com.itsaky.androidide.idetooltips.TooltipCategory -import com.itsaky.androidide.idetooltips.TooltipManager -import com.itsaky.androidide.utils.getCreatedTime -import com.itsaky.androidide.utils.getLastModifiedTime -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.launch -import kotlinx.coroutines.withContext -import org.adfa.constants.CONTENT_KEY -import org.adfa.constants.CONTENT_TITLE_KEY -import org.appdevforall.codeonthego.layouteditor.BaseActivity -import org.appdevforall.codeonthego.layouteditor.LayoutFile -import org.appdevforall.codeonthego.layouteditor.ProjectFile -import org.appdevforall.codeonthego.layouteditor.R -import org.appdevforall.codeonthego.layouteditor.R.string -import org.appdevforall.codeonthego.layouteditor.adapters.LayoutListAdapter -import org.appdevforall.codeonthego.layouteditor.adapters.PaletteListAdapter -import org.appdevforall.codeonthego.layouteditor.databinding.ActivityLayoutEditorBinding -import org.appdevforall.codeonthego.layouteditor.editor.DesignEditor -import org.appdevforall.codeonthego.layouteditor.editor.DeviceConfiguration -import org.appdevforall.codeonthego.layouteditor.editor.DeviceSize -import org.appdevforall.codeonthego.layouteditor.editor.convert.ConvertImportedXml -import org.appdevforall.codeonthego.layouteditor.managers.DrawableManager -import org.appdevforall.codeonthego.layouteditor.managers.IdManager.clear -import org.appdevforall.codeonthego.layouteditor.managers.PreferencesManager -import org.appdevforall.codeonthego.layouteditor.managers.ProjectManager -import org.appdevforall.codeonthego.layouteditor.managers.UndoRedoManager -import org.appdevforall.codeonthego.layouteditor.tools.XmlLayoutGenerator -import org.appdevforall.codeonthego.layouteditor.utils.BitmapUtil.createBitmapFromView -import org.appdevforall.codeonthego.layouteditor.utils.Constants -import org.appdevforall.codeonthego.layouteditor.utils.FileCreator -import org.appdevforall.codeonthego.layouteditor.utils.FilePicker -import org.appdevforall.codeonthego.layouteditor.utils.FileUtil -import org.appdevforall.codeonthego.layouteditor.utils.SBUtils -import org.appdevforall.codeonthego.layouteditor.utils.SBUtils.Companion.make -import org.appdevforall.codeonthego.layouteditor.utils.Utils -import org.appdevforall.codeonthego.layouteditor.utils.doubleArgSafeLet -import org.appdevforall.codeonthego.layouteditor.views.CustomDrawerLayout -import java.io.File - -@SuppressLint("UnsafeOptInUsageError") -class EditorActivity : BaseActivity() { - private lateinit var binding: ActivityLayoutEditorBinding - - private lateinit var drawerLayout: DrawerLayout - private var actionBarDrawerToggle: ActionBarDrawerToggle? = null - - private lateinit var projectManager: ProjectManager - private lateinit var project: ProjectFile - private var feedbackButtonManager: FeedbackButtonManager? = null - - private var undoRedo: UndoRedoManager? = null - private var fileCreator: FileCreator? = null - private var xmlPicker: FilePicker? = null - - private lateinit var layoutAdapter: LayoutListAdapter - - private val updateMenuIconsState: Runnable = Runnable { undoRedo!!.updateButtons() } - private var originalProductionXml: String? = null - private var originalDesignXml: String? = null - private var currentLayoutBasePath: String? = null - - private val onBackPressedCallback = - object : OnBackPressedCallback(true) { - override fun handleOnBackPressed() { - when { - drawerLayout.isDrawerOpen(GravityCompat.START) || - drawerLayout.isDrawerOpen( - GravityCompat.END, - ) -> { - drawerLayout.closeDrawers() - } - - !isProjectReady() -> { - finishAfterTransition() - } - - binding.editorLayout.isLayoutModified() -> { - showSaveChangesDialog() - } - - else -> { - lifecycleScope.launch { - saveXml() - finishAfterTransition() - } - } - } - } - } - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - init() - } - - private fun init() { - binding = ActivityLayoutEditorBinding.inflate(layoutInflater) - - setContentView(binding.root) - setSupportActionBar(binding.topAppBar) - onBackPressedDispatcher.addCallback(this, onBackPressedCallback) - - projectManager = ProjectManager.instance - - projectManager.initManger(context = this) - - defineFileCreator() - defineXmlPicker() - setupDrawerLayout() - setupStructureView() - setupFeedbackButton() - setupDrawerNavigationRail() - setToolbarButtonOnClickListener(binding) - - // todo extract file_key to layouteditor constants and use it in both modules. - // todo extract replace 0 date with actual value. - // todo extract replace activity_main date with actual value. - doubleArgSafeLet( - intent.getStringExtra(Constants.EXTRA_KEY_FILE_PATH), - intent.getStringExtra(Constants.EXTRA_KEY_LAYOUT_FILE_NAME), - ) { filePath, fileName -> - supportActionBar?.title = getString(string.loading_project) - lifecycleScope.launch { - val createdAt = getCreatedTime(filePath).toString() - val modifiedAt = getLastModifiedTime(filePath).toString() - - try { - projectManager.openProject( - ProjectFile( - filePath, - createdAt, - modifiedAt, - this@EditorActivity, - mainLayoutName = fileName - ) - ) - project = projectManager.openedProject!! - invalidateOptionsMenu() - androidToDesignConversion( - Uri.fromFile(File(projectManager.openedProject?.mainLayout?.path ?: "")), - ) - - supportActionBar?.title = project.name - layoutAdapter = LayoutListAdapter(project) - binding.editorLayout.setBackgroundColor( - Utils.getSurfaceColor(this@EditorActivity) - ) - } catch (e: Exception) { - Log.e("EditorActivity", "Error loading project", e) - Toast.makeText( - this@EditorActivity, - getString(string.msg_error_opening_project), - Toast.LENGTH_SHORT - ).show() - finish() - } - } - } ?: showNothingDialog() - } - - private fun defineXmlPicker() { - xmlPicker = - object : FilePicker(this) { - override fun onPickFile(uri: Uri?) { - val path = uri?.path - if (path != null && path.endsWith(".xml")) { - androidToDesignConversion(uri) - } else { - Toast - .makeText( - this@EditorActivity, - getString(string.error_invalid_xml_file), - Toast.LENGTH_SHORT, - ).show() - } - } - } - } - - private fun androidToDesignConversion(uri: Uri?) { - if (uri == null) { - Toast.makeText( - this@EditorActivity, - getString(string.error_invalid_xml_file), - Toast.LENGTH_SHORT - ).show() - return - } - - lifecycleScope.launch { - try { - val fileName = FileUtil.getLastSegmentFromPath(uri.path ?: "") - - if (!fileName.endsWith(".xml", ignoreCase = true)) { - Toast.makeText( - this@EditorActivity, - getString(string.error_invalid_xml_file), - Toast.LENGTH_SHORT - ).show() - return@launch - } - - val xml = withContext(Dispatchers.IO) { - FileUtil.readFromUri(uri, this@EditorActivity) - } ?: run { - make(binding.root, getString(string.error_failed_to_import)) - .setSlideAnimation() - .showAsError() - return@launch - } - - val xmlConverted = withContext(Dispatchers.Default) { - ConvertImportedXml(xml).getXmlConverted(this@EditorActivity) - } - - if (xmlConverted == null) { - make(binding.root, getString(string.error_failed_to_import)) - .setSlideAnimation() - .showAsError() - return@launch - } - - val productionPath = project.layoutPath + fileName - val designPath = project.layoutDesignPath + fileName - withContext(Dispatchers.IO) { - FileUtil.writeFile(productionPath, xml) - FileUtil.writeFile(designPath, xmlConverted) - } - - openLayout(LayoutFile(productionPath, designPath)) - make(binding.root, getString(string.success_imported)) - .setFadeAnimation() - .showAsSuccess() - } catch (t: Throwable) { - make(binding.root, getString(string.error_failed_to_import)) - .setSlideAnimation() - .showAsError() - } - } - } - - private fun defineFileCreator() { - fileCreator = - object : FileCreator(this) { - override fun onCreateFile(uri: Uri) { - val result = XmlLayoutGenerator().generate(binding.editorLayout, true) - - if (FileUtil.saveFile(this@EditorActivity, uri, result)) { - make( - binding.root, - getString(string.success_saved), - ).setSlideAnimation() - .showAsSuccess() - } else { - make(binding.root, getString(string.error_failed_to_save)) - .setSlideAnimation() - .showAsError() - FileUtil.deleteFile(FileUtil.convertUriToFilePath(this@EditorActivity, uri)) - } - } - } - } - - private fun setupDrawerLayout() { - drawerLayout = binding.drawer - actionBarDrawerToggle = - ActionBarDrawerToggle( - this, - drawerLayout, - binding.topAppBar, - string.palette, - string.palette, - ) - - (drawerLayout as CustomDrawerLayout).addDrawerListener(actionBarDrawerToggle!!) - actionBarDrawerToggle!!.syncState() - (drawerLayout as CustomDrawerLayout).addDrawerListener( - object : DrawerLayout.SimpleDrawerListener() { - override fun onDrawerStateChanged(state: Int) { - super.onDrawerStateChanged(state) - undoRedo!!.updateButtons() - } - - override fun onDrawerSlide( - v: View, - slideOffset: Float, - ) { - super.onDrawerSlide(v, slideOffset) - undoRedo!!.updateButtons() - } - - override fun onDrawerClosed(v: View) { - super.onDrawerClosed(v) - undoRedo!!.updateButtons() - } - - override fun onDrawerOpened(v: View) { - super.onDrawerOpened(v) - undoRedo!!.updateButtons() - } - }, - ) - } - - private fun setupStructureView() { - binding.editorLayout.setStructureView(binding.structureView) - - binding.structureView.apply { - onItemClickListener = { - binding.editorLayout.showDefinedAttributes(it) - drawerLayout.closeDrawer(GravityCompat.END) - } - onItemLongClickListener = { view -> - TooltipManager.showTooltip( - context = this@EditorActivity, - anchorView = view, - category = TooltipCategory.CATEGORY_XML, - tag = view.javaClass.superclass.name, - ) - } - } - } - - @SuppressLint("SetTextI18n") - private fun setupDrawerNavigationRail() { - val helpFab = - binding.paletteNavigation.headerView?.findViewById(R.id.help_fab) - - // Set tooltip text for help FAB - TooltipCompat.setTooltipText(helpFab as View, getString(string.help)) - - val paletteMenu = binding.paletteNavigation.menu - paletteMenu - .add(Menu.NONE, 0, Menu.NONE, Constants.TAB_TITLE_COMMON) - .setIcon(R.drawable.android) - paletteMenu - .add(Menu.NONE, 1, Menu.NONE, Constants.TAB_TITLE_TEXT) - .setIcon(R.mipmap.ic_palette_text_view) - paletteMenu - .add(Menu.NONE, 2, Menu.NONE, Constants.TAB_TITLE_BUTTONS) - .setIcon(R.mipmap.ic_palette_button) - paletteMenu - .add(Menu.NONE, 3, Menu.NONE, Constants.TAB_TITLE_WIDGETS) - .setIcon(R.mipmap.ic_palette_view) - paletteMenu - .add(Menu.NONE, 4, Menu.NONE, Constants.TAB_TITLE_LAYOUTS) - .setIcon(R.mipmap.ic_palette_relative_layout) - paletteMenu - .add(Menu.NONE, 5, Menu.NONE, Constants.TAB_TITLE_CONTAINERS) - .setIcon(R.mipmap.ic_palette_view_pager) - - binding.listView.layoutManager = LinearLayoutManager(this, RecyclerView.VERTICAL, false) - - val adapter = PaletteListAdapter(binding.drawer) - try { - adapter.submitPaletteList(projectManager.getPalette(0)) - - binding.paletteNavigation.setOnItemSelectedListener { item: MenuItem -> - try { - adapter.submitPaletteList(projectManager.getPalette(item.itemId)) - binding.paletteText.text = getString(string.label_palette) - binding.title.text = item.title - replaceListViewAdapter(adapter) - } catch (e: Exception) { - Toast - .makeText( - this, - "${getString(string.error_failed_to_load_palette)}: ${e.message}", - Toast.LENGTH_SHORT, - ).show() - } - true - } - replaceListViewAdapter(adapter) - } catch (e: Exception) { - Toast - .makeText( - this, - "${getString(string.error_failed_to_initialize_palette)}: ${e.message}", - Toast.LENGTH_SHORT, - ).show() - } - - helpFab.setOnClickListener { - val intent = - Intent(this, HelpActivity::class.java).apply { - putExtra(CONTENT_KEY, getString(R.string.layout_editor_url)) - putExtra( - CONTENT_TITLE_KEY, - getString(R.string.back_to_cogo), - ) - } - this.startActivity(intent) - } - clear() - } - - private fun replaceListViewAdapter(adapter: RecyclerView.Adapter<*>) { - binding.listView.adapter = adapter - } - - private fun isProjectReady(): Boolean { - if (!::project.isInitialized) { - ToastUtils.showShort(getString(R.string.loading_project)) - return false - } - return true - } - - override fun onOptionsItemSelected(item: MenuItem): Boolean { - val id = item.itemId - undoRedo!!.updateButtons() - if (actionBarDrawerToggle!!.onOptionsItemSelected(item)) return true - - when (id) { - R.id.resources_manager, - R.id.preview, - R.id.export_xml, - R.id.export_as_image, - R.id.save_xml, - R.id.exit_editor, - R.id.edit_xml -> { - if (!isProjectReady()) return false - } - } - - when (id) { - android.R.id.home -> { - drawerLayout.openDrawer(GravityCompat.START) - return true - } - - R.id.undo -> { - binding.editorLayout.undo() - return true - } - - R.id.redo -> { - binding.editorLayout.redo() - return true - } - - R.id.show_structure -> { - drawerLayout.openDrawer(GravityCompat.END) - return true - } - - R.id.edit_xml -> { - showXml() - return true - } - - R.id.resources_manager -> { - startActivity( - Intent(this, ResourceManagerActivity::class.java) - .putExtra(Constants.EXTRA_KEY_PROJECT, project), - ) - return true - } - - R.id.preview -> { - val result = XmlLayoutGenerator().generate(binding.editorLayout, true) - if (result.isEmpty()) { - showNothingDialog() - } else { - lifecycleScope.launch { - saveXml() - startActivity( - Intent(this@EditorActivity, PreviewLayoutActivity::class.java) - .putExtra(Constants.EXTRA_KEY_LAYOUT, project.currentLayout), - ) - } - } - return true - } - - R.id.export_xml -> { - val uri = Uri.fromFile(File(project.currentLayout.path)) - val result = XmlLayoutGenerator().generate(binding.editorLayout, true) - - if (FileUtil.saveFile(this@EditorActivity, uri, result)) { - binding.editorLayout.markAsSaved() - make(binding.root, getString(string.success_saved)) - .setSlideAnimation() - .showAsSuccess() - } else { - make(binding.root, getString(string.error_failed_to_save)) - .setSlideAnimation() - .showAsError() - FileUtil.deleteFile(FileUtil.convertUriToFilePath(this@EditorActivity, uri)) - } - - return true - } - - R.id.export_as_image -> { - if (binding.editorLayout.getChildAt(0) != null) { - showSaveMessage( - Utils.saveBitmapAsImageToGallery( - this, - createBitmapFromView(binding.editorLayout), - project.name, - ), - ) - } else { - make(binding.root, getString(string.info_add_some_views)) - .setFadeAnimation() - .setType(SBUtils.Type.INFO) - .show() - } - return true - } - - R.id.save_xml -> { - MaterialAlertDialogBuilder(this@EditorActivity) - .setTitle(string.save) - .setMessage(string.save_layout_message) - .setCancelable(false) - .setNeutralButton(string.cancel) { d, _ -> - d.cancel() - }.setNegativeButton(string.export_as_image) { d, _ -> - if (binding.editorLayout.getChildAt(0) != null) { - showSaveMessage( - Utils.saveBitmapAsImageToGallery( - this, - createBitmapFromView(binding.editorLayout), - project.name, - ), - ) - } else { - make(binding.root, getString(string.info_add_some_views)) - .setFadeAnimation() - .setType(SBUtils.Type.INFO) - .show() - } - }.setPositiveButton(string.export_layout) { _, _ -> - val uri = Uri.fromFile(File(project.currentLayout.path)) - val result = XmlLayoutGenerator().generate(binding.editorLayout, true) - - if (FileUtil.saveFile(this@EditorActivity, uri, result)) { - binding.editorLayout.markAsSaved() - make(binding.root, getString(string.success_saved)) - .setSlideAnimation() - .showAsSuccess() - } else { - make(binding.root, getString(string.error_failed_to_save)) - .setSlideAnimation() - .showAsError() - FileUtil.deleteFile( - FileUtil.convertUriToFilePath( - this@EditorActivity, - uri, - ), - ) - } - }.show() - return true - } - - R.id.exit_editor -> { - if (binding.editorLayout.isLayoutModified()) { - showSaveChangesDialog() - } else { - lifecycleScope.launch { - saveXml() - finishAfterTransition() - } - } - return true - } - - else -> return false - } - } - - override fun onPrepareOptionsMenu(menu: Menu): Boolean { - val isReady = ::project.isInitialized - menu.findItem(R.id.resources_manager)?.isEnabled = isReady - menu.findItem(R.id.preview)?.isEnabled = isReady - menu.findItem(R.id.export_xml)?.isEnabled = isReady - menu.findItem(R.id.export_as_image)?.isEnabled = isReady - menu.findItem(R.id.save_xml)?.isEnabled = isReady - menu.findItem(R.id.edit_xml)?.isEnabled = isReady - menu.findItem(R.id.exit_editor)?.isEnabled = isReady - return super.onPrepareOptionsMenu(menu) - } - - override fun onConfigurationChanged(config: Configuration) { - super.onConfigurationChanged(config) - actionBarDrawerToggle!!.onConfigurationChanged(config) - undoRedo!!.updateButtons() - } - - override fun onPostCreate(savedInstanceState: Bundle?) { - super.onPostCreate(savedInstanceState) - actionBarDrawerToggle!!.syncState() - if (undoRedo != null) undoRedo!!.updateButtons() - } - - override fun onResume() { - super.onResume() - if (::project.isInitialized) { - DrawableManager.loadFromFiles(project.drawables) - } - if (undoRedo != null) undoRedo!!.updateButtons() - feedbackButtonManager?.loadFabPosition() - } - - override fun onDestroy() { - super.onDestroy() - projectManager.closeProject() - } - - private fun showXml() { - val result = XmlLayoutGenerator().generate(binding.editorLayout, true) - if (result.isEmpty()) { - showNothingDialog() - } else { - lifecycleScope.launch { - saveXml() - finish() - } - } - } - - private fun showNothingDialog() { - MaterialAlertDialogBuilder(this) - .setTitle(string.nothing) - .setMessage(string.msg_add_some_widgets) - .setPositiveButton(string.okay) { d, _ -> d.cancel() } - .show() - } - - @SuppressLint("RestrictedApi") - override fun onCreateOptionsMenu(menu: Menu): Boolean { - if (menu is MenuBuilder) menu.setOptionalIconsVisible(true) - - menuInflater.inflate(R.menu.menu_editor, menu) - val undo = menu.findItem(R.id.undo) - val redo = menu.findItem(R.id.redo) - undoRedo = UndoRedoManager(undo, redo) - binding.editorLayout.bindUndoRedoManager(undoRedo) - binding.editorLayout.updateUndoRedoHistory() - updateUndoRedoBtnState() - return super.onCreateOptionsMenu(menu) - } - - private fun updateUndoRedoBtnState() { - Handler(Looper.getMainLooper()).postDelayed(updateMenuIconsState, 10) - } - - private fun showSaveMessage(success: Boolean) { - if (success) { - make(binding.root, getString(string.success_saved_to_gallery)) - .setFadeAnimation() - .setType(SBUtils.Type.INFO) - .show() - } else { - make(binding.root, getString(string.error_failed_to_save_gallery)) - .setFadeAnimation() - .setType(SBUtils.Type.ERROR) - .show() - } - } - - private fun setToolbarButtonOnClickListener(binding: ActivityLayoutEditorBinding) { - TooltipCompat.setTooltipText(binding.viewType, getString(string.tooltip_view_type)) - TooltipCompat.setTooltipText(binding.deviceSize, getString(string.tooltip_size)) - binding.viewType.setOnClickListener { view -> - val popupMenu = PopupMenu(view.context, view) - popupMenu.inflate(R.menu.menu_view_type) - popupMenu.setOnMenuItemClickListener { - val id = it.itemId - when (id) { - R.id.view_type_design -> { - binding.editorLayout.viewType = DesignEditor.ViewType.DESIGN - } - - R.id.view_type_blueprint -> { - binding.editorLayout.viewType = DesignEditor.ViewType.BLUEPRINT - } - } - true - } - popupMenu.show() - } - binding.deviceSize.setOnClickListener { - val popupMenu = PopupMenu(it.context, it) - popupMenu.inflate(R.menu.menu_device_size) - popupMenu.setOnMenuItemClickListener { item -> - val id = item.itemId - when (id) { - R.id.device_size_small -> { - binding.editorLayout.resizeLayout(DeviceConfiguration(DeviceSize.SMALL)) - } - - R.id.device_size_medium -> { - binding.editorLayout.resizeLayout(DeviceConfiguration(DeviceSize.MEDIUM)) - } - - R.id.device_size_large -> { - binding.editorLayout.resizeLayout(DeviceConfiguration(DeviceSize.LARGE)) - } - } - true - } - popupMenu.show() - } - } - - private suspend fun openLayout(layoutFile: LayoutFile) { - val (production, design, layoutName) = withContext(Dispatchers.IO) { - val production = layoutFile.readLayoutFile() - var design = layoutFile.readDesignFile() - - if (design.isNullOrBlank() && !production.isNullOrBlank()) { - val converted = withContext(Dispatchers.Default) { - ConvertImportedXml(production).getXmlConverted(this@EditorActivity) - } - if (!converted.isNullOrBlank()) { - layoutFile.saveDesignFile(converted) - design = converted - } - } - Triple(production, design, layoutFile.name) - } - originalProductionXml = production - originalDesignXml = design - - currentLayoutBasePath = File(layoutFile.path).parent - binding.editorLayout.loadLayoutFromParser(design, currentLayoutBasePath) - - project.currentLayout = layoutFile - supportActionBar?.subtitle = layoutName - - if (drawerLayout.isDrawerOpen(GravityCompat.START)) { - drawerLayout.closeDrawer(GravityCompat.START) - } - - binding.editorLayout.post { - binding.editorLayout.requestLayout() - binding.editorLayout.invalidate() - binding.editorLayout.updateUndoRedoHistory() - binding.editorLayout.markAsSaved() - } - - make(binding.root, getString(string.success_loaded)) - .setFadeAnimation() - .setType(SBUtils.Type.INFO) - .show() - } - - private fun currentLayoutFileOrNull(): LayoutFile? { - if (!::project.isInitialized) return null - return project.currentLayout - } - - private fun restoreOriginalXmlIfNeeded() { - val xmlToRestore = originalDesignXml ?: originalProductionXml - if (!xmlToRestore.isNullOrBlank()) { - binding.editorLayout.loadLayoutFromParser(xmlToRestore, currentLayoutBasePath) - } - } - - /** - * Writes the current editor state to disk. - * - Generates XML on the current thread (UI-safe) - * - Performs file I/O on Dispatchers.IO - * - No UI side-effects (no toast / no markAsSaved) to keep it reusable - */ - private suspend fun persistEditorLayout(layoutFile: LayoutFile): Boolean { - return runCatching { - if (binding.editorLayout.isEmpty()) { - withContext(Dispatchers.IO) { - layoutFile.saveLayout("") - layoutFile.saveDesignFile("") - } - return@runCatching - } - - val generator = XmlLayoutGenerator() - val productionXml = generator.generate(binding.editorLayout, true) - val designXml = generator.generate(binding.editorLayout, false) - - withContext(Dispatchers.IO) { - layoutFile.saveLayout(productionXml) - layoutFile.saveDesignFile(designXml) - } - }.isSuccess - } - - private suspend fun saveXml() { - val layoutFile = currentLayoutFileOrNull() ?: return - - val success = persistEditorLayout(layoutFile) - if (!success) { - withContext(Dispatchers.Main) { - ToastUtils.showShort(getString(string.failed_to_save_layout)) - } - return - } - - binding.editorLayout.markAsSaved() - ToastUtils.showShort(getString(string.layout_saved)) - } - - private fun showSaveChangesDialog() { - MaterialAlertDialogBuilder(this) - .setTitle(R.string.save_changes) - .setMessage(R.string.msg_save_changes_to_layout) - .setPositiveButton(R.string.save_changes_and_exit) { _, _ -> - lifecycleScope.launch { - saveXml() - finishAfterTransition() - } - }.setNegativeButton(R.string.discard_changes_and_exit) { _, _ -> - lifecycleScope.launch { - val layoutFile = currentLayoutFileOrNull() ?: run { - finishAfterTransition() - return@launch - } - restoreOriginalXmlIfNeeded() - persistEditorLayout(layoutFile) - finishAfterTransition() - } - }.setNeutralButton(R.string.cancel_and_stay_in_editor) { dialog, _ -> - dialog.dismiss() - }.setCancelable(false) - .show() - } - - private fun setupFeedbackButton() { - feedbackButtonManager = FeedbackButtonManager(this, binding.fabFeedback) - feedbackButtonManager?.setupDraggableFab() - } - -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/activities/PreviewDrawableActivity.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/activities/PreviewDrawableActivity.kt deleted file mode 100644 index c8f5506614..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/activities/PreviewDrawableActivity.kt +++ /dev/null @@ -1,33 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.activities - -import android.os.Bundle -import android.widget.ImageView -import androidx.appcompat.app.ActionBar -import org.appdevforall.codeonthego.layouteditor.BaseActivity -import org.appdevforall.codeonthego.layouteditor.R -import org.appdevforall.codeonthego.layouteditor.databinding.ActivityPreviewDrawableBinding -import org.appdevforall.codeonthego.layouteditor.views.AlphaPatternDrawable - -class PreviewDrawableActivity : BaseActivity() { - private lateinit var binding: ActivityPreviewDrawableBinding - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - binding = ActivityPreviewDrawableBinding.inflate(layoutInflater) - setContentView(binding.getRoot()) - - setSupportActionBar(binding.topAppBar) - supportActionBar!!.setTitle(R.string.preview_drawable) - - binding.topAppBar.setNavigationOnClickListener { onBackPressedDispatcher.onBackPressed() } - binding.background.setImageDrawable(AlphaPatternDrawable(24)) - - onLoad(binding.mainImage, supportActionBar) - } - - //todo remove and replace this with some reasonable replacement. - companion object { - @JvmStatic - var onLoad: (ImageView, ActionBar?) -> Unit = { _, _ -> } - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/activities/PreviewLayoutActivity.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/activities/PreviewLayoutActivity.kt deleted file mode 100644 index 4fb5f4f566..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/activities/PreviewLayoutActivity.kt +++ /dev/null @@ -1,52 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.activities - -import android.os.Bundle -import android.view.ViewGroup -import android.view.ViewGroup.LayoutParams -import androidx.appcompat.app.AlertDialog -import org.appdevforall.codeonthego.layouteditor.BaseActivity -import org.appdevforall.codeonthego.layouteditor.LayoutFile -import org.appdevforall.codeonthego.layouteditor.R -import com.itsaky.androidide.resources.R.string -import org.appdevforall.codeonthego.layouteditor.databinding.ActivityPreviewLayoutBinding -import org.appdevforall.codeonthego.layouteditor.tools.XmlLayoutParser -import org.appdevforall.codeonthego.layouteditor.utils.Constants - -class PreviewLayoutActivity : BaseActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - val binding = ActivityPreviewLayoutBinding.inflate(layoutInflater) - setContentView(binding.getRoot()) - @Suppress("DEPRECATION") - val layoutFile = intent.extras?.getParcelable(Constants.EXTRA_KEY_LAYOUT) - val basePath = layoutFile?.path?.let { java.io.File(it).parent } - val parser = XmlLayoutParser(this, basePath) - layoutFile?.readDesignFile()?.let { parser.processXml(it, this) } - - val previewContainer = binding.root.findViewById(R.id.preview_container) - - val layoutParams = LayoutParams( - LayoutParams.MATCH_PARENT, - LayoutParams.MATCH_PARENT - ) - - parser.root?.let { rootView -> - (rootView.parent as? ViewGroup)?.removeView(rootView) - previewContainer.addView(rootView, layoutParams) - } ?: run { - showErrorDialog() - } - } - - private fun showErrorDialog() { - AlertDialog.Builder(this) - .setTitle(getString(string.preview_render_error_title)) - .setMessage(getString(string.preview_render_error_message)) - .setPositiveButton(getString(string.msg_ok)) { dialog, _ -> - dialog.dismiss() - finish() - } - .setCancelable(false) - .show() - } -} \ No newline at end of file diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/activities/ResourceManagerActivity.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/activities/ResourceManagerActivity.kt deleted file mode 100644 index 74e2645ec4..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/activities/ResourceManagerActivity.kt +++ /dev/null @@ -1,327 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.activities - -import android.Manifest -import android.annotation.SuppressLint -import android.content.Intent -import android.content.pm.PackageManager -import android.net.Uri -import android.os.Build -import android.os.Bundle -import android.util.Log -import android.view.Menu -import android.view.MenuItem -import android.widget.ArrayAdapter -import androidx.activity.result.ActivityResultLauncher -import androidx.activity.result.PickVisualMediaRequest -import androidx.activity.result.contract.ActivityResultContracts -import androidx.activity.result.contract.ActivityResultContracts.PickVisualMedia.Companion.isPhotoPickerAvailable -import androidx.activity.result.contract.ActivityResultContracts.PickVisualMedia.ImageOnly -import androidx.annotation.RequiresApi -import androidx.core.content.IntentCompat -import androidx.lifecycle.lifecycleScope -import androidx.viewpager2.widget.ViewPager2 -import com.blankj.utilcode.util.ToastUtils -import com.google.android.material.dialog.MaterialAlertDialogBuilder -import kotlinx.coroutines.launch -import org.appdevforall.codeonthego.layouteditor.BaseActivity -import org.appdevforall.codeonthego.layouteditor.ProjectFile -import org.appdevforall.codeonthego.layouteditor.R -import org.appdevforall.codeonthego.layouteditor.adapters.PagerAdapter -import org.appdevforall.codeonthego.layouteditor.databinding.ActivityResourceManagerBinding -import org.appdevforall.codeonthego.layouteditor.fragments.resources.ColorFragment -import org.appdevforall.codeonthego.layouteditor.fragments.resources.DrawableFragment -import org.appdevforall.codeonthego.layouteditor.fragments.resources.FontFragment -import org.appdevforall.codeonthego.layouteditor.fragments.resources.StringFragment -import org.appdevforall.codeonthego.layouteditor.managers.ProjectManager -import org.appdevforall.codeonthego.layouteditor.utils.Constants -import org.appdevforall.codeonthego.layouteditor.utils.FilePicker -import org.appdevforall.codeonthego.layouteditor.utils.FileUtil -import org.appdevforall.codeonthego.layouteditor.utils.SBUtils -import org.appdevforall.codeonthego.vectormaster.VectorMasterDrawable -import java.io.FileNotFoundException - -class ResourceManagerActivity : BaseActivity() { - private var binding: ActivityResourceManagerBinding? = null - private var project: ProjectFile? = null - private var photoPicker: FilePicker? = null - private var fontPicker: FilePicker? = null - private var xmlPicker: FilePicker? = null - private var pickMedia: ActivityResultLauncher? = null - private var requestPermission: ActivityResultLauncher? = null - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - binding = ActivityResourceManagerBinding.inflate( - layoutInflater - ) - setContentView(binding!!.getRoot()) - setSupportActionBar(binding!!.topAppBar) - supportActionBar!!.setTitle(R.string.res_manager) - binding!!.topAppBar.setNavigationOnClickListener { onBackPressedDispatcher.onBackPressed() } - lifecycleScope.launch { - try { - val projectExtra = IntentCompat.getParcelableExtra(intent, Constants.EXTRA_KEY_PROJECT, ProjectFile::class.java) - project = projectExtra ?: ProjectManager.instance.openedProject - - if (project == null) { - finish() - return@launch - } - - project?.let { resolvedProject -> - if (ProjectManager.instance.openedProject?.path != resolvedProject.path) { - ProjectManager.instance.openProject(resolvedProject) - } - } - - setupViewPager() - } catch (e: Exception) { - ToastUtils.showShort(R.string.msg_error_opening_project) - Log.e("ResourcesManagerActivity", "Error loading project", e) - finish() - } - } - requestPermission = registerForActivityResult( - ActivityResultContracts.RequestPermission() - ) { onRequestPermission(it) } - photoPicker = object : FilePicker(this) { - override fun onPickFile(uri: Uri?) { - onPickPhoto(uri) - } - } - fontPicker = object : FilePicker(this) { - override fun onPickFile(uri: Uri?) { - onPickFont(uri) - } - } - xmlPicker = object : FilePicker(this) { - override fun onPickFile(uri: Uri?) { - onPickXml(uri) - } - } - pickMedia = - registerForActivityResult(ActivityResultContracts.PickVisualMedia()) { uri: Uri? -> - onPickPhoto(uri) - } - } - - @SuppressLint("UseCompatLoadingForDrawables") - private fun setupViewPager() { - val currentProject = project ?: return - val adapter = PagerAdapter(supportFragmentManager, lifecycle) - adapter.setup(binding!!.pager, binding!!.tabLayout) - adapter.addFragmentToAdapter( - DrawableFragment.newInstance(currentProject), - getString(R.string.drawable), - getDrawable(R.drawable.image_outline)!! - ) - adapter.addFragmentToAdapter( - ColorFragment.newInstance(currentProject), - getString(R.string.color), - getDrawable(R.drawable.palette_outline)!! - ) - adapter.addFragmentToAdapter( - StringFragment.newInstance(currentProject), - getString(R.string.string), - getDrawable(R.drawable.format_letter_case)!! - ) - adapter.addFragmentToAdapter( - FontFragment.newInstance(currentProject), - getString(R.string.font), - getDrawable(R.drawable.format_font)!! - ) - adapter.setupPager(ViewPager2.ORIENTATION_HORIZONTAL) - adapter.setupMediatorWithIcon() - } - - override fun onCreateOptionsMenu(menu: Menu): Boolean { - menuInflater.inflate(R.menu.menu_resource_manager, menu) - return super.onCreateOptionsMenu(menu) - } - - override fun onOptionsItemSelected(item: MenuItem): Boolean { - val fragment = supportFragmentManager.findFragmentByTag("f" + binding!!.pager.currentItem) - - return when (item.itemId) { - R.id.menu_add -> { - handleAddResourceAction(fragment) - true - } - R.id.menu_viewxml -> { - handleViewXmlAction(fragment) - true - } - else -> super.onOptionsItemSelected(item) - } - } - - private fun handleAddResourceAction(fragment: androidx.fragment.app.Fragment?) { - if (fragment == null) { - showErrorState("Something went wrong..") - return - } - - when (fragment) { - is DrawableFragment -> showDrawableTypePicker() - is ColorFragment -> fragment.addColor() - is StringFragment -> fragment.addString() - is FontFragment -> fontPicker!!.launch("font/*") - } - } - - private fun handleViewXmlAction(fragment: androidx.fragment.app.Fragment?) { - val currentProject = project - if (currentProject == null) { - showErrorState(R.string.msg_error_opening_project) - return - } - - if (fragment == null) { - showErrorState("Something went wrong..") - return - } - - when (fragment) { - is ColorFragment -> launchXmlViewer(currentProject.colorsPath) - is StringFragment -> launchXmlViewer(currentProject.stringsPath) - else -> { - SBUtils.make(binding!!.getRoot(), "Unavailable for this fragment..") - .setSlideAnimation() - .showAsSuccess() - } - } - } - - private fun showDrawableTypePicker() { - MaterialAlertDialogBuilder(this) - .setTitle(R.string.select_drawable_type) - .setAdapter( - ArrayAdapter( - this, - android.R.layout.simple_list_item_1, - arrayOf("Vector Drawable", "Image Drawable") - ) - ) { _, w: Int -> - when (w) { - 0 -> xmlPicker!!.launch("text/xml") - 1 -> if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { - launchPhotoPicker() - } else { - photoPicker?.launch("image/*") - } - } - } - .show() - } - - private fun launchXmlViewer(filePath: String) { - val intent = Intent(this, ShowXMLActivity::class.java).apply { - putExtra(ShowXMLActivity.EXTRA_KEY_XML, FileUtil.readFile(filePath)) - } - startActivity(intent) - } - - private fun showErrorState(message: String) { - SBUtils.make(binding!!.getRoot(), message) - .setSlideAnimation() - .showAsError() - } - - private fun showErrorState(messageResId: Int) { - SBUtils.make(binding!!.getRoot(), messageResId) - .setSlideAnimation() - .showAsError() - } - - @RequiresApi(api = Build.VERSION_CODES.TIRAMISU) - private fun launchPhotoPicker() { - if (isPhotoPickerAvailable(this)) { - if (checkSelfPermission(Manifest.permission.READ_MEDIA_IMAGES) - == PackageManager.PERMISSION_DENIED - ) { - requestPermission!!.launch(Manifest.permission.READ_MEDIA_IMAGES) - return - } - // Launch the photo picker and allow the user to choose only images. - pickMedia!!.launch( - PickVisualMediaRequest.Builder() - .setMediaType(ImageOnly) - .build() - ) - } else { - photoPicker!!.launch("image/*") - } - } - - private fun onPickPhoto(uri: Uri?) { - if (uri != null) { - Log.d("PhotoPicker", "Selected URI: $uri") - if (FileUtil.isDownloadsDocument(uri)) { - SBUtils.make(binding!!.getRoot(), R.string.select_from_storage).showAsError() - return - } - val fragment = supportFragmentManager.findFragmentByTag("f" + binding!!.pager.currentItem) - if (fragment is DrawableFragment) { - fragment.addDrawable(uri) - } - } else { - Log.d("PhotoPicker", "No media selected") - SBUtils.make(binding!!.getRoot(), "No image selected").setFadeAnimation().show() - } - } - - private fun onPickFont(uri: Uri?) { - if (uri != null) { - Log.d("FontPicker", "Selected URI: $uri") - if (FileUtil.isDownloadsDocument(uri)) { - SBUtils.make(binding!!.getRoot(), R.string.select_from_storage).showAsError() - return - } - val fragment = supportFragmentManager.findFragmentByTag("f" + binding!!.pager.currentItem) - if (fragment is FontFragment) { - fragment.addFont(uri) - } - } else { - Log.d("FontPicker", "No font selected") - SBUtils.make(binding!!.getRoot(), "No font selected").setFadeAnimation().show() - } - } - - private fun onPickXml(uri: Uri?) { - if (uri != null) { - Log.d("DrawablePicker", "Selected URI: $uri") - if (FileUtil.isDownloadsDocument(uri)) { - SBUtils.make(binding!!.getRoot(), R.string.select_from_storage).showAsError() - return - } - val fragment = supportFragmentManager.findFragmentByTag("f" + binding!!.pager.currentItem) - if (fragment is DrawableFragment) { - try { - val drawable = VectorMasterDrawable(this) - drawable.setInputStream(contentResolver.openInputStream(uri)) - if (drawable.isVector) fragment.addDrawable(uri) else SBUtils.make( - binding!!.getRoot(), "Not a valid vector drawable" - ) - .setFadeAnimation() - .setType(SBUtils.Type.INFO) - .show() - } catch (e: FileNotFoundException) { - e.printStackTrace() - ToastUtils.showShort(e.toString()) - } - } - } else { - Log.d("DrawablePicker", "No drawable selected") - SBUtils.make(binding!!.getRoot(), "No drawable selected").setFadeAnimation().show() - } - } - - private fun onRequestPermission(isGranted: Boolean) { - if (isGranted) SBUtils.make(findViewById(android.R.id.content), R.string.permission_granted) - .setSlideAnimation() - .showAsSuccess() else SBUtils.make( - findViewById(android.R.id.content), - R.string.permission_denied - ).setSlideAnimation().showAsError() - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/activities/ShowXMLActivity.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/activities/ShowXMLActivity.kt deleted file mode 100644 index 8f18437c8a..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/activities/ShowXMLActivity.kt +++ /dev/null @@ -1,120 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.activities - -import android.graphics.Typeface -import android.os.Bundle -import androidx.core.content.res.ResourcesCompat -import com.blankj.utilcode.util.ClipboardUtils -import io.github.rosemoe.sora.langs.textmate.TextMateColorScheme -import io.github.rosemoe.sora.langs.textmate.TextMateLanguage -import io.github.rosemoe.sora.langs.textmate.registry.FileProviderRegistry -import io.github.rosemoe.sora.langs.textmate.registry.GrammarRegistry -import io.github.rosemoe.sora.langs.textmate.registry.ThemeRegistry -import io.github.rosemoe.sora.langs.textmate.registry.model.ThemeModel -import io.github.rosemoe.sora.langs.textmate.registry.provider.AssetsFileResolver -import io.github.rosemoe.sora.widget.schemes.EditorColorScheme -import org.appdevforall.codeonthego.layouteditor.BaseActivity -import org.appdevforall.codeonthego.layouteditor.R -import org.appdevforall.codeonthego.layouteditor.databinding.ActivityShowXMLBinding -import org.appdevforall.codeonthego.layouteditor.utils.SBUtils.Companion.make -import org.eclipse.tm4e.core.registry.IThemeSource - -class ShowXMLActivity : BaseActivity() { - private var binding: ActivityShowXMLBinding? = null - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - binding = ActivityShowXMLBinding.inflate(layoutInflater) - - setContentView(binding!!.getRoot()) - setSupportActionBar(binding!!.topAppBar) - supportActionBar!!.setTitle(R.string.xml_preview) - - binding!!.topAppBar.setNavigationOnClickListener { onBackPressedDispatcher.onBackPressed() } - - binding!!.editor.apply { - setText(intent.getStringExtra(EXTRA_KEY_XML)) - typefaceText = jetBrainsMono() - typefaceLineNumber = jetBrainsMono() - isEditable = false - } - try { - loadDefaultThemes() - ThemeRegistry.getInstance().setTheme("darcula") - loadDefaultLanguages() - - ensureTextmateTheme() - - val editor = binding!!.editor - val language = TextMateLanguage.create("text.xml", true) - editor.setEditorLanguage(language) - } catch (e: Exception) { - e.printStackTrace() - } - - binding!!.fab.setOnClickListener { - ClipboardUtils.copyText(binding!!.editor.text.toString()) - make(binding!!.getRoot(), getString(R.string.copied)) - .setAnchorView(binding!!.fab) - .setSlideAnimation() - .show() - } - - binding!!.editor.setOnScrollChangeListener { _, _, y, _, oldY -> - if (y > oldY + 20 && binding!!.fab.isExtended) { - binding!!.fab.shrink() - } - if (y < oldY - 20 && !binding!!.fab.isExtended) { - binding!!.fab.extend() - } - if (y == 0) { - binding!!.fab.extend() - } - } - } - - override fun onDestroy() { - binding = null - super.onDestroy() - } - - @Throws(Exception::class) - private fun loadDefaultThemes() { - // add assets file provider - FileProviderRegistry.getInstance() - .addFileProvider(AssetsFileResolver(applicationContext.assets)) - - val themeRegistry = ThemeRegistry.getInstance() - val path = "editor/textmate/darcula.json" - themeRegistry.loadTheme( - ThemeModel( - IThemeSource.fromInputStream( - FileProviderRegistry.getInstance().tryGetInputStream(path), path, null - ), "darcula" - ) - ) - - themeRegistry.setTheme("darcula") - } - - private fun loadDefaultLanguages() { - GrammarRegistry.getInstance().loadGrammars("editor/textmate/languages.json") - } - - @Throws(Exception::class) - private fun ensureTextmateTheme() { - val editor = binding!!.editor - var editorColorScheme: EditorColorScheme? = editor.colorScheme - if (editorColorScheme !is TextMateColorScheme) { - editorColorScheme = TextMateColorScheme.create(ThemeRegistry.getInstance()) - editor.colorScheme = editorColorScheme - } - } - - private fun jetBrainsMono(): Typeface? { - return ResourcesCompat.getFont(this, R.font.jetbrains_mono_regular) - } - - companion object { - const val EXTRA_KEY_XML: String = "xml" - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/adapters/AppliedAttributesAdapter.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/adapters/AppliedAttributesAdapter.kt deleted file mode 100644 index 547ad17140..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/adapters/AppliedAttributesAdapter.kt +++ /dev/null @@ -1,61 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.adapters - -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import androidx.appcompat.widget.TooltipCompat -import androidx.recyclerview.widget.RecyclerView -import com.itsaky.androidide.idetooltips.TooltipCategory -import com.itsaky.androidide.utils.displayTooltipOnLongPress -import org.appdevforall.codeonthego.layouteditor.databinding.ShowAttributeItemBinding -import org.appdevforall.codeonthego.layouteditor.utils.Constants - -class AppliedAttributesAdapter( - private val attrs: List>, - private val values: List -) : RecyclerView.Adapter() { - - var onClick: (Int) -> Unit = {} - var onRemoveButtonClick: (Int) -> Unit = {} - - class VH(var binding: ShowAttributeItemBinding) : RecyclerView.ViewHolder( - binding.root - ) { - var btnRemove = binding.btnRemoveAttribute - var attributeName = binding.attributeName - var attributeValue = binding.attributeValue - } - - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): VH { - return VH( - ShowAttributeItemBinding.inflate(LayoutInflater.from(parent.context), parent, false) - ) - } - - override fun onBindViewHolder(holder: VH, position: Int) { - val attributeName = attrs[position]["name"].toString() - holder.attributeName.text = attributeName - holder.attributeValue.text = values[position] - - TooltipCompat.setTooltipText(holder.btnRemove, "Remove") - - if (attrs[position].containsKey(Constants.KEY_CAN_DELETE)) { - holder.btnRemove.visibility = View.GONE - } - - holder.binding.root.apply { - setOnClickListener { onClick(position) } - displayTooltipOnLongPress( - context = this.context, - anchorView = this, - tooltipCategory = TooltipCategory.CATEGORY_XML, - tooltipTag = attributeName.substringAfterLast(":") - ) - } - holder.btnRemove.setOnClickListener { onRemoveButtonClick(position) } - } - - override fun getItemCount(): Int { - return attrs.size - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/adapters/AvailableAttributesAdapter.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/adapters/AvailableAttributesAdapter.kt deleted file mode 100644 index f257368ca9..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/adapters/AvailableAttributesAdapter.kt +++ /dev/null @@ -1,48 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.adapters - -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import android.widget.TextView -import androidx.recyclerview.widget.RecyclerView - -class AvailableAttributesAdapter( - private var attributes: List, - private val onAttributeClick: (String) -> Unit -) : RecyclerView.Adapter() { - - private var filteredAttributes: List = attributes - - class ViewHolder(view: View) : RecyclerView.ViewHolder(view) { - val textView: TextView = view.findViewById(android.R.id.text1) - } - - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { - val view = LayoutInflater.from(parent.context) - .inflate(android.R.layout.simple_list_item_1, parent, false) - return ViewHolder(view) - } - - override fun onBindViewHolder(holder: ViewHolder, position: Int) { - val attribute = filteredAttributes[position] - holder.textView.text = attribute - holder.itemView.setOnClickListener { onAttributeClick(attribute) } - } - - override fun getItemCount(): Int = filteredAttributes.size - - fun filter(query: String) { - filteredAttributes = if (query.isEmpty()) { - attributes - } else { - attributes.filter { it.contains(query, ignoreCase = true) } - } - notifyDataSetChanged() - } - - fun updateAttributes(newAttributes: List) { - attributes = newAttributes - filteredAttributes = newAttributes - notifyDataSetChanged() - } -} \ No newline at end of file diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/adapters/ColorResourceAdapter.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/adapters/ColorResourceAdapter.kt deleted file mode 100644 index 42e45df66d..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/adapters/ColorResourceAdapter.kt +++ /dev/null @@ -1,292 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.adapters - -import android.annotation.SuppressLint -import android.graphics.Color -import android.graphics.drawable.Drawable -import android.graphics.drawable.GradientDrawable -import android.text.Editable -import android.text.TextWatcher -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import android.view.animation.AnimationUtils -import android.widget.TextView -import androidx.annotation.ColorInt -import androidx.appcompat.app.AlertDialog -import androidx.appcompat.widget.PopupMenu -import androidx.appcompat.widget.TooltipCompat -import androidx.core.graphics.ColorUtils -import androidx.core.graphics.toColorInt -import androidx.recyclerview.widget.RecyclerView -import com.blankj.utilcode.util.ClipboardUtils -import com.google.android.material.dialog.MaterialAlertDialogBuilder -import com.skydoves.colorpickerview.ColorPickerDialog -import com.skydoves.colorpickerview.listeners.ColorEnvelopeListener -import org.appdevforall.codeonthego.layouteditor.ProjectFile -import org.appdevforall.codeonthego.layouteditor.R -import org.appdevforall.codeonthego.layouteditor.adapters.models.ValuesItem -import org.appdevforall.codeonthego.layouteditor.databinding.LayoutColorItemBinding -import org.appdevforall.codeonthego.layouteditor.databinding.LayoutValuesItemDialogBinding -import org.appdevforall.codeonthego.layouteditor.tools.ColorPickerDialogFlag -import org.appdevforall.codeonthego.layouteditor.utils.FileUtil -import org.appdevforall.codeonthego.layouteditor.utils.NameErrorChecker -import org.appdevforall.codeonthego.layouteditor.utils.SBUtils - -class ColorResourceAdapter( - private val project: ProjectFile, - private val colorList: MutableList -) : RecyclerView.Adapter() { - - class VH(var binding: LayoutColorItemBinding) : RecyclerView.ViewHolder(binding.root) { - val colorName: TextView = binding.colorName - val colorValue: TextView = binding.colorValue - val colorPreview = binding.colorPreview - } - - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): VH { - return VH( - LayoutColorItemBinding.inflate(LayoutInflater.from(parent.context), parent, false) - ) - } - - override fun onBindViewHolder(holder: VH, position: Int) { - holder.itemView.animation = AnimationUtils.loadAnimation( - holder.itemView.context, R.anim.project_list_animation - ) - - val item = colorList[position] - holder.colorName.text = item.name - holder.colorValue.text = item.value - - val colorInt = getSafeColorInt(item.value) - - if (colorInt != null) { - holder.colorValue.setTextColor(Color.DKGRAY) - holder.colorPreview.setImageDrawable(drawCircle(colorInt)) - } else { - holder.colorValue.text = "${item.value} (Error)" - holder.colorValue.setTextColor(Color.RED) - holder.colorPreview.setImageDrawable(drawCircle(Color.LTGRAY)) - } - - TooltipCompat.setTooltipText(holder.itemView, item.name) - TooltipCompat.setTooltipText(holder.binding.menu, "Options") - - holder.binding.menu.setOnClickListener { showOptions(it, position) } - holder.itemView.setOnClickListener { editColor(it, position) } - } - - /** - * Returns the total number of items in the data set held by the adapter. - * - * @return The total number of items. - */ - override fun getItemCount(): Int = colorList.size - - /** - * Generates the content for the colors.xml file based on the current list - * and writes it to the project's file system. - */ - fun generateColorsXml() { - val colorsPath = project.colorsPath - val sb = StringBuilder() - sb.append("\n") - for (colorItem in colorList) { - // Generate color item code - sb.append("\t") - .append(colorItem.value) - .append("\n") - } - sb.append("") - FileUtil.writeFile(colorsPath, sb.toString().trim { it <= ' ' }) - } - - /** - * Shows a popup menu with options for the selected item (Copy Name, Delete). - * - * @param v The view that anchored the popup menu. - * @param position The adapter position of the item. - */ - private fun showOptions(v: View, position: Int) { - val popupMenu = PopupMenu(v.context, v) - popupMenu.inflate(R.menu.menu_values) - popupMenu.setOnMenuItemClickListener { - when (it.itemId) { - R.id.menu_copy_name -> { - ClipboardUtils.copyText(colorList[position].name) - SBUtils.make(v, "${v.context.getString(R.string.copied)} ${colorList[position].name}") - .setSlideAnimation().showAsSuccess() - true - } - R.id.menu_delete -> { - MaterialAlertDialogBuilder(v.context) - .setTitle(R.string.remove_color_dialog_title) - .setMessage(v.context.getString(R.string.msg_confirm_remove_color, colorList[position].name)) - .setNegativeButton(R.string.no, null) - .setPositiveButton(R.string.yes) { _, _ -> - if (colorList[position].name == "default_color") { - SBUtils.make(v, v.context.getString(R.string.msg_cannot_delete_default, "color")) - .setFadeAnimation().setType(SBUtils.Type.INFO).show() - } else { - colorList.removeAt(position) - notifyItemRemoved(position) - generateColorsXml() - } - } - .show() - true - } - else -> false - } - } - popupMenu.show() - } - - @SuppressLint("SetTextI18n") - private fun editColor(itemView: View, pos: Int) { - val context = itemView.context - val binding = LayoutValuesItemDialogBinding.inflate(LayoutInflater.from(context)) - val item = colorList[pos] - - // 1. Setup Views - binding.textinputName.setText(item.name) - binding.textinputValue.setText(item.value) - - // 2. Setup Dialog - val dialog = MaterialAlertDialogBuilder(context) - .setTitle(R.string.edit_color_dialog_title) - .setView(binding.root) - .setNegativeButton(R.string.cancel, null) - .setPositiveButton(R.string.okay) { _, _ -> - performSaveColor(itemView, pos, binding) - } - .create() - - // 3. Setup Logic Components - setupColorPickerInteraction(itemView, binding) - setupValidation(dialog, binding, pos) - - dialog.show() - - // Initial Check (Trigger validation immediately to set button state) - validateEditForm(dialog, binding, pos) - } - - private fun performSaveColor(v: View, pos: Int, binding: LayoutValuesItemDialogBinding) { - val newName = binding.textinputName.text.toString() - val newValue = binding.textinputValue.text.toString() - val item = colorList[pos] - - if (item.name == "default_color" && newName != "default_color") { - SBUtils.make(v, v.context.getString(R.string.msg_cannot_rename_default, "color")) - .setFadeAnimation() - .setType(SBUtils.Type.INFO) - .show() - return - } - - item.name = newName - item.value = newValue - - notifyItemChanged(pos) - generateColorsXml() - } - - private fun setupColorPickerInteraction(v: View, binding: LayoutValuesItemDialogBinding) { - binding.textInputLayoutValue.setEndIconOnClickListener { - val initialColorInt = getSafeColorInt(binding.textinputValue.text.toString()) ?: Color.WHITE - - val builder = ColorPickerDialog.Builder(v.context) - .setTitle(R.string.color_picker_dialog_title) - .setPositiveButton(v.context.getString(R.string.confirm), - ColorEnvelopeListener { envelope, _ -> - binding.textinputValue.setText("#${envelope.hexCode}") - binding.textInputLayoutValue.error = null - } - ) - .setNegativeButton(v.context.getString(R.string.cancel)) { d, _ -> d.dismiss() } - .attachAlphaSlideBar(true) - .attachBrightnessSlideBar(true) - .setBottomSpace(12) - - builder.colorPickerView.apply { - setFlagView(ColorPickerDialogFlag(v.context)) - setInitialColor(initialColorInt) - } - builder.show() - } - } - - /** - * Sets up listeners for both Name and Value fields. - */ - private fun setupValidation(dialog: AlertDialog, binding: LayoutValuesItemDialogBinding, pos: Int) { - val textWatcher = object : TextWatcher { - override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {} - override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {} - - override fun afterTextChanged(s: Editable?) { - // Call the central validation method whenever text changes in EITHER field - validateEditForm(dialog, binding, pos) - } - } - - binding.textinputName.addTextChangedListener(textWatcher) - binding.textinputValue.addTextChangedListener(textWatcher) - } - - /** - * Central validation logic. Checks both Name and Value validity. - * Updates UI errors and Button state. - */ - private fun validateEditForm(dialog: AlertDialog, binding: LayoutValuesItemDialogBinding, pos: Int) { - val nameInput = binding.textinputName.text.toString() - val valueInput = binding.textinputValue.text.toString() - - // 1. Check Name (Using helper) - NameErrorChecker.checkForValues(nameInput, binding.textInputLayoutName, dialog, colorList, pos) - // NameErrorChecker sets the error on the layout, so we check if error is null - val isNameValid = binding.textInputLayoutName.error == null && nameInput.isNotBlank() - - // 2. Check Color Value - val isValidColor = getSafeColorInt(valueInput) != null - if (isValidColor) { - binding.textInputLayoutValue.error = null - binding.textInputLayoutValue.isErrorEnabled = false - } else { - binding.textInputLayoutValue.error = dialog.context.getString(R.string.error_invalid_color) - } - - // 3. Update Button State (Only enabled if BOTH are valid) - dialog.getButton(AlertDialog.BUTTON_POSITIVE).isEnabled = isNameValid && isValidColor - } - - private fun drawCircle(@ColorInt backgroundColor: Int): Drawable { - return GradientDrawable().apply { - shape = GradientDrawable.OVAL - cornerRadii = floatArrayOf(0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f) - setColor(backgroundColor) - setStroke(2, getContrastStrokeColor(backgroundColor)) - } - } - - private fun getContrastStrokeColor(@ColorInt color: Int): Int { - if (ColorUtils.calculateLuminance(color) >= 0.5) { - return "#FF313131".toColorInt() - } - return "#FFD9D9D9".toColorInt() - } - - private fun getSafeColorInt(value: String): Int? { - val directParse = runCatching { value.toColorInt() }.getOrNull() - if (directParse != null) return directParse - - if (!value.startsWith("#")) { - val fixedParse = runCatching { "#$value".toColorInt() }.getOrNull() - if (fixedParse != null) return fixedParse - } - return null - } -} \ No newline at end of file diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/adapters/DPIsListAdapter.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/adapters/DPIsListAdapter.kt deleted file mode 100644 index 99e7db4682..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/adapters/DPIsListAdapter.kt +++ /dev/null @@ -1,77 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.adapters - -import android.annotation.SuppressLint -import android.graphics.drawable.Drawable -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import android.widget.RelativeLayout -import androidx.recyclerview.widget.RecyclerView -import org.appdevforall.codeonthego.layouteditor.databinding.LayoutSelectDpiItemBinding -import org.appdevforall.codeonthego.layouteditor.utils.Utils -import java.util.Collections - -class DPIsListAdapter(private val image: Drawable) : RecyclerView.Adapter() { - private val dpiList: MutableList = ArrayList() - private val mSelectedItems: MutableList - - init { - dpiList.add("ldpi") - dpiList.add("mdpi") - dpiList.add("hdpi") - dpiList.add("xhdpi") - dpiList.add("xxhdpi") - dpiList.add("xxxhdpi") - - mSelectedItems = ArrayList(Collections.nCopies(dpiList.size, false)) - } - - inner class VH(binding: LayoutSelectDpiItemBinding) : RecyclerView.ViewHolder(binding.root) { - var shadowView = binding.shadowView - var image = binding.image - var checkbox = binding.checkbox - var dpiName = binding.dpiName - } - - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): VH { - return VH( - LayoutSelectDpiItemBinding.inflate( - LayoutInflater.from(parent.context), parent, false - ) - ) - } - - @SuppressLint("SetTextI18n") - override fun onBindViewHolder(holder: VH, position: Int) { - holder.image.layoutParams = - RelativeLayout.LayoutParams(Utils.getScreenWidth() / 2, Utils.getScreenWidth() / 2) - holder.shadowView.layoutParams = - RelativeLayout.LayoutParams(Utils.getScreenWidth() / 2, Utils.getScreenWidth() / 2) - val dpi = dpiList[position] - holder.image.setImageDrawable(image) - holder.dpiName.text = "drawable-$dpi" - holder.checkbox.isChecked = mSelectedItems[position] - holder.shadowView.visibility = if (mSelectedItems[position]) View.VISIBLE else View.INVISIBLE - - holder.itemView.setOnClickListener { - val isChecked = !mSelectedItems[position] - mSelectedItems[position] = isChecked - holder.checkbox.isChecked = isChecked - } - } - - override fun getItemCount(): Int { - return dpiList.size - } - - val selectedItems: List - get() { - val selectedItems: MutableList = ArrayList() - for (i in mSelectedItems.indices) { - if (mSelectedItems[i]) { - selectedItems.add(dpiList[i]) - } - } - return selectedItems - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/adapters/DrawableResourceAdapter.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/adapters/DrawableResourceAdapter.kt deleted file mode 100644 index 6e2328cf64..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/adapters/DrawableResourceAdapter.kt +++ /dev/null @@ -1,126 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.adapters - -import android.annotation.SuppressLint -import android.content.Intent -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import android.view.animation.AnimationUtils -import androidx.appcompat.widget.PopupMenu -import androidx.appcompat.widget.TooltipCompat -import androidx.recyclerview.widget.RecyclerView -import com.blankj.utilcode.util.ClipboardUtils -import org.appdevforall.codeonthego.layouteditor.R -import org.appdevforall.codeonthego.layouteditor.activities.PreviewDrawableActivity -import org.appdevforall.codeonthego.layouteditor.adapters.models.DrawableFile -import org.appdevforall.codeonthego.layouteditor.databinding.LayoutDrawableItemBinding -import org.appdevforall.codeonthego.layouteditor.utils.SBUtils.Companion.make -import org.appdevforall.codeonthego.layouteditor.views.AlphaPatternDrawable - -class DrawableResourceAdapter( - private var drawableList: MutableList, - private val listener: OnDrawableActionListener -) : - RecyclerView.Adapter() { - - interface OnDrawableActionListener { - fun onRenameRequested(position: Int) - fun onDeleteRequested(position: Int) - } - - inner class VH(var binding: LayoutDrawableItemBinding) : RecyclerView.ViewHolder( - binding.root - ) { - var drawableName = binding.drawableName - var imageType = binding.imageType - var versions = binding.versions - var drawable = binding.drawable - var drawableBackground = binding.background - } - - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): VH { - return VH( - LayoutDrawableItemBinding.inflate(LayoutInflater.from(parent.context), parent, false) - ) - } - - @SuppressLint("SetTextI18n") - override fun onBindViewHolder(holder: VH, position: Int) { - val name = drawableList[position].name - holder.itemView.animation = AnimationUtils.loadAnimation( - holder.itemView.context, R.anim.project_list_animation - ) - - holder.drawableName.text = name.substring(0, name.lastIndexOf(".")) - holder.imageType.text = "Drawable" - - val version = drawableList[position].versions - holder.versions.text = "$version version${if (version > 1) "s" else ""}" - holder.drawableBackground.setImageDrawable(AlphaPatternDrawable(16)) - - TooltipCompat.setTooltipText( - holder.binding.root, name.substring(0, name.lastIndexOf(".")) - ) - TooltipCompat.setTooltipText(holder.binding.menu, "Options") - - holder.drawable.setImageDrawable(drawableList[position].drawable) - holder.binding.menu.setOnClickListener { - showOptions( - it, - holder.absoluteAdapterPosition, - holder - ) - } - - holder.itemView.setOnClickListener { - PreviewDrawableActivity.onLoad = { imageView, actionBar -> - imageView.setImageDrawable(drawableList[holder.absoluteAdapterPosition].drawable) - actionBar?.subtitle = name - } - it.context.startActivity(Intent(it.context, PreviewDrawableActivity::class.java)) - } - } - - override fun getItemCount(): Int { - return drawableList.size - } - - private fun showOptions(v: View, position: Int, holder: VH) { - val popupMenu = PopupMenu(v.context, v) - popupMenu.inflate(R.menu.menu_drawable) - popupMenu.setOnMenuItemClickListener { - val id = it.itemId - when (id) { - R.id.menu_copy_name -> { - ClipboardUtils.copyText( - drawableList[position].name - .substring(0, drawableList[position].name.lastIndexOf(".")) - ) - make(holder.binding.root, v.context.getString(R.string.copied)) - .setSlideAnimation() - .showAsSuccess() - true - } - - R.id.menu_delete -> { - listener.onDeleteRequested(position) - true - } - - R.id.menu_rename -> { - listener.onRenameRequested(position) - true - } - - else -> false - } - } - - popupMenu.show() - } - - fun getItemAt(position: Int): DrawableFile { - return drawableList[position] - } - -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/adapters/FontResourceAdapter.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/adapters/FontResourceAdapter.kt deleted file mode 100644 index 795fd292be..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/adapters/FontResourceAdapter.kt +++ /dev/null @@ -1,202 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.adapters - -import android.annotation.SuppressLint -import android.content.Context -import android.graphics.Typeface -import android.text.Editable -import android.text.TextWatcher -import android.view.LayoutInflater -import android.view.MenuItem -import android.view.View -import android.view.ViewGroup -import android.view.WindowManager -import android.view.animation.AnimationUtils -import android.view.inputmethod.InputMethodManager -import androidx.appcompat.widget.PopupMenu -import androidx.recyclerview.widget.RecyclerView -import com.blankj.utilcode.util.ClipboardUtils -import com.google.android.material.dialog.MaterialAlertDialogBuilder -import org.appdevforall.codeonthego.layouteditor.R -import org.appdevforall.codeonthego.layouteditor.adapters.models.FontItem -import org.appdevforall.codeonthego.layouteditor.databinding.LayoutFontItemBinding -import org.appdevforall.codeonthego.layouteditor.databinding.TextinputlayoutBinding -import org.appdevforall.codeonthego.layouteditor.managers.ProjectManager.Companion.instance -import org.appdevforall.codeonthego.layouteditor.utils.FileUtil.deleteFile -import org.appdevforall.codeonthego.layouteditor.utils.FileUtil.getLastSegmentFromPath -import org.appdevforall.codeonthego.layouteditor.utils.NameErrorChecker -import org.appdevforall.codeonthego.layouteditor.utils.SBUtils -import org.appdevforall.codeonthego.layouteditor.utils.SBUtils.Companion.make -import org.appdevforall.codeonthego.layouteditor.utils.Utils -import java.io.File - -class FontResourceAdapter(private val fontList: MutableList) : - RecyclerView.Adapter() { - private val project = instance.openedProject - - class VH(var binding: LayoutFontItemBinding) : RecyclerView.ViewHolder( - binding.root - ) { - var fontName = binding.name - var fontLook = binding.fontLook - } - - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): VH { - return VH( - LayoutFontItemBinding.inflate(LayoutInflater.from(parent.context), parent, false) - ) - } - - override fun onBindViewHolder(holder: VH, position: Int) { - val fontName = fontList[position].name - holder - .binding - .root.animation = AnimationUtils.loadAnimation( - holder.itemView.context, R.anim.project_list_animation - ) - holder.fontName.text = fontName.substring(0, fontName.lastIndexOf(".")) - holder.fontLook.typeface = Typeface.createFromFile(File(fontList[position].path)) - - holder - .itemView - .setOnClickListener { - ClipboardUtils.copyText(fontName.substring(0, fontName.lastIndexOf("."))) - make( - holder.binding.root, - "${it.context.getString(R.string.copied)} $fontName" - ) - .setSlideAnimation() - .showAsSuccess() - } - holder.binding.menu.setOnClickListener { - showOptions( - it, - holder.absoluteAdapterPosition, - holder - ) - } - } - - override fun getItemCount(): Int { - return fontList.size - } - - private fun showOptions(v: View, position: Int, holder: VH) { - val popupMenu = PopupMenu(v.context, v) - popupMenu.inflate(R.menu.menu_font) - popupMenu.setOnMenuItemClickListener { item: MenuItem -> - val id = item.itemId - when (id) { - R.id.menu_delete -> { - MaterialAlertDialogBuilder(v.context) - .setTitle(R.string.remove_font) - .setMessage(R.string.msg_remove_font) - .setNegativeButton(R.string.no) { d, _ -> d.dismiss() } - .setPositiveButton( - R.string.yes - ) { _, _ -> - val name = fontList[position].name - if (name.substring(0, name.lastIndexOf(".")) == "default_font") { - make( - v, - v.context - .getString( - R.string.msg_cannot_delete_default, "font" - ) - ) - .setFadeAnimation() - .setType(SBUtils.Type.INFO) - .show() - } else { - deleteFile(fontList[position].path) - fontList.removeAt(position) - notifyItemRemoved(position) - } - } - .show() - true - } - R.id.menu_rename -> { - rename(v, position, holder) - true - } - else -> false - } - } - - popupMenu.show() - } - - @SuppressLint("RestrictedApi") - private fun rename(v: View, position: Int, holder: VH) { - val lastSegment = getLastSegmentFromPath(fontList[position].path) - val fileName = lastSegment.substring(0, lastSegment.lastIndexOf(".")) - val extension = - lastSegment.substring(lastSegment.lastIndexOf(".")) - val builder = MaterialAlertDialogBuilder(v.context) - val bind = - TextinputlayoutBinding.inflate(builder.create().layoutInflater) - val editText = bind.textinputEdittext - val inputLayout = bind.textinputLayout - editText.setText(fileName) - val padding = Utils.pxToDp(builder.context, 10) - @Suppress("DEPRECATION") - builder.setView(bind.root, padding, padding, padding, padding) - builder.setTitle(R.string.rename_font) - builder.setNegativeButton(R.string.cancel) { _, _ -> } - builder.setPositiveButton( - R.string.rename - ) { _, _ -> - if (fontList[position].name - .substring(0, fontList[position].name.lastIndexOf(".")) - == "default_font" - ) { - make(v, v.context.getString(R.string.msg_cannot_rename_default, "font")) - .setFadeAnimation() - .setType(SBUtils.Type.INFO) - .show() - } else { - val fontPath = project!!.fontPath - - val toPath = fontPath + editText.text.toString() + extension - val newFile = File(toPath) - val oldFile = File(fontList[position].path) - oldFile.renameTo(newFile) - - val name = editText.text.toString() - fontList[position].path = toPath - fontList[position].name = getLastSegmentFromPath(toPath) - holder.fontName.text = name - holder.fontLook.typeface = Typeface.createFromFile(File(fontList[position].path)) - notifyItemChanged(position) - } - } - - val dialog = builder.create() - dialog.window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE) - dialog.show() - - editText.addTextChangedListener( - object : TextWatcher { - override fun beforeTextChanged(p1: CharSequence, p2: Int, p3: Int, p4: Int) {} - - override fun onTextChanged(p1: CharSequence, p2: Int, p3: Int, p4: Int) {} - - override fun afterTextChanged(p1: Editable) { - NameErrorChecker.checkForFont( - editText.text.toString(), inputLayout, dialog, fontList, position - ) - } - }) - - NameErrorChecker.checkForFont(fileName, inputLayout, dialog, fontList, position) - - editText.requestFocus() - val inputMethodManager = - v.context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager - inputMethodManager.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT) - - if (editText.text.toString().isNotEmpty()) { - editText.setSelection(0, editText.text.toString().length) - } - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/adapters/LayoutListAdapter.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/adapters/LayoutListAdapter.kt deleted file mode 100644 index 4e571d8bc7..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/adapters/LayoutListAdapter.kt +++ /dev/null @@ -1,69 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.adapters - -import android.annotation.SuppressLint -import android.graphics.Color -import android.graphics.drawable.GradientDrawable -import android.os.Build -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import android.view.animation.AnimationUtils -import android.widget.TextView -import androidx.annotation.RequiresApi -import androidx.recyclerview.widget.RecyclerView -import org.appdevforall.codeonthego.layouteditor.LayoutFile -import org.appdevforall.codeonthego.layouteditor.ProjectFile -import org.appdevforall.codeonthego.layouteditor.R -import org.appdevforall.codeonthego.layouteditor.databinding.LayoutProjectLayoutItemBinding - -class LayoutListAdapter( - val project: ProjectFile -) : RecyclerView.Adapter() { - - var onClickListener: ((LayoutFile) -> Unit)? = null - var onLongClickListener: ((View, Int) -> Boolean)? = null - - class VH(binding: LayoutProjectLayoutItemBinding) : RecyclerView.ViewHolder(binding.getRoot()) { - val iconText: TextView = binding.icon - val layoutName: TextView = binding.layoutName - } - - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): VH { - return VH( - LayoutProjectLayoutItemBinding.inflate(LayoutInflater.from(parent.context), parent, false) - ) - } - - @RequiresApi(Build.VERSION_CODES.S) - @SuppressLint("RecyclerView", "WrongConstant") - override fun onBindViewHolder(holder: VH, position: Int) { - val layoutList = project.allLayouts - - holder.itemView.apply { - animation = AnimationUtils.loadAnimation( - holder.itemView.context, R.anim.project_list_animation - ) - setOnClickListener { onClickListener?.invoke(layoutList[position]) } - setOnLongClickListener { onLongClickListener?.invoke(it, position) == true } - } - holder.layoutName.text = layoutList[position].name - val gradientDrawable = GradientDrawable( - GradientDrawable.Orientation.BL_TR, - intArrayOf( - Color.MAGENTA, - Color.YELLOW - ) - ).apply { - cornerRadius = 8f - } - holder.iconText.apply { - text = layoutList[position].name.substring(0, 1).uppercase() - background = gradientDrawable - setTextColor(Color.WHITE) - } - } - - override fun getItemCount(): Int { - return project.allLayouts.size - } -} \ No newline at end of file diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/adapters/PagerAdapter.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/adapters/PagerAdapter.kt deleted file mode 100644 index bd31f3f8c6..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/adapters/PagerAdapter.kt +++ /dev/null @@ -1,106 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.adapters - -import android.graphics.drawable.Drawable -import androidx.fragment.app.Fragment -import androidx.fragment.app.FragmentManager -import androidx.lifecycle.Lifecycle -import androidx.viewpager2.adapter.FragmentStateAdapter -import androidx.viewpager2.widget.ViewPager2 -import com.google.android.material.tabs.TabLayout -import com.google.android.material.tabs.TabLayoutMediator - -class PagerAdapter(fragmentManager: FragmentManager, lifecycle: Lifecycle) { - private val adapter: Adapter - - private var pager: ViewPager2? = null - private var layout: TabLayout? = null - - private val fragmentList: MutableList = ArrayList() - private val fragmentTitleList: MutableList = ArrayList() - private val fragmentIconList: MutableList = ArrayList() - - private inner class Adapter(fragmentManager: FragmentManager, lifecycle: Lifecycle) : - FragmentStateAdapter(fragmentManager, lifecycle) { - override fun getItemCount(): Int { - return fragmentList.size - } - - override fun createFragment(position: Int): Fragment { - return fragmentList[position] - } - } - - init { - adapter = Adapter(fragmentManager, lifecycle) - } - - fun setup(pager: ViewPager2?, layout: TabLayout?) { - this.pager = pager - this.layout = layout - } - - fun addFragmentToAdapter(fragment: Fragment, title: CharSequence?) { - fragmentList.add(fragment) - fragmentTitleList.add(title) - } - - fun addFragmentToAdapter(fragment: Fragment, title: CharSequence?, icon: Drawable) { - fragmentList.add(fragment) - fragmentTitleList.add(title) - fragmentIconList.add(icon) - } - - val fragmentsCount: Int - get() = fragmentList.size - - fun getFragmentAt(position: Int): Fragment { - return fragmentList[position] - } - - fun getFragmentTitleAt(position: Int): CharSequence? { - if (fragmentTitleList[position] == null) return fragmentTitleList[0] - return fragmentTitleList[position] - } - - fun getFragmentIconAt(position: Int): Drawable { - return fragmentIconList[position] - } - - fun getFragmentWithTitle(title: CharSequence): Fragment { - for (i in 0 until fragmentsCount) { - if (title === getFragmentTitleAt(i)) { - return getFragmentAt(i) - } - } - return fragmentList[0] - } - - fun getFragmentPosition(fragment: Fragment): Int { - for (i in 0 until fragmentsCount) { - if (fragment === fragmentList[i]) { - return i - } - } - return 0 - } - - fun setupPager(orientation: Int) { - pager!!.orientation = orientation - pager!!.adapter = adapter - } - - fun setupMediatorWithIcon() { - val mediator = TabLayoutMediator(layout!!, pager!!) { tab, position -> - tab.setText(getFragmentTitleAt(position)) - tab.setIcon(getFragmentIconAt(position)) - } - mediator.attach() - } - - fun setupMediatorWithoutIcon() { - val mediator = TabLayoutMediator(layout!!, pager!!) { tab: TabLayout.Tab, position: Int -> - tab.setText(getFragmentTitleAt(position)) - } - mediator.attach() - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/adapters/PaletteListAdapter.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/adapters/PaletteListAdapter.kt deleted file mode 100644 index 9f45fe9ac6..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/adapters/PaletteListAdapter.kt +++ /dev/null @@ -1,80 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.adapters - -import android.view.LayoutInflater -import android.view.View -import android.view.View.DragShadowBuilder -import android.view.ViewGroup -import android.view.animation.AnimationUtils -import androidx.core.view.ViewCompat -import androidx.drawerlayout.widget.DrawerLayout -import androidx.recyclerview.widget.RecyclerView -import com.itsaky.androidide.idetooltips.TooltipCategory -import com.itsaky.androidide.idetooltips.TooltipManager.showTooltip -import com.itsaky.androidide.utils.setupGestureHandling -import org.appdevforall.codeonthego.layouteditor.R -import org.appdevforall.codeonthego.layouteditor.databinding.LayoutPaletteItemBinding -import org.appdevforall.codeonthego.layouteditor.utils.InvokeUtil.getMipmapId -import org.appdevforall.codeonthego.layouteditor.utils.InvokeUtil.getSuperClassName - -class PaletteListAdapter(private val drawerLayout: DrawerLayout) : - RecyclerView.Adapter() { - private lateinit var tab: List> - - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { - return ViewHolder( - LayoutPaletteItemBinding.inflate(LayoutInflater.from(parent.context), parent, false) - ) - } - - override fun onBindViewHolder(holder: ViewHolder, position: Int) { - val widgetItem = tab[position] - - val binding = holder.binding - - binding.icon.setImageResource(getMipmapId(widgetItem["iconName"].toString())) - binding.name.text = widgetItem["name"].toString() - binding.className.text = getSuperClassName(widgetItem["className"].toString()) - binding.root.contentDescription = widgetItem["name"].toString() - binding.root.setupGestureHandling( - onLongPress = { view -> showTooltipForWidget(view, widgetItem) }, - onDrag = { view -> - if (ViewCompat.startDragAndDrop(view, null, DragShadowBuilder(view), widgetItem, 0)) { - drawerLayout.closeDrawers() - } - } - ) - - binding - .root.animation = AnimationUtils.loadAnimation( - holder.itemView.context, R.anim.project_list_animation - ) - } - - - private fun showTooltipForWidget(anchorView: View, widgetItem: HashMap) { - val className = getSuperClassName(widgetItem["className"].toString()) - - className?.let { - showTooltip( - context = anchorView.context, - anchorView = anchorView, - tag = className, - category = TooltipCategory.CATEGORY_JAVA - ) - } - } - - - override fun getItemCount(): Int { - return tab.size - } - - fun submitPaletteList(tab: List>) { - this.tab = tab - notifyDataSetChanged() - } - - class ViewHolder(var binding: LayoutPaletteItemBinding) : RecyclerView.ViewHolder( - binding.root - ) -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/adapters/ProjectListAdapter.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/adapters/ProjectListAdapter.kt deleted file mode 100644 index 057338b53d..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/adapters/ProjectListAdapter.kt +++ /dev/null @@ -1,295 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.adapters - -import android.annotation.SuppressLint -import android.app.Activity -import android.content.Context -import android.content.Intent -import android.text.Editable -import android.text.TextWatcher -import android.util.Log -import android.util.TypedValue -import android.view.LayoutInflater -import android.view.MenuItem -import android.view.View -import android.view.ViewGroup -import android.view.WindowManager -import android.view.animation.AnimationUtils -import android.view.inputmethod.InputMethodManager -import android.widget.ArrayAdapter -import android.widget.Toast -import androidx.appcompat.app.AlertDialog -import androidx.appcompat.widget.PopupMenu -import androidx.appcompat.widget.TooltipCompat -import androidx.lifecycle.findViewTreeLifecycleOwner -import androidx.lifecycle.lifecycleScope -import androidx.recyclerview.widget.RecyclerView -import com.google.android.material.dialog.MaterialAlertDialogBuilder -import com.google.android.material.textfield.TextInputLayout -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.launch -import kotlinx.coroutines.withContext -import org.appdevforall.codeonthego.layouteditor.LayoutEditor.Companion.instance -import org.appdevforall.codeonthego.layouteditor.ProjectFile -import org.appdevforall.codeonthego.layouteditor.R -import org.appdevforall.codeonthego.layouteditor.R.string -import org.appdevforall.codeonthego.layouteditor.activities.EditorActivity -import org.appdevforall.codeonthego.layouteditor.activities.PreviewLayoutActivity -import org.appdevforall.codeonthego.layouteditor.databinding.ListProjectFileBinding -import org.appdevforall.codeonthego.layouteditor.databinding.TextinputlayoutBinding -import org.appdevforall.codeonthego.layouteditor.managers.PreferencesManager -import org.appdevforall.codeonthego.layouteditor.managers.ProjectManager -import org.appdevforall.codeonthego.layouteditor.utils.Constants -import org.appdevforall.codeonthego.layouteditor.utils.FileUtil -import org.appdevforall.codeonthego.layouteditor.utils.SBUtils.Companion.make -import java.io.File -import androidx.core.content.edit -import androidx.lifecycle.LifecycleOwner - -class ProjectListAdapter(private val projects: MutableList) : - RecyclerView.Adapter() { - - var onDeleteCallback: ((Int) -> Unit)? = null - - class ViewHolder(var binding: ListProjectFileBinding) : RecyclerView.ViewHolder( - binding.root - ) { - var projectName = binding.projectName - var projectDate = binding.projectDate - var projectIcon = binding.icon - var menu = binding.menu - } - - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { - return ViewHolder( - ListProjectFileBinding.inflate(LayoutInflater.from(parent.context), parent, false) - ) - } - - @SuppressLint("RecyclerView") - override fun onBindViewHolder(holder: ViewHolder, position: Int) { - val context = holder.binding.root.context - holder.itemView.animation = AnimationUtils.loadAnimation( - holder.itemView.context, R.anim.project_list_animation - ) - holder.projectName.text = projects[position].name - holder.projectDate.text = projects[position].createdAt - - TooltipCompat.setTooltipText(holder.menu, context.getString(string.options)) - TooltipCompat.setTooltipText(holder.binding.root, projects[position].name) - - holder.binding.root.setOnClickListener { openProject(it, holder.absoluteAdapterPosition) } - holder.projectIcon.text = projects[position].name.substring(0, 1).uppercase() - holder.menu.setOnClickListener { showOptions(it, holder.absoluteAdapterPosition) } - } - - override fun getItemCount(): Int { - return projects.size - } - - private fun checkNameErrors( - projects: List, - name: String, - currentName: String, - inputLayout: TextInputLayout, - dialog: AlertDialog - ) { - if (name.isEmpty()) { - inputLayout.isErrorEnabled = true - inputLayout.error = dialog.context.getString(string.msg_cannnot_empty) - dialog.getButton(AlertDialog.BUTTON_POSITIVE).isEnabled = false - return - } - - for (file in projects) { - if (name == currentName) break - - if (file.name == name) { - inputLayout.isErrorEnabled = true - inputLayout.error = instance!!.context.getString(string.msg_current_name_unavailable) - dialog.getButton(AlertDialog.BUTTON_POSITIVE).isEnabled = false - return - } - } - - inputLayout.isErrorEnabled = false - inputLayout.error = "" - dialog.getButton(AlertDialog.BUTTON_POSITIVE).isEnabled = true - } - - @Suppress("deprecation") - @SuppressLint("RestrictedApi") - private fun renameProject(v: View, position: Int) { - val builder = MaterialAlertDialogBuilder(v.context) - builder.setTitle(string.rename_project) - val bind = - TextinputlayoutBinding.inflate(builder.create().layoutInflater) - val editText = bind.textinputEdittext - val inputLayout = bind.textinputLayout - - editText.setText(projects[position].name) - inputLayout.setHint(string.msg_new_project_name) - - val padding = TypedValue.applyDimension( - TypedValue.COMPLEX_UNIT_DIP, 10f, v.context.resources.displayMetrics - ).toInt() - - builder.setView(bind.root, padding, padding, padding, padding) - builder.setNegativeButton(string.cancel) { _, _ -> } - builder.setPositiveButton( - string.rename - ) { _, _ -> - val path = projects[position].path - val newPath = - "${path.substring(0, path.lastIndexOf("/"))}/${editText.text.toString()}" - projects[position].rename(newPath) - notifyItemChanged(position) - } - - val dialog = builder.create() - dialog.window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE) - dialog.show() - - editText.addTextChangedListener( - object : TextWatcher { - override fun beforeTextChanged(p1: CharSequence, p2: Int, p3: Int, p4: Int) { - } - - override fun onTextChanged(p1: CharSequence, p2: Int, p3: Int, p4: Int) { - } - - override fun afterTextChanged(p1: Editable) { - checkNameErrors( - projects, - editText.text.toString(), - projects[position].name, - inputLayout, - dialog - ) - } - }) - - checkNameErrors( - projects, - editText.text.toString(), - projects[position].name, - inputLayout, - dialog - ) - - editText.requestFocus() - val inputMethodManager = - v.context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager - inputMethodManager.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT) - - if (editText.text.toString().isNotEmpty()) { - editText.setSelection(0, editText.text.toString().length) - } - } - - private fun deleteProject(v: View, position: Int) { - val builder = MaterialAlertDialogBuilder(v.context) - builder.setTitle(string.delete_project) - builder.setMessage(string.msg_delete_project) - builder.setNegativeButton(string.no) { d, _ -> d.dismiss() } - builder.setPositiveButton( - string.yes - ) { _, _ -> - FileUtil.deleteFile(projects[position].path) - projects.remove(projects[position]) - notifyItemRemoved(position) - onDeleteCallback?.invoke(position) - } - - builder.create().show() - } - - private fun showOptions(v: View, position: Int) { - val popupMenu = PopupMenu(v.context, v) - popupMenu.inflate(R.menu.menu_project_file_options) - popupMenu.setOnMenuItemClickListener { item: MenuItem -> - val id = item.itemId - when (id) { - R.id.menu_delete -> { - deleteProject(v, position) - true - } - - R.id.menu_preview -> { - previewLayout(v, position) - true - } - - R.id.menu_rename -> { - renameProject(v, position) - true - } - - else -> false - } - } - - popupMenu.show() - } - - private fun openProject(v: View, position: Int) { - val lifecycleOwner = v.findViewTreeLifecycleOwner() ?: (v.context as? LifecycleOwner) - val scope = lifecycleOwner?.lifecycleScope ?: return - - v.isEnabled = false - - scope.launch { - try { - withContext(Dispatchers.IO) { - ProjectManager.instance.openProject(projects[position]) - val prefsManager = PreferencesManager(v.context) - - val projectDir = - "${FileUtil.getPackageDataDir(instance!!.context)}/projects/${projects[position].name}" - val checkFile = File("$projectDir/values/colors.xml") - - if (!prefsManager.prefs.getBoolean("copyAssets", false) && !checkFile.exists()) { - FileUtil.makeDir("$projectDir/values/") - FileUtil.copyFileFromAsset("colors.xml", "$projectDir/values") - prefsManager.prefs.edit { putBoolean("copyAssets", true) } - } - } - val intent = Intent(v.context, EditorActivity::class.java) - v.context.startActivity(intent) - } catch (e: Exception) { - withContext(Dispatchers.Main) { - Toast.makeText(v.context, v.context.getString(R.string.msg_error_opening_project), Toast.LENGTH_SHORT).show() - } - Log.e("ProjectListAdapter", "Error opening project", e) - } finally { - if (v.context is Activity && !(v.context as Activity).isFinishing) { - v.isEnabled = true - } - } - } - } - - private fun previewLayout(v: View, position: Int) { - val layouts = ArrayList() - val allLayouts = projects[position].allLayouts - allLayouts.forEach { layouts.add(it.name) } - - MaterialAlertDialogBuilder(v.context) - .setTitle("Choose layout") - .setAdapter( - ArrayAdapter( - v.context, - android.R.layout.simple_list_item_1, - layouts - ) - ) { d, w -> - val intent = Intent(v.context, PreviewLayoutActivity::class.java) - intent.putExtra(Constants.EXTRA_KEY_LAYOUT, allLayouts[w]) - if (allLayouts[w].readDesignFile().isEmpty()) { - make(v, layouts[w] + " is empty...").setFadeAnimation().showAsError() - } else v.context.startActivity(intent) - d.dismiss() - } - .setPositiveButton(string.cancel, null) - .show() - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/adapters/StringResourceAdapter.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/adapters/StringResourceAdapter.kt deleted file mode 100644 index 0dbfab81f8..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/adapters/StringResourceAdapter.kt +++ /dev/null @@ -1,180 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.adapters - -import android.content.DialogInterface -import android.text.Editable -import android.text.TextWatcher -import android.view.LayoutInflater -import android.view.MenuItem -import android.view.View -import android.view.ViewGroup -import android.view.animation.AnimationUtils -import android.widget.TextView -import androidx.appcompat.widget.PopupMenu -import androidx.recyclerview.widget.RecyclerView -import com.blankj.utilcode.util.ClipboardUtils -import com.google.android.material.dialog.MaterialAlertDialogBuilder -import org.apache.commons.lang3.StringEscapeUtils -import org.appdevforall.codeonthego.layouteditor.ProjectFile -import org.appdevforall.codeonthego.layouteditor.R -import org.appdevforall.codeonthego.layouteditor.adapters.models.ValuesItem -import org.appdevforall.codeonthego.layouteditor.databinding.LayoutValuesItemBinding -import org.appdevforall.codeonthego.layouteditor.databinding.LayoutValuesItemDialogBinding -import org.appdevforall.codeonthego.layouteditor.utils.FileUtil.writeFile -import org.appdevforall.codeonthego.layouteditor.utils.NameErrorChecker -import org.appdevforall.codeonthego.layouteditor.utils.SBUtils -import org.appdevforall.codeonthego.layouteditor.utils.SBUtils.Companion.make - -class StringResourceAdapter( - private val project: ProjectFile, - private val stringList: MutableList -) : RecyclerView.Adapter() { - class VH(var binding: LayoutValuesItemBinding) : RecyclerView.ViewHolder( - binding.root - ) { - var stringName: TextView = binding.name - var stringValue: TextView = binding.value - } - - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): VH { - return VH( - LayoutValuesItemBinding.inflate(LayoutInflater.from(parent.context), parent, false) - ) - } - - override fun onBindViewHolder(holder: VH, position: Int) { - holder.stringName.text = stringList[position].name - holder.stringValue.text = stringList[position].value - holder.itemView.animation = AnimationUtils.loadAnimation( - holder.itemView.context, R.anim.project_list_animation - ) - - holder.binding.menu.setOnClickListener { showOptions(it, holder.absoluteAdapterPosition) } - holder.itemView.setOnClickListener { editString(it, holder.absoluteAdapterPosition) } - } - - override fun getItemCount(): Int { - return stringList.size - } - - fun generateStringsXml() { - val stringsPath = project.stringsPath - - val sb = StringBuilder() - sb.append("\n") - for ((name, value) in stringList) { - // Generate string item code - sb.append("\t") - .append(StringEscapeUtils.escapeXml11(value)) - .append("\n") - } - sb.append("") - - writeFile(stringsPath, sb.toString().trim { it <= ' ' }) - } - - private fun showOptions(v: View, position: Int) { - val popupMenu = PopupMenu(v.context, v) - popupMenu.inflate(R.menu.menu_values) - popupMenu.setOnMenuItemClickListener { item: MenuItem -> - val id = item.itemId - when (id) { - R.id.menu_copy_name -> { - ClipboardUtils.copyText(stringList[position].name) - make( - v, - "${v.context.getString(R.string.copied)} ${stringList[position].name}" - ) - .setSlideAnimation() - .showAsSuccess() - true - } - R.id.menu_delete -> { - MaterialAlertDialogBuilder(v.context) - .setTitle("Remove String") - .setMessage( - String.format("Do you want to remove %s?", stringList[position].name) - ) - .setNegativeButton(R.string.no, null) - .setPositiveButton( - R.string.yes - ) { _, _ -> - val name = stringList[position].name - if (name == "default_string") { - make( - v, - v.context - .getString(R.string.msg_cannot_delete_default, "string") - ) - .setFadeAnimation() - .setType(SBUtils.Type.INFO) - .show() - } else { - stringList.removeAt(position) - notifyItemRemoved(position) - generateStringsXml() - } - } - .show() - true - } - else -> false - } - } - - popupMenu.show() - } - - private fun editString(v: View, pos: Int) { - val builder = MaterialAlertDialogBuilder(v.context) - builder.setTitle("Edit String") - - val bind = - LayoutValuesItemDialogBinding.inflate(builder.create().layoutInflater) - val ilName = bind.textInputLayoutName - val ilValue = bind.textInputLayoutValue - val etName = bind.textinputName - val etValue = bind.textinputValue - - etName.setText(stringList[pos].name) - etValue.setText(stringList[pos].value) - builder.setView(bind.root) - builder.setPositiveButton( - R.string.okay - ) { dlg: DialogInterface?, i: Int -> - if (stringList[pos].name == "default_string" && etName.text.toString() != "default_string") { - make(v, v.context.getString(R.string.msg_cannot_rename_default, "string")) - .setFadeAnimation() - .setType(SBUtils.Type.INFO) - .show() - } else { - // Update position - stringList[pos].name = etName.text.toString() - } - // Update position - stringList[pos].value = etValue.text.toString() - notifyItemChanged(pos) - // Generate code from all strings in list - generateStringsXml() - } - builder.setNegativeButton(R.string.cancel, null) - - val dialog = builder.create() - dialog.show() - - etName.addTextChangedListener( - object : TextWatcher { - override fun beforeTextChanged(p1: CharSequence, p2: Int, p3: Int, p4: Int) {} - - override fun onTextChanged(p1: CharSequence, p2: Int, p3: Int, p4: Int) {} - - override fun afterTextChanged(p1: Editable) { - NameErrorChecker.checkForValues( - etName.text.toString(), ilName, dialog, stringList, pos - ) - } - }) - NameErrorChecker.checkForValues(etName.text.toString(), ilName, dialog, stringList, pos) - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/adapters/models/DrawableFile.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/adapters/models/DrawableFile.kt deleted file mode 100644 index 5a4f238b9a..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/adapters/models/DrawableFile.kt +++ /dev/null @@ -1,8 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.adapters.models - -import android.graphics.drawable.Drawable -import org.appdevforall.codeonthego.layouteditor.utils.FileUtil - -data class DrawableFile(var versions: Int, var drawable: Drawable, var path: String) { - var name: String = FileUtil.getLastSegmentFromPath(path) -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/adapters/models/FontItem.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/adapters/models/FontItem.kt deleted file mode 100644 index 6e9d538d50..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/adapters/models/FontItem.kt +++ /dev/null @@ -1,3 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.adapters.models - -data class FontItem(@JvmField var name: String, @JvmField var path: String) diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/adapters/models/ValuesItem.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/adapters/models/ValuesItem.kt deleted file mode 100644 index 187f53818c..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/adapters/models/ValuesItem.kt +++ /dev/null @@ -1,8 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.adapters.models - -data class ValuesItem -/** - * @param name = - * @param value = @param value - */ -(@JvmField var name: String, @JvmField var value: String) diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/APILevel.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/APILevel.kt deleted file mode 100644 index 511a2a18fe..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/APILevel.kt +++ /dev/null @@ -1,11 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor - -class APILevel(val level: Level) { - enum class Level { - OREO, // Android 8.0 & 8.1 - PIE, // Android 9 - QUEEN_CAKE, // Android 10 - RED_VELVET_CAKE, // Android 11 - SNOW_CONE // Android 12 - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/DesignEditor.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/DesignEditor.kt deleted file mode 100644 index f6872f69e2..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/DesignEditor.kt +++ /dev/null @@ -1,1102 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor - -import android.animation.LayoutTransition -import android.content.Context -import android.graphics.Canvas -import android.graphics.Paint -import android.text.Editable -import android.text.TextWatcher -import android.util.AttributeSet -import android.view.DragEvent -import android.view.View -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 -import android.widget.Toast -import androidx.appcompat.widget.TooltipCompat -import androidx.core.view.isEmpty -import androidx.recyclerview.widget.LinearLayoutManager -import androidx.recyclerview.widget.RecyclerView -import com.blankj.utilcode.util.VibrateUtils -import com.google.android.material.bottomsheet.BottomSheetBehavior -import com.google.android.material.bottomsheet.BottomSheetDialog -import com.google.android.material.color.MaterialColors -import com.google.android.material.dialog.MaterialAlertDialogBuilder -import com.google.gson.Gson -import com.google.gson.reflect.TypeToken -import com.itsaky.androidide.idetooltips.TooltipCategory -import com.itsaky.androidide.idetooltips.TooltipManager -import com.itsaky.androidide.utils.displayTooltipOnLongPress -import com.itsaky.androidide.utils.handleLongClicksAndDrag -import org.appdevforall.codeonthego.layouteditor.R -import org.appdevforall.codeonthego.layouteditor.adapters.AppliedAttributesAdapter -import org.appdevforall.codeonthego.layouteditor.adapters.AvailableAttributesAdapter -import org.appdevforall.codeonthego.layouteditor.databinding.DialogAvailableAttributesBinding -import org.appdevforall.codeonthego.layouteditor.databinding.ShowAttributesDialogBinding -import org.appdevforall.codeonthego.layouteditor.editor.dialogs.AttributeDialog -import org.appdevforall.codeonthego.layouteditor.editor.dialogs.BooleanDialog -import org.appdevforall.codeonthego.layouteditor.editor.dialogs.ColorDialog -import org.appdevforall.codeonthego.layouteditor.editor.dialogs.DimensionDialog -import org.appdevforall.codeonthego.layouteditor.editor.dialogs.EnumDialog -import org.appdevforall.codeonthego.layouteditor.editor.dialogs.FlagDialog -import org.appdevforall.codeonthego.layouteditor.editor.dialogs.IdDialog -import org.appdevforall.codeonthego.layouteditor.editor.dialogs.NumberDialog -import org.appdevforall.codeonthego.layouteditor.editor.dialogs.SizeDialog -import org.appdevforall.codeonthego.layouteditor.editor.dialogs.StringDialog -import org.appdevforall.codeonthego.layouteditor.editor.dialogs.ViewDialog -import org.appdevforall.codeonthego.layouteditor.editor.initializer.AttributeInitializer -import org.appdevforall.codeonthego.layouteditor.editor.initializer.AttributeMap -import org.appdevforall.codeonthego.layouteditor.editor.positioning.positionAtDrop -import org.appdevforall.codeonthego.layouteditor.editor.positioning.restoreSingleViewPosition -import org.appdevforall.codeonthego.layouteditor.editor.validation.HierarchyResult -import org.appdevforall.codeonthego.layouteditor.editor.validation.HierarchyValidator -import org.appdevforall.codeonthego.layouteditor.managers.IdManager -import org.appdevforall.codeonthego.layouteditor.managers.IdManager.addId -import org.appdevforall.codeonthego.layouteditor.managers.IdManager.getViewId -import org.appdevforall.codeonthego.layouteditor.managers.IdManager.removeId -import org.appdevforall.codeonthego.layouteditor.managers.PreferencesManager -import org.appdevforall.codeonthego.layouteditor.managers.UndoRedoManager -import org.appdevforall.codeonthego.layouteditor.tools.XmlLayoutGenerator -import org.appdevforall.codeonthego.layouteditor.tools.XmlLayoutParser -import org.appdevforall.codeonthego.layouteditor.utils.ArgumentUtil.parseType -import org.appdevforall.codeonthego.layouteditor.utils.Constants -import org.appdevforall.codeonthego.layouteditor.utils.FileUtil -import org.appdevforall.codeonthego.layouteditor.utils.InvokeUtil -import org.appdevforall.codeonthego.layouteditor.utils.Utils -import org.appdevforall.codeonthego.layouteditor.views.StructureView - -class DesignEditor : LinearLayout { - var viewType: ViewType? = null - set(value) { - isBlueprint = viewType == ViewType.BLUEPRINT - setBlueprintOnChildren() - invalidate() - field = value - } - var deviceConfiguration: DeviceConfiguration? = null - var apiLevel: APILevel? = null - - lateinit var viewAttributeMap: HashMap - private set - - private lateinit var paint: Paint - private lateinit var shadow: View - - private lateinit var initializer: AttributeInitializer - - private var isBlueprint = false - private var structureView: StructureView? = null - private var undoRedoManager: UndoRedoManager? = null - private var isModified = false - private lateinit var preferencesManager: PreferencesManager - private var parser: XmlLayoutParser? = null - private var currentBasePath: String? = null - private val attrTranslationX = "android:translationX" - private val attrTranslationY = "android:translationY" - private val widgetIdOverrides = mapOf( - "switch" to "switchWidget", - ) - - init { - viewAttributeMap = HashMap() - } - - companion object { - @Volatile - private var cachedAttributes: HashMap>>? = null - - @Volatile - private var cachedParentAttributes: HashMap>>? = null - - private fun getAttributes(context: Context): HashMap>> { - return cachedAttributes ?: synchronized(this) { - cachedAttributes ?: loadAttributesFromAssets(context, Constants.ATTRIBUTES_FILE).also { - cachedAttributes = it - } - } - } - - private fun getParentAttributes(context: Context): HashMap>> { - return cachedParentAttributes ?: synchronized(this) { - cachedParentAttributes ?: loadAttributesFromAssets(context, Constants.PARENT_ATTRIBUTES_FILE).also { - cachedParentAttributes = it - } - } - } - - private fun loadAttributesFromAssets( - context: Context, - filePath: String - ): HashMap>> { - return Gson().fromJson( - FileUtil.readFromAsset(filePath, context), - object : TypeToken?>?>?>() {}.type, - ) - } - - fun preload(context: Context) { - getAttributes(context) - getParentAttributes(context) - } - } - - constructor(context: Context) : super(context) { - init(context) - } - - constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) { - init(context) - } - - constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super( - context, - attrs, - defStyleAttr, - ) { - init(context) - } - - fun getParser(): XmlLayoutParser? = parser - - private fun init(context: Context) { - viewType = ViewType.DESIGN - isBlueprint = false - deviceConfiguration = DeviceConfiguration(DeviceSize.LARGE) - // initAttributes() - shadow = View(context) - paint = Paint() - - this.preferencesManager = PreferencesManager(context) - - shadow.setBackgroundColor( - MaterialColors.getColor(this, com.google.android.material.R.attr.colorOutline), - ) - shadow.layoutParams = - ViewGroup.LayoutParams( - Utils.pxToDp(context, 50), - Utils.pxToDp(context, 35), - ) - paint.strokeWidth = Utils.pxToDp(context, 3).toFloat() - - orientation = VERTICAL - setTransition(this) - setDragListener(this) - - toggleStrokeWidgets() - setBlueprintOnChildren() - } - - override fun dispatchDraw(canvas: Canvas) { - super.dispatchDraw(canvas) - when (viewType) { - ViewType.BLUEPRINT -> drawBlueprint(canvas) - ViewType.DESIGN -> drawDesign(canvas) - else -> drawDesign(canvas) - } - when (deviceConfiguration!!.size) { - DeviceSize.SMALL -> { - scaleX = 0.75f - scaleY = 0.75f - } - - DeviceSize.MEDIUM -> { - scaleX = 0.85f - scaleY = 0.85f - } - - DeviceSize.LARGE -> { - scaleX = 0.95f - scaleY = 0.95f - } - } - } - - private fun drawBlueprint(canvas: Canvas) { - paint.color = Constants.BLUEPRINT_DASH_COLOR - setBackgroundColor(Constants.BLUEPRINT_BACKGROUND_COLOR) - Utils.drawDashPathStroke(this, canvas, (paint)) - } - - private fun drawDesign(canvas: Canvas) { - paint.color = Constants.DESIGN_DASH_COLOR - setBackgroundColor(Utils.getSurfaceColor(context)) - Utils.drawDashPathStroke(this, canvas, (paint)) - } - - fun previewLayout( - deviceConfiguration: DeviceConfiguration?, - apiLevel: APILevel?, - ) { - this.deviceConfiguration = deviceConfiguration - this.apiLevel = apiLevel - } - - fun resizeLayout(deviceConfiguration: DeviceConfiguration?) { - this.deviceConfiguration = deviceConfiguration - invalidate() - } - - private fun setTransition(group: ViewGroup) { - if (group is RecyclerView) return - LayoutTransition() - .apply { - disableTransitionType(LayoutTransition.CHANGE_DISAPPEARING) - enableTransitionType(LayoutTransition.CHANGING) - setDuration(150) - }.also { group.layoutTransition = it } - } - - private fun toggleStrokeWidgets() { - try { - for (view in viewAttributeMap.keys) { - val cls = view.javaClass - val method = cls.getMethod("setStrokeEnabled", Boolean::class.javaPrimitiveType) - method.invoke(view, preferencesManager.isShowStroke) - } - } catch (e: Exception) { - e.printStackTrace() - } - } - - private fun setBlueprintOnChildren() { - try { - for (view in viewAttributeMap.keys) { - val cls = view.javaClass - val method = cls.getMethod("setBlueprint", Boolean::class.javaPrimitiveType) - method.invoke(view, isBlueprint) - } - } catch (e: Exception) { - e.printStackTrace() - } - } - - private fun setDragListener(group: ViewGroup) { - group.setOnDragListener( - OnDragListener { host, event -> - var parent = host as ViewGroup - val draggedView = - if (event.localState is View) event.localState as View else null - - when (event.action) { - DragEvent.ACTION_DRAG_STARTED -> { - if (preferencesManager.isEnableVibration) VibrateUtils.vibrate(100) - if (( - draggedView != null && - !(draggedView is AdapterView<*> && parent is AdapterView<*>) - ) - ) { - parent.removeView(draggedView) - } - } - - DragEvent.ACTION_DRAG_EXITED -> { - removeWidget(shadow) - updateUndoRedoHistory() - } - - DragEvent.ACTION_DRAG_ENDED -> - if (!event.result && draggedView != null) { - removeId(draggedView, draggedView is ViewGroup) - removeViewAttributes(draggedView) - viewAttributeMap.remove(draggedView) - updateStructure() - } - - DragEvent.ACTION_DRAG_LOCATION, DragEvent.ACTION_DRAG_ENTERED -> - if (shadow.parent == null) { - addWidget( - shadow, - parent, - event, - ) - } else { - if (parent is LinearLayout) { - val index = parent.indexOfChild(shadow) - val newIndex = getIndexForNewChildOfLinear(parent, event) - - if (index != newIndex) { - parent.removeView(shadow) - runCatching { parent.addView(shadow, newIndex) } - } - } else { - if (shadow.parent !== parent) addWidget(shadow, parent, event) - } - } - - DragEvent.ACTION_DROP -> { - removeWidget(shadow) - - val dragData = event.localState as? HashMap<*, *> - val className = dragData?.get(Constants.KEY_CLASS_NAME).toString() - if (draggedView == null && dragData != null) { - val shouldBlock = HierarchyValidator(context) - .validate(className, parent) - .handle(context) - if (shouldBlock) return@OnDragListener true - } - - if (childCount >= 1) { - if (getChildAt(0) !is ViewGroup) { - Toast - .makeText( - context, - "Can\'t add more than one widget in the editor.", - Toast.LENGTH_SHORT, - ).show() - return@OnDragListener true - } else { - if (parent is DesignEditor) parent = getChildAt(0) as ViewGroup - } - } - - if (draggedView == null) { - @Suppress("UNCHECKED_CAST") - val data: HashMap = - event.localState as HashMap - val newView = - InvokeUtil.createView( - data[Constants.KEY_CLASS_NAME].toString(), - context, - ) as View - - 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) { - setDragListener(newView) - setTransition(newView) - } - newView.minimumWidth = Utils.pxToDp(context, 20) - newView.minimumHeight = Utils.pxToDp(context, 20) - - if (newView is EditText) newView.isFocusable = false - - val map = AttributeMap() - val raw = newView.javaClass.superclass.simpleName - .replace(" ".toRegex(), "_") - .lowercase() - val sanitized = sanitizeIdName(raw) - val id = getIdForNewView(sanitized) - - IdManager.addNewId(newView, id) - map.putValue("android:id", "@+id/$id") - map.putValue("android:layout_width", "wrap_content") - map.putValue("android:layout_height", "wrap_content") - viewAttributeMap[newView] = map - - addWidget(newView, parent, event) - - try { - val cls: Class<*> = newView.javaClass - val setStrokeEnabled = - cls.getMethod( - "setStrokeEnabled", - Boolean::class.javaPrimitiveType, - ) - val setBlueprint = - cls.getMethod("setBlueprint", Boolean::class.javaPrimitiveType) - setStrokeEnabled.invoke(newView, preferencesManager.isShowStroke) - setBlueprint.invoke(newView, isBlueprint) - } catch (e: Exception) { - e.printStackTrace() - } - - if (data.containsKey(Constants.KEY_DEFAULT_ATTRS)) { - initAttributeInitializer() - @Suppress("UNCHECKED_CAST") - val defaults = (data[Constants.KEY_DEFAULT_ATTRS] as MutableMap).toMutableMap() - defaults.remove(attrTranslationX) - defaults.remove(attrTranslationY) - initializer.applyDefaultAttributes(newView, defaults) - } - - positionAtDrop(newView, event.x, event.y, viewAttributeMap) - val rootLayout = getChildAt(0) - restoreSingleViewPosition(rootLayout, newView, viewAttributeMap) - } else addWidget(draggedView, parent, event) - - updateStructure() - updateUndoRedoHistory() - } - } - true - }) - } - - private fun getIdForNewView(name: String): String { - var id = name - var n = 0 - var firstTime = true - while (IdManager.containsId(id)) { - n++ - id = - if (firstTime) { - "$name$n" - } else { - id.replace( - id.elementAt(id.lastIndex).toString().toRegex(), - n.toString(), - ) - } - firstTime = false - } - return id - } - - private fun sanitizeIdName(base: String): String = widgetIdOverrides[base] ?: base - - fun loadLayoutFromParser(xml: String, basePath: String? = null) { - clearAll() - if (xml.isEmpty()) return - - // Store basePath for undo/redo operations - if (basePath != null) { - currentBasePath = basePath - } - - val parser = XmlLayoutParser(context, currentBasePath) - this.parser = parser - - parser.processXml(xml, context) - - val root = parser.root ?: return - addView(root) - viewAttributeMap = parser.viewAttributeMap - - for (view in (viewAttributeMap as HashMap?)!!.keys) { - rearrangeListeners(view) - - if (view is ViewGroup) { - setDragListener(view) - setTransition(view) - } - view.minimumWidth = Utils.pxToDp(context, 20) - view.minimumHeight = Utils.pxToDp(context, 20) - } - - ensureConstraintsApplied() - - updateStructure() - toggleStrokeWidgets() - - initAttributeInitializer() - } - - private fun ensureConstraintsApplied() { - if (childCount > 0) { - val rootView = getChildAt(0) - - // For ConstraintLayout or any ViewGroup that might contain a ConstraintLayout - if (rootView is ViewGroup) { - // Set full size for root view - rootView.layoutParams = - LayoutParams( - LayoutParams.MATCH_PARENT, - LayoutParams.MATCH_PARENT, - ) - - // Force correct constraints by requesting layout and waiting for next layout pass - rootView.post { - rootView.requestLayout() - invalidate() - } - } - } - } - - fun undo() { - if (undoRedoManager == null) return - if (undoRedoManager!!.isUndoEnabled) loadLayoutFromParser(undoRedoManager!!.undo()) - } - - fun redo() { - if (undoRedoManager == null) return - if (undoRedoManager!!.isRedoEnabled) loadLayoutFromParser(undoRedoManager!!.redo()) - } - - private fun clearAll() { - removeAllViews() - structureView?.clear() - viewAttributeMap.clear() - } - - fun setStructureView(view: StructureView?) { - structureView = view - } - - fun bindUndoRedoManager(manager: UndoRedoManager?) { - undoRedoManager = manager - } - - private fun updateStructure() { - if (isEmpty()) { - structureView?.clear() - } else { - structureView?.setView(getChildAt(0)) - } - } - - fun updateUndoRedoHistory() { - if (undoRedoManager == null) return - val result = XmlLayoutGenerator().generate(this, false) - - // Don't add empty states to history - if (result.isEmpty()) return - - undoRedoManager!!.addToHistory(result) - markAsModified() - } - - fun markAsModified() { - isModified = true - } - - fun markAsSaved() { - isModified = false - } - - fun isLayoutModified(): Boolean = isModified - - /** - * Configures the View for the design editor by disabling focus and input. - * - * For [TextView] subclasses, it explicitly disables text selection to prevent the - * internal `android.widget.Editor` from intercepting drag events, avoiding a - * `NullPointerException` on Android 12+ (API 31) caused by conflictive base class interactions. - */ - private fun View.configureForDesignMode() { - isFocusable = false - isFocusableInTouchMode = false - - if (this is TextView) { - keyListener = null - isCursorVisible = false - setTextIsSelectable(false) - } - } - - private fun rearrangeListeners(view: View) { - view.configureForDesignMode() - - when (view) { - is Spinner -> { - view.onItemSelectedListener = object : AdapterView.OnItemSelectedListener { - override fun onItemSelected(parent: AdapterView<*>?, v: View?, position: Int, id: Long) { - showDefinedAttributes(view) - } - override fun onNothingSelected(parent: AdapterView<*>?) {} - } - } - is AdapterView<*> -> { - view.setOnItemClickListener { _, _, _, _ -> - showDefinedAttributes(view) - } - } - else -> - view.setOnClickListener { - showDefinedAttributes(view) - } - } - - view.handleLongClicksAndDrag( - onLongPress = { view -> - TooltipManager.showTooltip( - context = view.context, - anchorView = view, - category = TooltipCategory.CATEGORY_JAVA, - tag = view.javaClass.superclass.name, - ) - }, - onDrop = { child, x, y -> - positionAtDrop(child, x, y, viewAttributeMap) - val rootLayout = getChildAt(0) - restoreSingleViewPosition(rootLayout, child, viewAttributeMap) - - updateStructure() - updateUndoRedoHistory() - }, - ) - } - - private fun addWidget( - view: View, - newParent: ViewGroup, - event: DragEvent, - ) { - removeWidget(view) - if (newParent is LinearLayout) { - val index = getIndexForNewChildOfLinear(newParent, event) - newParent.addView(view, index) - } else { - try { - newParent.addView(view, newParent.childCount) - } catch (e: Exception) { - e.printStackTrace() - } - } - } - - private fun removeWidget(view: View) { - (view.parent as ViewGroup?)?.removeView(view) - } - - private fun getIndexForNewChildOfLinear( - layout: LinearLayout, - event: DragEvent, - ): Int { - val orientation = layout.orientation - if (orientation == HORIZONTAL) { - var index = 0 - for (i in 0 until layout.childCount) { - val child = layout.getChildAt(i) - if (child === shadow) continue - if (child.right < event.x) index++ - } - return index - } - if (orientation == VERTICAL) { - var index = 0 - for (i in 0 until layout.childCount) { - val child = layout.getChildAt(i) - if (child === shadow) continue - if (child.bottom < event.y) index++ - } - return index - } - return -1 - } - - fun showDefinedAttributes(target: View) { - val allKeysAndValues = viewAttributeMap[target] ?: return - val allAttrs = initializer.getAllAttributesForView(target) - - val displayKeys = mutableListOf() - val displayValues = mutableListOf() - val displayAttrs = mutableListOf>() - - allKeysAndValues.keySet().forEachIndexed { i, key -> - val foundAttrDef = allAttrs.find { it[Constants.KEY_ATTRIBUTE_NAME].toString() == key } - - if (foundAttrDef != null) { - displayKeys.add(key) - displayValues.add(allKeysAndValues.values()[i]) - displayAttrs.add(foundAttrDef) - } - } - - val dialog = BottomSheetDialog(context).apply { - behavior.isFitToContents = true - behavior.state = BottomSheetBehavior.STATE_EXPANDED - behavior.skipCollapsed = true - } - - val binding = ShowAttributesDialogBinding.inflate(dialog.layoutInflater) - dialog.setContentView(binding.root) - - TooltipCompat.setTooltipText(binding.btnAdd, "Add attribute") - TooltipCompat.setTooltipText(binding.btnDelete, "Delete") - - val appliedAttributesAdapter = AppliedAttributesAdapter(displayAttrs, displayValues).apply { - onClick = { position -> - showAttributeEdit(target, displayKeys[position]) - dialog.dismiss() - } - - onRemoveButtonClick = { position -> - dialog.dismiss() - val updatedView = removeAttribute(target, displayKeys[position]) - showDefinedAttributes(updatedView) - } - } - - binding.attributesList.apply { - adapter = appliedAttributesAdapter - layoutManager = LinearLayoutManager(context, RecyclerView.VERTICAL, false) - } - - binding.viewLayout.displayTooltipOnLongPress( - context = context, - anchorView = binding.viewLayout, - tooltipCategory = TooltipCategory.CATEGORY_XML, - tooltipTag = target.javaClass.superclass.simpleName, - ) - - binding.viewName.text = target.javaClass.superclass.simpleName - binding.viewFullName.text = target.javaClass.superclass.name - - binding.btnAdd.setOnClickListener { - showAvailableAttributes(target) - dialog.dismiss() - } - - binding.btnDelete.setOnClickListener { - confirmViewDeletion(target, dialog) - } - - dialog.show() - } - - private fun showAvailableAttributes(target: View) { - val availableAttrs = initializer.getAvailableAttributesForView(target) - val names = availableAttrs.map { it["name"].toString() }.toMutableList() - val dialog = BottomSheetDialog(context).apply { - behavior.isFitToContents = true - behavior.state = BottomSheetBehavior.STATE_EXPANDED - behavior.skipCollapsed = true - } - - val binding = DialogAvailableAttributesBinding.inflate(dialog.layoutInflater) - - dialog.setContentView(binding.root) - - val adapter = AvailableAttributesAdapter(names) { attributeName -> - availableAttrs.find { it["name"].toString() == attributeName }?.let { attr -> - showAttributeEdit(target, attr[Constants.KEY_ATTRIBUTE_NAME].toString()) - } - dialog.dismiss() - } - - binding.attributesList.apply { - this.adapter = adapter - layoutManager = LinearLayoutManager(context, RecyclerView.VERTICAL, false) - } - - binding.searchEditText.addTextChangedListener( - object : TextWatcher { - override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {} - override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {} - override fun afterTextChanged(s: Editable?) { - adapter.filter(s?.toString() ?: "") - } - } - ) - - dialog.show() - } - - private fun confirmViewDeletion(target: View, dialog: BottomSheetDialog) { - MaterialAlertDialogBuilder(context) - .setTitle(R.string.delete_view) - .setMessage(R.string.msg_delete_view) - .setNegativeButton(R.string.no) { d, _ -> - d.dismiss() - } - .setPositiveButton(R.string.yes) { _, _ -> - removeId(target, target is ViewGroup) - removeViewAttributes(target) - removeWidget(target) - updateStructure() - updateUndoRedoHistory() - dialog.dismiss() - }.show() - } - - private fun showAttributeEdit( - target: View, - attributeKey: String, - ) { - val allAttrs = initializer.getAllAttributesForView(target) - val currentAttr = - initializer.getAttributeFromKey(attributeKey, allAttrs) - val attributeMap = viewAttributeMap[target] - - val argumentTypes = - currentAttr - ?.get(Constants.KEY_ARGUMENT_TYPE) - ?.toString() - ?.split("\\|".toRegex()) - ?.dropLastWhile { it.isEmpty() } - ?.toTypedArray() - - if (argumentTypes != null) { - if (argumentTypes.size > 1) { - if (attributeMap!!.contains(attributeKey)) { - val argumentType = - parseType(attributeMap.getValue(attributeKey), argumentTypes) - showAttributeEdit(target, attributeKey, argumentType) - return - } - MaterialAlertDialogBuilder(context) - .setTitle(R.string.select_arg_type) - .setAdapter( - ArrayAdapter( - context, - android.R.layout.simple_list_item_1, - argumentTypes, - ), - ) { _, w -> - showAttributeEdit(target, attributeKey, argumentTypes[w]) - }.show() - - return - } - } - showAttributeEdit(target, attributeKey, argumentTypes?.get(0)) - } - - @Suppress("UNCHECKED_CAST") - private fun showAttributeEdit( - target: View, - attributeKey: String, - argumentType: String?, - ) { - val allAttrs = initializer.getAllAttributesForView(target) - val currentAttr = - initializer.getAttributeFromKey(attributeKey, allAttrs) - val attributeMap = viewAttributeMap[target] - - var savedValue = - if (attributeMap!!.contains(attributeKey)) attributeMap.getValue(attributeKey) else "" - val defaultValue = - if (currentAttr?.containsKey(Constants.KEY_DEFAULT_VALUE) == true) { - currentAttr[Constants.KEY_DEFAULT_VALUE].toString() - } else { - null - } - val constant = - if (currentAttr?.containsKey(Constants.KEY_CONSTANT) == true - ) { - currentAttr[Constants.KEY_CONSTANT].toString() - } else { - null - } - - val context = context - - var dialog: AttributeDialog? = null - - when (argumentType) { - Constants.ARGUMENT_TYPE_SIZE -> dialog = SizeDialog(context, savedValue) - Constants.ARGUMENT_TYPE_DIMENSION -> - dialog = - DimensionDialog(context, savedValue, currentAttr?.get("dimensionUnit")?.toString()) - - Constants.ARGUMENT_TYPE_ID -> dialog = IdDialog(context, savedValue) - Constants.ARGUMENT_TYPE_VIEW -> dialog = ViewDialog(context, savedValue, constant) - Constants.ARGUMENT_TYPE_BOOLEAN -> dialog = BooleanDialog(context, savedValue) - Constants.ARGUMENT_TYPE_DRAWABLE -> { - if (savedValue.startsWith("@drawable/")) { - savedValue = savedValue.replace("@drawable/", "") - } - dialog = StringDialog(context, savedValue, Constants.ARGUMENT_TYPE_DRAWABLE) - } - - Constants.ARGUMENT_TYPE_STRING -> { - if (savedValue.startsWith("@string/")) { - savedValue = savedValue.replace("@string/", "") - } - dialog = StringDialog(context, savedValue, Constants.ARGUMENT_TYPE_STRING) - } - - Constants.ARGUMENT_TYPE_TEXT -> - dialog = - StringDialog(context, savedValue, Constants.ARGUMENT_TYPE_TEXT) - - Constants.ARGUMENT_TYPE_INT -> - dialog = - NumberDialog(context, savedValue, Constants.ARGUMENT_TYPE_INT) - - Constants.ARGUMENT_TYPE_FLOAT -> - dialog = - NumberDialog(context, savedValue, Constants.ARGUMENT_TYPE_FLOAT) - - Constants.ARGUMENT_TYPE_FLAG -> - dialog = - FlagDialog(context, savedValue, currentAttr?.get("arguments") as ArrayList?) - - Constants.ARGUMENT_TYPE_ENUM -> - dialog = - EnumDialog(context, savedValue, currentAttr?.get("arguments") as ArrayList?) - - Constants.ARGUMENT_TYPE_COLOR -> dialog = ColorDialog(context, savedValue) - } - if (dialog == null) return - - dialog.setTitle(currentAttr?.get("name")?.toString()) - dialog.setOnSaveValueListener { - if (defaultValue != null && (defaultValue == it)) { - if (attributeMap.contains(attributeKey)) removeAttribute(target, attributeKey) - } else { - if (currentAttr != null) { - initializer.applyAttribute(target, it!!, currentAttr) - } - showDefinedAttributes(target) - updateUndoRedoHistory() - updateStructure() - } - } - - dialog.show() - } - - private fun removeViewAttributes(view: View) { - viewAttributeMap.remove(view) - if (view is ViewGroup) { - for (i in 0 until view.childCount) { - removeViewAttributes(view.getChildAt(i)) - } - } - } - - private fun removeAttribute( - target: View, - attributeKey: String, - ): View { - @Suppress("NAME_SHADOWING") - var target = target - val allAttrs = initializer.getAllAttributesForView(target) - val currentAttr = initializer.getAttributeFromKey(attributeKey, allAttrs) - val attributeMap = viewAttributeMap[target] - - if (currentAttr?.containsKey(Constants.KEY_CAN_DELETE) == true) { - return target - } - - val name = - if (attributeMap!!.contains("android:id")) attributeMap.getValue("android:id") else null - val id = if (name != null) getViewId(name.replace("@+id/", "")) else -1 - attributeMap.removeValue(attributeKey) - - if (attributeKey == "android:id") { - removeId(target, false) - target.id = -1 - target.requestLayout() - - for (view: View in viewAttributeMap.keys) { - val map = viewAttributeMap[view] - for (key: String in map!!.keySet()) { - val value = map.getValue(key) - if (value.startsWith("@id/") && (value == name!!.replace("+", ""))) { - map.removeValue(key) - } - } - } - updateStructure() - return target - } - - viewAttributeMap.remove(target) - val parent = target.parent as ViewGroup - val indexOfView = parent.indexOfChild(target) - parent.removeView(target) - - val childs: MutableList = ArrayList() - if (target is ViewGroup) { - val group = target - if (group.childCount > 0) { - for (i in 0 until group.childCount) { - childs.add(group.getChildAt(i)) - } - } - group.removeAllViews() - } - - if (name != null) removeId(target, false) - target = InvokeUtil.createView(target.javaClass.name, context) as View - rearrangeListeners(target) - - if (target is ViewGroup) { - target.minimumWidth = Utils.pxToDp(context, 20) - target.minimumHeight = Utils.pxToDp(context, 20) - val group = target - if (childs.isNotEmpty()) { - for (i in childs.indices) { - group.addView(childs[i]) - } - } - setTransition(group) - } - - parent.addView(target, indexOfView) - viewAttributeMap[target] = attributeMap - - if (name != null) { - addId(target, name, id) - target.requestLayout() - } - - val currentKeys = attributeMap.keySet() - val currentValues = attributeMap.values() - - for (i in currentKeys.indices) { - val key = currentKeys[i] - - if (key == "android:id") { - continue - } - - val attrDef = initializer.getAttributeFromKey(key, allAttrs) - - if (attrDef != null) { - initializer.applyAttribute(target, currentValues[i], attrDef) - } - } - - try { - val cls: Class<*> = target.javaClass - val method = cls.getMethod("setStrokeEnabled", Boolean::class.javaPrimitiveType) - method.invoke(target, preferencesManager.isShowStroke) - } catch (e: Exception) { - e.printStackTrace() - } - updateStructure() - updateUndoRedoHistory() - return target - } - - private fun initAttributeInitializer() { - initializer = AttributeInitializer( - context, - viewAttributeMap, - getAttributes(context), - getParentAttributes(context) - ) - } - - fun HierarchyResult.handle(context: Context): Boolean { - return when (this) { - is HierarchyResult.Invalid -> { - Toast.makeText(context, errorMessage, Toast.LENGTH_LONG).show() - true - } - - is HierarchyResult.Warning -> { - Toast.makeText(context, message, Toast.LENGTH_SHORT).show() - false - } - - HierarchyResult.Valid -> false - } - } - - enum class ViewType { - DESIGN, - BLUEPRINT, - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/DeviceConfiguration.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/DeviceConfiguration.kt deleted file mode 100644 index 010b699a16..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/DeviceConfiguration.kt +++ /dev/null @@ -1,3 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor - -class DeviceConfiguration(var size: DeviceSize) diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/DeviceSize.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/DeviceSize.kt deleted file mode 100644 index 528bcd1089..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/DeviceSize.kt +++ /dev/null @@ -1,7 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor - -enum class DeviceSize { - SMALL, - MEDIUM, - LARGE -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/CardViewCaller.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/CardViewCaller.java deleted file mode 100644 index cd03b53ef1..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/CardViewCaller.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.callers; - -import android.content.Context; -import android.graphics.Color; -import android.view.View; - -import androidx.cardview.widget.CardView; - -import org.appdevforall.codeonthego.layouteditor.utils.DimensionUtil; - -public class CardViewCaller { - - public static void setCardElevation(View target, String value, Context context) { - ((CardView) target).setCardElevation(DimensionUtil.parse(value, context)); - } - - public static void setCardCornerRadius(View target, String value, Context context) { - ((CardView) target).setRadius(DimensionUtil.parse(value, context)); - } - - public static void setCardUseCompatPadding(View target, String value, Context context) { - ((CardView) target).setUseCompatPadding(value.equals("true")); - } - - public static void setCardBackgroundColor(View target, String value, Context context) { - ((CardView) target).setCardBackgroundColor(Color.parseColor(value)); - } -} \ No newline at end of file diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/FABCaller.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/FABCaller.java deleted file mode 100644 index eb4806e48c..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/FABCaller.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.callers; - -import android.content.Context; -import android.content.res.ColorStateList; -import android.graphics.Color; -import android.view.View; - -import com.google.android.material.floatingactionbutton.FloatingActionButton; - -import org.appdevforall.codeonthego.layouteditor.utils.DimensionUtil; - -import java.util.HashMap; - -public class FABCaller { - - private static final HashMap sizeMap = new HashMap<>(); - static { - sizeMap.put("auto", FloatingActionButton.SIZE_AUTO); - sizeMap.put("mini", FloatingActionButton.SIZE_MINI); - sizeMap.put("normal", FloatingActionButton.SIZE_NORMAL); - } - - public static void setSize(View target, String value, Context context) { - ((FloatingActionButton) target).setSize(sizeMap.get(value)); - } - - public static void setCustomSize(View target, String value, Context context) { - ((FloatingActionButton) target).setCustomSize((int) DimensionUtil.parse(value, context)); - } - - public static void setCompatElevation(View target, String value, Context context) { - ((FloatingActionButton) target).setCompatElevation(DimensionUtil.parse(value, context)); - } - - public static void setBackgroundColor(View target, String value, Context context) { - ((FloatingActionButton) target).setBackgroundTintList(ColorStateList.valueOf(Color.parseColor(value))); - } -} \ No newline at end of file diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/ImageViewCaller.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/ImageViewCaller.java deleted file mode 100644 index 5818afd92b..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/ImageViewCaller.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.callers; - -import android.content.Context; -import android.graphics.Color; -import android.view.View; -import android.widget.ImageView; - -import org.appdevforall.codeonthego.layouteditor.managers.DrawableManager; - -import java.util.HashMap; - -public class ImageViewCaller { - - private static HashMap scaleTypes = new HashMap<>(); - - static { - scaleTypes.put("fitXY", ImageView.ScaleType.FIT_XY); - scaleTypes.put("fitStart", ImageView.ScaleType.FIT_START); - scaleTypes.put("fitCenter", ImageView.ScaleType.FIT_CENTER); - scaleTypes.put("fitEnd", ImageView.ScaleType.FIT_END); - scaleTypes.put("center", ImageView.ScaleType.CENTER); - scaleTypes.put("centerCrop", ImageView.ScaleType.CENTER_CROP); - scaleTypes.put("centerInside", ImageView.ScaleType.CENTER_INSIDE); - } - - public static void setImage(View target, String value, Context context) { - String name = value.replace("@drawable/", ""); - ((ImageView) target).setImageDrawable(DrawableManager.getDrawable(context, name)); - } - - public static void setScaleType(View target, String value, Context context) { - ((ImageView) target).setScaleType(scaleTypes.get(value)); - } - - public static void setTint(View target, String value, Context context) { - ((ImageView) target).setColorFilter(Color.parseColor(value)); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/LinearLayoutCaller.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/LinearLayoutCaller.java deleted file mode 100644 index 1d8d9ce600..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/LinearLayoutCaller.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.callers; - -import android.content.Context; -import android.view.View; -import android.widget.LinearLayout; - -import androidx.appcompat.widget.LinearLayoutCompat; - -import org.appdevforall.codeonthego.layouteditor.utils.Constants; - -import java.util.HashMap; - -public class LinearLayoutCaller { - - private static final HashMap orientationMap = new HashMap<>(); - - static { - orientationMap.put("horizontal", LinearLayout.HORIZONTAL); - orientationMap.put("vertical", LinearLayout.VERTICAL); - } - - public static void setOrientation(View target, String value, Context context) { - if (target instanceof LinearLayout) - ((LinearLayout) target).setOrientation(orientationMap.get(value)); - else ((LinearLayoutCompat) target).setOrientation(orientationMap.get(value)); - } - - public static void setGravity(View target, String value, Context context) { - String[] flags = value.split("\\|"); - int result = 0; - - for (String flag : flags) result |= Constants.gravityMap.get(flag); - if (target instanceof LinearLayout) ((LinearLayout) target).setGravity(result); - else ((LinearLayoutCompat) target).setGravity(result); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/SwitchCaller.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/SwitchCaller.java deleted file mode 100644 index 01e50979b8..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/SwitchCaller.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.callers; - -import android.content.Context; -import android.view.View; -import android.widget.Switch; - -import androidx.appcompat.widget.SwitchCompat; - -import com.google.android.material.materialswitch.MaterialSwitch; - -public class SwitchCaller { - public static void setChecked(View target, String value, Context context) { - if (value.equals("true")) { - if (target instanceof Switch) ((Switch) target).setChecked(true); - else if (target instanceof SwitchCompat) ((SwitchCompat) target).setChecked(true); - else if (target instanceof MaterialSwitch) ((MaterialSwitch) target).setChecked(true); - } else { - if (target instanceof Switch) ((Switch) target).setChecked(false); - else if (target instanceof SwitchCompat) ((SwitchCompat) target).setChecked(false); - else if (target instanceof MaterialSwitch) ((MaterialSwitch) target).setChecked(false); - } - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/ViewCaller.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/ViewCaller.java deleted file mode 100644 index ecb9cfd421..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/ViewCaller.java +++ /dev/null @@ -1,130 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.callers; - -import android.content.Context; -import android.graphics.Color; -import android.graphics.drawable.ColorDrawable; -import android.view.View; - -import org.appdevforall.codeonthego.layouteditor.managers.DrawableManager; -import org.appdevforall.codeonthego.layouteditor.managers.IdManager; -import org.appdevforall.codeonthego.layouteditor.utils.ArgumentUtil; -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.utils.DimensionUtil; - -public class ViewCaller { - public static void setId(View target, String value, Context context) { - IdManager.addNewId(target, value); - } - - public static void setLayoutWidth(View target, String value, Context context) { - if (target.getLayoutParams() != null) { - target.getLayoutParams().width = (int) DimensionUtil.parse(value, context); - target.requestLayout(); - } - } - - public static void setLayoutHeight(View target, String value, Context context) { - if (target.getLayoutParams() != null) { - target.getLayoutParams().height = (int) DimensionUtil.parse(value, context); - target.requestLayout(); - } - } - - public static void setBackground(View target, String value, Context context) { - if (ArgumentUtil.parseType(value, new String[] {"color", "drawable"}) - .equals(ArgumentUtil.COLOR)) { - target.setBackgroundColor(Color.parseColor(value)); - } else { - String name = value.replace("@drawable/", ""); - target.setBackground(DrawableManager.getDrawable(context, name)); - } - } - - public static void setForeground(View target, String value, Context context) { - if (ArgumentUtil.parseType(value, new String[] {"color", "drawable"}) - .equals(ArgumentUtil.COLOR)) { - target.setForeground(new ColorDrawable(Color.parseColor(value))); - } else { - String name = value.replace("@drawable/", ""); - target.setForeground(DrawableManager.getDrawable(context, name)); - } - } - - public static void setElevation(View target, String value, Context context) { - target.setElevation(DimensionUtil.parse(value, context)); - } - - public static void setAlpha(View target, String value, Context context) { - target.setAlpha(Float.valueOf(value)); - } - - public static void setRotation(View target, String value, Context context) { - target.setRotation(Float.valueOf(value)); - } - - public static void setRotationX(View target, String value, Context context) { - target.setRotationX(Float.valueOf(value)); - } - - public static void setRotationY(View target, String value, Context context) { - target.setRotationY(Float.valueOf(value)); - } - - public static void setTranslationX(View target, String value, Context context) { - target.setTranslationX(DimensionUtil.parse(value, context)); - } - - public static void setTranslationY(View target, String value, Context context) { - target.setTranslationY(DimensionUtil.parse(value, context)); - } - - public static void setTranslationZ(View target, String value, Context context) { - target.setTranslationZ(DimensionUtil.parse(value, context)); - } - - public static void setScaleX(View target, String value, Context context) { - target.setScaleX(Float.valueOf(value)); - } - - public static void setScaleY(View target, String value, Context context) { - target.setScaleY(Float.valueOf(value)); - } - - public static void setPadding(View target, String value, Context context) { - int pad = (int) DimensionUtil.parse(value, context); - target.setPadding(pad, pad, pad, pad); - } - - public static void setPaddingLeft(View target, String value, Context context) { - int pad = (int) DimensionUtil.parse(value, context); - target.setPadding( - pad, target.getPaddingTop(), target.getPaddingRight(), target.getPaddingBottom()); - } - - public static void setPaddingRight(View target, String value, Context context) { - int pad = (int) DimensionUtil.parse(value, context); - target.setPadding( - target.getPaddingLeft(), target.getPaddingTop(), pad, target.getPaddingBottom()); - } - - public static void setPaddingTop(View target, String value, Context context) { - int pad = (int) DimensionUtil.parse(value, context); - target.setPadding( - target.getPaddingLeft(), pad, target.getPaddingRight(), target.getPaddingBottom()); - } - - public static void setPaddingBottom(View target, String value, Context context) { - int pad = (int) DimensionUtil.parse(value, context); - target.setPadding( - target.getPaddingLeft(), target.getPaddingTop(), target.getPaddingRight(), pad); - } - - public static void setEnabled(View target, String value, Context context) { - if (value.equals("true")) target.setEnabled(true); - else target.setEnabled(false); - } - - public static void setVisibility(View target, String value, Context context) { - target.setVisibility(Constants.visibilityMap.get(value)); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/containers/ScrollViewCaller.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/containers/ScrollViewCaller.java deleted file mode 100644 index 1950829779..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/containers/ScrollViewCaller.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.callers.containers; - -import android.content.Context; -import android.view.View; -import android.widget.ScrollView; - -public class ScrollViewCaller { - public static void setFillViewport(View target, String value, Context context) { - if (value.equals("true")) ((ScrollView) target).setFillViewport(true); - else if (value.equals("false")) ((ScrollView) target).setFillViewport(false); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/layouts/ConstraintLayoutCaller.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/layouts/ConstraintLayoutCaller.java deleted file mode 100644 index 3b5b13ec30..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/layouts/ConstraintLayoutCaller.java +++ /dev/null @@ -1,200 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.callers.layouts; - -import android.content.Context; -import android.view.View; - -import androidx.constraintlayout.widget.ConstraintLayout; -import androidx.constraintlayout.widget.ConstraintSet; - -import org.appdevforall.codeonthego.layouteditor.managers.IdManager; -import org.appdevforall.codeonthego.layouteditor.utils.DimensionUtil; - -public class ConstraintLayoutCaller { - - private static final int PARENT_ID = ConstraintSet.PARENT_ID; - private static final int LEFT = ConstraintSet.LEFT; - private static final int RIGHT = ConstraintSet.RIGHT; - private static final int TOP = ConstraintSet.TOP; - private static final int BOTTOM = ConstraintSet.BOTTOM; - private static final int BASELINE = ConstraintSet.BASELINE; - private static final int START = ConstraintSet.START; - private static final int END = ConstraintSet.END; - - private static ConstraintSet cloneWithIds(ConstraintLayout layout) { - for (int i = 0; i < layout.getChildCount(); i++) { - View child = layout.getChildAt(i); - if (child.getId() == View.NO_ID) { - child.setId(View.generateViewId()); - } - } - ConstraintSet set = new ConstraintSet(); - set.clone(layout); - return set; - } - - private static ConstraintLayout getParentLayout(View target) { - return (ConstraintLayout) target.getParent(); - } - - private static void setConstraint( - ConstraintLayout layout, View target, String value, int startSide, int endSide) { - ConstraintSet set = cloneWithIds(layout); - int targetViewId = "parent".equals(value) ? PARENT_ID : IdManager.getViewId(value); - set.connect(target.getId(), startSide, targetViewId, endSide); - set.applyTo(layout); - } - - private static void setConstraint(View target, String value, int startSide, int endSide) { - setConstraint(getParentLayout(target), target, value, startSide, endSide); - } - - private static void setMargin(ConstraintLayout layout, View target, int side, int value) { - ConstraintSet set = cloneWithIds(layout); - set.setMargin(target.getId(), side, value); - set.applyTo(layout); - } - - private static void setMargin(View target, int side, String value) { - ConstraintLayout layout = getParentLayout(target); - int margin = (int) DimensionUtil.parse(value, target.getContext()); - setMargin(layout, target, side, margin); - } - - private static void setGoneMargin(ConstraintLayout layout, View target, int side, int value) { - ConstraintSet set = cloneWithIds(layout); - set.setGoneMargin(target.getId(), side, value); - set.applyTo(layout); - } - - private static void setGoneMargin(View target, int side, String value) { - ConstraintLayout layout = getParentLayout(target); - int margin = (int) DimensionUtil.parse(value, target.getContext()); - setGoneMargin(layout, target, side, margin); - } - - public static void setLeftToLeft(View target, String value, Context context) { - setConstraint(target, value, LEFT, LEFT); - } - - public static void setLeftToRight(View target, String value, Context context) { - setConstraint(target, value, LEFT, RIGHT); - } - - public static void setRightToLeft(View target, String value, Context context) { - setConstraint(target, value, RIGHT, LEFT); - } - - public static void setRightToRight(View target, String value, Context context) { - setConstraint(target, value, RIGHT, RIGHT); - } - - public static void setTopToTop(View target, String value, Context context) { - setConstraint(target, value, TOP, TOP); - } - - public static void setTopToBottom(View target, String value, Context context) { - setConstraint(target, value, TOP, BOTTOM); - } - - public static void setBottomToTop(View target, String value, Context context) { - setConstraint(target, value, BOTTOM, TOP); - } - - public static void setBottomToBottom(View target, String value, Context context) { - setConstraint(target, value, BOTTOM, BOTTOM); - } - - public static void setBaselineToBaseline(View target, String value, Context context) { - setConstraint(target, value, BASELINE, BASELINE); - } - - public static void setStartToStart(View target, String value, Context context) { - setConstraint(target, value, START, START); - } - - public static void setStartToEnd(View target, String value, Context context) { - setConstraint(target, value, START, END); - } - - public static void setEndToStart(View target, String value, Context context) { - setConstraint(target, value, END, START); - } - - public static void setEndToEnd(View target, String value, Context context) { - setConstraint(target, value, END, END); - } - - public static void setLayoutMarginStart(View target, String value, Context context) { - setMargin(target, START, value); - } - - public static void setLayoutMarginEnd(View target, String value, Context context) { - setMargin(target, END, value); - } - - public static void setLayoutMarginLeft(View target, String value, Context context) { - setMargin(target, LEFT, value); - } - - public static void setLayoutMarginTop(View target, String value, Context context) { - setMargin(target, TOP, value); - } - - public static void setLayoutMarginRight(View target, String value, Context context) { - setMargin(target, RIGHT, value); - } - - public static void setLayoutMarginBottom(View target, String value, Context context) { - setMargin(target, BOTTOM, value); - } - - public static void setLayoutMarginBaseline(View target, String value, Context context) { - setMargin(target, BASELINE, value); - } - - public static void setLayoutGoneMarginStart(View target, String value, Context context) { - setGoneMargin(target, START, value); - } - - public static void setLayoutGoneMarginEnd(View target, String value, Context context) { - setGoneMargin(target, END, value); - } - - public static void setLayoutGoneMarginLeft(View target, String value, Context context) { - setGoneMargin(target, LEFT, value); - } - - public static void setLayoutGoneMarginTop(View target, String value, Context context) { - setGoneMargin(target, TOP, value); - } - - public static void setLayoutGoneMarginRight(View target, String value, Context context) { - setGoneMargin(target, RIGHT, value); - } - - public static void setLayoutGoneMarginBottom(View target, String value, Context context) { - setGoneMargin(target, BOTTOM, value); - } - - public static void setLayoutGoneMarginBaseline(View target, String value, Context context) { - setGoneMargin(target, BASELINE, value); - } - - private static float parseBias(String value) { - return Math.max(0f, Math.min(1f, Float.parseFloat(value))); - } - - public static void setHorizontalBias(View target, String value, Context context) { - ConstraintLayout layout = getParentLayout(target); - ConstraintSet set = cloneWithIds(layout); - set.setHorizontalBias(target.getId(), parseBias(value)); - set.applyTo(layout); - } - - public static void setVerticalBias(View target, String value, Context context) { - ConstraintLayout layout = getParentLayout(target); - ConstraintSet set = cloneWithIds(layout); - set.setVerticalBias(target.getId(), parseBias(value)); - set.applyTo(layout); - } -} \ No newline at end of file diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/layouts/FrameLayoutCaller.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/layouts/FrameLayoutCaller.java deleted file mode 100644 index 862855f321..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/layouts/FrameLayoutCaller.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.callers.layouts; - -import android.content.Context; -import android.view.View; -import android.widget.FrameLayout; - -import org.appdevforall.codeonthego.layouteditor.utils.Constants; - -public class FrameLayoutCaller { - public static void setForegroundGravity(View target, String value, Context context) { - String[] flags = value.split("\\|"); - int result = 0; - - for (String flag : flags) { - result |= Constants.gravityMap.get(flag); - } - - target.setForegroundGravity(result); - target.requestLayout(); - } - - public static void setMeasureAllChildren(View target, String value, Context context) { - ((FrameLayout) target).setMeasureAllChildren(Boolean.parseBoolean(value)); - } -} \ No newline at end of file diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/layouts/LinearLayoutCaller.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/layouts/LinearLayoutCaller.java deleted file mode 100644 index 1d15fb9332..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/layouts/LinearLayoutCaller.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.callers.layouts; - -import android.content.Context; -import android.view.View; -import android.widget.LinearLayout; - -public class LinearLayoutCaller { - public static void setWeightSum(View target, String value, Context context) { - if (target instanceof LinearLayout) ((LinearLayout) target).setWeightSum(Float.valueOf(value)); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/parentcallers/FrameLayoutCaller.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/parentcallers/FrameLayoutCaller.java deleted file mode 100644 index 8f8f67e78a..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/parentcallers/FrameLayoutCaller.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.callers.parentcallers; - -import android.content.Context; -import android.view.View; -import android.widget.FrameLayout; - -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.utils.DimensionUtil; - -public class FrameLayoutCaller { - public static void setLayoutGravity(View target, String value, Context context) { - String[] flags = value.split("\\|"); - int result = 0; - - for (String flag : flags) { - result |= Constants.gravityMap.get(flag); - } - - ((FrameLayout.LayoutParams) target.getLayoutParams()).gravity = result; - target.requestLayout(); - } - - public static void setLayoutMargin(View target, String value, Context context) { - int margin = (int) DimensionUtil.parse(value, context); - ((FrameLayout.LayoutParams) target.getLayoutParams()).setMargins(margin, margin, margin, margin); - target.requestLayout(); - } - - public static void setLayoutMarginLeft(View target, String value, Context context) { - ((FrameLayout.LayoutParams) target.getLayoutParams()).leftMargin = (int) DimensionUtil.parse(value, context); - target.requestLayout(); - } - - public static void setLayoutMarginRight(View target, String value, Context context) { - ((FrameLayout.LayoutParams) target.getLayoutParams()).rightMargin = (int) DimensionUtil.parse(value, context); - target.requestLayout(); - } - - public static void setLayoutMarginTop(View target, String value, Context context) { - ((FrameLayout.LayoutParams) target.getLayoutParams()).topMargin = (int) DimensionUtil.parse(value, context); - target.requestLayout(); - } - - public static void setLayoutMarginBottom(View target, String value, Context context) { - ((FrameLayout.LayoutParams) target.getLayoutParams()).bottomMargin = (int) DimensionUtil.parse(value, context); - target.requestLayout(); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/parentcallers/LinearLayoutCaller.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/parentcallers/LinearLayoutCaller.java deleted file mode 100644 index f334829f96..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/parentcallers/LinearLayoutCaller.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.callers.parentcallers; - -import android.content.Context; -import android.view.View; -import android.widget.LinearLayout; - -import org.appdevforall.codeonthego.layouteditor.utils.DimensionUtil; - -public class LinearLayoutCaller { - public static void setLayoutWeight(View target, String value, Context context) { - ((LinearLayout.LayoutParams) target.getLayoutParams()).weight = Float.parseFloat(value); - target.requestLayout(); - } - - public static void setLayoutMargin(View target, String value, Context context) { - int margin = (int) DimensionUtil.parse(value, context); - ((LinearLayout.LayoutParams) target.getLayoutParams()).setMargins(margin, margin, margin, margin); - target.requestLayout(); - } - - public static void setLayoutMarginLeft(View target, String value, Context context) { - ((LinearLayout.LayoutParams) target.getLayoutParams()).leftMargin = (int) DimensionUtil.parse(value, context); - target.requestLayout(); - } - - public static void setLayoutMarginRight(View target, String value, Context context) { - ((LinearLayout.LayoutParams) target.getLayoutParams()).rightMargin = (int) DimensionUtil.parse(value, context); - target.requestLayout(); - } - - public static void setLayoutMarginTop(View target, String value, Context context) { - ((LinearLayout.LayoutParams) target.getLayoutParams()).topMargin = (int) DimensionUtil.parse(value, context); - target.requestLayout(); - } - - public static void setLayoutMarginBottom(View target, String value, Context context) { - ((LinearLayout.LayoutParams) target.getLayoutParams()).bottomMargin = (int) DimensionUtil.parse(value, context); - target.requestLayout(); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/parentcallers/RelativeLayoutCaller.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/parentcallers/RelativeLayoutCaller.java deleted file mode 100644 index 739807950d..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/parentcallers/RelativeLayoutCaller.java +++ /dev/null @@ -1,191 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.callers.parentcallers; - -import android.content.Context; -import android.view.View; -import android.widget.RelativeLayout; - -import org.appdevforall.codeonthego.layouteditor.managers.IdManager; -import org.appdevforall.codeonthego.layouteditor.utils.DimensionUtil; - -public class RelativeLayoutCaller { - - public static void setLayoutBelow(View target, String value, Context context) { - RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) target.getLayoutParams(); - int id = IdManager.getViewId(value); - params.addRule(RelativeLayout.BELOW, id); - target.requestLayout(); - } - - public static void setLayoutAbove(View target, String value, Context context) { - RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) target.getLayoutParams(); - int id = IdManager.getViewId(value); - params.addRule(RelativeLayout.ABOVE, id); - target.requestLayout(); - } - - public static void setLayoutToLeftOf(View target, String value, Context context) { - RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) target.getLayoutParams(); - int id = IdManager.getViewId(value); - params.addRule(RelativeLayout.LEFT_OF, id); - target.requestLayout(); - } - - public static void setLayoutToRightOf(View target, String value, Context context) { - RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) target.getLayoutParams(); - int id = IdManager.getViewId(value); - params.addRule(RelativeLayout.RIGHT_OF, id); - target.requestLayout(); - } - - public static void setLayoutAlignLeft(View target, String value, Context context) { - RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) target.getLayoutParams(); - int id = IdManager.getViewId(value); - params.addRule(RelativeLayout.ALIGN_LEFT, id); - target.requestLayout(); - } - - public static void setLayoutAlignRight(View target, String value, Context context) { - RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) target.getLayoutParams(); - int id = IdManager.getViewId(value); - params.addRule(RelativeLayout.ALIGN_RIGHT, id); - target.requestLayout(); - } - - public static void setLayoutAlignTop(View target, String value, Context context) { - RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) target.getLayoutParams(); - int id = IdManager.getViewId(value); - params.addRule(RelativeLayout.ALIGN_TOP, id); - target.requestLayout(); - } - - public static void setLayoutAlignBottom(View target, String value, Context context) { - RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) target.getLayoutParams(); - int id = IdManager.getViewId(value); - params.addRule(RelativeLayout.ALIGN_BOTTOM, id); - target.requestLayout(); - } - - public static void setLayoutAlignParentLeft(View target, String value, Context context) { - RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) target.getLayoutParams(); - - if(value.equals("true")) { - params.addRule(RelativeLayout.ALIGN_PARENT_LEFT); - } - else { - params.removeRule(RelativeLayout.ALIGN_PARENT_LEFT); - } - - target.requestLayout(); - } - - public static void setLayoutAlignParentRight(View target, String value, Context context) { - RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) target.getLayoutParams(); - - if(value.equals("true")) { - params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); - } - else { - params.removeRule(RelativeLayout.ALIGN_PARENT_RIGHT); - } - - target.requestLayout(); - } - - public static void setLayoutAlignParentTop(View target, String value, Context context) { - RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) target.getLayoutParams(); - - if(value.equals("true")) { - params.addRule(RelativeLayout.ALIGN_PARENT_TOP); - } - else { - params.removeRule(RelativeLayout.ALIGN_PARENT_TOP); - } - - target.requestLayout(); - } - - public static void setLayoutAlignParentBottom(View target, String value, Context context) { - RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) target.getLayoutParams(); - - if(value.equals("true")) { - params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); - } - else { - params.removeRule(RelativeLayout.ALIGN_PARENT_BOTTOM); - } - - target.requestLayout(); - } - - public static void setLayoutAlignBaseline(View target, String value, Context context) { - RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) target.getLayoutParams(); - int id = IdManager.getViewId(value); - params.addRule(RelativeLayout.ALIGN_BASELINE, id); - target.requestLayout(); - } - - public static void setLayoutCenterHorizontal(View target, String value, Context context) { - RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) target.getLayoutParams(); - - if(value.equals("true")) { - params.addRule(RelativeLayout.CENTER_HORIZONTAL); - } - else { - params.removeRule(RelativeLayout.CENTER_HORIZONTAL); - } - - target.requestLayout(); - } - - public static void setLayoutCenterVertical(View target, String value, Context context) { - RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) target.getLayoutParams(); - - if(value.equals("true")) { - params.addRule(RelativeLayout.CENTER_VERTICAL); - } - else { - params.removeRule(RelativeLayout.CENTER_VERTICAL); - } - - target.requestLayout(); - } - - public static void setLayoutCenterInParent(View target, String value, Context context) { - RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) target.getLayoutParams(); - - if(value.equals("true")) { - params.addRule(RelativeLayout.CENTER_IN_PARENT); - } - else { - params.removeRule(RelativeLayout.CENTER_IN_PARENT); - } - - target.requestLayout(); - } - - public static void setLayoutMargin(View target, String value, Context context) { - int margin = (int) DimensionUtil.parse(value, context); - ((RelativeLayout.LayoutParams) target.getLayoutParams()).setMargins(margin, margin, margin, margin); - target.requestLayout(); - } - - public static void setLayoutMarginLeft(View target, String value, Context context) { - ((RelativeLayout.LayoutParams) target.getLayoutParams()).leftMargin = (int) DimensionUtil.parse(value, context); - target.requestLayout(); - } - - public static void setLayoutMarginRight(View target, String value, Context context) { - ((RelativeLayout.LayoutParams) target.getLayoutParams()).rightMargin = (int) DimensionUtil.parse(value, context); - target.requestLayout(); - } - - public static void setLayoutMarginTop(View target, String value, Context context) { - ((RelativeLayout.LayoutParams) target.getLayoutParams()).topMargin = (int) DimensionUtil.parse(value, context); - target.requestLayout(); - } - - public static void setLayoutMarginBottom(View target, String value, Context context) { - ((RelativeLayout.LayoutParams) target.getLayoutParams()).bottomMargin = (int) DimensionUtil.parse(value, context); - target.requestLayout(); - } -} \ No newline at end of file diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/text/AutoCompleteTextViewCaller.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/text/AutoCompleteTextViewCaller.java deleted file mode 100644 index 663ad0a735..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/text/AutoCompleteTextViewCaller.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.callers.text; - -import android.content.Context; -import android.graphics.Color; -import android.view.View; -import android.widget.AutoCompleteTextView; - -import org.appdevforall.codeonthego.layouteditor.ProjectFile; -import org.appdevforall.codeonthego.layouteditor.managers.ProjectManager; -import org.appdevforall.codeonthego.layouteditor.managers.ValuesManager; -import org.appdevforall.codeonthego.layouteditor.tools.ValuesResourceParser; -import org.appdevforall.codeonthego.layouteditor.utils.DimensionUtil; - -public class AutoCompleteTextViewCaller extends EditTextCaller { - public static void setCompletionHint(View target, String value, Context context) { - if (value.startsWith("@string/")) { - ProjectFile project = ProjectManager.getInstance().getOpenedProject(); - value = - ValuesManager.getValueFromResources( - ValuesResourceParser.TAG_STRING, value, project.getStringsPath()); - } - ((AutoCompleteTextView) target).setCompletionHint(value); - } - - public static void setThreshold(View target, String value, Context context) { - ((AutoCompleteTextView) target).setThreshold((int) DimensionUtil.parse(value, context)); - } - - public static void setDropDownHeight(View target, String value, Context context) { - ((AutoCompleteTextView) target).setDropDownHeight((int) DimensionUtil.parse(value, context)); - } - - public static void setDropDownHorizontalOffset(View target, String value, Context context) { - ((AutoCompleteTextView) target) - .setDropDownHorizontalOffset((int) DimensionUtil.parse(value, context)); - } - - public static void setDropDownVerticalOffset(View target, String value, Context context) { - ((AutoCompleteTextView) target) - .setDropDownVerticalOffset((int) DimensionUtil.parse(value, context)); - } - - public static void setDropDownWidth(View target, String value, Context context) { - ((AutoCompleteTextView) target).setDropDownWidth((int) DimensionUtil.parse(value, context)); - } - - public static void setDropDownBackgroundResource(View target, String value, Context context) { - ((AutoCompleteTextView) target).setDropDownBackgroundResource(Color.parseColor(value)); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/text/EditTextCaller.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/text/EditTextCaller.java deleted file mode 100644 index df3b15df75..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/text/EditTextCaller.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.callers.text; - -import android.content.Context; -import android.graphics.Color; -import android.view.View; -import android.widget.EditText; - -import androidx.appcompat.widget.AppCompatEditText; - -import org.appdevforall.codeonthego.layouteditor.ProjectFile; -import org.appdevforall.codeonthego.layouteditor.managers.ProjectManager; -import org.appdevforall.codeonthego.layouteditor.managers.ValuesManager; -import org.appdevforall.codeonthego.layouteditor.tools.ValuesResourceParser; -import org.appdevforall.codeonthego.layouteditor.utils.Constants; - -public class EditTextCaller { - - public static void setHint(View target, String value, Context context) { - if (value.startsWith("@string/")) { - ProjectFile project = ProjectManager.getInstance().getOpenedProject(); - - value = - ValuesManager.getValueFromResources( - ValuesResourceParser.TAG_STRING, value, project.getStringsPath()); - } - if (target instanceof EditText) ((EditText) target).setHint(value); - else if (target instanceof AppCompatEditText) ((AppCompatEditText) target).setHint(value); - } - - public static void setHintTextColor(View target, String value, Context context) { - if (target instanceof EditText) ((EditText) target).setHintTextColor(Color.parseColor(value)); - else if (target instanceof AppCompatEditText) - ((AppCompatEditText) target).setHintTextColor(Color.parseColor(value)); - } - - public static void setSingleLine(View target, String value, Context context) { - if (value.equals("true")) { - if (target instanceof EditText) ((EditText) target).setSingleLine(true); - else if (target instanceof AppCompatEditText) - ((AppCompatEditText) target).setSingleLine(true); - } else { - if (target instanceof EditText) ((EditText) target).setSingleLine(false); - else if (target instanceof AppCompatEditText) - ((AppCompatEditText) target).setSingleLine(false); - } - } - - public static void setInputType(View target, String value, Context context) { - String[] flags = value.split("\\|"); - int result = 0; - - for (String flag : flags) result |= Constants.inputTypes.get(flag); - - if (target instanceof EditText) ((EditText) target).setInputType(result); - else if (target instanceof AppCompatEditText) ((AppCompatEditText) target).setInputType(result); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/text/TextInputEditTextCaller.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/text/TextInputEditTextCaller.kt deleted file mode 100644 index 04b1d92eb3..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/text/TextInputEditTextCaller.kt +++ /dev/null @@ -1,5 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.callers.text - -open class TextInputEditTextCaller : EditTextCaller() { - // Inherits typical EditText attributes -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/text/TextInputLayoutCaller.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/text/TextInputLayoutCaller.kt deleted file mode 100644 index 9e4946b194..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/text/TextInputLayoutCaller.kt +++ /dev/null @@ -1,38 +0,0 @@ -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 - } - - @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() - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/text/TextViewCaller.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/text/TextViewCaller.java deleted file mode 100644 index cd17c91f58..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/callers/text/TextViewCaller.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.callers.text; - -import android.content.Context; -import android.graphics.Color; -import android.view.View; -import android.widget.CheckedTextView; -import android.widget.TextView; - -import org.appdevforall.codeonthego.layouteditor.ProjectFile; -import org.appdevforall.codeonthego.layouteditor.managers.DrawableManager; -import org.appdevforall.codeonthego.layouteditor.managers.ProjectManager; -import org.appdevforall.codeonthego.layouteditor.managers.ValuesManager; -import org.appdevforall.codeonthego.layouteditor.tools.ValuesResourceParser; -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.utils.DimensionUtil; - -public class TextViewCaller { - public static void setText(View target, String value, Context context) { - if (value.startsWith("@string/")) { - ProjectFile project = ProjectManager.getInstance().getOpenedProject(); - - value = - ValuesManager.getValueFromResources( - ValuesResourceParser.TAG_STRING, value, project.getStringsPath()); - } - ((TextView) target).setText(value); - } - - public static void setTextSize(View target, String value, Context context) { - ((TextView) target).setTextSize(DimensionUtil.parse(value, context)); - } - - public static void setTextColor(View target, String value, Context context) { - ((TextView) target).setTextColor(Color.parseColor(value)); - } - - public static void setGravity(View target, String value, Context context) { - String[] flags = value.split("\\|"); - int result = 0; - - for (String flag : flags) { - result |= Constants.gravityMap.get(flag); - } - - ((TextView) target).setGravity(result); - } - - public static void setCheckMark(View target, String value, Context context) { - String name = value.replace("@drawable/", ""); - if (target instanceof CheckedTextView) - ((CheckedTextView) target).setCheckMarkDrawable(DrawableManager.getDrawable(context, name)); - } - - public static void setChecked(View target, String value, Context context) { - if (target instanceof CheckedTextView) { - if (value.equals("true")) ((CheckedTextView) target).setChecked(true); - else if (value.equals("false")) ((CheckedTextView) target).setChecked(false); - } - } - - public static void setTextStyle(View target, String value, Context context) { - ((TextView) target).setTypeface(null, Constants.textStyleMap.get(value)); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/convert/ConvertImportedXml.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/convert/ConvertImportedXml.kt deleted file mode 100644 index dbd8b194e7..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/convert/ConvertImportedXml.kt +++ /dev/null @@ -1,68 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.convert - -import android.content.Context -import org.appdevforall.codeonthego.layouteditor.utils.FileUtil -import org.json.JSONObject -import org.xml.sax.InputSource -import java.io.StringReader -import java.util.regex.Pattern -import javax.xml.parsers.DocumentBuilderFactory - -class ConvertImportedXml(private val xml: String?) { - - fun getXmlConverted(context: Context): String? { - var convertedXml = xml - - if (isWellFormed(xml)) { - val pattern = "<([a-zA-Z0-9]+\\.)*([a-zA-Z0-9]+)" - - val matcher = Pattern.compile(pattern).matcher( - xml.toString() - ) - try { - while (matcher.find()) { - val fullTag = matcher.group(0)?.replace("<", "") - val widgetName = matcher.group(2) - - val classes = - JSONObject(FileUtil.readFromAsset("widgetclasses.json", context)) - - val widgetClass = widgetName?.let { - try { - classes.getString(it) - } catch (e: Exception) { - e.printStackTrace() - // If the widget isn't found in the mapping, use the original widget name - fullTag - } - } - if (convertedXml != null) { - convertedXml = convertedXml.replace("<$fullTag", "<$widgetClass") - } - if (convertedXml != null) { - convertedXml = convertedXml.replace(" {}); - dialog.setButton(AlertDialog.BUTTON_POSITIVE, "Save", (di, which) -> onClickSave()); - - inputMethodManager = - (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); - } - - /** - * Set title of the dialog - * - * @param title Title of the dialog - */ - public void setTitle(String title) { - dialog.setTitle(title); - } - - /** - * Set view of the dialog - * - * @param view View of the dialog - */ - public void setView(View view) { - dialog.setView(view); - } - - /** - * Set view of the dialog with padding - * - * @param view View of the dialog - * @param padding Padding for the view - */ - public void setView(@NonNull View view, int padding) { - int pad = getDip(view.getContext(), padding); - dialog.setView(view, pad, pad, pad, pad); - } - - /** - * Set view of the dialog with padding - * - * @param view View of the dialog - * @param left Left padding for the view - * @param top Top padding for the view - * @param right Right padding for the view - * @param bottom Bottom padding for the view - */ - public void setView(View view, int left, int top, int right, int bottom) { - dialog.setView( - view, - getDip(view.getContext(), left), - getDip(view.getContext(), top), - getDip(view.getContext(), right), - getDip(view.getContext(), bottom)); - } - - /** Show the dialog */ - public void show() { - dialog.show(); - } - - /** - * Set enabled state of the positive button - * - * @param enabled Enabled state of the positive button - */ - public void setEnabled(boolean enabled) { - dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(enabled); - } - - /** Show Keyboard when open */ - protected void showKeyboardWhenOpen() { - dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE); - } - - /** - * Request EditText for focus - * - * @param editText TextInputEditText for focus - */ - protected void requestEditText(@NonNull TextInputEditText editText) { - editText.requestFocus(); - inputMethodManager.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT); - - if (!editText.getText().toString().isEmpty()) { - editText.setSelection(0, editText.getText().toString().length()); - } - } - - /** - * Get dip for the value - * - * @param context Application context - * @param value Value for which dip is required - * @return Dip value - */ - private int getDip(@NonNull Context context, int value) { - return (int) - TypedValue.applyDimension( - TypedValue.COMPLEX_UNIT_DIP, value, context.getResources().getDisplayMetrics()); - } - - /** - * Get string from resource - * - * @param context Application context - * @param id Resource id - * @return String value - */ - protected String getString(@NonNull Context context, int id) { - return context.getString(id); - } - - /** - * Set OnSaveValueListener - * - * @param listener OnSaveValueListener - */ - public void setOnSaveValueListener(OnSaveValueListener listener) { - this.listener = listener; - } - - /** Called on clicking save */ - protected void onClickSave() {} - - /** - * Getter for dialog - * - * @return AlertDialog - */ - public AlertDialog getDialog() { - return this.dialog; - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/dialogs/BooleanDialog.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/dialogs/BooleanDialog.java deleted file mode 100644 index 26ffca7e90..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/dialogs/BooleanDialog.java +++ /dev/null @@ -1,60 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.dialogs; - -import android.content.Context; - -import androidx.annotation.NonNull; -import androidx.appcompat.widget.AppCompatRadioButton; - -import org.appdevforall.codeonthego.layouteditor.R; -import org.appdevforall.codeonthego.layouteditor.databinding.LayoutBooleanDialogBinding; - -public class BooleanDialog extends AttributeDialog { - - private LayoutBooleanDialogBinding binding; - - /** - * Constructor for BooleanDialog - * - * @param context current context - * @param savedValue previously saved value - */ - public BooleanDialog(Context context, @NonNull String savedValue) { - super(context); - - // Inflate the layout for this dialog - binding = LayoutBooleanDialogBinding.inflate(getDialog().getLayoutInflater()); - - // Initialize radio buttons - AppCompatRadioButton rbTrue = binding.rbTrue; - AppCompatRadioButton rbFalse = binding.rbFalse; - - // Set view padding - setView(binding.getRoot(), 10, 20, 10, 0); - - // Check radio button for previously saved value - if (!savedValue.isEmpty()) { - if (savedValue.equals("true")) { - rbTrue.setChecked(true); - } else { - rbFalse.setChecked(true); - } - } - } - - /** - * Method called when save button is clicked - */ - @Override - protected void onClickSave() { - super.onClickSave(); - - // Get the checked radio button id - int checkedRadioButtonId = binding.getRoot().getCheckedRadioButtonId(); - - // Check if radio button is true or false - String value = checkedRadioButtonId == R.id.rbTrue ? "true" : "false"; - - // Invoke the listener to save the value - listener.onSave(value); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/dialogs/ColorDialog.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/dialogs/ColorDialog.java deleted file mode 100644 index bf029b4427..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/dialogs/ColorDialog.java +++ /dev/null @@ -1,417 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.dialogs; - -import android.annotation.SuppressLint; -import android.content.Context; -import android.graphics.Color; -import android.text.Editable; -import android.text.InputFilter; -import android.text.TextWatcher; -import android.view.View; -import android.widget.SeekBar; -import android.widget.Toast; - -import androidx.annotation.NonNull; -import androidx.appcompat.widget.AppCompatSeekBar; - -import com.google.android.material.textfield.TextInputEditText; -import com.google.android.material.textfield.TextInputLayout; - -import org.appdevforall.codeonthego.layouteditor.R; -import org.appdevforall.codeonthego.layouteditor.databinding.LayoutColorDialogBinding; -import org.appdevforall.codeonthego.layouteditor.views.ColorView; - -import java.util.regex.Pattern; - -public class ColorDialog extends AttributeDialog - implements AppCompatSeekBar.OnSeekBarChangeListener { - - // Declaring Views - private ColorView colorPreview; - private AppCompatSeekBar seekAlpha; - private AppCompatSeekBar seekRed; - private AppCompatSeekBar seekGreen; - private AppCompatSeekBar seekBlue; - private TextInputLayout inputLayout, aInputLayout, rInputLayout, gInputLayout, bInputLayout; - private TextInputEditText editText, aEdittext, rEdittext, gEdittext, bEdittext; - - /** - * Constructor of ColorDialog - * - * @param context Application Context - * @param savedValue Saved Color Value - */ - public ColorDialog(Context context, String savedValue) { - super(context); - - // Inflate Layout Binding - org.appdevforall.codeonthego.layouteditor.databinding.LayoutColorDialogBinding binding = LayoutColorDialogBinding.inflate(getDialog().getLayoutInflater()); - - // Getting View from binding - final View dialogView = binding.getRoot(); - - // Initializing Views - colorPreview = binding.colorPreview; - seekAlpha = binding.seekAlpha; - seekRed = binding.seekRed; - seekGreen = binding.seekGreen; - seekBlue = binding.seekBlue; - inputLayout = dialogView.findViewById(R.id.textinput_layout); - aInputLayout = binding.ainputLayout; - rInputLayout = binding.rinputLayout; - gInputLayout = binding.ginputLayout; - bInputLayout = binding.binputLayout; - editText = dialogView.findViewById(R.id.textinput_edittext); - aEdittext = binding.ainputEdittext; - rEdittext = binding.rinputEdittext; - gEdittext = binding.ginputEdittext; - bEdittext = binding.binputEdittext; - - // Setting Seekbar Progress and Listener - setSeekbarProgressAndListener(seekAlpha); - setSeekbarProgressAndListener(seekRed); - setSeekbarProgressAndListener(seekGreen); - setSeekbarProgressAndListener(seekBlue); - - // Setting UI Values - setUIValues(savedValue); - - // Setting TextWatcher on EditText - setTextWatcherOnEditText(); - - setView(dialogView, 10); - } - - /** - * Sets Seekbar Progress and Listener - * - * @param seekBar SeekBar to set - */ - private void setSeekbarProgressAndListener(@NonNull AppCompatSeekBar seekBar) { - seekBar.setOnSeekBarChangeListener(this); - seekBar.setMax(255); - seekBar.setProgress(255); - } - - /** - * Sets UI Values - * - * @param savedValue Saved Color Value - */ - private void setUIValues(@NonNull String savedValue) { - inputLayout.setHint("Enter custom HEX code"); - inputLayout.setPrefixText("#"); - editText.setFilters(new InputFilter[] {new InputFilter.LengthFilter(8)}); - aEdittext.setFilters(new InputFilter[] {new InputFilter.LengthFilter(3)}); - rEdittext.setFilters(new InputFilter[] {new InputFilter.LengthFilter(3)}); - gEdittext.setFilters(new InputFilter[] {new InputFilter.LengthFilter(3)}); - bEdittext.setFilters(new InputFilter[] {new InputFilter.LengthFilter(3)}); - - if (savedValue.isEmpty()) return; - - try { - colorPreview.setColor(Color.parseColor(savedValue)); - } catch (IllegalArgumentException e) { - colorPreview.setColor(Color.BLUE); - showUnsupportedColorMsg(savedValue, colorPreview.getContext()); - } - aEdittext.setText(String.valueOf(Color.alpha(colorPreview.getColor()))); - aEdittext.setTextColor(colorPreview.getInvertedRGB()); - rEdittext.setText(String.valueOf(Color.red(colorPreview.getColor()))); - rEdittext.setTextColor(colorPreview.getInvertedRGB()); - gEdittext.setText(String.valueOf(Color.green(colorPreview.getColor()))); - gEdittext.setTextColor(colorPreview.getInvertedRGB()); - bEdittext.setText(String.valueOf(Color.blue(colorPreview.getColor()))); - bEdittext.setTextColor(colorPreview.getInvertedRGB()); - updateARGB(colorPreview.getColor()); - updateSeekbars(colorPreview.getColor()); - updateEditText(); - } - - private void showUnsupportedColorMsg(@NonNull String savedValue, @NonNull Context context) { - Toast.makeText( - context, - context.getString(R.string.msg_unsupported_color_format, savedValue), - Toast.LENGTH_SHORT - ).show(); - } - - /** Sets TextWatcher on EditText */ - private void setTextWatcherOnEditText() { - editText.addTextChangedListener( - new TextWatcher() { - - @Override - public void beforeTextChanged(CharSequence p1, int p2, int p3, int p4) {} - - @Override - public void onTextChanged(CharSequence p1, int p2, int p3, int p4) {} - - @Override - public void afterTextChanged(Editable p1) { - if (!editText.getText().toString().isEmpty()) checkHexErrors(editText.getText().toString()); - } - }); - aEdittext.addTextChangedListener( - new TextWatcher() { - - @Override - public void beforeTextChanged(CharSequence p1, int p2, int p3, int p4) {} - - @Override - public void onTextChanged(CharSequence p1, int p2, int p3, int p4) { - checkAlphaErrors(p1.toString()); - } - - @Override - public void afterTextChanged(Editable p1) {} - }); - rEdittext.addTextChangedListener( - new TextWatcher() { - - @Override - public void beforeTextChanged(CharSequence p1, int p2, int p3, int p4) {} - - @Override - public void onTextChanged(CharSequence p1, int p2, int p3, int p4) { - checkRedErrors(p1.toString()); - } - - @Override - public void afterTextChanged(Editable p1) {} - }); - gEdittext.addTextChangedListener( - new TextWatcher() { - - @Override - public void beforeTextChanged(CharSequence p1, int p2, int p3, int p4) {} - - @Override - public void onTextChanged(CharSequence p1, int p2, int p3, int p4) { - checkGreenErrors(p1.toString()); - } - - @Override - public void afterTextChanged(Editable p1) {} - }); - bEdittext.addTextChangedListener( - new TextWatcher() { - - @Override - public void beforeTextChanged(CharSequence p1, int p2, int p3, int p4) {} - - @Override - public void onTextChanged(CharSequence p1, int p2, int p3, int p4) { - checkBlueErrors(p1.toString()); - } - - @Override - public void afterTextChanged(Editable p1) {} - }); - } - - /** Called when Save button is clicked */ - @Override - public void onClickSave() { - listener.onSave("#" + colorPreview.getHexColor()); - } - - /** - * Checks for Alpha Errors - * - * @param alpha user entered Alpha value - */ - private void checkAlphaErrors(@NonNull String alpha) { - if (!alpha.isEmpty() && Pattern.matches("[0-9]*", alpha)) { - aInputLayout.setErrorEnabled(false); - aInputLayout.setError(""); - setEnabled(true); - if (Integer.parseInt(alpha) != Color.alpha(colorPreview.getColor())) { - colorPreview.setAlpha(Integer.parseInt(alpha)); - updateSeekbars(colorPreview.getColor()); - updateEditText(); - } - return; - } - aInputLayout.setErrorEnabled(true); - aInputLayout.setError("Invalid Alpha value"); - setEnabled(false); - } - - /** - * Checks for Red Errors - * - * @param red user entered RED value - */ - private void checkRedErrors(@NonNull String red) { - if (!red.isEmpty() && Pattern.matches("[0-9]*", red)) { - rInputLayout.setErrorEnabled(false); - rInputLayout.setError(""); - setEnabled(true); - if (Integer.parseInt(red) != Color.alpha(colorPreview.getColor())) { - colorPreview.setRed(Integer.parseInt(red)); - updateSeekbars(colorPreview.getColor()); - updateEditText(); - } - return; - } - rInputLayout.setErrorEnabled(true); - rInputLayout.setError("Invalid Red value"); - setEnabled(false); - } - - /** - * Checks for Green Errors - * - * @param green user entered GREEN value - */ - private void checkGreenErrors(@NonNull String green) { - if (!green.isEmpty() && Pattern.matches("[0-9]*", green)) { - gInputLayout.setErrorEnabled(false); - gInputLayout.setError(""); - setEnabled(true); - if (Integer.parseInt(green) != Color.alpha(colorPreview.getColor())) { - colorPreview.setGreen(Integer.parseInt(green)); - updateSeekbars(colorPreview.getColor()); - updateEditText(); - } - return; - } - gInputLayout.setErrorEnabled(true); - gInputLayout.setError("Invalid Green value"); - setEnabled(false); - } - - /** - * Checks for Blue Errors - * - * @param blue user entered BLUE value - */ - private void checkBlueErrors(@NonNull String blue) { - if (!blue.isEmpty() && Pattern.matches("[0-9]*", blue)) { - bInputLayout.setErrorEnabled(false); - bInputLayout.setError(""); - setEnabled(true); - if (Integer.parseInt(blue) != Color.alpha(colorPreview.getColor())) { - colorPreview.setBlue(Integer.parseInt(blue)); - updateSeekbars(colorPreview.getColor()); - updateEditText(); - } - return; - } - bInputLayout.setErrorEnabled(true); - bInputLayout.setError("Invalid Blue value"); - setEnabled(false); - } - - /** - * Checks for Hex Errors - * - * @param hex user entered HEX value - */ - private void checkHexErrors(String hex) { - if (Pattern.matches("[a-fA-F0-9]{6}", hex) || Pattern.matches("[a-fA-F0-9]{8}", hex)) { - colorPreview.setColor(Color.parseColor("#" + hex)); - updateSeekbars(colorPreview.getColor()); - updateARGB(colorPreview.getColor()); - inputLayout.setErrorEnabled(false); - inputLayout.setError(""); - setEnabled(true); - return; - } - inputLayout.setErrorEnabled(true); - inputLayout.setError("Invalid HEX value"); - setEnabled(false); - } - - /** - * Updates ARGB with Color Values - * - * @param color Color to be set - */ - private void updateARGB(int color) { - int a = Color.alpha(color); - int r = Color.red(color); - int g = Color.green(color); - int b = Color.blue(color); - - if (a != (aEdittext.getText().toString().isEmpty() ? 0 : Integer.parseInt(aEdittext.getText().toString()))) { - aEdittext.setText(String.valueOf(a)); - } - - if (r != (rEdittext.getText().toString().isEmpty() ? 0 : Integer.parseInt(rEdittext.getText().toString()))) { - rEdittext.setText(String.valueOf(r)); - } - - if (g != (gEdittext.getText().toString().isEmpty() ? 0 : Integer.parseInt(gEdittext.getText().toString()))) { - gEdittext.setText(String.valueOf(g)); - } - - if (b != (bEdittext.getText().toString().isEmpty() ? 0 : Integer.parseInt(bEdittext.getText().toString()))) { - bEdittext.setText(String.valueOf(b)); - } - - aEdittext.setTextColor(colorPreview.getInvertedRGB()); - rEdittext.setTextColor(colorPreview.getInvertedRGB()); - gEdittext.setTextColor(colorPreview.getInvertedRGB()); - bEdittext.setTextColor(colorPreview.getInvertedRGB()); - } - - /** - * Updates Seekbars with Color Values - * - * @param color Color to be set - */ - private void updateSeekbars(int color) { - int a = Color.alpha(color); - int r = Color.red(color); - int g = Color.green(color); - int b = Color.blue(color); - seekAlpha.setProgress(a); - seekRed.setProgress(r); - seekGreen.setProgress(g); - seekBlue.setProgress(b); - } - - /** Updates EditText with Color Values */ - private void updateEditText() { - editText.setText(colorPreview.getHexColor()); - } - - /** - * Called when Seekbar progress is changed - * - * @param seek Seekbar which is changed - * @param progress Progress of Seekbar - * @param fromUser True if changed by user - */ - @SuppressLint("NonConstantResourceId") - @Override - public void onProgressChanged(SeekBar seek, int progress, boolean fromUser) { - if (fromUser) { - int id = seek.getId(); - if (id == R.id.seek_alpha) { - colorPreview.setAlpha(progress); - updateARGB(colorPreview.getColor()); - updateEditText(); - } else if (id == R.id.seek_red) { - colorPreview.setRed(progress); - updateARGB(colorPreview.getColor()); - updateEditText(); - } else if (id == R.id.seek_green) { - colorPreview.setGreen(progress); - updateARGB(colorPreview.getColor()); - updateEditText(); - } else if (id == R.id.seek_blue) { - colorPreview.setBlue(progress); - updateARGB(colorPreview.getColor()); - updateEditText(); - } - } - } - - @Override - public void onStartTrackingTouch(SeekBar p1) {} - - @Override - public void onStopTrackingTouch(SeekBar p1) {} -} \ No newline at end of file diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/dialogs/DimensionDialog.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/dialogs/DimensionDialog.java deleted file mode 100644 index 080e6bb023..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/dialogs/DimensionDialog.java +++ /dev/null @@ -1,107 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.dialogs; - -import android.content.Context; -import android.text.Editable; -import android.text.InputType; -import android.text.TextWatcher; - -import androidx.annotation.NonNull; - -import com.google.android.material.textfield.TextInputEditText; -import com.google.android.material.textfield.TextInputLayout; - -import org.appdevforall.codeonthego.layouteditor.databinding.TextinputlayoutBinding; -import org.appdevforall.codeonthego.layouteditor.utils.DimensionUtil; - -public class DimensionDialog extends AttributeDialog { - - private TextInputLayout textInputLayout; - private TextInputEditText textInputEditText; - - private String unit; - - // Constructor to create a new instance of DimensionDialog - public DimensionDialog(Context context, @NonNull String savedValue, String unit) { - super(context); - - this.unit = unit; - - // Inflate the textinputlayout layout - TextinputlayoutBinding binding = TextinputlayoutBinding.inflate(getDialog().getLayoutInflater()); - - // Get the root view of the textinputlayout - textInputLayout = binding.getRoot(); - - // Set the hint of the textInputLayout - textInputLayout.setHint("Enter dimension value"); - - // Set the suffix text of the textInputLayout - textInputLayout.setSuffixText(unit); - - // Get the textInputEditText - textInputEditText = binding.textinputEdittext; - - // Set the input type of the textInputEditText - textInputEditText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED); - - // Set the saved value or default value 0 - textInputEditText.setText( - savedValue.isEmpty() ? "0" : DimensionUtil.getDimenWithoutSuffix(savedValue)); - - // Add TextWatcher to the textInputEditText to check the error - textInputEditText.addTextChangedListener( - new TextWatcher() { - - // Before text changed - @Override - public void beforeTextChanged(CharSequence p1, int p2, int p3, int p4) {} - - // On text changed - @Override - public void onTextChanged(CharSequence text, int p2, int p3, int p4) {} - - // After text changed - @Override - public void afterTextChanged(Editable p1) { - checkError(); - } - }); - - // Set the view and margin to the dialog - setView(textInputLayout, 10); - - // Show the keyboard when the dialog open - showKeyboardWhenOpen(); - } - - @Override - public void show() { - super.show(); - // Request the focus on the textInputEditText - requestEditText(textInputEditText); - } - - @Override - protected void onClickSave() { - super.onClickSave(); - // Call the listener on save and append the unit - listener.onSave(textInputEditText.getText().toString() + unit); - } - - // Method to check the error - private void checkError() { - String text = textInputEditText.getText().toString(); - - // If the text is empty set the error and disable the save button - if (text.isEmpty()) { - setEnabled(false); - textInputLayout.setErrorEnabled(true); - textInputLayout.setError("Field cannot be empty!"); - } else { - // Else enable the save button and remove the error - setEnabled(true); - textInputLayout.setErrorEnabled(false); - textInputLayout.setError(""); - } - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/dialogs/EnumDialog.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/dialogs/EnumDialog.java deleted file mode 100644 index 318d461e7c..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/dialogs/EnumDialog.java +++ /dev/null @@ -1,66 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.dialogs; - -import android.content.Context; -import android.view.ViewGroup; -import android.widget.ArrayAdapter; -import android.widget.ListView; - -import androidx.annotation.NonNull; - -import java.util.ArrayList; -import java.util.List; - -public class EnumDialog extends AttributeDialog { - - private ListView listview; - private List arguments; - - /** - * Constructor for EnumDialog class - * - * @param context the context of the activity - * @param savedValue the saved value of the parameter - * @param arguments the list of arguments in the parameter - */ - public EnumDialog(Context context, @NonNull String savedValue, ArrayList arguments) { - super(context); - - this.arguments = arguments; - - listview = new ListView(context); - // Set the view layout parameters - listview.setLayoutParams( - new ViewGroup.LayoutParams( - ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); - // Set adapter - listview.setAdapter( - new ArrayAdapter( - context, android.R.layout.simple_list_item_single_choice, arguments)); - // Set choice mode - listview.setChoiceMode(ListView.CHOICE_MODE_SINGLE); - // Remove divider - listview.setDivider(null); - - if (!savedValue.isEmpty()) { - listview.setItemChecked(arguments.indexOf(savedValue), true); - } - - // Set view, and pass in padding arguments - setView(listview, 0, 20, 0, 0); - } - - /** - * Overridden method from AttributeDialog class - * Gets the listview checked item position, saves it - * and passes the saved value to the listener - */ - @Override - protected void onClickSave() { - if (listview.getCheckedItemPosition() == -1) { - listener.onSave("-1"); - return; - } - - listener.onSave(arguments.get(listview.getCheckedItemPosition())); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/dialogs/FlagDialog.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/dialogs/FlagDialog.java deleted file mode 100644 index 4fb189b008..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/dialogs/FlagDialog.java +++ /dev/null @@ -1,115 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.dialogs; - -import android.content.Context; -import android.util.SparseBooleanArray; -import android.view.ViewGroup; -import android.widget.ArrayAdapter; -import android.widget.ListView; - -import androidx.annotation.NonNull; - -import java.util.ArrayList; -import java.util.List; - -public class FlagDialog extends AttributeDialog { - - // Declaring a ListView object - private ListView listview; - - // Declaring a List object to store arguments - private List arguments; - - /** - * Constructor to initialize the FlagDialog object - * - * @param context The context of the calling activity - * @param savedValue The savedValue of the calling activity - * @param arguments The list of arguments - */ - public FlagDialog(Context context, @NonNull String savedValue, ArrayList arguments) { - super(context); - - // Assigning arguments to the List object - this.arguments = arguments; - - // Initializing listview - listview = new ListView(context); - - // Setting the layout params - listview.setLayoutParams( - new ViewGroup.LayoutParams( - ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); - - // Setting multiple choice mode for listview - listview.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); - - // Setting adapter to listview - listview.setAdapter( - new ArrayAdapter( - context, android.R.layout.simple_list_item_multiple_choice, arguments)); - - // Setting divider to null - listview.setDivider(null); - - // Checking if the savedValue is not empty - if (!savedValue.isEmpty()) { - // Splitting the savedValue using | as the delimiter - String[] flags = savedValue.split("\\|"); - - // Looping through the flags array - for (String flag : flags) { - // Getting the index of the flag in the arguments list - int index = arguments.indexOf(flag); - - // Setting the listview item at the index as checked - listview.setItemChecked(index, true); - } - } - - // Setting padding around the listview - setView(listview, 0, 20, 0, 0); - } - - /** Overriding the superclass's method to save the data */ - @Override - protected void onClickSave() { - // Calling the superclass's method - super.onClickSave(); - - // Checking if no item is checked in the listview - if (listview.getCheckedItemCount() == 0) { - // Passing -1 as the saved value - listener.onSave("-1"); - - // Returning - return; - } - - // Creating a StringBuilder object - StringBuilder builder = new StringBuilder(); - - // Getting the checked item positions - SparseBooleanArray array = listview.getCheckedItemPositions(); - - // Looping through the array - for (int i = 0; i < array.size(); i++) { - // Getting the checked item - int checkedItem = array.keyAt(i); - - // Checking if the item is checked - if (array.get(checkedItem)) { - // Appending the checked item's argument in the arguments list to the StringBuilder object - builder.append(arguments.get(checkedItem)).append("|"); - } - } - - // Converting the StringBuilder object to String object - String value = builder.toString(); - - // Removing the last | from the String object - value = value.substring(0, value.lastIndexOf("|")); - - // Passing the String object as the saved value - listener.onSave(value); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/dialogs/IdDialog.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/dialogs/IdDialog.kt deleted file mode 100644 index 5e6cb262a2..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/dialogs/IdDialog.kt +++ /dev/null @@ -1,110 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.dialogs - -import android.content.Context -import android.text.Editable -import android.text.TextWatcher -import com.google.android.material.textfield.TextInputEditText -import com.google.android.material.textfield.TextInputLayout -import org.appdevforall.codeonthego.layouteditor.R -import org.appdevforall.codeonthego.layouteditor.databinding.TextinputlayoutBinding -import org.appdevforall.codeonthego.layouteditor.managers.IdManager.getIds -import java.util.regex.Pattern - -class IdDialog(context: Context, savedValue: String) : AttributeDialog(context) { - private val textInputLayout: TextInputLayout - private val textInputEditText: TextInputEditText - - private val ids: MutableList - - init { - // Initialize the binding and savedValue variables - val binding = TextinputlayoutBinding.inflate(dialog.layoutInflater) - - // Get all the IDs from the IdManager - ids = getIds() - - // Initialize the TextInputLayout and set hint and prefix text - textInputLayout = binding.root - textInputLayout.apply { - hint = "Enter new ID" - prefixText = "@+id/" - } - - // Initialize the TextInputEditText and set the text from the savedValue - textInputEditText = binding.textinputEdittext - if (savedValue.isNotEmpty()) { - ids.remove(savedValue.replace("@+id/", "")) - textInputEditText.setText(savedValue.replace("@+id/", "")) - } - - // Add a TextWatcher to the TextInputEditText for checking errors - textInputEditText.addTextChangedListener( - object : TextWatcher { - override fun beforeTextChanged(p1: CharSequence, p2: Int, p3: Int, p4: Int) { - } - - override fun onTextChanged(p1: CharSequence, p2: Int, p3: Int, p4: Int) { - } - - override fun afterTextChanged(p1: Editable) { - checkErrors() - } - }) - - // Set the view with a margin of 10dp - setView(textInputLayout, 10) - showKeyboardWhenOpen() - } - - /** - * Check errors in the TextInputEditText - */ - private fun checkErrors() { - val text = textInputEditText.text.toString() - - // Check if the TextInputEditText is empty - if (text.isEmpty()) { - textInputLayout.isErrorEnabled = true - textInputLayout.error = "Field cannot be empty!" - setEnabled(false) - return - } - - if (!Pattern.matches("[a-z][A-Za-z0-9_\\s]*", text)) { - textInputLayout.isErrorEnabled = true - textInputLayout.error = dialog.context.getString(R.string.msg_symbol_not_allowed) - setEnabled(false) - return - } - - // Check if the ID is already taken - for (id in ids) { - if (id == text) { - textInputLayout.isErrorEnabled = true - textInputLayout.error = "Current ID is unavailable!" - setEnabled(false) - return - } - } - - // No errors detected - textInputLayout.isErrorEnabled = false - textInputLayout.error = "" - setEnabled(true) - } - - override fun show() { - super.show() - - // Request focus to the TextInputEditText and check errors - requestEditText(textInputEditText) - checkErrors() - } - - override fun onClickSave() { - // Call the onSave method and pass the ID - listener.onSave( - "@+id/${textInputEditText.text.toString().lowercase().replace(" ".toRegex(), "_")}" - ) - } -} \ No newline at end of file diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/dialogs/NumberDialog.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/dialogs/NumberDialog.java deleted file mode 100644 index 633113e599..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/dialogs/NumberDialog.java +++ /dev/null @@ -1,98 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.dialogs; - -import android.content.Context; -import android.text.Editable; -import android.text.InputType; -import android.text.TextWatcher; - -import androidx.annotation.NonNull; - -import com.google.android.material.textfield.TextInputEditText; -import com.google.android.material.textfield.TextInputLayout; - -import org.appdevforall.codeonthego.layouteditor.databinding.TextinputlayoutBinding; - -public class NumberDialog extends AttributeDialog { - - private TextInputLayout textInputLayout; - private TextInputEditText textInputEditText; - - /** - * Constructor for creating a NumberDialog - * - * @param context the context of the activity - * @param savedValue the saved value - * @param type the type of number input - */ - public NumberDialog(Context context, String savedValue, @NonNull String type) { - super(context); - - TextinputlayoutBinding binding = TextinputlayoutBinding.inflate(getDialog().getLayoutInflater()); - - textInputLayout = binding.getRoot(); - textInputLayout.setHint("Enter " + type + " value"); - - textInputEditText = binding.textinputEdittext; - - if (type.equals("float")) { - // Set input type to signed float - textInputEditText.setInputType( - InputType.TYPE_CLASS_NUMBER - | InputType.TYPE_NUMBER_FLAG_SIGNED - | InputType.TYPE_NUMBER_FLAG_DECIMAL); - } else { - // Set input type to signed integer - textInputEditText.setInputType( - InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED); - } - - // If no saved value, set to 0 - textInputEditText.setText(savedValue.isEmpty() ? "0" : savedValue); - textInputEditText.addTextChangedListener( - new TextWatcher() { - @Override - public void beforeTextChanged(CharSequence p1, int p2, int p3, int p4) {} - - @Override - public void onTextChanged(CharSequence text, int p2, int p3, int p4) {} - - // Check for error on text change - @Override - public void afterTextChanged(Editable p1) { - checkError(); - } - }); - - // Set padding of the view - setView(textInputLayout, 10); - showKeyboardWhenOpen(); - } - - /** Show the dialog, and request focus in edit text */ - @Override - public void show() { - super.show(); - requestEditText(textInputEditText); - } - - /** On clicking save, invoke listener's onSave method */ - @Override - protected void onClickSave() { - listener.onSave(textInputEditText.getText().toString()); - } - - /** Check for error. Set enabled to false if empty and set error message */ - private void checkError() { - String text = textInputEditText.getText().toString(); - - if (text.isEmpty()) { - setEnabled(false); - textInputLayout.setErrorEnabled(true); - textInputLayout.setError("Field cannot be empty!"); - } else { - setEnabled(true); - textInputLayout.setErrorEnabled(false); - textInputLayout.setError(""); - } - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/dialogs/SizeDialog.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/dialogs/SizeDialog.java deleted file mode 100644 index 35c1fb618b..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/dialogs/SizeDialog.java +++ /dev/null @@ -1,136 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.dialogs; - -import android.animation.LayoutTransition; -import android.annotation.SuppressLint; -import android.content.Context; -import android.text.Editable; -import android.text.InputType; -import android.text.TextWatcher; -import android.view.View; -import android.view.ViewGroup; -import android.widget.RadioGroup; - -import androidx.annotation.NonNull; -import androidx.appcompat.widget.AppCompatRadioButton; - -import com.google.android.material.textfield.TextInputEditText; -import com.google.android.material.textfield.TextInputLayout; - -import org.appdevforall.codeonthego.layouteditor.R; -import org.appdevforall.codeonthego.layouteditor.databinding.LayoutSizeDialogBinding; -import org.appdevforall.codeonthego.layouteditor.utils.DimensionUtil; - -public class SizeDialog extends AttributeDialog { - - private TextInputLayout textInputLayout; - private TextInputEditText textInputEditText; - - private RadioGroup group; - - /** - * Constructor to create SizeDialog instance - * - * @param context The context of the activity - * @param savedValue The saved value of the attribute - */ - public SizeDialog(Context context, @NonNull String savedValue) { - super(context); - - LayoutSizeDialogBinding binding = LayoutSizeDialogBinding.inflate(getDialog().getLayoutInflater()); - - final ViewGroup dialogView = binding.getRoot(); - group = binding.radiogroup; - - final AppCompatRadioButton rbMatchParent = binding.rbMatchParent; - final AppCompatRadioButton rbWrapContent = binding.rbWrapContent; - final AppCompatRadioButton rbFixedValue = binding.rbFixedValue; - - textInputLayout = dialogView.findViewById(R.id.textinput_layout); - textInputLayout.setHint("Enter dimension value"); - textInputLayout.setSuffixText("dp"); - - textInputEditText = dialogView.findViewById(R.id.textinput_edittext); - textInputEditText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED); - textInputLayout.setVisibility(View.GONE); - - // Check if savedValue is "match_parent", "wrap_content", or a fixed value - if (!savedValue.isEmpty()) { - if (savedValue.equals("match_parent")) { - rbMatchParent.setChecked(true); - } else if (savedValue.equals("wrap_content")) { - rbWrapContent.setChecked(true); - } else { - rbFixedValue.setChecked(true); - textInputLayout.setVisibility(View.VISIBLE); - textInputEditText.setText(DimensionUtil.getDimenWithoutSuffix(savedValue)); - } - } - - // Add a TextChangeListener to the TextInputEditText to check for an error - textInputEditText.addTextChangedListener( - new TextWatcher() { - - @Override - public void beforeTextChanged(CharSequence p1, int p2, int p3, int p4) {} - - @Override - public void onTextChanged(CharSequence text, int p2, int p3, int p4) {} - - @Override - public void afterTextChanged(Editable p1) { - checkError(); - } - }); - - // Set onCheckedChangeListener to the RadioGroup - group.setOnCheckedChangeListener( - (p1, id) -> { - if (id == R.id.rb_fixed_value) { - dialogView.setLayoutTransition(new LayoutTransition()); - textInputLayout.setVisibility(View.VISIBLE); - checkError(); - } else { - dialogView.setLayoutTransition(new LayoutTransition()); - textInputLayout.setVisibility(View.GONE); - setEnabled(true); - } - }); - - setView(dialogView, 10); - } - - /** Method to check for an error */ - private void checkError() { - String text = textInputEditText.getText().toString(); - - // Check if the field is empty, and set the appropriate error messages - if (text.isEmpty()) { - setEnabled(false); - textInputLayout.setErrorEnabled(true); - textInputLayout.setError("Field cannot be empty!"); - } else { - setEnabled(true); - textInputLayout.setErrorEnabled(false); - textInputLayout.setError(""); - } - } - - /** Method to save the value of the attribute */ - @SuppressLint("NonConstantResourceId") - @Override - protected void onClickSave() { - String value = ""; - - // Get the value of the attribute based on the checked radio button - int checkedRadioButtonId = group.getCheckedRadioButtonId(); - if (checkedRadioButtonId == R.id.rb_match_parent) { - value = "match_parent"; - } else if (checkedRadioButtonId == R.id.rb_wrap_content) { - value = "wrap_content"; - } else if (checkedRadioButtonId == R.id.rb_fixed_value) { - value = textInputEditText.getText().toString() + DimensionUtil.DP; - } - - listener.onSave(value); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/dialogs/StringDialog.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/dialogs/StringDialog.java deleted file mode 100644 index ea1f27415a..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/dialogs/StringDialog.java +++ /dev/null @@ -1,163 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.dialogs; - -import android.content.Context; -import android.text.Editable; -import android.text.TextWatcher; - -import androidx.annotation.NonNull; - -import com.google.android.material.textfield.TextInputEditText; -import com.google.android.material.textfield.TextInputLayout; - -import org.appdevforall.codeonthego.layouteditor.databinding.TextinputlayoutBinding; -import org.appdevforall.codeonthego.layouteditor.managers.DrawableManager; -import org.appdevforall.codeonthego.layouteditor.managers.ProjectManager; -import org.appdevforall.codeonthego.layouteditor.managers.ValuesManager; -import org.appdevforall.codeonthego.layouteditor.tools.ValuesResourceParser; -import org.appdevforall.codeonthego.layouteditor.utils.Constants; - -import java.util.regex.Pattern; - -public class StringDialog extends AttributeDialog { - - /** TextInputLayout object */ - private TextInputLayout textInputLayout; - - /** TextInputEditText object */ - private TextInputEditText textInputEditText; - - /** Boolean flag to check if the dialog is for drawable */ - String argumentType; - - /** - * Constructor for StringDialog class - * - * @param context The Activity context - * @param savedValue The saved value - */ - public StringDialog(Context context, String savedValue, @NonNull String argumentType) { - super(context); - this.argumentType = argumentType; - TextinputlayoutBinding binding = TextinputlayoutBinding.inflate(getDialog().getLayoutInflater()); - - textInputLayout = binding.getRoot(); - textInputLayout.setHint("Enter string value"); - - textInputEditText = binding.textinputEdittext; - textInputEditText.setText(savedValue); - - switch (argumentType) { - case Constants.ARGUMENT_TYPE_DRAWABLE: - textInputLayout.setHint("Enter drawable name"); - textInputLayout.setPrefixText("@drawable/"); - textInputEditText.addTextChangedListener( - new TextWatcher() { - @Override - public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {} - - @Override - public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {} - - @Override - public void afterTextChanged(Editable arg0) { - checkErrors(); - } - }); - break; - case Constants.ARGUMENT_TYPE_TEXT: - textInputLayout.setHint("Enter string value"); - break; - case Constants.ARGUMENT_TYPE_STRING: - textInputLayout.setHint("Enter string name"); - textInputLayout.setPrefixText("@string/"); - textInputEditText.addTextChangedListener( - new TextWatcher() { - @Override - public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {} - - @Override - public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {} - - @Override - public void afterTextChanged(Editable arg0) { - checkErrors(); - } - }); - break; - } - - setView(textInputLayout, 10); - showKeyboardWhenOpen(); - } - - /** Method to check for errors */ - private void checkErrors() { - String text = textInputEditText.getText().toString(); - if (!argumentType.equals(Constants.ARGUMENT_TYPE_TEXT)) { - - if (text.isEmpty()) { - textInputLayout.setErrorEnabled(true); - textInputLayout.setError("Field cannot be empty!"); - setEnabled(false); - return; - } - - if (!Pattern.matches("[a-z_][a-z0-9_]*", text)) { - textInputLayout.setErrorEnabled(true); - textInputLayout.setError("Only small letters(a-z) and numbers!"); - setEnabled(false); - return; - } - - if (argumentType.equals(Constants.ARGUMENT_TYPE_DRAWABLE) - && !DrawableManager.contains(text)) { - textInputLayout.setErrorEnabled(true); - textInputLayout.setError("No Drawable found"); - setEnabled(false); - return; - } - - if (argumentType.equals(Constants.ARGUMENT_TYPE_STRING) - && ValuesManager.getValueFromResources( - ValuesResourceParser.TAG_STRING, - (text.startsWith("@string/") ? text : "@string/" + text), - ProjectManager.getInstance().getOpenedProject().getStringsPath()) - == null) { - textInputLayout.setErrorEnabled(true); - textInputLayout.setError("No string found"); - setEnabled(false); - return; - } - } - - textInputLayout.setErrorEnabled(false); - textInputLayout.setError(""); - setEnabled(true); - } - - /** Method to show the dialog */ - @Override - public void show() { - super.show(); - requestEditText(textInputEditText); - checkErrors(); - } - - /** Method to be invoked when the save button is clicked */ - @Override - protected void onClickSave() { - super.onClickSave(); - String text = textInputEditText.getText().toString(); - switch (argumentType) { - case Constants.ARGUMENT_TYPE_DRAWABLE: - listener.onSave("@drawable/" + text); - break; - case Constants.ARGUMENT_TYPE_STRING: - listener.onSave("@string/" + text); - break; - case Constants.ARGUMENT_TYPE_TEXT: - listener.onSave(text); - break; - } - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/dialogs/ViewDialog.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/dialogs/ViewDialog.java deleted file mode 100644 index 1ddbe41cc7..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/dialogs/ViewDialog.java +++ /dev/null @@ -1,72 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.dialogs; - -import android.content.Context; -import android.view.ViewGroup; -import android.widget.ArrayAdapter; -import android.widget.ListView; - -import org.appdevforall.codeonthego.layouteditor.managers.IdManager; - -import java.util.ArrayList; -import java.util.List; - -public class ViewDialog extends AttributeDialog { - - private List ids = new ArrayList<>(); - private ListView listview; - - private String constant; - - /** - * This is the constructor of the ViewDialog. - * - * @param context the context of the application - * @param savedValue the saved value - * @param constant the constant - */ - public ViewDialog(Context context, String savedValue, String constant) { - super(context); - this.constant = constant; - - ids.addAll(IdManager.getIds()); - - if (constant != null) { - ids.add(0, constant); - } - - listview = new ListView(context); - listview.setLayoutParams( - new ViewGroup.LayoutParams( - ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); - listview.setAdapter( - new ArrayAdapter(context, android.R.layout.simple_list_item_single_choice, ids)); - listview.setChoiceMode(ListView.CHOICE_MODE_SINGLE); - listview.setDivider(null); - - if (!savedValue.isEmpty()) { - listview.setItemChecked(ids.indexOf(savedValue.replace("@id/", "")), true); - } - - setView(listview, 0, 20, 0, 0); - } - - /** This method is called when the save button is clicked. */ - @Override - protected void onClickSave() { - super.onClickSave(); - if (listview.getCheckedItemPosition() == -1) { - listener.onSave("-1"); - } else { - // listener.onSave("@id/" + ids.get(listview.getCheckedItemPosition())); - if (constant == null) { - listener.onSave("@id/" + ids.get(listview.getCheckedItemPosition())); - } else { - if (listview.getCheckedItemPosition() > 0) { - listener.onSave("@id/" + ids.get(listview.getCheckedItemPosition())); - } else { - listener.onSave(constant); - } - } - } - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/dialogs/interfaces/OnSaveValueListener.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/dialogs/interfaces/OnSaveValueListener.kt deleted file mode 100644 index fe36eae56d..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/dialogs/interfaces/OnSaveValueListener.kt +++ /dev/null @@ -1,12 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.dialogs.interfaces - -/** - * OnSaveValueListener interface for saving value - */ -fun interface OnSaveValueListener { - /** - * Called when value is saved - * @param value Value to be saved - */ - fun onSave(value: String?) -} \ No newline at end of file diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/initializer/AttributeInitializer.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/initializer/AttributeInitializer.kt deleted file mode 100644 index f4d2b0d4a6..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/initializer/AttributeInitializer.kt +++ /dev/null @@ -1,144 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.initializer - -import android.content.Context -import android.view.View -import org.appdevforall.codeonthego.layouteditor.editor.DesignEditor -import org.appdevforall.codeonthego.layouteditor.utils.Constants -import org.appdevforall.codeonthego.layouteditor.utils.InvokeUtil.invokeMethod - -class AttributeInitializer { - private var context: Context - - private var viewAttributeMap = HashMap() - private var attributes: HashMap>> - private var parentAttributes: HashMap>> - - constructor( - context: Context, - attributes: HashMap>>, - parentAttributes: HashMap>> - ) { - this.context = context - this.attributes = attributes - this.parentAttributes = parentAttributes - } - - constructor( - context: Context, - viewAttributeMap: HashMap, - attributes: HashMap>>, - parentAttributes: HashMap>> - ) { - this.viewAttributeMap = viewAttributeMap - this.context = context - this.attributes = attributes - this.parentAttributes = parentAttributes - } - - fun applyDefaultAttributes(target: View, defaultAttrs: Map) { - val allAttrs = getAllAttributesForView(target) - - for (key in defaultAttrs.keys) { - for (map in allAttrs) { - if (map[Constants.KEY_ATTRIBUTE_NAME].toString() == key) { - applyAttribute(target, defaultAttrs[key]!!, map) - break - } - } - } - } - - fun applyAttribute( - target: View, value: String, attribute: HashMap - ) { - val methodName = attribute[Constants.KEY_METHOD_NAME]?.toString() - val className = attribute[Constants.KEY_CLASS_NAME]?.toString() - val attributeName = attribute[Constants.KEY_ATTRIBUTE_NAME]?.toString() - - // update ids attributes for all views - if (value.startsWith("@+id/") && viewAttributeMap[target]!!.contains("android:id")) { - for (view in viewAttributeMap.keys) { - val map = viewAttributeMap[view] - - for (key in map!!.keySet()) { - val mValue = map.getValue(key) - - if (mValue.startsWith("@id/") && mValue == viewAttributeMap[target]!! - .getValue("android:id").replace("+", "") - ) { - map.putValue(key, value.replace("+", "")) - } - } - } - } - - if (attributeName != null) { - viewAttributeMap[target]!!.putValue(attributeName, value) - } - if (methodName != null) { - if (className != null) { - invokeMethod(methodName, className, target, value, context) - } - } - } - - fun getAvailableAttributesForView(target: View): List> { - val keys = viewAttributeMap[target]!!.keySet() - val allAttrs = getAllAttributesForView(target) - - for (i in allAttrs.indices.reversed()) { - for (key in keys) { - if (key == allAttrs[i][Constants.KEY_ATTRIBUTE_NAME].toString()) { - allAttrs.removeAt(i) - break - } - } - } - - return allAttrs - } - - @Suppress("UNCHECKED_CAST") - fun getAllAttributesForView(target: View): MutableList> { - val allAttrs: MutableList> = ArrayList() - - var cls = target.javaClass - val viewParentCls = View::class.java.superclass - - while (cls != viewParentCls) { - if (attributes.containsKey(cls.name)) allAttrs.addAll(0, attributes[cls.name]!!) - - cls = cls.superclass as Class - } - - if (target.parent != null && target.parent.javaClass != DesignEditor::class.java) { - cls = target.parent.javaClass as Class - - while (cls != viewParentCls) { - if (parentAttributes.containsKey(cls.name)) allAttrs.addAll(parentAttributes[cls.name]!!) - - cls = cls.superclass as Class - } - } - - return allAttrs - } - - fun getAttributeFromKey( - key: String, list: MutableList> - ): HashMap? { - for (map in list) { - val attributeName = map[Constants.KEY_ATTRIBUTE_NAME] - if (attributeName != null && attributeName.toString() == key) { - return map - } else if (attributeName != null && attributeName.toString().contains(":")) { - val namespace = attributeName.toString().split(":")[0] - val attribute = attributeName.toString().split(":")[1] - if (attribute == key) { - return map - } - } - } - return null - } -} \ No newline at end of file diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/initializer/AttributeMap.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/initializer/AttributeMap.kt deleted file mode 100644 index 0eb7f029d6..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/initializer/AttributeMap.kt +++ /dev/null @@ -1,136 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.initializer - -class AttributeMap { - private val attrs: MutableList = ArrayList() - - /** - * Puts a key-value pair into the AttributeMap - * - * @param key the key of the attribute - * @param value the value of the attribute - */ - fun putValue(key: String, value: String) { - if (contains(key)) { - // Remove the old attribute (with or without prefix) - val index = getAttributeIndexFromKey(key) - attrs.removeAt(index) - } - // Add the new attribute with the correct key - attrs.add(Attribute(key, value)) - } - - /** - * Removes a key-value pair from the AttributeMap - * - * @param key the key of the attribute to be removed - */ - fun removeValue(key: String) { - val index = getAttributeIndexFromKey(key) - if (index < attrs.size) { - attrs.removeAt(index) - } - } - - /** - * Gets the value associated with the given key in the AttributeMap - * - * @param key the key of the attribute - * @return the value of the attribute - */ - fun getValue(key: String): String { - val index = getAttributeIndexFromKey(key) - return if (index < attrs.size) { - attrs[index].value - } else { - "" - } - } - - /** - * Gets a list of all the keys in the AttributeMap - * - * @return a list of all keys - */ - fun keySet(): List { - val keys: MutableList = ArrayList() - - for (attr in attrs) { - keys.add(attr.key) - } - - return keys - } - - /** - * Gets a list of all the values in the AttributeMap - * - * @return a list of all values - */ - fun values(): List { - val values: MutableList = ArrayList() - - for (attr in attrs) { - values.add(attr.value) - } - - return values - } - - /** - * Checks if the AttributeMap contains a key - * - * @param key the key to check for - * @return true if the AttributeMap contains the key, false otherwise - */ - fun contains(key: String): Boolean { - for (attr in attrs) { - if (attr.key == key) { - return true - } - // Check for attribute with/without android: prefix - if (key.startsWith("android:") && attr.key == key.substring(8)) { - return true - } - if (attr.key.startsWith("android:") && attr.key.substring(8) == key) { - return true - } - } - - return false - } - - /** - * Gets the index of the Attribute with the given key - * - * @param key the key of the Attribute - * @return the index of the Attribute - */ - private fun getAttributeIndexFromKey(key: String): Int { - var index = 0 - - for (attr in attrs) { - if (attr.key == key) { - return index - } - // Check for attribute with/without android: prefix - if (key.startsWith("android:") && attr.key == key.substring(8)) { - return index - } - if (attr.key.startsWith("android:") && attr.key.substring(8) == key) { - return index - } - - index++ - } - - return index - } - - private class Attribute - /** - * Constructs an Attribute with the specified key-value pair - * - * @param key the key of the Attribute - * @param value the value of the Attribute - */(val key: String, var value: String) -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/buttons/ButtonDesign.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/buttons/ButtonDesign.java deleted file mode 100644 index 9089154954..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/buttons/ButtonDesign.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.palette.buttons; - -import android.annotation.SuppressLint; -import android.content.Context; -import android.graphics.Canvas; -import android.widget.Button; - -import androidx.annotation.NonNull; - -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.utils.Utils; - -@SuppressLint("AppCompatCustomView") -public class ButtonDesign extends Button { - - private boolean drawStrokeEnabled; - private boolean isBlueprint; - - public ButtonDesign(Context context) { - super(context); - } - - @Override - protected void dispatchDraw(@NonNull Canvas canvas) { - super.dispatchDraw(canvas); - if (drawStrokeEnabled) - Utils.drawDashPathStroke( - this, canvas, isBlueprint ? Constants.BLUEPRINT_DASH_COLOR : Constants.DESIGN_DASH_COLOR); - } - - public void setStrokeEnabled(boolean enabled) { - drawStrokeEnabled = enabled; - invalidate(); - } - - @Override - public void draw(@NonNull Canvas canvas) { - if (isBlueprint) Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR); - else super.draw(canvas); - } - - public void setBlueprint(boolean isBlueprint) { - this.isBlueprint = isBlueprint; - invalidate(); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/buttons/CheckBoxDesign.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/buttons/CheckBoxDesign.java deleted file mode 100644 index 912de18016..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/buttons/CheckBoxDesign.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.palette.buttons; - -import android.annotation.SuppressLint; -import android.content.Context; -import android.graphics.Canvas; -import android.widget.CheckBox; - -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.utils.Utils; - -@SuppressLint("AppCompatCustomView") -public class CheckBoxDesign extends CheckBox { - - private boolean drawStrokeEnabled; - private boolean isBlueprint; - - public CheckBoxDesign(Context context) { - super(context); - } - - @Override - protected void dispatchDraw(Canvas canvas) { - super.dispatchDraw(canvas); - - if (drawStrokeEnabled) - Utils.drawDashPathStroke( - this, canvas, isBlueprint ? Constants.BLUEPRINT_DASH_COLOR : Constants.DESIGN_DASH_COLOR); - } - - @Override - public void draw(Canvas canvas) { - if (isBlueprint) Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR); - else super.draw(canvas); - } - - public void setBlueprint(boolean isBlueprint) { - this.isBlueprint = isBlueprint; - invalidate(); - } - - public void setStrokeEnabled(boolean enabled) { - drawStrokeEnabled = enabled; - invalidate(); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/buttons/ChipDesign.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/buttons/ChipDesign.java deleted file mode 100644 index 9b0cabe807..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/buttons/ChipDesign.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.palette.buttons; - -import android.content.Context; -import android.graphics.Canvas; - -import com.google.android.material.chip.Chip; - -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.utils.Utils; - -public class ChipDesign extends Chip { - - private boolean drawStrokeEnabled; - private boolean isBlueprint; - - public ChipDesign(Context context) { - super(context); - } - - @Override - protected void dispatchDraw(Canvas canvas) { - super.dispatchDraw(canvas); - if (drawStrokeEnabled) - Utils.drawDashPathStroke( - this, canvas, isBlueprint ? Constants.BLUEPRINT_DASH_COLOR : Constants.DESIGN_DASH_COLOR); - } - - public void setStrokeEnabled(boolean enabled) { - drawStrokeEnabled = enabled; - invalidate(); - } - - @Override - public void draw(Canvas canvas) { - if (isBlueprint) Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR); - else super.draw(canvas); - } - - public void setBlueprint(boolean isBlueprint) { - this.isBlueprint = isBlueprint; - invalidate(); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/buttons/ChipGroupDesign.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/buttons/ChipGroupDesign.java deleted file mode 100644 index f9dfe76004..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/buttons/ChipGroupDesign.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.palette.buttons; - -import android.content.Context; -import android.graphics.Canvas; - -import com.google.android.material.chip.ChipGroup; - -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.utils.Utils; - -public class ChipGroupDesign extends ChipGroup { - - private boolean drawStrokeEnabled; - private boolean isBlueprint; - - public ChipGroupDesign(Context context) { - super(context); - } - - @Override - protected void dispatchDraw(Canvas canvas) { - super.dispatchDraw(canvas); - if (drawStrokeEnabled) - Utils.drawDashPathStroke( - this, canvas, isBlueprint ? Constants.BLUEPRINT_DASH_COLOR : Constants.DESIGN_DASH_COLOR); - } - - public void setStrokeEnabled(boolean enabled) { - drawStrokeEnabled = enabled; - invalidate(); - } - - @Override - public void draw(Canvas canvas) { - if (isBlueprint) Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR); - else super.draw(canvas); - } - - public void setBlueprint(boolean isBlueprint) { - this.isBlueprint = isBlueprint; - invalidate(); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/buttons/FloatingActionButtonDesign.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/buttons/FloatingActionButtonDesign.java deleted file mode 100644 index dc340024b5..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/buttons/FloatingActionButtonDesign.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.palette.buttons; - -import android.content.Context; -import android.graphics.Canvas; - -import com.google.android.material.floatingactionbutton.FloatingActionButton; - -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.utils.Utils; - -public class FloatingActionButtonDesign extends FloatingActionButton { - - private boolean drawStrokeEnabled; - private boolean isBlueprint; - - public FloatingActionButtonDesign(Context context) { - super(context); - } - - @Override - protected void dispatchDraw(Canvas canvas) { - super.dispatchDraw(canvas); - - if (drawStrokeEnabled) - Utils.drawDashPathStroke( - this, canvas, isBlueprint ? Constants.BLUEPRINT_DASH_COLOR : Constants.DESIGN_DASH_COLOR); - } - - public void setStrokeEnabled(boolean enabled) { - drawStrokeEnabled = enabled; - invalidate(); - } - - @Override - public void draw(Canvas canvas) { - if (isBlueprint) Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR); - else super.draw(canvas); - } - - public void setBlueprint(boolean isBlueprint) { - this.isBlueprint = isBlueprint; - invalidate(); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/buttons/ImageButtonDesign.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/buttons/ImageButtonDesign.java deleted file mode 100644 index 8e9cb8925e..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/buttons/ImageButtonDesign.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.palette.buttons; - -import android.content.Context; -import android.graphics.Canvas; -import android.widget.ImageButton; - -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.utils.Utils; - -public class ImageButtonDesign extends ImageButton { - - private boolean drawStrokeEnabled; - private boolean isBlueprint; - - public ImageButtonDesign(Context context) { - super(context); - } - - @Override - protected void dispatchDraw(Canvas canvas) { - super.dispatchDraw(canvas); - - if (drawStrokeEnabled) - Utils.drawDashPathStroke( - this, canvas, isBlueprint ? Constants.BLUEPRINT_DASH_COLOR : Constants.DESIGN_DASH_COLOR); - } - - public void setStrokeEnabled(boolean enabled) { - drawStrokeEnabled = enabled; - invalidate(); - } - - @Override - public void draw(Canvas canvas) { - if (isBlueprint) Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR); - else super.draw(canvas); - } - - public void setBlueprint(boolean isBlueprint) { - this.isBlueprint = isBlueprint; - invalidate(); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/buttons/RadioButtonDesign.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/buttons/RadioButtonDesign.java deleted file mode 100644 index cb2497dcb8..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/buttons/RadioButtonDesign.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.palette.buttons; - -import android.annotation.SuppressLint; -import android.content.Context; -import android.graphics.Canvas; -import android.widget.RadioButton; - -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.utils.Utils; - -@SuppressLint("AppCompatCustomView") -public class RadioButtonDesign extends RadioButton { - - private boolean drawStrokeEnabled; - private boolean isBlueprint; - - public RadioButtonDesign(Context context) { - super(context); - } - - @Override - protected void dispatchDraw(Canvas canvas) { - super.dispatchDraw(canvas); - - if (drawStrokeEnabled) - Utils.drawDashPathStroke( - this, canvas, isBlueprint ? Constants.BLUEPRINT_DASH_COLOR : Constants.DESIGN_DASH_COLOR); - } - - public void setStrokeEnabled(boolean enabled) { - drawStrokeEnabled = enabled; - invalidate(); - } - - @Override - public void draw(Canvas canvas) { - if (isBlueprint) Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR); - else super.draw(canvas); - } - - public void setBlueprint(boolean isBlueprint) { - this.isBlueprint = isBlueprint; - invalidate(); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/buttons/RadioGroupDesign.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/buttons/RadioGroupDesign.java deleted file mode 100644 index b436f6aefc..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/buttons/RadioGroupDesign.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.palette.buttons; - -import android.content.Context; -import android.graphics.Canvas; -import android.widget.RadioGroup; - -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.utils.Utils; - -public class RadioGroupDesign extends RadioGroup { - - private boolean drawStrokeEnabled; - private boolean isBlueprint; - - public RadioGroupDesign(Context context) { - super(context); - } - - @Override - protected void dispatchDraw(Canvas canvas) { - super.dispatchDraw(canvas); - if (drawStrokeEnabled) - Utils.drawDashPathStroke( - this, canvas, isBlueprint ? Constants.BLUEPRINT_DASH_COLOR : Constants.DESIGN_DASH_COLOR); - } - - public void setStrokeEnabled(boolean enabled) { - drawStrokeEnabled = enabled; - invalidate(); - } - - @Override - public void draw(Canvas canvas) { - if (isBlueprint) Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR); - else super.draw(canvas); - } - - public void setBlueprint(boolean isBlueprint) { - this.isBlueprint = isBlueprint; - invalidate(); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/buttons/SwitchDesign.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/buttons/SwitchDesign.java deleted file mode 100644 index 95996b840f..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/buttons/SwitchDesign.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.palette.buttons; - -import android.annotation.SuppressLint; -import android.content.Context; -import android.graphics.Canvas; -import android.widget.Switch; - -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.utils.Utils; - -@SuppressLint("UseSwitchCompatOrMaterialCode") -public class SwitchDesign extends Switch { - - private boolean drawStrokeEnabled; - private boolean isBlueprint; - - public SwitchDesign(Context context) { - super(context); - } - - @Override - protected void dispatchDraw(Canvas canvas) { - super.dispatchDraw(canvas); - if (drawStrokeEnabled) - Utils.drawDashPathStroke( - this, canvas, isBlueprint ? Constants.BLUEPRINT_DASH_COLOR : Constants.DESIGN_DASH_COLOR); - } - - public void setStrokeEnabled(boolean enabled) { - drawStrokeEnabled = enabled; - invalidate(); - } - - @Override - public void draw(Canvas canvas) { - if (isBlueprint) Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR); - else super.draw(canvas); - } - - public void setBlueprint(boolean isBlueprint) { - this.isBlueprint = isBlueprint; - invalidate(); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/buttons/ToggleButtonDesign.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/buttons/ToggleButtonDesign.java deleted file mode 100644 index 3ee3a3b46a..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/buttons/ToggleButtonDesign.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.palette.buttons; - -import android.content.Context; -import android.graphics.Canvas; -import android.widget.ToggleButton; - -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.utils.Utils; - -public class ToggleButtonDesign extends ToggleButton { - - private boolean drawStrokeEnabled; - private boolean isBlueprint; - - public ToggleButtonDesign(Context context) { - super(context); - } - - @Override - protected void dispatchDraw(Canvas canvas) { - super.dispatchDraw(canvas); - if (drawStrokeEnabled) - Utils.drawDashPathStroke( - this, canvas, isBlueprint ? Constants.BLUEPRINT_DASH_COLOR : Constants.DESIGN_DASH_COLOR); - } - - public void setStrokeEnabled(boolean enabled) { - drawStrokeEnabled = enabled; - invalidate(); - } - - @Override - public void draw(Canvas canvas) { - if (isBlueprint) Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR); - else super.draw(canvas); - } - - public void setBlueprint(boolean isBlueprint) { - this.isBlueprint = isBlueprint; - invalidate(); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/containers/AppBarLayoutDesign.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/containers/AppBarLayoutDesign.java deleted file mode 100644 index 6f3063d091..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/containers/AppBarLayoutDesign.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.palette.containers; - -import android.content.Context; -import android.graphics.Canvas; - -import com.google.android.material.appbar.AppBarLayout; - -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.utils.Utils; - -public class AppBarLayoutDesign extends AppBarLayout { - - private boolean drawStrokeEnabled; - private boolean isBlueprint; - - public AppBarLayoutDesign(Context context) { - super(context); - } - - @Override - protected void dispatchDraw(Canvas canvas) { - super.dispatchDraw(canvas); - - if (drawStrokeEnabled) - Utils.drawDashPathStroke( - this, canvas, isBlueprint ? Constants.BLUEPRINT_DASH_COLOR : Constants.DESIGN_DASH_COLOR); - } - - public void setStrokeEnabled(boolean enabled) { - drawStrokeEnabled = enabled; - invalidate(); - } - - @Override - public void draw(Canvas canvas) { - if (isBlueprint) Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR); - else super.draw(canvas); - } - - public void setBlueprint(boolean isBlueprint) { - this.isBlueprint = isBlueprint; - invalidate(); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/containers/BottomAppBarDesign.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/containers/BottomAppBarDesign.java deleted file mode 100644 index 7364dc8aaf..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/containers/BottomAppBarDesign.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.palette.containers; - -import android.content.Context; -import android.graphics.Canvas; - -import com.google.android.material.bottomappbar.BottomAppBar; - -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.utils.Utils; - -public class BottomAppBarDesign extends BottomAppBar { - - private boolean drawStrokeEnabled; - private boolean isBlueprint; - - public BottomAppBarDesign(Context context) { - super(context); - } - - @Override - protected void dispatchDraw(Canvas canvas) { - super.dispatchDraw(canvas); - - if (drawStrokeEnabled) - Utils.drawDashPathStroke( - this, canvas, isBlueprint ? Constants.BLUEPRINT_DASH_COLOR : Constants.DESIGN_DASH_COLOR); - } - - public void setStrokeEnabled(boolean enabled) { - drawStrokeEnabled = enabled; - invalidate(); - } - - @Override - public void draw(Canvas canvas) { - if (isBlueprint) Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR); - else super.draw(canvas); - } - - public void setBlueprint(boolean isBlueprint) { - this.isBlueprint = isBlueprint; - invalidate(); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/containers/BottomNavigationViewDesign.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/containers/BottomNavigationViewDesign.java deleted file mode 100644 index b6a75dff1b..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/containers/BottomNavigationViewDesign.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.palette.containers; - -import android.content.Context; -import android.graphics.Canvas; - -import com.google.android.material.bottomnavigation.BottomNavigationView; - -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.utils.Utils; - -public class BottomNavigationViewDesign extends BottomNavigationView { - - private boolean drawStrokeEnabled; - private boolean isBlueprint; - - public BottomNavigationViewDesign(Context context) { - super(context); - } - - @Override - protected void dispatchDraw(Canvas canvas) { - super.dispatchDraw(canvas); - if (drawStrokeEnabled) - Utils.drawDashPathStroke( - this, canvas, isBlueprint ? Constants.BLUEPRINT_DASH_COLOR : Constants.DESIGN_DASH_COLOR); - } - - public void setStrokeEnabled(boolean enabled) { - drawStrokeEnabled = enabled; - invalidate(); - } - - @Override - public void draw(Canvas canvas) { - if (isBlueprint) Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR); - else super.draw(canvas); - } - - public void setBlueprint(boolean isBlueprint) { - this.isBlueprint = isBlueprint; - invalidate(); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/containers/CardViewDesign.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/containers/CardViewDesign.java deleted file mode 100644 index e26305c6e8..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/containers/CardViewDesign.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.palette.containers; - -import android.content.Context; -import android.graphics.Canvas; - -import androidx.cardview.widget.CardView; - -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.utils.Utils; - -public class CardViewDesign extends CardView { - - private boolean drawStrokeEnabled; - private boolean isBlueprint; - - public CardViewDesign(Context context) { - super(context); - } - - @Override - protected void dispatchDraw(Canvas canvas) { - super.dispatchDraw(canvas); - - if (drawStrokeEnabled) - Utils.drawDashPathStroke( - this, canvas, isBlueprint ? Constants.BLUEPRINT_DASH_COLOR : Constants.DESIGN_DASH_COLOR); - } - - public void setStrokeEnabled(boolean enabled) { - drawStrokeEnabled = enabled; - invalidate(); - } - - @Override - public void draw(Canvas canvas) { - if (isBlueprint) Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR); - else super.draw(canvas); - } - - public void setBlueprint(boolean isBlueprint) { - this.isBlueprint = isBlueprint; - invalidate(); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/containers/HorizontalScrollViewDesign.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/containers/HorizontalScrollViewDesign.java deleted file mode 100644 index c1bd4816d0..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/containers/HorizontalScrollViewDesign.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.palette.containers; - -import android.content.Context; -import android.graphics.Canvas; -import android.widget.HorizontalScrollView; - -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.utils.Utils; - -public class HorizontalScrollViewDesign extends HorizontalScrollView { - - private boolean drawStrokeEnabled; - private boolean isBlueprint; - - public HorizontalScrollViewDesign(Context context) { - super(context); - } - - @Override - protected void dispatchDraw(Canvas canvas) { - super.dispatchDraw(canvas); - - if (drawStrokeEnabled) - Utils.drawDashPathStroke( - this, canvas, isBlueprint ? Constants.BLUEPRINT_DASH_COLOR : Constants.DESIGN_DASH_COLOR); - } - - public void setStrokeEnabled(boolean enabled) { - drawStrokeEnabled = enabled; - invalidate(); - } - - @Override - public void draw(Canvas canvas) { - if (isBlueprint) Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR); - else super.draw(canvas); - } - - public void setBlueprint(boolean isBlueprint) { - this.isBlueprint = isBlueprint; - invalidate(); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/containers/MaterialToolbarDesign.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/containers/MaterialToolbarDesign.java deleted file mode 100644 index ca2dddac2b..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/containers/MaterialToolbarDesign.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.palette.containers; - -import android.content.Context; -import android.graphics.Canvas; - -import com.google.android.material.appbar.MaterialToolbar; - -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.utils.Utils; - -public class MaterialToolbarDesign extends MaterialToolbar { - - private boolean drawStrokeEnabled; - private boolean isBlueprint; - - public MaterialToolbarDesign(Context context) { - super(context); - } - - @Override - protected void dispatchDraw(Canvas canvas) { - super.dispatchDraw(canvas); - - if (drawStrokeEnabled) - Utils.drawDashPathStroke( - this, canvas, isBlueprint ? Constants.BLUEPRINT_DASH_COLOR : Constants.DESIGN_DASH_COLOR); - } - - public void setStrokeEnabled(boolean enabled) { - drawStrokeEnabled = enabled; - invalidate(); - } - - @Override - public void draw(Canvas canvas) { - if (isBlueprint) Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR); - else super.draw(canvas); - } - - public void setBlueprint(boolean isBlueprint) { - this.isBlueprint = isBlueprint; - invalidate(); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/containers/NavigationViewDesign.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/containers/NavigationViewDesign.java deleted file mode 100644 index 75d27b6606..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/containers/NavigationViewDesign.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.palette.containers; - -import android.content.Context; -import android.graphics.Canvas; -import com.google.android.material.navigation.NavigationView; -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.utils.Utils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class NavigationViewDesign extends NavigationView { - - private boolean drawStrokeEnabled; - private boolean isBlueprint; - - private final Logger logger = LoggerFactory.getLogger(NavigationViewDesign.class); - - public NavigationViewDesign(Context context) { - super(context); - } - - @Override - public void draw(Canvas canvas) { - if (isBlueprint) - Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR); - else - super.draw(canvas); - } - - public void setBlueprint(boolean isBlueprint) { - this.isBlueprint = isBlueprint; - invalidate(); - } - - public void setStrokeEnabled(boolean enabled) { - drawStrokeEnabled = enabled; - invalidate(); - } - - @Override - protected void dispatchDraw(Canvas canvas) { - super.dispatchDraw(canvas); - - if (drawStrokeEnabled) - Utils.drawDashPathStroke( - this, canvas, isBlueprint ? Constants.BLUEPRINT_DASH_COLOR : Constants.DESIGN_DASH_COLOR); - } - - @Override - protected void onAttachedToWindow() { - try { - super.onAttachedToWindow(); - } catch (IllegalArgumentException e) { - logger.error("NavigationView should be placed in a DrawerLayout", e); - } - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/containers/NestedScrollViewDesign.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/containers/NestedScrollViewDesign.java deleted file mode 100644 index 1363d94ea9..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/containers/NestedScrollViewDesign.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.palette.containers; - -import android.content.Context; -import android.graphics.Canvas; - -import androidx.core.widget.NestedScrollView; - -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.utils.Utils; - -public class NestedScrollViewDesign extends NestedScrollView { - - private boolean drawStrokeEnabled; - private boolean isBlueprint; - - public NestedScrollViewDesign(Context context) { - super(context); - } - - @Override - protected void dispatchDraw(Canvas canvas) { - super.dispatchDraw(canvas); - - if (drawStrokeEnabled) - Utils.drawDashPathStroke( - this, canvas, isBlueprint ? Constants.BLUEPRINT_DASH_COLOR : Constants.DESIGN_DASH_COLOR); - } - - public void setStrokeEnabled(boolean enabled) { - drawStrokeEnabled = enabled; - invalidate(); - } - - @Override - public void draw(Canvas canvas) { - if (isBlueprint) Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR); - else super.draw(canvas); - } - - public void setBlueprint(boolean isBlueprint) { - this.isBlueprint = isBlueprint; - invalidate(); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/containers/RecyclerViewDesign.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/containers/RecyclerViewDesign.java deleted file mode 100644 index 2a3739e901..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/containers/RecyclerViewDesign.java +++ /dev/null @@ -1,78 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.palette.containers; - -import android.content.Context; -import android.graphics.Canvas; -import android.graphics.Color; -import android.graphics.Paint; - -import androidx.recyclerview.widget.RecyclerView; - -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.utils.Utils; - -public class RecyclerViewDesign extends RecyclerView { - - private boolean drawStrokeEnabled; - private boolean isBlueprint; - private Paint previewPaint; - - public RecyclerViewDesign(Context context) { - super(context); - init(); - } - - private void init() { - previewPaint = new Paint(); - previewPaint.setColor(Color.GRAY); - previewPaint.setStyle(Paint.Style.FILL); - previewPaint.setTextSize(35); - } - - @Override - protected void dispatchDraw(Canvas canvas) { - super.dispatchDraw(canvas); - - int numColumns = 3; // number of columns in the grid - int itemWidth = getWidth() / numColumns; - int itemHeight = getHeight() / numColumns; - int x = 0; - int y = 0; - - for (int i = 1; i <= numColumns * numColumns; i++) { - // draw item placeholder - String text = "item " + i; - float textWidth = previewPaint.measureText(text); - float textHeight = previewPaint.descent() - previewPaint.ascent(); - float xPos = x + (itemWidth - textWidth) / 2; - float yPos = y + (itemHeight - textHeight) / 2 - previewPaint.ascent(); - canvas.drawText(text, xPos, yPos, previewPaint); - - // update x and y position for next item - x += itemWidth; - if (i % numColumns == 0) { - x = 0; - y += itemHeight; - } - } - - if (drawStrokeEnabled) - Utils.drawDashPathStroke( - this, canvas, isBlueprint ? Constants.BLUEPRINT_DASH_COLOR : Constants.DESIGN_DASH_COLOR); - } - - public void setStrokeEnabled(boolean enabled) { - drawStrokeEnabled = enabled; - invalidate(); - } - - @Override - public void draw(Canvas canvas) { - if (isBlueprint) Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR); - else super.draw(canvas); - } - - public void setBlueprint(boolean isBlueprint) { - this.isBlueprint = isBlueprint; - invalidate(); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/containers/ScrollViewDesign.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/containers/ScrollViewDesign.kt deleted file mode 100644 index 640a72284d..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/containers/ScrollViewDesign.kt +++ /dev/null @@ -1,73 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.palette.containers - -import android.content.Context -import android.graphics.Canvas -import android.util.AttributeSet -import android.view.GestureDetector -import android.view.MotionEvent -import android.widget.ScrollView -import org.appdevforall.codeonthego.layouteditor.utils.Constants -import org.appdevforall.codeonthego.layouteditor.utils.Utils - -class ScrollViewDesign @JvmOverloads constructor( - context: Context, attrs: AttributeSet? = null -) : ScrollView(context, attrs) { - private var drawStrokeEnabled = false - private var isBlueprint = false - - private val gestureDetector: GestureDetector - - init { - gestureDetector = GestureDetector(context, ScrollDetector()) - } - - override fun onTouchEvent(ev: MotionEvent): Boolean { - return gestureDetector.onTouchEvent(ev) || super.onTouchEvent(ev) - } - - 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 - ) - } - - override fun draw(canvas: Canvas) { - if (isBlueprint) Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR) - else super.draw(canvas) - } - - inner class ScrollDetector : GestureDetector.SimpleOnGestureListener() { - override fun onScroll( - e1: MotionEvent?, - e2: MotionEvent, - distanceX: Float, - distanceY: Float - ): Boolean { - if (e1 != null) { - val deltaY = e2.y - e1.y - val threshold = resources.displayMetrics.heightPixels * 0.2f - if (deltaY > threshold) { - smoothScrollTo(0, scrollY + 100) - return true - } else if (deltaY < -threshold) { - smoothScrollTo(0, scrollY - 100) - return true - } - } - - return super.onScroll(e1, e2, distanceX, distanceY) - } - } - - fun setStrokeEnabled(enabled: Boolean) { - drawStrokeEnabled = enabled - invalidate() - } - - fun setBlueprint(isBlueprint: Boolean) { - this.isBlueprint = isBlueprint - invalidate() - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/containers/SpinnerDesign.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/containers/SpinnerDesign.java deleted file mode 100644 index 3fb590061d..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/containers/SpinnerDesign.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.palette.containers; - -import android.content.Context; -import android.graphics.Canvas; -import android.widget.Spinner; - -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.utils.Utils; - -public class SpinnerDesign extends Spinner { - - private boolean drawStrokeEnabled; - private boolean isBlueprint; - - public SpinnerDesign(Context context) { - super(context); - } - - @Override - protected void dispatchDraw(Canvas canvas) { - super.dispatchDraw(canvas); - - if (drawStrokeEnabled) - Utils.drawDashPathStroke( - this, canvas, isBlueprint ? Constants.BLUEPRINT_DASH_COLOR : Constants.DESIGN_DASH_COLOR); - } - - public void setStrokeEnabled(boolean enabled) { - drawStrokeEnabled = enabled; - invalidate(); - } - - @Override - public void draw(Canvas canvas) { - if (isBlueprint) Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR); - else super.draw(canvas); - } - - public void setBlueprint(boolean isBlueprint) { - this.isBlueprint = isBlueprint; - invalidate(); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/containers/TabItemDesign.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/containers/TabItemDesign.java deleted file mode 100644 index 9b8ada6344..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/containers/TabItemDesign.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.palette.containers; - -import android.content.Context; -import android.graphics.Canvas; - -import com.google.android.material.tabs.TabItem; - -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.utils.Utils; - -public class TabItemDesign extends TabItem { - - private boolean drawStrokeEnabled; - private boolean isBlueprint; - - public TabItemDesign(Context context) { - super(context); - } - - @Override - protected void dispatchDraw(Canvas canvas) { - super.dispatchDraw(canvas); - - if (drawStrokeEnabled) - Utils.drawDashPathStroke( - this, canvas, isBlueprint ? Constants.BLUEPRINT_DASH_COLOR : Constants.DESIGN_DASH_COLOR); - } - - public void setStrokeEnabled(boolean enabled) { - drawStrokeEnabled = enabled; - invalidate(); - } - - @Override - public void draw(Canvas canvas) { - if (isBlueprint) Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR); - else super.draw(canvas); - } - - public void setBlueprint(boolean isBlueprint) { - this.isBlueprint = isBlueprint; - invalidate(); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/containers/TabLayoutDesign.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/containers/TabLayoutDesign.java deleted file mode 100644 index ea4008b283..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/containers/TabLayoutDesign.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.palette.containers; - -import android.content.Context; -import android.graphics.Canvas; - -import com.google.android.material.tabs.TabLayout; - -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.utils.Utils; - -public class TabLayoutDesign extends TabLayout { - - private boolean drawStrokeEnabled; - private boolean isBlueprint; - - public TabLayoutDesign(Context context) { - super(context); - } - - @Override - protected void dispatchDraw(Canvas canvas) { - super.dispatchDraw(canvas); - - if (drawStrokeEnabled) - Utils.drawDashPathStroke( - this, canvas, isBlueprint ? Constants.BLUEPRINT_DASH_COLOR : Constants.DESIGN_DASH_COLOR); - } - - public void setStrokeEnabled(boolean enabled) { - drawStrokeEnabled = enabled; - invalidate(); - } - - @Override - public void draw(Canvas canvas) { - if (isBlueprint) Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR); - else super.draw(canvas); - } - - public void setBlueprint(boolean isBlueprint) { - this.isBlueprint = isBlueprint; - invalidate(); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/containers/ToolbarDesign.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/containers/ToolbarDesign.java deleted file mode 100644 index 1c763120f9..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/containers/ToolbarDesign.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.palette.containers; - -import android.content.Context; -import android.graphics.Canvas; -import android.widget.Toolbar; - -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.utils.Utils; - -public class ToolbarDesign extends Toolbar { - - private boolean drawStrokeEnabled; - private boolean isBlueprint; - - public ToolbarDesign(Context context) { - super(context); - } - - @Override - protected void dispatchDraw(Canvas canvas) { - super.dispatchDraw(canvas); - - if (drawStrokeEnabled) - Utils.drawDashPathStroke( - this, canvas, isBlueprint ? Constants.BLUEPRINT_DASH_COLOR : Constants.DESIGN_DASH_COLOR); - } - - public void setStrokeEnabled(boolean enabled) { - drawStrokeEnabled = enabled; - invalidate(); - } - - @Override - public void draw(Canvas canvas) { - if (isBlueprint) Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR); - else super.draw(canvas); - } - - public void setBlueprint(boolean isBlueprint) { - this.isBlueprint = isBlueprint; - invalidate(); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/containers/ViewPagerDesign.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/containers/ViewPagerDesign.java deleted file mode 100644 index 58f4f04661..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/containers/ViewPagerDesign.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.palette.containers; - -import android.content.Context; -import android.graphics.Canvas; - -import androidx.viewpager.widget.ViewPager; - -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.utils.Utils; - -public class ViewPagerDesign extends ViewPager { - - private boolean drawStrokeEnabled; - private boolean isBlueprint; - - public ViewPagerDesign(Context context) { - super(context); - } - - @Override - protected void dispatchDraw(Canvas canvas) { - super.dispatchDraw(canvas); - - if (drawStrokeEnabled) - Utils.drawDashPathStroke( - this, canvas, isBlueprint ? Constants.BLUEPRINT_DASH_COLOR : Constants.DESIGN_DASH_COLOR); - } - - public void setStrokeEnabled(boolean enabled) { - drawStrokeEnabled = enabled; - invalidate(); - } - - @Override - public void draw(Canvas canvas) { - if (isBlueprint) Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR); - else super.draw(canvas); - } - - public void setBlueprint(boolean isBlueprint) { - this.isBlueprint = isBlueprint; - invalidate(); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/layouts/ConstraintLayoutDesign.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/layouts/ConstraintLayoutDesign.java deleted file mode 100644 index 956c5fa52e..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/layouts/ConstraintLayoutDesign.java +++ /dev/null @@ -1,187 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.palette.layouts; - -import android.content.Context; -import android.graphics.Canvas; -import android.graphics.Color; -import android.graphics.Paint; -import android.view.View; - -import androidx.constraintlayout.widget.ConstraintLayout; - -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.utils.Utils; - -public class ConstraintLayoutDesign extends ConstraintLayout { - private boolean drawStrokeEnabled; - private boolean isBlueprint; - - private Paint linePaint; - private Paint fillPaint; - - private final int PARENT_ID = ConstraintLayout.LayoutParams.PARENT_ID; - private final int LEFT = 1; - private final int RIGHT = 2; - private final int TOP = 3; - private final int BOTTOM = 4; - - public ConstraintLayoutDesign(Context context) { - super(context); - - linePaint = new Paint(); - linePaint.setColor(Color.LTGRAY); - linePaint.setStrokeWidth(2); - linePaint.setAntiAlias(true); - linePaint.setStyle(Paint.Style.STROKE); - - fillPaint = new Paint(); - fillPaint.setColor(Color.LTGRAY); - fillPaint.setAntiAlias(true); - } - - @Override - protected void dispatchDraw(Canvas canvas) { - if (drawStrokeEnabled) { - drawBindings(canvas); - } - - super.dispatchDraw(canvas); - - if (drawStrokeEnabled) - Utils.drawDashPathStroke( - this, canvas, isBlueprint ? Constants.BLUEPRINT_DASH_COLOR : Constants.DESIGN_DASH_COLOR); - } - - @Override - public void draw(Canvas canvas) { - if (isBlueprint) Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR); - else super.draw(canvas); - } - - public void setBlueprint(boolean isBlueprint) { - this.isBlueprint = isBlueprint; - invalidate(); - } - - public void setStrokeEnabled(boolean enabled) { - drawStrokeEnabled = enabled; - invalidate(); - } - - private void drawBindings(Canvas canvas) { - for (int i = 0; i < getChildCount(); i++) { - View view = getChildAt(i); - ConstraintLayout.LayoutParams params = (ConstraintLayout.LayoutParams) view.getLayoutParams(); - - // Draw connection lines for the view's constraints - if (params.leftToLeft != -1) { - int targetId = params.leftToLeft; - drawConstraintLine(canvas, view, targetId, LEFT, LEFT); - } - if (params.leftToRight != -1) { - int targetId = params.leftToRight; - drawConstraintLine(canvas, view, targetId, LEFT, RIGHT); - } - if (params.rightToLeft != -1) { - int targetId = params.rightToLeft; - drawConstraintLine(canvas, view, targetId, RIGHT, LEFT); - } - if (params.rightToRight != -1) { - int targetId = params.rightToRight; - drawConstraintLine(canvas, view, targetId, RIGHT, RIGHT); - } - if (params.topToTop != -1) { - int targetId = params.topToTop; - drawConstraintLine(canvas, view, targetId, TOP, TOP); - } - if (params.topToBottom != -1) { - int targetId = params.topToBottom; - drawConstraintLine(canvas, view, targetId, TOP, BOTTOM); - } - if (params.bottomToTop != -1) { - int targetId = params.bottomToTop; - drawConstraintLine(canvas, view, targetId, BOTTOM, TOP); - } - if (params.bottomToBottom != -1) { - int targetId = params.bottomToBottom; - drawConstraintLine(canvas, view, targetId, BOTTOM, BOTTOM); - } - } - } - - private void drawConstraintLine(Canvas canvas, View view, int targetId, int startSide, int endSide) { - View targetView = targetId == PARENT_ID ? this : findViewById(targetId); - if (targetView == null) return; - - int x1 = 0, y1 = 0, x2 = 0, y2 = 0; - - // Get source coordinates - switch (startSide) { - case LEFT: - x1 = view.getLeft(); - y1 = view.getTop() + view.getHeight() / 2; - break; - case RIGHT: - x1 = view.getRight(); - y1 = view.getTop() + view.getHeight() / 2; - break; - case TOP: - x1 = view.getLeft() + view.getWidth() / 2; - y1 = view.getTop(); - break; - case BOTTOM: - x1 = view.getLeft() + view.getWidth() / 2; - y1 = view.getBottom(); - break; - } - - // Get target coordinates - switch (endSide) { - case LEFT: - x2 = targetView.getLeft(); - y2 = targetView.getTop() + targetView.getHeight() / 2; - break; - case RIGHT: - x2 = targetView.getRight(); - y2 = targetView.getTop() + targetView.getHeight() / 2; - break; - case TOP: - x2 = targetView.getLeft() + targetView.getWidth() / 2; - y2 = targetView.getTop(); - break; - case BOTTOM: - x2 = targetView.getLeft() + targetView.getWidth() / 2; - y2 = targetView.getBottom(); - break; - } - - // Draw the constraint line - Paint constraintPaint = new Paint(); - constraintPaint.setColor(Color.DKGRAY); - constraintPaint.setStrokeWidth(2); - constraintPaint.setStyle(Paint.Style.STROKE); - canvas.drawLine(x1, y1, x2, y2, constraintPaint); - } - - private void drawHorArrow(Canvas canvas, int x, int y, int x2, int y2) { - int width = x2 - x; - int step = 10; - int height = 10; - - for (int i = 0; i < width; i += step) { - // line(x + i, y, x + i + step, y + step); - canvas.drawLine(x + i, y - height / 2, x + i + step, y + height / 2, linePaint); - canvas.drawLine(x + i + step, y - height / 2, x + i + step, y + height / 2, linePaint); - } - } - - private void drawVerArrow(Canvas canvas, int x, int y, int x2, int y2) { - int height = y2 - y; - int step = 10; - int width = 10; - - for (int i = 0; i < height; i += step) { - canvas.drawLine(x - width / 2, y + i, x + width / 2, y + i + step, linePaint); - canvas.drawLine(x - width / 2, y + i + step, x + width / 2, y + i + step, linePaint); - } - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/layouts/CoordinatorLayoutDesign.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/layouts/CoordinatorLayoutDesign.java deleted file mode 100644 index e1050e9ed6..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/layouts/CoordinatorLayoutDesign.java +++ /dev/null @@ -1,79 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.palette.layouts; - -import android.content.Context; -import android.graphics.Canvas; - -import androidx.annotation.NonNull; -import androidx.coordinatorlayout.widget.CoordinatorLayout; - -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.utils.Utils; - -/** - * A design-time representation of a CoordinatorLayout. - *

- * This class provides visual feedback within the layout editor, such as a dashed - * border, to indicate its boundaries and state (e.g., blueprint mode). It mirrors - * the functionality of ConstraintLayoutDesign for a consistent look and feel. - */ -public class CoordinatorLayoutDesign extends CoordinatorLayout { - private boolean isBlueprint; - private boolean drawStrokeEnabled; - - public CoordinatorLayoutDesign(Context context) { - super(context); - } - - /** - * Overridden to draw custom design-time visuals *after* the children have been drawn. - * This is where we draw the dashed border for the layout itself. - */ - @Override - protected void dispatchDraw(@NonNull Canvas canvas) { - // Let the default CoordinatorLayout draw its children first. - super.dispatchDraw(canvas); - - // After drawing children, draw our custom dashed stroke on top if enabled. - if (drawStrokeEnabled) { - Utils.drawDashPathStroke( - this, - canvas, - isBlueprint ? Constants.BLUEPRINT_DASH_COLOR : Constants.DESIGN_DASH_COLOR); - } - } - - /** - * Overridden to handle the "blueprint" mode. In blueprint mode, we don't draw - * the standard background or children, only a dashed outline. - */ - @Override - public void draw(@NonNull Canvas canvas) { - if (isBlueprint) { - // In blueprint mode, only draw the dashed outline and nothing else. - Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR); - } else { - // In normal design mode, perform the standard draw operation. - super.draw(canvas); - } - } - - /** - * Toggles blueprint mode. - * - * @param isBlueprint true to enable blueprint mode, false for normal design mode. - */ - public void setBlueprint(boolean isBlueprint) { - this.isBlueprint = isBlueprint; - invalidate(); // Redraw the view with the new mode. - } - - /** - * Toggles the visibility of the dashed stroke outline in design mode. - * - * @param enabled true to show the dashed outline. - */ - public void setStrokeEnabled(boolean enabled) { - this.drawStrokeEnabled = enabled; - invalidate(); // Redraw the view. - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/layouts/DrawerLayoutDesign.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/layouts/DrawerLayoutDesign.kt deleted file mode 100644 index 3ab468ea8a..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/layouts/DrawerLayoutDesign.kt +++ /dev/null @@ -1,56 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.palette.layouts - -import android.content.Context -import android.graphics.Canvas -import androidx.drawerlayout.widget.DrawerLayout -import org.appdevforall.codeonthego.layouteditor.utils.Constants -import org.appdevforall.codeonthego.layouteditor.utils.Utils -import org.slf4j.Logger -import org.slf4j.LoggerFactory - -class DrawerLayoutDesign( - context: Context, -) : DrawerLayout(context) { - private var drawStrokeEnabled = false - private var isBlueprint = false - - private val logger: Logger = LoggerFactory.getLogger(DrawerLayoutDesign::class.java) - - 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, - ) - } - } - - override fun draw(canvas: Canvas) { - if (isBlueprint) { - Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR) - } else { - super.draw(canvas) - } - } - - fun setStrokeEnabled(enabled: Boolean) { - drawStrokeEnabled = enabled - invalidate() - } - - fun setBlueprint(isBlueprint: Boolean) { - this.isBlueprint = isBlueprint - invalidate() - } - - override fun onAttachedToWindow() { - try { - super.onAttachedToWindow() - } catch (e: Exception) { - logger.error("Error in previewing DrawerLayoutDesign", e) - } - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/layouts/FrameLayoutDesign.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/layouts/FrameLayoutDesign.java deleted file mode 100644 index 15243094ae..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/layouts/FrameLayoutDesign.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.palette.layouts; - -import android.content.Context; -import android.graphics.Canvas; -import android.widget.FrameLayout; - -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.utils.Utils; - -public class FrameLayoutDesign extends FrameLayout { - - private boolean drawStrokeEnabled; - private boolean isBlueprint; - - public FrameLayoutDesign(Context context) { - super(context); - } - - @Override - protected void dispatchDraw(Canvas canvas) { - super.dispatchDraw(canvas); - - if (drawStrokeEnabled) - Utils.drawDashPathStroke( - this, canvas, isBlueprint ? Constants.BLUEPRINT_DASH_COLOR : Constants.DESIGN_DASH_COLOR); - } - - public void setStrokeEnabled(boolean enabled) { - drawStrokeEnabled = enabled; - invalidate(); - } - - @Override - public void draw(Canvas canvas) { - if (isBlueprint) Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR); - else super.draw(canvas); - } - - public void setBlueprint(boolean isBlueprint) { - this.isBlueprint = isBlueprint; - invalidate(); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/layouts/LinearLayoutDesign.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/layouts/LinearLayoutDesign.java deleted file mode 100644 index 0ce5f05790..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/layouts/LinearLayoutDesign.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.palette.layouts; - -import android.content.Context; -import android.graphics.Canvas; -import android.widget.LinearLayout; - -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.utils.Utils; - -public class LinearLayoutDesign extends LinearLayout { - - private boolean drawStrokeEnabled; - private boolean isBlueprint; - - public LinearLayoutDesign(Context context) { - super(context); - } - - @Override - protected void dispatchDraw(Canvas canvas) { - super.dispatchDraw(canvas); - - if (drawStrokeEnabled) - Utils.drawDashPathStroke( - this, canvas, isBlueprint ? Constants.BLUEPRINT_DASH_COLOR : Constants.DESIGN_DASH_COLOR); - } - - public void setStrokeEnabled(boolean enabled) { - drawStrokeEnabled = enabled; - invalidate(); - } - - @Override - public void draw(Canvas canvas) { - if (isBlueprint) Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR); - else super.draw(canvas); - } - - public void setBlueprint(boolean isBlueprint) { - this.isBlueprint = isBlueprint; - invalidate(); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/layouts/RelativeLayoutDesign.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/layouts/RelativeLayoutDesign.java deleted file mode 100644 index adf252bd48..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/layouts/RelativeLayoutDesign.java +++ /dev/null @@ -1,258 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.palette.layouts; - -import android.content.Context; -import android.graphics.Canvas; -import android.graphics.Color; -import android.graphics.Paint; -import android.graphics.Path; -import android.view.View; -import android.widget.RelativeLayout; - -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.utils.Utils; - -public class RelativeLayoutDesign extends RelativeLayout { - - private Paint linePaint; - private Paint fillPaint; - - private boolean drawStrokeEnabled; - private boolean isBlueprint; - - public RelativeLayoutDesign(Context context) { - super(context); - - linePaint = new Paint(); - linePaint.setColor(Color.LTGRAY); - linePaint.setStrokeWidth(Utils.pxToDp(context, 2)); - linePaint.setAntiAlias(true); - linePaint.setStyle(Paint.Style.STROKE); - - fillPaint = new Paint(); - fillPaint.setColor(Color.LTGRAY); - fillPaint.setAntiAlias(true); - } - - @Override - protected void dispatchDraw(Canvas canvas) { - if (drawStrokeEnabled) { - drawBindings(canvas); - } - - super.dispatchDraw(canvas); - - if (drawStrokeEnabled) - Utils.drawDashPathStroke( - this, canvas, isBlueprint ? Constants.BLUEPRINT_DASH_COLOR : Constants.DESIGN_DASH_COLOR); - } - - private void drawBindings(Canvas canvas) { - for (int i = 0; i < getChildCount(); i++) { - View view = getChildAt(i); - - RelativeLayout.LayoutParams par = (RelativeLayout.LayoutParams) view.getLayoutParams(); - - if (par.getRule(CENTER_HORIZONTAL) == -1) { - drawHorArrow( - canvas, - 0, - view.getTop() + view.getHeight() / 2, - view.getLeft(), - view.getTop() + view.getHeight() / 2); - drawHorArrow( - canvas, - view.getRight(), - view.getTop() + view.getHeight() / 2, - getWidth(), - view.getTop() + view.getHeight() / 2); - } - - if (par.getRule(CENTER_VERTICAL) == -1) { - drawVerArrow( - canvas, - view.getLeft() + view.getWidth() / 2, - 0, - view.getLeft() + view.getWidth() / 2, - view.getTop()); - drawVerArrow( - canvas, - view.getLeft() + view.getWidth() / 2, - view.getBottom(), - view.getLeft() + view.getWidth() / 2, - getHeight()); - } - - if (par.getRule(CENTER_IN_PARENT) == -1) { - drawHorArrow( - canvas, - 0, - view.getTop() + view.getHeight() / 2, - view.getLeft(), - view.getTop() + view.getHeight() / 2); - drawHorArrow( - canvas, - view.getRight(), - view.getTop() + view.getHeight() / 2, - getWidth(), - view.getTop() + view.getHeight() / 2); - - drawVerArrow( - canvas, - view.getLeft() + view.getWidth() / 2, - 0, - view.getLeft() + view.getWidth() / 2, - view.getTop()); - drawVerArrow( - canvas, - view.getLeft() + view.getWidth() / 2, - view.getBottom(), - view.getLeft() + view.getWidth() / 2, - getHeight()); - } - - if (par.getRule(ABOVE) != 0) { - View anchor = findViewById(par.getRule(ABOVE)); - - if (anchor != null) drawBind(canvas, view, anchor, ABOVE); - } - - if (par.getRule(BELOW) != 0) { - View anchor = findViewById(par.getRule(BELOW)); - - if (anchor != null) drawBind(canvas, view, anchor, BELOW); - } - - if (par.getRule(LEFT_OF) != 0) { - View anchor = findViewById(par.getRule(LEFT_OF)); - - if (anchor != null) drawBind(canvas, view, anchor, LEFT_OF); - } - - if (par.getRule(RIGHT_OF) != 0) { - View anchor = findViewById(par.getRule(RIGHT_OF)); - - if (anchor != null) drawBind(canvas, view, anchor, RIGHT_OF); - } - } - } - - public void setStrokeEnabled(boolean enabled) { - drawStrokeEnabled = enabled; - invalidate(); - } - - private void drawHorArrow(Canvas canvas, int x, int y, int x2, int y2) { - int width = x2 - x; - int step = 10; - int height = 10; - - for (int i = 0; i < width; i += step) { - // line(x + i, y, x + i + step, y + step); - canvas.drawLine(x + i, y - height / 2, x + i + step, y + height / 2, linePaint); - canvas.drawLine(x + i + step, y - height / 2, x + i + step, y + height / 2, linePaint); - } - } - - private void drawVerArrow(Canvas canvas, int x, int y, int x2, int y2) { - int height = y2 - y; - int step = 10; - int width = 10; - - for (int i = 0; i < height; i += step) { - canvas.drawLine(x - width / 2, y + i, x + width / 2, y + i + step, linePaint); - canvas.drawLine(x - width / 2, y + i + step, x + width / 2, y + i + step, linePaint); - } - } - - private void drawBind(Canvas canvas, View view, View anchor, int rule) { - int x1 = 0, y1 = 0; - int x2 = 0, y2 = 0; - int offset = 100; - - Path path = new Path(); - - switch (rule) { - case BELOW: - { - x1 = view.getLeft() + view.getWidth() / 2; - y1 = view.getTop(); - x2 = anchor.getLeft() + anchor.getWidth() / 2; - y2 = anchor.getBottom(); - - int halfX = (x1 + x2) / 2; - int halfY = (y1 + y2) / 2; - - path.moveTo(x1, y1); - path.cubicTo(x1, y1, x1, y1 - offset, halfX, halfY); - path.moveTo(x2, y2); - path.cubicTo(x2, y2, x2, y2 + offset, halfX, halfY); - break; - } - - case ABOVE: - { - x1 = view.getLeft() + view.getWidth() / 2; - y1 = view.getBottom(); - x2 = anchor.getLeft() + anchor.getWidth() / 2; - y2 = anchor.getTop(); - - int halfX = (x1 + x2) / 2; - int halfY = (y1 + y2) / 2; - - path.moveTo(x1, y1); - path.cubicTo(x1, y1, x1, y1 + offset, halfX, halfY); - path.moveTo(x2, y2); - path.cubicTo(x2, y2, x2, y2 - offset, halfX, halfY); - break; - } - - case LEFT_OF: - { - x1 = view.getRight(); - y1 = view.getTop() + view.getHeight() / 2; - x2 = anchor.getLeft(); - y2 = anchor.getTop() + anchor.getHeight() / 2; - - int halfX = (x1 + x2) / 2; - int halfY = (y1 + y2) / 2; - - path.moveTo(x1, y1); - path.cubicTo(x1, y1, x1 + offset, y1, halfX, halfY); - path.moveTo(x2, y2); - path.cubicTo(x2, y2, x2 - offset, y2, halfX, halfY); - break; - } - - case RIGHT_OF: - { - x1 = view.getLeft(); - y1 = view.getTop() + view.getHeight() / 2; - x2 = anchor.getRight(); - y2 = anchor.getTop() + anchor.getHeight() / 2; - - int halfX = (x1 + x2) / 2; - int halfY = (y1 + y2) / 2; - - path.moveTo(x1, y1); - path.cubicTo(x1, y1, x1 - offset, y1, halfX, halfY); - path.moveTo(x2, y2); - path.cubicTo(x2, y2, x2 + offset, y2, halfX, halfY); - break; - } - } - - canvas.drawPath(path, linePaint); - canvas.drawCircle(x2, y2, 10, fillPaint); - } - - @Override - public void draw(Canvas canvas) { - if (isBlueprint) Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR); - else super.draw(canvas); - } - - public void setBlueprint(boolean isBlueprint) { - this.isBlueprint = isBlueprint; - invalidate(); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/layouts/TableLayoutDesign.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/layouts/TableLayoutDesign.java deleted file mode 100644 index bc17dcd006..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/layouts/TableLayoutDesign.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.palette.layouts; - -import android.content.Context; -import android.graphics.Canvas; -import android.widget.TableLayout; - -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.utils.Utils; - -public class TableLayoutDesign extends TableLayout { - - private boolean drawStrokeEnabled; - private boolean isBlueprint; - - public TableLayoutDesign(Context context) { - super(context); - } - - @Override - protected void dispatchDraw(Canvas canvas) { - super.dispatchDraw(canvas); - - if (drawStrokeEnabled) - Utils.drawDashPathStroke( - this, canvas, isBlueprint ? Constants.BLUEPRINT_DASH_COLOR : Constants.DESIGN_DASH_COLOR); - } - - public void setStrokeEnabled(boolean enabled) { - drawStrokeEnabled = enabled; - invalidate(); - } - - @Override - public void draw(Canvas canvas) { - if (isBlueprint) Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR); - else super.draw(canvas); - } - - public void setBlueprint(boolean isBlueprint) { - this.isBlueprint = isBlueprint; - invalidate(); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/layouts/TableRowDesign.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/layouts/TableRowDesign.java deleted file mode 100644 index 25b9462165..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/layouts/TableRowDesign.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.palette.layouts; - -import android.content.Context; -import android.graphics.Canvas; -import android.widget.TableRow; - -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.utils.Utils; - -public class TableRowDesign extends TableRow { - - private boolean drawStrokeEnabled; - private boolean isBlueprint; - - public TableRowDesign(Context context) { - super(context); - } - - @Override - protected void dispatchDraw(Canvas canvas) { - super.dispatchDraw(canvas); - - if (drawStrokeEnabled) - Utils.drawDashPathStroke( - this, canvas, isBlueprint ? Constants.BLUEPRINT_DASH_COLOR : Constants.DESIGN_DASH_COLOR); - } - - public void setStrokeEnabled(boolean enabled) { - drawStrokeEnabled = enabled; - invalidate(); - } - - @Override - public void draw(Canvas canvas) { - if (isBlueprint) Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR); - else super.draw(canvas); - } - - public void setBlueprint(boolean isBlueprint) { - this.isBlueprint = isBlueprint; - invalidate(); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/legacy/GridLayoutDesign.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/legacy/GridLayoutDesign.java deleted file mode 100644 index 745003ac70..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/legacy/GridLayoutDesign.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.palette.legacy; - -import android.content.Context; -import android.graphics.Canvas; -import android.widget.GridLayout; - -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.utils.Utils; - -public class GridLayoutDesign extends GridLayout { - - private boolean drawStrokeEnabled; - private boolean isBlueprint; - - public GridLayoutDesign(Context context) { - super(context); - } - - @Override - protected void dispatchDraw(Canvas canvas) { - super.dispatchDraw(canvas); - - if (drawStrokeEnabled) - Utils.drawDashPathStroke( - this, canvas, isBlueprint ? Constants.BLUEPRINT_DASH_COLOR : Constants.DESIGN_DASH_COLOR); - } - - public void setStrokeEnabled(boolean enabled) { - drawStrokeEnabled = enabled; - invalidate(); - } - - @Override - public void draw(Canvas canvas) { - if (isBlueprint) Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR); - else super.draw(canvas); - } - - public void setBlueprint(boolean isBlueprint) { - this.isBlueprint = isBlueprint; - invalidate(); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/legacy/GridViewDesign.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/legacy/GridViewDesign.java deleted file mode 100644 index dd82e118fc..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/legacy/GridViewDesign.java +++ /dev/null @@ -1,77 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.palette.legacy; - -import android.content.Context; -import android.graphics.Canvas; -import android.graphics.Color; -import android.graphics.Paint; -import android.widget.GridView; - -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.utils.Utils; - -public class GridViewDesign extends GridView { - - private boolean drawStrokeEnabled; - private boolean isBlueprint; - private Paint previewPaint; - - public GridViewDesign(Context context) { - super(context); - init(); - } - - private void init() { - previewPaint = new Paint(); - previewPaint.setColor(Color.GRAY); - previewPaint.setStyle(Paint.Style.FILL); - previewPaint.setTextSize(35); - } - - @Override - protected void dispatchDraw(Canvas canvas) { - super.dispatchDraw(canvas); - - int numColumns = 3; // number of columns in the grid - int itemWidth = getWidth() / numColumns; - int itemHeight = getHeight() / numColumns; - int x = 0; - int y = 0; - - for (int i = 1; i <= numColumns * numColumns; i++) { - // draw item placeholder - String text = "item " + i; - float textWidth = previewPaint.measureText(text); - float textHeight = previewPaint.descent() - previewPaint.ascent(); - float xPos = x + (itemWidth - textWidth) / 2; - float yPos = y + (itemHeight - textHeight) / 2 - previewPaint.ascent(); - canvas.drawText(text, xPos, yPos, previewPaint); - - // update x and y position for next item - x += itemWidth; - if (i % numColumns == 0) { - x = 0; - y += itemHeight; - } - } - - if (drawStrokeEnabled) - Utils.drawDashPathStroke( - this, canvas, isBlueprint ? Constants.BLUEPRINT_DASH_COLOR : Constants.DESIGN_DASH_COLOR); - } - - public void setStrokeEnabled(boolean enabled) { - drawStrokeEnabled = enabled; - invalidate(); - } - - @Override - public void draw(Canvas canvas) { - if (isBlueprint) Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR); - else super.draw(canvas); - } - - public void setBlueprint(boolean isBlueprint) { - this.isBlueprint = isBlueprint; - invalidate(); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/legacy/ListViewDesign.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/legacy/ListViewDesign.java deleted file mode 100644 index 6b41b39a09..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/legacy/ListViewDesign.java +++ /dev/null @@ -1,67 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.palette.legacy; - -import android.content.Context; -import android.graphics.Canvas; -import android.graphics.Color; -import android.graphics.Paint; -import android.widget.ListView; - -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.utils.Utils; - -public class ListViewDesign extends ListView { - - private boolean drawStrokeEnabled; - private boolean isBlueprint; - private Paint previewPaint; - - public ListViewDesign(Context context) { - super(context); - init(); - } - - private void init() { - previewPaint = new Paint(); - previewPaint.setColor(Color.GRAY); - previewPaint.setStyle(Paint.Style.FILL); - previewPaint.setTextSize(35); - } - - @Override - protected void dispatchDraw(Canvas canvas) { - super.dispatchDraw(canvas); - - int numItems = 3; - int itemHeight = getHeight() / numItems; - - for (int i = 0; i < numItems; i++) { - // draw item placeholder - String text = "ListView Item " + (i + 1); - float textWidth = previewPaint.measureText(text); - float textHeight = previewPaint.descent() - previewPaint.ascent(); - float xPos = (getWidth() - textWidth) / 2; - float yPos = i * itemHeight + (itemHeight - textHeight) / 2 - previewPaint.ascent(); - canvas.drawText(text, xPos, yPos, previewPaint); - } - - if (drawStrokeEnabled) - Utils.drawDashPathStroke( - this, canvas, isBlueprint ? Constants.BLUEPRINT_DASH_COLOR : Constants.DESIGN_DASH_COLOR); - } - - public void setStrokeEnabled(boolean enabled) { - drawStrokeEnabled = enabled; - invalidate(); - } - - @Override - public void draw(Canvas canvas) { - if (isBlueprint) Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR); - else super.draw(canvas); - } - - public void setBlueprint(boolean isBlueprint) { - this.isBlueprint = isBlueprint; - invalidate(); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/legacy/TabHostDesign.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/legacy/TabHostDesign.java deleted file mode 100644 index 97e714ad6f..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/legacy/TabHostDesign.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.palette.legacy; - -import android.content.Context; -import android.graphics.Canvas; -import android.widget.TabHost; - -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.utils.Utils; - -@SuppressWarnings("deprecation") -public class TabHostDesign extends TabHost { - - private boolean drawStrokeEnabled; - private boolean isBlueprint; - - public TabHostDesign(Context context) { - super(context); - } - - @Override - protected void dispatchDraw(Canvas canvas) { - super.dispatchDraw(canvas); - - if (drawStrokeEnabled) - Utils.drawDashPathStroke( - this, canvas, isBlueprint ? Constants.BLUEPRINT_DASH_COLOR : Constants.DESIGN_DASH_COLOR); - } - - public void setStrokeEnabled(boolean enabled) { - drawStrokeEnabled = enabled; - invalidate(); - } - - @Override - public void draw(Canvas canvas) { - if (isBlueprint) Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR); - else super.draw(canvas); - } - - public void setBlueprint(boolean isBlueprint) { - this.isBlueprint = isBlueprint; - invalidate(); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/text/AutoCompleteTextViewDesign.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/text/AutoCompleteTextViewDesign.java deleted file mode 100644 index 77d62d62f4..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/text/AutoCompleteTextViewDesign.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.palette.text; - -import android.content.Context; -import android.graphics.Canvas; -import android.widget.AutoCompleteTextView; - -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.utils.Utils; - -public class AutoCompleteTextViewDesign extends AutoCompleteTextView { - - private boolean drawStrokeEnabled; - private boolean isBlueprint; - - public AutoCompleteTextViewDesign(Context context) { - super(context); - } - - @Override - protected void dispatchDraw(Canvas canvas) { - super.dispatchDraw(canvas); - - if (drawStrokeEnabled) - Utils.drawDashPathStroke( - this, canvas, isBlueprint ? Constants.BLUEPRINT_DASH_COLOR : Constants.DESIGN_DASH_COLOR); - } - - public void setStrokeEnabled(boolean enabled) { - drawStrokeEnabled = enabled; - invalidate(); - } - - @Override - public void draw(Canvas canvas) { - if (isBlueprint) Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR); - else super.draw(canvas); - } - - public void setBlueprint(boolean isBlueprint) { - this.isBlueprint = isBlueprint; - invalidate(); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/text/CheckedTextViewDesign.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/text/CheckedTextViewDesign.java deleted file mode 100644 index bf1b9e1ece..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/text/CheckedTextViewDesign.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.palette.text; - -import android.content.Context; -import android.graphics.Canvas; -import android.widget.CheckedTextView; - -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.utils.Utils; - -public class CheckedTextViewDesign extends CheckedTextView { - - private boolean drawStrokeEnabled; - private boolean isBlueprint; - - public CheckedTextViewDesign(Context context) { - super(context); - } - - @Override - protected void dispatchDraw(Canvas canvas) { - super.dispatchDraw(canvas); - - if (drawStrokeEnabled) - Utils.drawDashPathStroke( - this, canvas, isBlueprint ? Constants.BLUEPRINT_DASH_COLOR : Constants.DESIGN_DASH_COLOR); - } - - public void setStrokeEnabled(boolean enabled) { - drawStrokeEnabled = enabled; - invalidate(); - } - - @Override - public void draw(Canvas canvas) { - if (isBlueprint) Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR); - else super.draw(canvas); - } - - public void setBlueprint(boolean isBlueprint) { - this.isBlueprint = isBlueprint; - invalidate(); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/text/EditTextDesign.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/text/EditTextDesign.java deleted file mode 100644 index 7ecaa1d60b..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/text/EditTextDesign.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.palette.text; - -import android.annotation.SuppressLint; -import android.content.Context; -import android.graphics.Canvas; -import android.widget.EditText; - -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.utils.Utils; - -@SuppressLint("AppCompatCustomView") -public class EditTextDesign extends EditText { - - private boolean drawStrokeEnabled; - private boolean isBlueprint; - - public EditTextDesign(Context context) { - super(context); - } - - @Override - protected void dispatchDraw(Canvas canvas) { - super.dispatchDraw(canvas); - - if (drawStrokeEnabled) - Utils.drawDashPathStroke( - this, canvas, isBlueprint ? Constants.BLUEPRINT_DASH_COLOR : Constants.DESIGN_DASH_COLOR); - } - - public void setStrokeEnabled(boolean enabled) { - drawStrokeEnabled = enabled; - invalidate(); - } - - @Override - public void draw(Canvas canvas) { - if (isBlueprint) Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR); - else super.draw(canvas); - } - - public void setBlueprint(boolean isBlueprint) { - this.isBlueprint = isBlueprint; - invalidate(); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/text/MultiAutoCompleteTextViewDesign.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/text/MultiAutoCompleteTextViewDesign.java deleted file mode 100644 index 8b19c07b63..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/text/MultiAutoCompleteTextViewDesign.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.palette.text; - -import android.content.Context; -import android.graphics.Canvas; -import android.widget.MultiAutoCompleteTextView; - -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.utils.Utils; - -public class MultiAutoCompleteTextViewDesign extends MultiAutoCompleteTextView { - - private boolean drawStrokeEnabled; - private boolean isBlueprint; - - public MultiAutoCompleteTextViewDesign(Context context) { - super(context); - } - - @Override - protected void dispatchDraw(Canvas canvas) { - super.dispatchDraw(canvas); - - if (drawStrokeEnabled) - Utils.drawDashPathStroke( - this, canvas, isBlueprint ? Constants.BLUEPRINT_DASH_COLOR : Constants.DESIGN_DASH_COLOR); - } - - public void setStrokeEnabled(boolean enabled) { - drawStrokeEnabled = enabled; - invalidate(); - } - - @Override - public void draw(Canvas canvas) { - if (isBlueprint) Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR); - else super.draw(canvas); - } - - public void setBlueprint(boolean isBlueprint) { - this.isBlueprint = isBlueprint; - invalidate(); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/text/TextInputEditTextDesign.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/text/TextInputEditTextDesign.kt deleted file mode 100644 index 999fc58858..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/text/TextInputEditTextDesign.kt +++ /dev/null @@ -1,43 +0,0 @@ -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) - } - } - - fun setBlueprint(isBlueprint: Boolean) { - this.isBlueprint = isBlueprint - invalidate() - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/text/TextInputLayoutDesign.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/text/TextInputLayoutDesign.kt deleted file mode 100644 index 03049bb20c..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/text/TextInputLayoutDesign.kt +++ /dev/null @@ -1,43 +0,0 @@ -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() - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/text/TextViewDesign.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/text/TextViewDesign.java deleted file mode 100644 index aea139982d..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/text/TextViewDesign.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.palette.text; - -import android.content.Context; -import android.graphics.Canvas; -import android.widget.TextView; - -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.utils.Utils; - -public class TextViewDesign extends TextView { - - private boolean drawStrokeEnabled; - private boolean isBlueprint; - - public TextViewDesign(Context context) { - super(context); - } - - @Override - protected void dispatchDraw(Canvas canvas) { - super.dispatchDraw(canvas); - - if (drawStrokeEnabled) - Utils.drawDashPathStroke( - this, canvas, isBlueprint ? Constants.BLUEPRINT_DASH_COLOR : Constants.DESIGN_DASH_COLOR); - } - - public void setStrokeEnabled(boolean enabled) { - drawStrokeEnabled = enabled; - invalidate(); - } - - @Override - public void draw(Canvas canvas) { - if (isBlueprint) Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR); - else super.draw(canvas); - } - - public void setBlueprint(boolean isBlueprint) { - this.isBlueprint = isBlueprint; - invalidate(); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/widgets/CalendarViewDesign.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/widgets/CalendarViewDesign.java deleted file mode 100644 index 1b45a579bd..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/widgets/CalendarViewDesign.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.palette.widgets; - -import android.content.Context; -import android.graphics.Canvas; -import android.widget.CalendarView; - -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.utils.Utils; - -public class CalendarViewDesign extends CalendarView { - - private boolean drawStrokeEnabled; - private boolean isBlueprint; - - public CalendarViewDesign(Context context) { - super(context); - } - - @Override - protected void dispatchDraw(Canvas canvas) { - super.dispatchDraw(canvas); - - if (drawStrokeEnabled) - Utils.drawDashPathStroke( - this, canvas, isBlueprint ? Constants.BLUEPRINT_DASH_COLOR : Constants.DESIGN_DASH_COLOR); - } - - public void setStrokeEnabled(boolean enabled) { - drawStrokeEnabled = enabled; - invalidate(); - } - - @Override - public void draw(Canvas canvas) { - if (isBlueprint) Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR); - else super.draw(canvas); - } - - public void setBlueprint(boolean isBlueprint) { - this.isBlueprint = isBlueprint; - invalidate(); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/widgets/ImageViewDesign.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/widgets/ImageViewDesign.java deleted file mode 100644 index 53e695554b..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/widgets/ImageViewDesign.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.palette.widgets; - -import android.content.Context; -import android.graphics.Canvas; -import android.widget.ImageView; - -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.utils.Utils; - -public class ImageViewDesign extends ImageView { - - private boolean drawStrokeEnabled; - private boolean isBlueprint; - - public ImageViewDesign(Context context) { - super(context); - } - - @Override - protected void dispatchDraw(Canvas canvas) { - super.dispatchDraw(canvas); - - if (drawStrokeEnabled) - Utils.drawDashPathStroke( - this, canvas, isBlueprint ? Constants.BLUEPRINT_DASH_COLOR : Constants.DESIGN_DASH_COLOR); - } - - public void setStrokeEnabled(boolean enabled) { - drawStrokeEnabled = enabled; - invalidate(); - } - - @Override - public void draw(Canvas canvas) { - if (isBlueprint) Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR); - else super.draw(canvas); - } - - public void setBlueprint(boolean isBlueprint) { - this.isBlueprint = isBlueprint; - invalidate(); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/widgets/ProgressBarDesign.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/widgets/ProgressBarDesign.java deleted file mode 100644 index 5aafd028ed..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/widgets/ProgressBarDesign.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.palette.widgets; - -import android.content.Context; -import android.graphics.Canvas; -import android.widget.ProgressBar; - -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.utils.Utils; - -public class ProgressBarDesign extends ProgressBar { - - private boolean drawStrokeEnabled; - private boolean isBlueprint; - - public ProgressBarDesign(Context context) { - super(context); - } - - @Override - protected void dispatchDraw(Canvas canvas) { - super.dispatchDraw(canvas); - - if (drawStrokeEnabled) - Utils.drawDashPathStroke( - this, canvas, isBlueprint ? Constants.BLUEPRINT_DASH_COLOR : Constants.DESIGN_DASH_COLOR); - } - - public void setStrokeEnabled(boolean enabled) { - drawStrokeEnabled = enabled; - invalidate(); - } - - @Override - public void draw(Canvas canvas) { - if (isBlueprint) Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR); - else super.draw(canvas); - } - - public void setBlueprint(boolean isBlueprint) { - this.isBlueprint = isBlueprint; - invalidate(); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/widgets/RatingBarDesign.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/widgets/RatingBarDesign.java deleted file mode 100644 index b949840d15..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/widgets/RatingBarDesign.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.palette.widgets; - -import android.content.Context; -import android.graphics.Canvas; -import android.widget.RatingBar; - -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.utils.Utils; - -public class RatingBarDesign extends RatingBar { - - private boolean drawStrokeEnabled; - private boolean isBlueprint; - - public RatingBarDesign(Context context) { - super(context); - } - - @Override - protected void dispatchDraw(Canvas canvas) { - super.dispatchDraw(canvas); - - if (drawStrokeEnabled) - Utils.drawDashPathStroke( - this, canvas, isBlueprint ? Constants.BLUEPRINT_DASH_COLOR : Constants.DESIGN_DASH_COLOR); - } - - public void setStrokeEnabled(boolean enabled) { - drawStrokeEnabled = enabled; - invalidate(); - } - - @Override - public void draw(Canvas canvas) { - if (isBlueprint) Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR); - else super.draw(canvas); - } - - public void setBlueprint(boolean isBlueprint) { - this.isBlueprint = isBlueprint; - invalidate(); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/widgets/SearchViewDesign.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/widgets/SearchViewDesign.java deleted file mode 100644 index 3b546f7605..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/widgets/SearchViewDesign.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.palette.widgets; - -import android.content.Context; -import android.graphics.Canvas; -import android.widget.SearchView; - -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.utils.Utils; - -public class SearchViewDesign extends SearchView { - - private boolean drawStrokeEnabled; - private boolean isBlueprint; - - public SearchViewDesign(Context context) { - super(context); - } - - @Override - protected void dispatchDraw(Canvas canvas) { - super.dispatchDraw(canvas); - - if (drawStrokeEnabled) - Utils.drawDashPathStroke( - this, canvas, isBlueprint ? Constants.BLUEPRINT_DASH_COLOR : Constants.DESIGN_DASH_COLOR); - } - - public void setStrokeEnabled(boolean enabled) { - drawStrokeEnabled = enabled; - invalidate(); - } - - @Override - public void draw(Canvas canvas) { - if (isBlueprint) Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR); - else super.draw(canvas); - } - - public void setBlueprint(boolean isBlueprint) { - this.isBlueprint = isBlueprint; - invalidate(); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/widgets/SeekBarDesign.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/widgets/SeekBarDesign.java deleted file mode 100644 index 1e9ed52343..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/widgets/SeekBarDesign.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.palette.widgets; - -import android.annotation.SuppressLint; -import android.content.Context; -import android.graphics.Canvas; -import android.widget.SeekBar; - -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.utils.Utils; - -@SuppressLint("AppCompatCustomView") -public class SeekBarDesign extends SeekBar { - - private boolean drawStrokeEnabled; - private boolean isBlueprint; - - public SeekBarDesign(Context context) { - super(context); - } - - @Override - protected void dispatchDraw(Canvas canvas) { - super.dispatchDraw(canvas); - - if (drawStrokeEnabled) - Utils.drawDashPathStroke( - this, canvas, isBlueprint ? Constants.BLUEPRINT_DASH_COLOR : Constants.DESIGN_DASH_COLOR); - } - - public void setStrokeEnabled(boolean enabled) { - drawStrokeEnabled = enabled; - invalidate(); - } - - @Override - public void draw(Canvas canvas) { - if (isBlueprint) Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR); - else super.draw(canvas); - } - - public void setBlueprint(boolean isBlueprint) { - this.isBlueprint = isBlueprint; - invalidate(); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/widgets/SurfaceViewDesign.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/widgets/SurfaceViewDesign.java deleted file mode 100644 index c2c506f18e..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/widgets/SurfaceViewDesign.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.palette.widgets; - -import android.content.Context; -import android.graphics.Canvas; -import android.view.SurfaceView; - -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.utils.Utils; - -public class SurfaceViewDesign extends SurfaceView { - - private boolean drawStrokeEnabled; - private boolean isBlueprint; - - public SurfaceViewDesign(Context context) { - super(context); - } - - @Override - protected void dispatchDraw(Canvas canvas) { - super.dispatchDraw(canvas); - - if (drawStrokeEnabled) - Utils.drawDashPathStroke( - this, canvas, isBlueprint ? Constants.BLUEPRINT_DASH_COLOR : Constants.DESIGN_DASH_COLOR); - } - - public void setStrokeEnabled(boolean enabled) { - drawStrokeEnabled = enabled; - invalidate(); - } - - @Override - public void draw(Canvas canvas) { - if (isBlueprint) Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR); - else super.draw(canvas); - } - - public void setBlueprint(boolean isBlueprint) { - this.isBlueprint = isBlueprint; - invalidate(); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/widgets/TextClockDesign.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/widgets/TextClockDesign.java deleted file mode 100644 index 3b3229d9b4..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/widgets/TextClockDesign.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.palette.widgets; - -import android.content.Context; -import android.graphics.Canvas; -import android.widget.TextClock; - -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.utils.Utils; - -public class TextClockDesign extends TextClock { - - private boolean drawStrokeEnabled; - private boolean isBlueprint; - - public TextClockDesign(Context context) { - super(context); - } - - @Override - protected void dispatchDraw(Canvas canvas) { - super.dispatchDraw(canvas); - - if (drawStrokeEnabled) - Utils.drawDashPathStroke( - this, canvas, isBlueprint ? Constants.BLUEPRINT_DASH_COLOR : Constants.DESIGN_DASH_COLOR); - } - - public void setStrokeEnabled(boolean enabled) { - drawStrokeEnabled = enabled; - invalidate(); - } - - @Override - public void draw(Canvas canvas) { - if (isBlueprint) Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR); - else super.draw(canvas); - } - - public void setBlueprint(boolean isBlueprint) { - this.isBlueprint = isBlueprint; - invalidate(); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/widgets/TextureViewDesign.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/widgets/TextureViewDesign.java deleted file mode 100644 index b439ffe952..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/widgets/TextureViewDesign.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.palette.widgets; - -import android.content.Context; -import android.graphics.Canvas; -import android.view.TextureView; - -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.utils.Utils; - -public class TextureViewDesign extends TextureView { - - private boolean drawStrokeEnabled; - private boolean isBlueprint; - - public TextureViewDesign(Context context) { - super(context); - } - - @Override - protected void dispatchDraw(Canvas canvas) { - super.dispatchDraw(canvas); - - if (drawStrokeEnabled) - Utils.drawDashPathStroke( - this, canvas, isBlueprint ? Constants.BLUEPRINT_DASH_COLOR : Constants.DESIGN_DASH_COLOR); - } - - public void setStrokeEnabled(boolean enabled) { - drawStrokeEnabled = enabled; - invalidate(); - } - - public void setBlueprint(boolean isBlueprint) { - this.isBlueprint = isBlueprint; - invalidate(); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/widgets/VideoViewDesign.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/widgets/VideoViewDesign.java deleted file mode 100644 index ae9652fa1a..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/widgets/VideoViewDesign.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.palette.widgets; - -import android.content.Context; -import android.graphics.Canvas; -import android.widget.VideoView; - -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.utils.Utils; - -public class VideoViewDesign extends VideoView { - - private boolean drawStrokeEnabled; - private boolean isBlueprint; - - public VideoViewDesign(Context context) { - super(context); - } - - @Override - protected void dispatchDraw(Canvas canvas) { - super.dispatchDraw(canvas); - - if (drawStrokeEnabled) - Utils.drawDashPathStroke( - this, canvas, isBlueprint ? Constants.BLUEPRINT_DASH_COLOR : Constants.DESIGN_DASH_COLOR); - } - - public void setStrokeEnabled(boolean enabled) { - drawStrokeEnabled = enabled; - invalidate(); - } - - @Override - public void draw(Canvas canvas) { - if (isBlueprint) Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR); - else super.draw(canvas); - } - - public void setBlueprint(boolean isBlueprint) { - this.isBlueprint = isBlueprint; - invalidate(); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/widgets/ViewDesign.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/widgets/ViewDesign.java deleted file mode 100644 index 54a14fd678..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/widgets/ViewDesign.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.palette.widgets; - -import android.content.Context; -import android.graphics.Canvas; -import android.view.View; - -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.utils.Utils; - -public class ViewDesign extends View { - - private boolean drawStrokeEnabled; - private boolean isBlueprint; - - public ViewDesign(Context context) { - super(context); - } - - @Override - protected void dispatchDraw(Canvas canvas) { - super.dispatchDraw(canvas); - - if (drawStrokeEnabled) - Utils.drawDashPathStroke( - this, canvas, isBlueprint ? Constants.BLUEPRINT_DASH_COLOR : Constants.DESIGN_DASH_COLOR); - } - - public void setStrokeEnabled(boolean enabled) { - drawStrokeEnabled = enabled; - invalidate(); - } - - @Override - public void draw(Canvas canvas) { - if (isBlueprint) Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR); - else super.draw(canvas); - } - - public void setBlueprint(boolean isBlueprint) { - this.isBlueprint = isBlueprint; - invalidate(); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/widgets/WebViewDesign.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/widgets/WebViewDesign.java deleted file mode 100644 index e7b6ab758c..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/palette/widgets/WebViewDesign.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.palette.widgets; - -import android.content.Context; -import android.graphics.Canvas; -import android.webkit.WebView; - -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.utils.Utils; - -public class WebViewDesign extends WebView { - - private boolean drawStrokeEnabled; - private boolean isBlueprint; - - public WebViewDesign(Context context) { - super(context); - } - - @Override - protected void dispatchDraw(Canvas canvas) { - super.dispatchDraw(canvas); - - if (drawStrokeEnabled) - Utils.drawDashPathStroke( - this, canvas, isBlueprint ? Constants.BLUEPRINT_DASH_COLOR : Constants.DESIGN_DASH_COLOR); - } - - public void setStrokeEnabled(boolean enabled) { - drawStrokeEnabled = enabled; - invalidate(); - } - - @Override - public void draw(Canvas canvas) { - if (isBlueprint) Utils.drawDashPathStroke(this, canvas, Constants.BLUEPRINT_DASH_COLOR); - else super.draw(canvas); - } - - public void setBlueprint(boolean isBlueprint) { - this.isBlueprint = isBlueprint; - invalidate(); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/positioning/LayoutDropHandler.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/positioning/LayoutDropHandler.kt deleted file mode 100644 index 56fa75bc19..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/positioning/LayoutDropHandler.kt +++ /dev/null @@ -1,66 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.positioning - -import android.view.View -import android.view.ViewGroup -import android.widget.FrameLayout -import android.widget.GridLayout -import android.widget.LinearLayout -import android.widget.RelativeLayout -import androidx.constraintlayout.widget.ConstraintLayout -import androidx.coordinatorlayout.widget.CoordinatorLayout -import org.appdevforall.codeonthego.layouteditor.editor.initializer.AttributeMap - - -/** - * Updates the stored attributes for a [child] view after it is "dropped" - * at a new position (x, y) within its parent [ViewGroup]. - * - * This function orchestrates the process of: - * 1. Calculating the final, clamped coordinates in Dp. - * 2. Clearing any previous positioning attributes to prevent conflicts. - * 3. Applying the correct new attributes based on the parent's layout type. - * - * @param child The view being positioned. - * @param x The raw target X coordinate in container pixels. - * @param y The raw target Y coordinate in container pixels. - */ -fun positionAtDrop(child: View, x: Float, y: Float, viewAttributeMap: HashMap) { - val container = child.parent as? ViewGroup ?: return - - val density = container.resources.displayMetrics.density - val coords = calculateDropCoordinatesInDp(container, child, x, y, density) - - val attributes = viewAttributeMap[child] ?: return - - clearPositioningAttributes(attributes) - - applyLayoutAttributes(container, child, attributes, coords, x, y, viewAttributeMap) -} - -/** - * Acts as a "dynamic mapper" or "strategy" function. - * It detects the type of the [container] and calls the appropriate - * helper function to apply layout-specific attributes. - * - * @param container The parent ViewGroup. - * @param attributes The AttributeMap for the child view. - * @param coords The final Dp coordinates to apply. - */ -internal fun applyLayoutAttributes( - container: ViewGroup, - child: View, - attributes: AttributeMap, - coords: DpCoordinates, - x: Float, - y: Float, - fullAttributeMap: HashMap -) { - when (container) { - is ConstraintLayout -> applyConstraintLayoutAttributes(attributes, coords) - is FrameLayout, is CoordinatorLayout -> applyGravityMarginAttributes(attributes, coords) - is RelativeLayout -> applyRelativeLayoutAttributes(attributes, coords) - is LinearLayout -> applyDragReorder(container, child, x, y) - is GridLayout -> applyGridLayoutAttributes(container, child, attributes, x, y, fullAttributeMap) - else -> applyGenericLayoutAttributes(attributes, coords) - } -} \ No newline at end of file diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/positioning/LayoutDropStrategies.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/positioning/LayoutDropStrategies.kt deleted file mode 100644 index d4e0b6a65b..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/positioning/LayoutDropStrategies.kt +++ /dev/null @@ -1,379 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.positioning - -import android.view.Gravity -import android.view.View -import android.view.ViewGroup -import android.widget.FrameLayout -import android.widget.GridLayout -import android.widget.LinearLayout -import android.widget.RelativeLayout -import android.widget.TableLayout -import android.widget.TableRow -import androidx.constraintlayout.widget.ConstraintLayout -import org.appdevforall.codeonthego.layouteditor.editor.initializer.AttributeMap -import kotlin.math.roundToInt - - -private data class GridCell(val row: Int, val col: Int) - - -/** - * Ensures the [child] view has valid [TableRow.LayoutParams]. - * - * This function is crucial for preventing a [View] from becoming invisible - * when added to a [TableRow]. It converts generic `LayoutParams` - * (like `LinearLayout.LayoutParams` or `MarginLayoutParams`) into - * `TableRow.LayoutParams`, ensuring the `weight` is 0f and - * the `width` is `WRAP_CONTENT` if not otherwise defined. - * - * @param child The [View] whose `layoutParams` will be checked and - * potentially replaced. - */ -private fun ensureTableRowLayoutParams(child: View) { - val newLp: TableRow.LayoutParams = when (val lp = child.layoutParams) { - is TableRow.LayoutParams -> { - if ((lp.width == 0 || lp.width == ViewGroup.LayoutParams.WRAP_CONTENT) && lp.weight == 0f) { - TableRow.LayoutParams( - ViewGroup.LayoutParams.WRAP_CONTENT, - if (lp.height <= 0) ViewGroup.LayoutParams.WRAP_CONTENT else lp.height - ).apply { - setMargins(lp.leftMargin, lp.topMargin, lp.rightMargin, lp.bottomMargin) - gravity = lp.gravity - weight = 0f - } - } else lp - } - - is LinearLayout.LayoutParams -> { - TableRow.LayoutParams( - if (lp.width == 0 && lp.weight == 0f) ViewGroup.LayoutParams.WRAP_CONTENT else lp.width, - if (lp.height <= 0) ViewGroup.LayoutParams.WRAP_CONTENT else lp.height - ).apply { - setMargins(lp.leftMargin, lp.topMargin, lp.rightMargin, lp.bottomMargin) - gravity = lp.gravity - weight = lp.weight - } - } - - is ViewGroup.MarginLayoutParams -> { - TableRow.LayoutParams(lp).apply { - if (width == 0) width = ViewGroup.LayoutParams.WRAP_CONTENT - if (height <= 0) height = ViewGroup.LayoutParams.WRAP_CONTENT - } - } - - else -> { - TableRow.LayoutParams( - ViewGroup.LayoutParams.WRAP_CONTENT, - ViewGroup.LayoutParams.WRAP_CONTENT - ) - } - } - - if (child.layoutParams !== newLp) child.layoutParams = newLp -} - - -/** - * Reorders a [child] within a [container] that supports drag-reordering - * (like [LinearLayout], [TableLayout], or [TableRow]). - * - * The function determines the container's orientation (vertical or horizontal) - * and uses the [x] or [y] coordinate to find the new index where - * the [child] should be inserted. - * - * If the [container] is a [TableRow], it first calls [ensureTableRowLayoutParams] - * to prevent the [child] from becoming invisible. - * - * @param container The parent [ViewGroup] (must be [LinearLayout], - * [TableLayout], or [TableRow]). - * @param child The [View] being moved. - * @param x The raw X coordinate of the drop (used for horizontal orientation). - * @param y The raw Y coordinate of the drop (used for vertical orientation). - */ -internal fun applyDragReorder(container: ViewGroup, child: View, x: Float, y: Float) { - if (container is TableRow) { - ensureTableRowLayoutParams(child) - } - - val currentIndex = container.indexOfChild(child) - var newIndex = -1 - - val isVertical = when (container) { - is TableLayout -> true - is TableRow -> false - is LinearLayout -> container.orientation == LinearLayout.VERTICAL - else -> return - } - - for (i in 0 until container.childCount) { - val otherChild = container.getChildAt(i) - if (otherChild == child) continue - - val center: Float - val dropCoord: Float - - if (isVertical) { - center = otherChild.top + (otherChild.height / 2f) - dropCoord = y - } else { - center = otherChild.left + (otherChild.width / 2f) - dropCoord = x - } - - if (dropCoord < center) { - newIndex = i - break - } - } - - if (newIndex == -1) { - newIndex = container.childCount - } - - if (currentIndex == -1) { - container.addView(child, newIndex) - } else { - if (currentIndex == newIndex) return - - val targetIndex = if (newIndex > currentIndex) newIndex - 1 else newIndex - - if (currentIndex == targetIndex) return - - container.removeViewAt(currentIndex) - container.addView(child, targetIndex) - } - - container.requestLayout() - - if (container is TableRow) { - (container.parent as? TableLayout)?.requestLayout() - container.invalidate() - } -} - - -/** - * Applies positioning attributes for a [ConstraintLayout] to the [map]. - * - * Anchors the view to the parent's top-start and uses margins. - * - * **Attributes Written:** - * - `app:layout_constraintStart_toStartOf` - * - `app:layout_constraintTop_toTopOf` - * - `android:layout_marginStart` - * - `android:layout_marginTop` - * - * @param map The [AttributeMap] to write attributes to. - * @param coords The [DpCoordinates] containing the margins to apply. - */ -internal fun applyConstraintLayoutAttributes( - map: AttributeMap, - coords: DpCoordinates -) { - map.putValue("app:layout_constraintStart_toStartOf", "parent") - map.putValue("app:layout_constraintTop_toTopOf", "parent") - map.putValue("android:layout_marginStart", "${coords.xDp}dp") - map.putValue("android:layout_marginTop", "${coords.yDp}dp") -} - -/** - * Applies positioning attributes for layouts that use gravity and margins (e.g., [FrameLayout], [androidx.coordinatorlayout.widget.CoordinatorLayout]) - * - * Uses `layout_gravity` to lock to the top-start and standard margins. - * - * **Attributes Written:** - * - `android:layout_gravity` - * - `android:layout_marginLeft` - * - `android:layout_marginTop` - * - * @param map The [AttributeMap] to write attributes to. - * @param coords The [DpCoordinates] containing the margins to apply. - */ -internal fun applyGravityMarginAttributes( - map: AttributeMap, - coords: DpCoordinates -) { - map.putValue("android:layout_gravity", "top|start") - map.putValue("android:layout_marginLeft", "${coords.xDp}dp") - map.putValue("android:layout_marginTop", "${coords.yDp}dp") -} - -/** - * Applies positioning attributes for a [RelativeLayout] to the [map]. - * - * Aligns the view to the parent's top-start and uses standard margins. - * - * **Attributes Written:** - * - `android:layout_alignParentStart` - * - `android:layout_alignParentTop` - * - `android:layout_marginLeft` - * - `android:layout_marginTop` - * - * @param map The [AttributeMap] to write attributes to. - * @param coords The [DpCoordinates] containing the margins to apply. - */ -internal fun applyRelativeLayoutAttributes( - map: AttributeMap, - coords: DpCoordinates -) { - map.putValue("android:layout_alignParentStart", "true") - map.putValue("android:layout_alignParentTop", "true") - map.putValue("android:layout_marginLeft", "${coords.xDp}dp") - map.putValue("android:layout_marginTop", "${coords.yDp}dp") -} - -/** - * Applies positioning attributes for a [GridLayout] child view. - * - * This function orchestrates the entire drop logic for a GridLayout: - * 1. Determines the intended row/column count by checking the [fullAttributeMap] first, - * falling back to the live [container] count. - * 2. Calculates the target cell (row, col) based on the drop coordinates and child's size. - * 3. Expands the [container] (updating its live `columnCount` and its attributes) - * if the `targetCell` is outside the current bounds. - * 4. Applies the final position (row, col) and a standard `columnWeight` of 1.0 - * to both the [childAttributes] (for XML saving) and the child's live - * `LayoutParams` (to prevent `onMeasure` crashes). - * - * @param container The parent [GridLayout] where the child is being dropped. - * @param child The [View] being positioned. - * @param childAttributes The [AttributeMap] for the [child] view (to be updated). - * @param x The raw X drop coordinate in container pixels. - * @param y The raw Y drop coordinate in container pixels. - * @param fullAttributeMap The complete map of all views to their attributes, used to - * read/write the [container]'s attributes (e.g., `android:columnCount`). - */ -internal fun applyGridLayoutAttributes( - container: GridLayout, - child: View, - childAttributes: AttributeMap, - x: Float, - y: Float, - fullAttributeMap: HashMap -) { - val intendedColCount = getIntendedGridCount(container, fullAttributeMap, isColumn = true) - val intendedRowCount = getIntendedGridCount(container, fullAttributeMap, isColumn = false) - - val targetCell = calculateTargetCell(container, child, x, y, intendedColCount, intendedRowCount) - - val gridChanged = expandGridIfNeeded(container, targetCell, intendedColCount, intendedRowCount, fullAttributeMap) - - val weight = 1f - updateChildGridAttributes(childAttributes, targetCell, weight) - updateChildGridLayoutPostDrop(child, targetCell, weight) - - if (gridChanged) { - container.requestLayout() - } -} - -/* START GridLayout Utils */ -private fun getIntendedGridCount( - container: GridLayout, - fullAttributeMap: HashMap, - isColumn: Boolean -): Int { - val attrKey = if (isColumn) "android:columnCount" else "android:rowCount" - val liveCount = if (isColumn) container.columnCount else container.rowCount - - return fullAttributeMap[container]?.getValue(attrKey)?.toIntOrNull() - ?.takeIf { it > 0 } - ?: liveCount.takeIf { it > 0 } - ?: 1 -} - -private fun calculateTargetCell( - container: GridLayout, - child: View, - x: Float, - y: Float, - intendedColCount: Int, - intendedRowCount: Int -): GridCell { - val rowHeight = (container.height.toFloat() / intendedRowCount).coerceAtLeast(1f) - - val colWidth = if (intendedColCount > 1) { - (container.width.toFloat() / intendedColCount).coerceAtLeast(1f) - } else { - child.width.toFloat().coerceAtLeast(100f) - } - - val childCenterX = x + (child.width / 2f) - val childCenterY = y + (child.height / 2f) - - val targetCol = (childCenterX / colWidth).roundToInt().coerceAtLeast(0) - val targetRow = (childCenterY / rowHeight).roundToInt().coerceAtLeast(0) - - return GridCell(row = targetRow, col = targetCol) -} - -private fun expandGridIfNeeded( - container: GridLayout, - targetCell: GridCell, - intendedColCount: Int, - intendedRowCount: Int, - fullAttributeMap: HashMap -): Boolean { - var gridChanged = false - - if (targetCell.col >= intendedColCount) { - container.columnCount = targetCell.col + 1 - gridChanged = true - } - if (targetCell.row >= intendedRowCount) { - container.rowCount = targetCell.row + 1 - gridChanged = true - } - - if (gridChanged) { - val contAttrs = fullAttributeMap[container] - contAttrs?.putValue("android:columnCount", container.columnCount.toString()) - contAttrs?.putValue("android:rowCount", container.rowCount.toString()) - } - - return gridChanged -} - -private fun updateChildGridAttributes(childAttributes: AttributeMap, targetCell: GridCell, weight: Float) { - childAttributes.putValue("android:layout_row", "${targetCell.row}") - childAttributes.putValue("android:layout_column", "${targetCell.col}") - childAttributes.putValue("android:layout_rowSpan", "1") - childAttributes.putValue("android:layout_columnSpan", "1") - childAttributes.putValue("android:layout_columnWeight", "$weight") - childAttributes.putValue("android:layout_gravity", "center") -} - -private fun updateChildGridLayoutPostDrop(child: View, targetCell: GridCell, weight: Float) { - val lp = (child.layoutParams as? GridLayout.LayoutParams) - ?: GridLayout.LayoutParams() - - lp.rowSpec = GridLayout.spec(targetCell.row, 1) - lp.columnSpec = GridLayout.spec(targetCell.col, 1, weight) - lp.setGravity(Gravity.CENTER) - - child.layoutParams = lp -} - -/* END GridLayout Utils */ - -/** - * A generic fallback that applies standard margins to the [map]. - * - * This is used for parent layouts that are not explicitly handled but - * still support [android.view.ViewGroup.MarginLayoutParams]. - * - * **Attributes Written:** - * - `android:layout_marginLeft` - * - `android:layout_marginTop` - * - * @param map The [AttributeMap] to write attributes to. - * @param coords The [DpCoordinates] containing the margins to apply. - */ -internal fun applyGenericLayoutAttributes( - map: AttributeMap, - coords: DpCoordinates -) { - map.putValue("android:layout_marginLeft", "${coords.xDp}dp") - map.putValue("android:layout_marginTop", "${coords.yDp}dp") -} \ No newline at end of file diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/positioning/LayoutRestoreHandler.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/positioning/LayoutRestoreHandler.kt deleted file mode 100644 index 115c4af67c..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/positioning/LayoutRestoreHandler.kt +++ /dev/null @@ -1,178 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.positioning - -import android.view.View -import android.view.ViewGroup -import android.widget.FrameLayout -import android.widget.GridLayout -import android.widget.LinearLayout -import android.widget.RelativeLayout -import android.widget.TableLayout -import android.widget.TableRow -import androidx.constraintlayout.widget.ConstraintLayout -import androidx.constraintlayout.widget.ConstraintSet -import androidx.coordinatorlayout.widget.CoordinatorLayout -import androidx.core.view.children -import androidx.core.view.doOnLayout -import org.appdevforall.codeonthego.layouteditor.editor.initializer.AttributeMap -import kotlin.sequences.forEach - - -private fun ConstraintLayout.cloneWithIds(): ConstraintSet { - children.forEach { child -> - if (child.id == View.NO_ID) { - child.id = View.generateViewId() - } - } - return ConstraintSet().apply { clone(this@cloneWithIds) } -} - -/** - * Executes the core positioning logic for a **single view**. - * - * This function resets the view's [View.translationX] and [View.translationY] to `0f`, - * as positions are restored using layout parameters (like margins) rather than translations. - * - * It then dispatches to a layout-specific helper (e.g., [collectConstraintLayoutChange] - * or [restoreFrameLayoutPosition]) based on the [view]'s parent [ViewGroup] type. - * - * If the parent is a [ConstraintLayout], this function populates the [constraintChanges] - * map for batch application in the "Application Pass." - * - * @param view The [View] to be repositioned. - * @param attrs The [AttributeMap] containing the saved positional attributes for the [view]. - * @param density The screen's display density for DP/PX calculations. - * @param constraintChanges An **output map**. If the [view]'s parent is a [ConstraintLayout], - * a [ViewConstraintChange] object will be added to this map, keyed by the parent container. - */ -private fun applyPositioningLogic( - view: View, - attrs: AttributeMap, - density: Float, - constraintChanges: MutableMap> -) { - val parent = view.parent as? ViewGroup ?: return - - view.translationX = 0f - view.translationY = 0f - - when (parent) { - is ConstraintLayout -> collectConstraintLayoutChange(parent, view, attrs, density, constraintChanges) - is FrameLayout -> restoreFrameLayoutPosition(parent, view, attrs, density) - is RelativeLayout -> restoreRelativeLayoutPosition(parent, view, attrs, density) - is CoordinatorLayout -> restoreCoordinatorLayoutPosition(parent, view, attrs, density) - is TableLayout, is TableRow, is LinearLayout -> {} // No-op - is GridLayout -> restoreGridLayoutPosition(view, attrs) - else -> restoreGenericMarginPosition(parent, view, attrs, density) - } -} - - -/** - * Applies a batch of collected [ConstraintLayout] changes. - * - * This function implements the **Application Pass**. It iterates through each - * [ConstraintLayout] container that has pending changes, clones its [ConstraintSet], - * modifies it with all the changes in the `changeList`, and finally applies the - * modified set back to the container using [ConstraintSet.applyTo]. - * - * This batch approach is significantly more efficient than applying changes one by one. - * - * @param changesByContainer A [Map] where each key is a [ConstraintLayout] and the - * value is a [List] of [ViewConstraintChange] objects to be applied to it. - */ -private fun applyConstraintChanges(changesByContainer: Map>) { - changesByContainer.forEach { (container, changeList) -> - if (changeList.isEmpty()) return@forEach - - val constraintSet = container.cloneWithIds() - changeList.forEach { change -> - modifyConstraintsForView( - constraintSet, - change.viewId, - change.startMargin, - change.topMargin - ) - } - constraintSet.applyTo(container) - } -} - - -/** - * Restores the saved positions of **all views** in the [attributeMap] after an initial layout pass. - * - * This function is intended for loading a complete layout from scratch. - * - * This function must run within [doOnLayout] to ensure parent and child view - * dimensions are measured, which is necessary for clamping coordinates correctly. - * - * It uses a "dynamic strategy" approach based on the parent [ViewGroup] type, - * implemented by [applyPositioningLogic] and [applyConstraintChanges]: - * - * 1. **Collection Pass:** - * - Iterates through the entire [attributeMap]. - * - For each view, it calls [applyPositioningLogic] to reset translations and - * collect [ConstraintLayout] changes. - * - * 2. **Application Pass (for ConstraintLayout):** - * - Calls [applyConstraintChanges] to apply all collected [ConstraintLayout] - * changes in a single batch for maximum efficiency. - * - * @param rootView The root [View] to observe for layout completion. - * @param attributeMap A [Map] of [View]s to their corresponding [AttributeMap] - * containing the saved positioning attributes. - */ -fun restorePositionsAfterLoad(rootView: View, attributeMap: Map) { - rootView.doOnLayout { container -> - val density = container.resources.displayMetrics.density - - val changesByContainer = mutableMapOf>() - - // --- 1. COLLECTION PASS - attributeMap.forEach { (view, attrs) -> - applyPositioningLogic(view, attrs, density, changesByContainer) - } - - // --- 2. APPLICATION PASS --- - applyConstraintChanges(changesByContainer) - } -} - - -/** - * Restores the saved position for a **single view** after a layout pass. - * - * This is an optimized version of [restorePositionsAfterLoad], designed to be called - * after a single view is added or moved (e.g., from a drag-and-drop operation). - * - * Like its counterpart, this function **must run within [doOnLayout]** to ensure - * coordinates are clamped correctly against measured parent/child dimensions. - * - * It performs the same Collection and Application pass, but **only for the - * specified [viewToRestore]**, providing a significant performance boost by not - * iterating over all other views. - * - * @param rootView The root [View] to observe for layout completion. - * @param viewToRestore The specific [View] whose position needs to be restored. - * @param attributeMap The complete [Map] of views to attributes, used to look up - * the data for [viewToRestore]. - */ -fun restoreSingleViewPosition( - rootView: View, - viewToRestore: View, - attributeMap: Map -) { - rootView.doOnLayout { container -> - val density = container.resources.displayMetrics.density - - val attrs = attributeMap[viewToRestore] ?: return@doOnLayout - - val changesByContainer = mutableMapOf>() - - // --- 1. COLLECTION PASS --- - applyPositioningLogic(viewToRestore, attrs, density, changesByContainer) - - // --- 2. APPLICATION PASS --- - applyConstraintChanges(changesByContainer) - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/positioning/LayoutRestoreStrategies.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/positioning/LayoutRestoreStrategies.kt deleted file mode 100644 index 2874fb7735..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/positioning/LayoutRestoreStrategies.kt +++ /dev/null @@ -1,295 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.positioning - -import android.view.Gravity -import android.view.View -import android.view.ViewGroup -import android.widget.FrameLayout -import android.widget.GridLayout -import android.widget.RelativeLayout -import androidx.constraintlayout.widget.ConstraintLayout -import androidx.constraintlayout.widget.ConstraintSet -import androidx.coordinatorlayout.widget.CoordinatorLayout -import org.appdevforall.codeonthego.layouteditor.editor.initializer.AttributeMap - - -/** - * Modifies a [ConstraintSet] to apply basic constraints to a specific view. - * - * - Anchors the view to the parent's START and TOP. - * - Clears existing END and BOTTOM constraints to avoid conflicts. - * - Sets START and TOP margins in **pixels** using the provided values. - * - * @param constraintSet The [ConstraintSet] instance to modify. - * @param viewId The ID of the target view. - * @param startPxMargin The START margin in **pixels**. - * @param topPxMargin The TOP margin in **pixels**. - */ -fun modifyConstraintsForView(constraintSet: ConstraintSet, viewId: Int, startPxMargin: Int, topPxMargin: Int) { - constraintSet.clear(viewId, ConstraintSet.BOTTOM) - constraintSet.clear(viewId, ConstraintSet.END) - constraintSet.connect(viewId, ConstraintSet.START, ConstraintSet.PARENT_ID, ConstraintSet.START) - constraintSet.connect(viewId, ConstraintSet.TOP, ConstraintSet.PARENT_ID, ConstraintSet.TOP) - constraintSet.setMargin(viewId, ConstraintSet.START, startPxMargin) - constraintSet.setMargin(viewId, ConstraintSet.TOP, topPxMargin) -} - -/** - * Reads [ConstraintLayout] positioning attributes and collects them for batch processing. - * - * This function does not apply changes directly. Instead, it calculates the pixel - * margins and adds them to the [changesByContainer] map. This allows all - * constraint changes for a single [ConstraintLayout] to be applied at once - * for better performance. - * - * **Attributes Read:** - * - `android:layout_marginStart` - * - `android:layout_marginTop` - * - * @param container The parent [ConstraintLayout]. - * @param view The child view to read attributes for. - * @param attrs The [AttributeMap] containing the stored attributes. - * @param density The screen density for px conversion. - * @param changesByContainer The map to add the [ViewConstraintChange] to. - */ -fun collectConstraintLayoutChange( - container: ConstraintLayout, - view: View, - attrs: AttributeMap, - density: Float, - changesByContainer: MutableMap> -) { - val txStr = attrs.getValue("android:layout_marginStart") - val tyStr = attrs.getValue("android:layout_marginTop") - - if (txStr.isNotEmpty() || tyStr.isNotEmpty()) { - val (txPx, tyPx) = calculateClampedPx(container, view, txStr, tyStr, density) - val changesList = changesByContainer.getOrPut(container) { mutableListOf() } - changesList.add(ViewConstraintChange( - viewId = view.id, - startMargin = txPx.toInt(), - topMargin = tyPx.toInt() - )) - } -} - -/** - * Restores the position for a child view within a [FrameLayout]. - * - * This function reads the stored margins, calculates the final clamped pixel values, - * and applies them directly to the [view]'s [FrameLayout.LayoutParams]. It also - * sets the `gravity` to `TOP|START` to match the positioning logic. - * - * **Attributes Read:** - * - `android:layout_marginLeft` - * - `android:layout_marginTop` - * - * @param container The parent [FrameLayout]. - * @param view The child view to position. - * @param attrs The [AttributeMap] containing the stored attributes. - * @param density The screen density for px conversion. - */ -fun restoreFrameLayoutPosition( - container: FrameLayout, view: View, attrs: AttributeMap, density: Float -) { - val lp = view.layoutParams as? FrameLayout.LayoutParams ?: return - val txStr = attrs.getValue("android:layout_marginLeft") - val tyStr = attrs.getValue("android:layout_marginTop") - - if (txStr.isNotEmpty() || tyStr.isNotEmpty()) { - val (txPx, tyPx) = calculateClampedPx(container, view, txStr, tyStr, density) - lp.leftMargin = txPx.toInt() - lp.topMargin = tyPx.toInt() - lp.gravity = Gravity.TOP or Gravity.START - view.layoutParams = lp - } -} - -/** - * Restores the position for a child view within a [CoordinatorLayout]. - * - * This function reads the stored margins, calculates the final clamped pixel values, - * and applies them directly to the [view]'s [CoordinatorLayout.LayoutParams]. It also - * sets the `gravity` to `TOP|START`. - * - * **Attributes Read:** - * - `android:layout_marginLeft` - * - `android:layout_marginTop` - * - * @param container The parent [CoordinatorLayout]. - * @param view The child view to position. - * @param attrs The [AttributeMap] containing the stored attributes. - * @param density The screen density for px conversion. - */ -internal fun restoreCoordinatorLayoutPosition( - container: CoordinatorLayout, view: View, attrs: AttributeMap, density: Float -) { - val lp = view.layoutParams as? CoordinatorLayout.LayoutParams ?: return - val txStr = attrs.getValue("android:layout_marginLeft") - val tyStr = attrs.getValue("android:layout_marginTop") - - if (txStr.isNotEmpty() || tyStr.isNotEmpty()) { - val (txPx, tyPx) = calculateClampedPx(container, view, txStr, tyStr, density) - lp.leftMargin = txPx.toInt() - lp.topMargin = tyPx.toInt() - lp.gravity = Gravity.TOP or Gravity.START - view.layoutParams = lp - } -} - -/** - * Restores the position for a child view within a [RelativeLayout]. - * - * This function reads stored margins and alignment rules. It first **clears** - * all existing parent alignment rules (START, TOP, END, BOTTOM) to prevent - * conflicts, then applies the new margins and `alignParent` rules directly to the - * [view]'s [RelativeLayout.LayoutParams]. - * - * **Attributes Read:** - * - `android:layout_marginLeft` - * - `android:layout_marginTop` - * - `android:layout_alignParentStart` - * - `android:layout_alignParentTop` - * - * @param container The parent [RelativeLayout]. - * @param view The child view to position. - * @param attrs The [AttributeMap] containing the stored attributes. - * @param density The screen density for px conversion. - */ -fun restoreRelativeLayoutPosition( - container: RelativeLayout, view: View, attrs: AttributeMap, density: Float -) { - val lp = view.layoutParams as? RelativeLayout.LayoutParams ?: return - val txStr = attrs.getValue("android:layout_marginLeft") - val tyStr = attrs.getValue("android:layout_marginTop") - val alignParentStart = attrs.getValue("android:layout_alignParentStart") == "true" - val alignParentTop = attrs.getValue("android:layout_alignParentTop") == "true" - - if (txStr.isNotEmpty() || tyStr.isNotEmpty() || alignParentStart || alignParentTop) { - val (txPx, tyPx) = calculateClampedPx(container, view, txStr, tyStr, density) - - lp.removeRule(RelativeLayout.ALIGN_PARENT_START) - lp.removeRule(RelativeLayout.ALIGN_PARENT_TOP) - lp.removeRule(RelativeLayout.ALIGN_PARENT_END) - lp.removeRule(RelativeLayout.ALIGN_PARENT_BOTTOM) - - lp.leftMargin = txPx.toInt() - lp.topMargin = tyPx.toInt() - - if (alignParentStart) lp.addRule(RelativeLayout.ALIGN_PARENT_START) - if (alignParentTop) lp.addRule(RelativeLayout.ALIGN_PARENT_TOP) - - view.layoutParams = lp - } -} - -internal fun restoreGridLayoutPosition( - view: View, - attrs: AttributeMap -) { - val lp = view.layoutParams as? GridLayout.LayoutParams ?: return - - val rowStr = attrs.getValue("android:layout_row") - val colStr = attrs.getValue("android:layout_column") - val gravityStr = attrs.getValue("android:layout_gravity") - val rowSpanStr = attrs.getValue("android:layout_rowSpan") - val colSpanStr = attrs.getValue("android:layout_columnSpan") - val weightStr = attrs.getValue("android:layout_columnWeight") - - var changed = false - - val row = rowStr.toIntOrNull() - val col = colStr.toIntOrNull() - val rowSpan = rowSpanStr.toIntOrNull()?.coerceAtLeast(1) ?: 1 - val colSpan = colSpanStr.toIntOrNull()?.coerceAtLeast(1) ?: 1 - val weight = weightStr.toFloatOrNull() ?: 0f - - if (row != null) { - lp.rowSpec = GridLayout.spec(row, rowSpan) - changed = true - } - - if (col != null) { - lp.columnSpec = GridLayout.spec(col, colSpan, weight) - changed = true - } - - if (gravityStr.isNotEmpty()) { - val gravity = parseGravityString(gravityStr) - if (gravity != Gravity.NO_GRAVITY) { - lp.setGravity(gravity) - changed = true - } - } - - if (changed) { - view.layoutParams = lp - } -} - -internal fun parseGravityString(gravityString: String): Int { - if (gravityString.isBlank()) { - return Gravity.NO_GRAVITY - } - - var totalGravity = 0 - - // Split by the '|' delimiter - gravityString.lowercase().split('|').forEach { part -> - val gravity = when (part.trim()) { - "top" -> Gravity.TOP - "bottom" -> Gravity.BOTTOM - "start" -> Gravity.START - "end" -> Gravity.END - "left" -> Gravity.LEFT - "right" -> Gravity.RIGHT - "center" -> Gravity.CENTER - "center_vertical" -> Gravity.CENTER_VERTICAL - "center_horizontal" -> Gravity.CENTER_HORIZONTAL - "fill" -> Gravity.FILL - "fill_vertical" -> Gravity.FILL_VERTICAL - "fill_horizontal" -> Gravity.FILL_HORIZONTAL - "clip_vertical" -> Gravity.CLIP_VERTICAL - "clip_horizontal" -> Gravity.CLIP_HORIZONTAL - else -> Gravity.NO_GRAVITY - } - - if (gravity != Gravity.NO_GRAVITY) { - totalGravity = totalGravity or gravity - } - } - - // Return NO_GRAVITY. Otherwise, return the combined flags. - return if (totalGravity == 0) Gravity.NO_GRAVITY else totalGravity -} - -/** - * A fallback position restore function for any [ViewGroup] that supports - * [ViewGroup.MarginLayoutParams]. - * - * This function reads standard margins and applies them directly to the - * [view]'s `layoutParams`. It does not handle alignment or flow logic, - * only margins. - * - * **Attributes Read:** - * - `android:layout_marginLeft` - * - `android:layout_marginTop` - * - * @param container The parent [ViewGroup]. - * @param view The child view to position. - * @param attrs The [AttributeMap] containing the stored attributes. - * @param density The screen density for px conversion. - */ -fun restoreGenericMarginPosition( - container: ViewGroup, view: View, attrs: AttributeMap, density: Float -) { - val lp = view.layoutParams as? ViewGroup.MarginLayoutParams ?: return - val txStr = attrs.getValue("android:layout_marginLeft") - val tyStr = attrs.getValue("android:layout_marginTop") - - if (txStr.isNotEmpty() || tyStr.isNotEmpty()) { - val (txPx, tyPx) = calculateClampedPx(container, view, txStr, tyStr, density) - lp.leftMargin = txPx.toInt() - lp.topMargin = tyPx.toInt() - view.layoutParams = lp - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/positioning/PositioningUtils.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/positioning/PositioningUtils.kt deleted file mode 100644 index 419d6c0be8..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/positioning/PositioningUtils.kt +++ /dev/null @@ -1,147 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.positioning - -import android.view.View -import android.view.ViewGroup -import org.appdevforall.codeonthego.layouteditor.editor.initializer.AttributeMap - -/** - * A set of all positioning-related attributes that should be cleared - * before applying new ones to prevent layout conflicts. - */ -internal val POSITIONING_KEYS_TO_REMOVE = setOf( - // ConstraintLayout - "app:layout_constraintBottom_toBottomOf", "app:layout_constraintEnd_toEndOf", - "app:layout_constraintStart_toStartOf", "app:layout_constraintTop_toTopOf", - "android:layout_marginStart", "android:layout_marginTop", "android:layout_marginEnd", "android:layout_marginBottom", - - // GridLayout - "android:layout_row", - "android:layout_column", - "android:layout_rowSpan", - "android:layout_columnSpan", - "android:layout_columnWeight", - - // FrameLayout and GridLayout - "android:layout_gravity", - - // RelativeLayout - "android:layout_alignParentStart", "android:layout_alignParentTop", - "android:layout_alignParentEnd", "android:layout_alignParentBottom", - - // Most common - "android:layout_marginLeft", "android:layout_marginTop", - "android:layout_marginEnd", "android:layout_marginBottom" -) - -/** - * Holds calculated X and Y coordinates in Density-Independent Pixels (dp). - */ -data class DpCoordinates(val xDp: Float, val yDp: Float) - -/** - * Calculates the final (x, y) coordinates in Dp for the dropped view. - * This function clamps the pixel values to ensure the [child] view remains - * entirely within the [container] bounds, then converts the clamped - * pixel values to Dp. - * - * @param container The parent ViewGroup. - * @param child The view being dropped. - * @param x The raw X coordinate of the drop in pixels. - * @param y The raw Y coordinate of the drop in pixels. - * @param density The screen density for px-to-dp conversion. - * @return A [DpCoordinates] object holding the final, safe coordinates in Dp. - */ -internal fun calculateDropCoordinatesInDp( - container: ViewGroup, - child: View, - x: Float, - y: Float, - density: Float -): DpCoordinates { - val maxX = (container.width - child.width).coerceAtLeast(0).toFloat() - val maxY = (container.height - child.height).coerceAtLeast(0).toFloat() - - val xPx = x.coerceIn(0f, maxX) - val yPx = y.coerceIn(0f, maxY) - - return DpCoordinates( - xDp = xPx / density, - yDp = yPx / density - ) -} - -/** - * Clears all known positioning attributes from the [attributes] map. - * This is crucial to prevent conflicts, e.g., having both - * `android:layout_marginStart` (from ConstraintLayout) and - * `android:layout_marginLeft` (from RelativeLayout) defined at the same time. - * - * @param attributes The AttributeMap for the view to be cleaned. - */ -internal fun clearPositioningAttributes(attributes: AttributeMap) { - POSITIONING_KEYS_TO_REMOVE.forEach { key -> - if (attributes.contains(key)) { - attributes.removeValue(key) - } - } -} - -/** - * Helper class to store a set of constraint changes for a single view. - */ -data class ViewConstraintChange( - val viewId: Int, - val startMargin: Int, - val topMargin: Int -) - -/** - * Converts a dimension string (e.g., `"12px"`, `"8dp"`, `"10dip"`, or `"14"`) - * into pixels using the given [density]. - * - * Supported suffixes: - * - `"px"` → interpreted as raw pixels. - * - `"dp"` or `"dip"` → multiplied by display density. - * - No suffix → assumed to be dp and multiplied by density. - * - * @receiver The dimension string to convert. - * @param density The display density for dp-to-px conversion. - * @return The equivalent pixel value, or `0f` if parsing fails. - */ -internal fun String.toPx(density: Float): Float { - val value = trim().lowercase() - val number = when { - value.endsWith("px") -> value.removeSuffix("px").toFloatOrNull() - value.endsWith("dp") -> value.removeSuffix("dp").toFloatOrNull()?.times(density) - value.endsWith("dip") -> value.removeSuffix("dip").toFloatOrNull()?.times(density) - else -> value.toFloatOrNull()?.times(density) - } - - return number?.takeIf { it.isFinite() } ?: 0f -} - - -/** - * Converts dimension strings (like "10dp" or "100px") into final, safe pixel values. - * - * This utility function performs two key actions: - * 1. Converts the string dimensions to pixels using [toPx]. - * 2. Clamps the resulting pixel values to ensure the [view] remains - * entirely within the bounds of the [container]. - * - * @param container The parent [ViewGroup] used to determine bounds. - * @param view The child [View] used to determine bounds. - * @param txStr The horizontal dimension string (e.g., `layout_marginStart`). - * @param tyStr The vertical dimension string (e.g., `layout_marginTop`). - * @param density The display density for dp-to-px conversion. - * @return A [Pair] containing the clamped (X, Y) pixel values. - */ -internal fun calculateClampedPx( - container: ViewGroup, view: View, txStr: String, tyStr: String, density: Float -): Pair { - val maxX = (container.width - view.width).coerceAtLeast(0).toFloat() - val maxY = (container.height - view.height).coerceAtLeast(0).toFloat() - val txPx = txStr.toPx(density).coerceIn(0f, maxX) - val tyPx = tyStr.toPx(density).coerceIn(0f, maxY) - return Pair(txPx, tyPx) -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/validation/HierarchyValidator.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/validation/HierarchyValidator.kt deleted file mode 100644 index bc2e62b4b2..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/editor/validation/HierarchyValidator.kt +++ /dev/null @@ -1,109 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.editor.validation - -import android.content.Context -import android.view.ViewGroup -import org.appdevforall.codeonthego.layouteditor.R -import org.appdevforall.codeonthego.layouteditor.editor.palette.containers.ToolbarDesign -import org.appdevforall.codeonthego.layouteditor.editor.palette.layouts.FrameLayoutDesign - -sealed class HierarchyResult { - object Valid : HierarchyResult() - data class Warning(val message: String) : HierarchyResult() - data class Invalid(val errorMessage: String) : HierarchyResult() -} - -private fun interface NestingRule { - fun matches(child: String, parentName: String, parentView: ViewGroup): Boolean -} - -class HierarchyValidator(private val context: Context) { - - /** - * Rules that must block insertion because they are known to crash - * or break the editor/runtime consistently. - */ - private val blockingRules = listOf( - - // DrawerLayout / ViewPager inside restrictive parents - NestingRule { child, _, parentView -> - val needsExactly = child.contains("drawerlayout") || child.contains("viewpager") - needsExactly && parentView.isCrashProneParent() - } - ) - - /** - * Rules that should not block insertion, but should inform the user - * that the hierarchy may behave poorly. - */ - private val warningRules = listOf( - - // Recycler-like views inside vertical ScrollView - NestingRule { child, parentName, _ -> - val isListOrGrid = child.contains("gridview") || - child.contains("listview") || - child.contains("recyclerview") - val isVerticalScroll = parentName.contains("scrollview") && - !parentName.contains("horizontal") - isListOrGrid && isVerticalScroll - }, - - // Vertical ScrollView inside vertical ScrollView - NestingRule { child, parentName, _ -> - val isVerticalScrollChild = child.contains("scrollview") && - !child.contains("horizontal") - val isVerticalScrollParent = parentName.contains("scrollview") && - !parentName.contains("horizontal") - isVerticalScrollChild && isVerticalScrollParent - }, - - // HorizontalScrollView inside HorizontalScrollView - NestingRule { child, parentName, _ -> - child.contains("horizontalscrollview") && - parentName.contains("horizontalscrollview") - } - ) - - fun validate(childClassName: String, parent: ViewGroup): HierarchyResult { - val cleanChild = childClassName.cleanWidgetName() - val cleanParent = parent.cleanWidgetName() - - val lowerChild = cleanChild.lowercase() - val lowerParent = cleanParent.lowercase() - - for (rule in blockingRules) { - if (rule.matches(lowerChild, lowerParent, parent)) { - val message = context.getString( - R.string.error_incompatible_hierarchy, - cleanChild, - cleanParent - ) - return HierarchyResult.Invalid(message) - } - } - - for (rule in warningRules) { - if (rule.matches(lowerChild, lowerParent, parent)) { - val message = context.getString( - R.string.warning_problematic_hierarchy, - cleanChild, - cleanParent - ) - return HierarchyResult.Warning(message) - } - } - - return HierarchyResult.Valid - } - - private fun String.cleanWidgetName(): String = - substringAfterLast('.').removeSuffix("Design") - - private fun ViewGroup.cleanWidgetName(): String = javaClass.name.cleanWidgetName() - - private fun ViewGroup.isCrashProneParent(): Boolean { - val cleanParent = cleanWidgetName().lowercase() - return this is ToolbarDesign || - this is FrameLayoutDesign || - cleanParent.contains("scrollview") - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/fragments/resources/ColorFragment.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/fragments/resources/ColorFragment.java deleted file mode 100644 index 95b7171a23..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/fragments/resources/ColorFragment.java +++ /dev/null @@ -1,269 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.fragments.resources; - -import android.annotation.SuppressLint; -import android.graphics.Color; -import android.os.Bundle; -import android.text.Editable; -import android.text.TextWatcher; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; - -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.appcompat.app.AlertDialog; -import androidx.fragment.app.Fragment; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; - -import com.google.android.material.dialog.MaterialAlertDialogBuilder; -import com.google.android.material.textfield.TextInputEditText; -import com.google.android.material.textfield.TextInputLayout; -import com.skydoves.colorpickerview.ColorPickerDialog; -import com.skydoves.colorpickerview.listeners.ColorEnvelopeListener; - -import org.appdevforall.codeonthego.layouteditor.ProjectFile; -import org.appdevforall.codeonthego.layouteditor.R; -import org.appdevforall.codeonthego.layouteditor.adapters.ColorResourceAdapter; -import org.appdevforall.codeonthego.layouteditor.adapters.models.ValuesItem; -import org.appdevforall.codeonthego.layouteditor.databinding.FragmentResourcesBinding; -import org.appdevforall.codeonthego.layouteditor.databinding.LayoutValuesItemDialogBinding; -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.tools.ColorPickerDialogFlag; -import org.appdevforall.codeonthego.layouteditor.tools.ValuesResourceParser; -import org.appdevforall.codeonthego.layouteditor.utils.NameErrorChecker; -import org.appdevforall.codeonthego.layouteditor.utils.ProjectResolver; -import org.appdevforall.codeonthego.layouteditor.utils.SBUtils; - -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; - -/** - * @authors: @raredeveloperofc and @itsvks19; - */ -public class ColorFragment extends Fragment { - - private FragmentResourcesBinding binding; - private ColorResourceAdapter adapter; - private List colorList = new ArrayList<>(); - ValuesResourceParser colorParser; - - public static ColorFragment newInstance(ProjectFile project) { - ColorFragment fragment = new ColorFragment(); - Bundle args = new Bundle(); - args.putParcelable(Constants.EXTRA_KEY_PROJECT, project); - fragment.setArguments(args); - return fragment; - } - - @Override - public android.view.View onCreateView( - @NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - binding = FragmentResourcesBinding.inflate(inflater, container, false); - return binding.getRoot(); - } - - @Override - public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { - super.onViewCreated(view, savedInstanceState); - ProjectFile project = ProjectResolver.getValidProjectOrShowError(getArguments(), view); - if (project == null) return; - - try { - loadColorsFromXML(project.getColorsPath()); - } catch (FileNotFoundException e) { - SBUtils.make(view, "An error occurred: " + e.getMessage()) - .setFadeAnimation() - .setType(SBUtils.Type.INFO) - .show(); - } - RecyclerView mRecyclerView = binding.recyclerView; - adapter = new ColorResourceAdapter(project, colorList); - mRecyclerView.setAdapter(adapter); - mRecyclerView.setLayoutManager( - new LinearLayoutManager(requireContext(), RecyclerView.VERTICAL, false)); - } - - /** - * @param filePath = Current project colors file path; - */ - public void loadColorsFromXML(String filePath) throws FileNotFoundException { - try (InputStream stream = new FileInputStream(filePath)) { - colorParser = new ValuesResourceParser(stream, ValuesResourceParser.TAG_COLOR); - colorList = colorParser.getValuesList(); - } catch (FileNotFoundException e) { - throw e; - } catch (IOException e) { - e.printStackTrace(); - } - } - - private void setupDialogViews(LayoutValuesItemDialogBinding bind) { - TextInputEditText etValue = bind.textinputValue; - etValue.setFocusable(true); - etValue.setFocusableInTouchMode(true); - etValue.setOnClickListener(null); - } - - private void setupColorPicker(TextInputLayout valueInputLayout, TextInputEditText valueEditText) { - valueInputLayout.setEndIconOnClickListener(v -> showColorPickerDialog(valueEditText, valueInputLayout)); - } - - private void setupInputValidation(AlertDialog dialog, LayoutValuesItemDialogBinding bind) { - TextWatcher validator = new TextWatcher() { - @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) {} - @Override - public void onTextChanged(CharSequence s, int start, int before, int count) {} - @Override - public void afterTextChanged(Editable s) { - validateInputs(dialog, bind); - } - }; - - bind.textinputName.addTextChangedListener(validator); - bind.textinputValue.addTextChangedListener(validator); - } - - private void validateInputs(AlertDialog dialog, LayoutValuesItemDialogBinding bind) { - String name = Objects.requireNonNull(bind.textinputName.getText()).toString(); - String value = Objects.requireNonNull(bind.textinputValue.getText()).toString(); - - NameErrorChecker.checkForValues(name, bind.textInputLayoutName, dialog, colorList); - boolean isNameValid = bind.textInputLayoutName.getError() == null && !name.trim().isEmpty(); - - boolean isColorValid = checkColorValidity(value, bind.textInputLayoutValue); - - boolean isFormValid = isNameValid && isColorValid; - dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(isFormValid); - } - - private boolean checkColorValidity(String colorHex, TextInputLayout ilValue) { - if (colorHex.trim().isEmpty()) { - ilValue.setError(null); - return false; - } - - try { - getSafeColor(colorHex); - ilValue.setError(null); - ilValue.setErrorEnabled(false); - return true; - } catch (IllegalArgumentException e) { - ilValue.setError(getString(R.string.error_invalid_color)); - return false; - } - } - - private void setupSaveButton(AlertDialog dialog, LayoutValuesItemDialogBinding bind) { - dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(v -> handleSaveColor(dialog, bind)); - } - - private void handleSaveColor(AlertDialog dialog, LayoutValuesItemDialogBinding bind) { - String name = Objects.requireNonNull(bind.textinputName.getText()).toString().trim(); - String value = Objects.requireNonNull(bind.textinputValue.getText()).toString().trim(); - - if (name.isEmpty()) { - bind.textInputLayoutName.setError(getString(R.string.error_color_name_required)); - return; - } - - try { - String finalValue = getSafeColor(value); - bind.textInputLayoutValue.setError(null); - - ValuesItem colorItem = new ValuesItem(name, finalValue); - colorList.add(colorItem); - adapter.notifyItemInserted(colorList.indexOf(colorItem)); - adapter.generateColorsXml(); - - dialog.dismiss(); - } catch (IllegalArgumentException e) { - bind.textInputLayoutValue.setError(getString(R.string.error_invalid_color)); - } - } - - public void addColor() { - LayoutValuesItemDialogBinding dialogBinding = LayoutValuesItemDialogBinding.inflate(getLayoutInflater()); - AlertDialog dialog = new MaterialAlertDialogBuilder(requireContext()) - .setTitle(R.string.new_color_dialog_title) - .setView(dialogBinding.getRoot()) - .setPositiveButton(R.string.add, null) - .setNegativeButton(R.string.cancel, null) - .create(); - - setupDialogViews(dialogBinding); - dialog.show(); - - dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false); - - setupColorPicker(dialogBinding.textInputLayoutValue, dialogBinding.textinputValue); - setupInputValidation(dialog, dialogBinding); - setupSaveButton(dialog, dialogBinding); - } - - private void showColorPickerDialog(TextInputEditText etValue, TextInputLayout ilValue) { - @SuppressLint("SetTextI18n") - ColorPickerDialog.Builder builder = new ColorPickerDialog.Builder(requireContext()) - .setTitle(R.string.color_picker_dialog_title) - .setPositiveButton(getString(R.string.confirm), (ColorEnvelopeListener) (envelope, fromUser) -> { - etValue.setText("#" + envelope.getHexCode()); - ilValue.setError(null); - }) - .setNegativeButton(getString(R.string.cancel), (d, i) -> d.dismiss()) - .attachAlphaSlideBar(true) - .attachBrightnessSlideBar(true) - .setBottomSpace(12); - - var colorView = builder.getColorPickerView(); - colorView.setFlagView(new ColorPickerDialogFlag(requireContext())); - - // Try to set initial color safely - try { - String colorStr = Objects.requireNonNull(etValue.getText()).toString(); - if (!colorStr.isEmpty()) { - colorView.setInitialColor(Color.parseColor(getSafeColor(colorStr))); - } - } catch (Exception ignored) {} - - builder.show(); - } - - /** - * Attempts to parse an input string and return a safe hexadecimal color string. - * It first tries to parse the [input] as is. If that fails, it checks if the "#" prefix - * is missing. If missing, it appends it and tries to parse again. - * - * @param input The raw color string (e.g., "FFFFFF" or "#FFFFFF"). - * @return The valid color string (including the "#" prefix if it was needed). - * @throws IllegalArgumentException If the input cannot be parsed as a valid color even after correction. - */ - private String getSafeColor(String input) throws IllegalArgumentException { - try { - Color.parseColor(input); - return input; - } catch (IllegalArgumentException ignored) {} - - String fixed = hexPrefixValidation(input); - if (fixed != null) return fixed; - - throw new IllegalArgumentException("Unknown color"); - } - - @Nullable - private static String hexPrefixValidation(String input) { - if (!input.startsWith("#")) { - String fixed = "#" + input; - try { - Color.parseColor(fixed); - return fixed; - } catch (IllegalArgumentException ignored) {} - } - return null; - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/fragments/resources/DrawableFragment.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/fragments/resources/DrawableFragment.kt deleted file mode 100644 index 51cf6bb253..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/fragments/resources/DrawableFragment.kt +++ /dev/null @@ -1,417 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.fragments.resources - -import android.content.Context -import android.graphics.BitmapFactory -import android.graphics.drawable.Drawable -import android.net.Uri -import android.os.Bundle -import android.text.Editable -import android.text.TextWatcher -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import android.view.WindowManager -import android.view.inputmethod.InputMethodManager -import androidx.fragment.app.Fragment -import androidx.lifecycle.lifecycleScope -import androidx.recyclerview.widget.GridLayoutManager -import androidx.recyclerview.widget.LinearLayoutManager -import androidx.recyclerview.widget.RecyclerView -import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat -import com.blankj.utilcode.util.ToastUtils -import com.google.android.material.dialog.MaterialAlertDialogBuilder -import com.itsaky.androidide.eventbus.events.file.FileRenameEvent -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.launch -import kotlinx.coroutines.withContext -import org.apache.commons.io.FileUtils -import org.appdevforall.codeonthego.layouteditor.ProjectFile -import org.appdevforall.codeonthego.layouteditor.R -import org.appdevforall.codeonthego.layouteditor.adapters.DPIsListAdapter -import org.appdevforall.codeonthego.layouteditor.adapters.DrawableResourceAdapter -import org.appdevforall.codeonthego.layouteditor.adapters.models.DrawableFile -import org.appdevforall.codeonthego.layouteditor.databinding.DialogSelectDpisBinding -import org.appdevforall.codeonthego.layouteditor.databinding.FragmentResourcesBinding -import org.appdevforall.codeonthego.layouteditor.databinding.TextinputlayoutBinding -import org.appdevforall.codeonthego.layouteditor.tools.ImageConverter -import org.appdevforall.codeonthego.layouteditor.utils.Constants -import org.appdevforall.codeonthego.layouteditor.utils.FileUtil -import org.appdevforall.codeonthego.layouteditor.utils.FileUtil.getLastSegmentFromPath -import org.appdevforall.codeonthego.layouteditor.utils.NameErrorChecker -import org.appdevforall.codeonthego.layouteditor.utils.ProjectResolver -import org.appdevforall.codeonthego.layouteditor.utils.Utils -import org.greenrobot.eventbus.EventBus -import org.slf4j.LoggerFactory -import java.io.File -import java.io.IOException - -class DrawableFragment : Fragment() { - private var binding: FragmentResourcesBinding? = null - private var mRecyclerView: RecyclerView? = null - - private var project: ProjectFile? = null - private var drawableList: MutableList = mutableListOf() - - private var adapter: DrawableResourceAdapter? = null - var dpiAdapter: DPIsListAdapter? = null - private var dpiList = mutableListOf("ldpi", "mdpi", "hdpi", "xhdpi", "xxhdpi", "xxxhdpi") - - private val logger = LoggerFactory.getLogger(DrawableFragment::class.java) - - companion object { - fun newInstance(project: ProjectFile): DrawableFragment { - val fragment = DrawableFragment() - val args = Bundle() - args.putParcelable(Constants.EXTRA_KEY_PROJECT, project) - fragment.arguments = args - return fragment - } - } - - - override fun onCreateView( - inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? - ): View? { - binding = FragmentResourcesBinding.inflate(inflater, container, false) - return binding!!.getRoot() - } - - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - project = ProjectResolver.getValidProjectOrShowError(arguments, view) - if (project == null) return - - loadDrawables() - mRecyclerView = binding!!.recyclerView - // Create the adapter and set it to the RecyclerView - adapter = DrawableResourceAdapter( - drawableList, - object : DrawableResourceAdapter.OnDrawableActionListener { - override fun onRenameRequested(position: Int) { - showRenameDialog(position) - } - - override fun onDeleteRequested(position: Int) { - deleteDrawable(position) - } - }) - mRecyclerView!!.setAdapter(adapter) - mRecyclerView!!.setLayoutManager( - LinearLayoutManager(requireContext(), RecyclerView.VERTICAL, false) - ) - } - - fun loadDrawables() { - val appContext = requireContext().applicationContext - - lifecycleScope.launch { - try { - val result = loadDrawableFiles(appContext) - - drawableList.clear() - drawableList.addAll(result) - adapter?.notifyDataSetChanged() - - } catch (e: Exception) { - logger.error("Error loading drawables", e) - } - } - } - - private suspend fun loadDrawableFiles(context: Context): List { - val currentProject = project ?: return emptyList() - - return withContext(Dispatchers.IO) { - val projectDir = File(currentProject.path) - val baseDrawableFolder = File(projectDir, "drawable") - - if (!baseDrawableFolder.exists()) { - return@withContext emptyList() - } - - val dpiVersionMap = buildDpiVersionMap(projectDir) - - val drawableFiles = FileUtils.listFiles( - baseDrawableFolder, - arrayOf("png", "jpg", "jpeg", "gif", "xml"), - false - ) - - drawableFiles.mapNotNull { file -> - createDrawableFile(context, file, dpiVersionMap) - } - } - } - - private fun buildDpiVersionMap(projectDir: File): Map { - val dpiMap = mutableMapOf() - dpiList.forEachIndexed { index, dpi -> - val dpiFolder = File(projectDir, "drawable-$dpi") - dpiFolder.listFiles()?.forEach { fileInDpiFolder -> - dpiMap[fileInDpiFolder.name] = index - } - } - return dpiMap - } - - private fun createDrawableFile( - context: Context, - file: File, - dpiVersionMap: Map - ): DrawableFile? { - val drawable = if (file.extension.equals("xml", ignoreCase = true)) { - Utils.getVectorDrawableAsync(context, Uri.fromFile(file)) - } else { - Drawable.createFromPath(file.path) - } - - val versionIndex = dpiVersionMap[file.name] ?: 0 - - return drawable?.let { - DrawableFile( - versions = versionIndex + 1, - drawable = it, - path = file.path - ) - } - } - - fun addDrawable(uri: Uri) { - val path = FileUtil.convertUriToFilePath(requireContext(), uri) - if (path.isEmpty()) { - ToastUtils.showLong(R.string.invalid_data_intent) - return - } - - val lastSegment = getLastSegmentFromPath(path) - val fileName = lastSegment.substring(0, lastSegment.lastIndexOf(".")) - val extension = lastSegment.substring(lastSegment.lastIndexOf(".")) - - val builder = MaterialAlertDialogBuilder(requireContext()) - val dialogBinding = DialogSelectDpisBinding.inflate(builder.create().layoutInflater) - val editText = dialogBinding.textinputEdittext - val inputLayout = dialogBinding.textinputLayout - - inputLayout.setHint(R.string.msg_enter_new_name) - editText.setText(fileName) - - if (!lastSegment.endsWith(".xml")) { - Drawable.createFromPath(path)?.let { drawable -> - dpiAdapter = DPIsListAdapter(drawable) - } - dialogBinding.listDpi.adapter = dpiAdapter - dialogBinding.listDpi.layoutManager = GridLayoutManager(requireActivity(), 2) - } - - dialogBinding.listDpi.visibility = - if (lastSegment.endsWith(".xml")) View.GONE else View.VISIBLE - - builder.setView(dialogBinding.root) - builder.setTitle(R.string.add_drawable) - builder.setNegativeButton(R.string.cancel, null) - - builder.setPositiveButton(R.string.add) { _, _ -> - val drawableName = editText.text.toString() - val selectedDPIs = dpiAdapter?.selectedItems ?: emptyList() - val isXml = lastSegment.endsWith(".xml") - val appContext = requireContext().applicationContext - - lifecycleScope.launch { - val newDrawableFile = withContext(Dispatchers.IO) { - val drawablePath = project?.drawablePath ?: return@withContext null - - if (!isXml && selectedDPIs.isNotEmpty()) { - - try { - ImageConverter.convertToDrawableDpis( - drawableName + extension, - BitmapFactory.decodeFile(path), - selectedDPIs - ) - } catch (e: IOException) { - logger.error("Error converting drawable to different DPIs", e) - } - } - - val toPath = drawablePath + drawableName + extension - FileUtil.copyFile(uri, toPath, appContext) - - val drawable = - if (isXml) - Utils.getVectorDrawableAsync( - appContext, - Uri.fromFile(File(toPath)) - ) - else - Drawable.createFromPath(toPath) - - val version = selectedDPIs.size + 1 - drawable?.let { - DrawableFile(version, it, toPath) - } - } - - newDrawableFile?.let { - val insertPosition = drawableList.size - drawableList.add(it) - adapter?.notifyItemInserted(insertPosition) - } - } - } - - val dialog = builder.create() - dialog.window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE) - dialog.show() - - editText.addTextChangedListener(object : TextWatcher { - override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {} - override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {} - override fun afterTextChanged(s: Editable?) { - NameErrorChecker.checkForDrawable( - editText.text.toString(), - inputLayout, - dialog, - drawableList - ) - } - }) - - NameErrorChecker.checkForDrawable(fileName, inputLayout, dialog, drawableList) - - editText.requestFocus() - val imm = dialogBinding.root.context - .getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager - imm.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT) - - if (editText.text?.isNotEmpty() == true) { - editText.setSelection(0, editText.text!!.length) - } - } - - private fun showRenameDialog(position: Int) { - val drawableFile = drawableList[position] - val segment = getLastSegmentFromPath(drawableFile.path) - - val fileName = segment.substring(0, segment.lastIndexOf(".")) - val extension = segment.substring(segment.lastIndexOf(".")) - - val builder = MaterialAlertDialogBuilder(requireContext()) - val bind = TextinputlayoutBinding.inflate(builder.create().layoutInflater) - val editText = bind.textinputEdittext - - editText.setText(fileName) - builder.setTitle(R.string.rename_drawable) - builder.setView(bind.root) - builder.setNegativeButton(R.string.cancel, null) - builder.setPositiveButton(R.string.rename) { _, _ -> - lifecycleScope.launch { - renameDrawable(position, editText.text.toString(), extension) - } - } - - val dialog = builder.create() - dialog.window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE) - dialog.show() - } - - private suspend fun renameDrawable( - position: Int, - newName: String, - extension: String - ) = withContext(Dispatchers.IO) { - - val drawable = drawableList[position] - val oldPath = drawable.path - val oldName = drawable.name.substring(0, drawable.name.lastIndexOf(".")) - - val oldFile = File(oldPath) - val newPath = project?.drawablePath + newName + extension - val newFile = File(newPath) - - if (!oldFile.renameTo(newFile)) { - withContext(Dispatchers.Main) { - ToastUtils.showLong(R.string.rename_failed) - } - return@withContext - } - - EventBus.getDefault().post(FileRenameEvent(oldFile, newFile)) - - val projectRoot = project?.let { File(it.path) }?.parentFile - projectRoot?.let { - renameDrawableReferences( - it, - oldName = oldName, - newName = newName - ) - } - - val updatedDrawable = - if (extension.equals(".xml", ignoreCase = true) || extension.equals(".svg", ignoreCase = true)) - VectorDrawableCompat.createFromPath(newPath) - else - Drawable.createFromPath(newPath) - - drawable.path = newPath - drawable.name = newName + extension - - withContext(Dispatchers.Main) { - val item = adapter?.getItemAt(position) - if (updatedDrawable != null) { - item?.drawable = updatedDrawable - } - adapter?.notifyItemChanged(position) - } - } - - private suspend fun renameDrawableReferences( - projectRoot: File, - oldName: String, - newName: String - ) = withContext(Dispatchers.IO) { - - val xmlFiles = projectRoot.walkTopDown() - .filter { it.isFile && it.extension.lowercase() == "xml" } - .toList() - - val codeFiles = projectRoot.walkTopDown() - .filter { it.isFile && (it.extension == "kt" || it.extension == "java") } - .toList() - - val xmlPattern = "@drawable/$oldName" - val xmlReplacement = "@drawable/$newName" - - val codePattern = "R.drawable.$oldName" - val codeReplacement = "R.drawable.$newName" - - // Update XML references - xmlFiles.forEach { file -> - val text = file.readText() - if (text.contains(xmlPattern)) { - file.writeText(text.replace(xmlPattern, xmlReplacement)) - } - } - - // Update Kotlin/Java references - codeFiles.forEach { file -> - val text = file.readText() - if (text.contains(codePattern)) { - file.writeText(text.replace(codePattern, codeReplacement)) - } - } - } - - private fun deleteDrawable(position: Int) { - lifecycleScope.launch { - val file = File(drawableList[position].path) - val deleted = withContext(Dispatchers.IO) { file.delete() } - if (deleted) { - drawableList.removeAt(position) - adapter?.notifyItemRemoved(position) - } else { - ToastUtils.showLong(R.string.delete_failed) - } - } - } - -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/fragments/resources/FontFragment.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/fragments/resources/FontFragment.java deleted file mode 100644 index d78c6bb15a..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/fragments/resources/FontFragment.java +++ /dev/null @@ -1,211 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.fragments.resources; - -import static org.appdevforall.codeonthego.layouteditor.utils.Utils.isValidFontFile; - -import android.content.Context; -import android.net.Uri; -import android.os.Bundle; -import android.text.Editable; -import android.text.TextUtils; -import android.text.TextWatcher; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.view.WindowManager; -import android.view.inputmethod.InputMethodManager; - -import androidx.annotation.NonNull; -import androidx.appcompat.app.AlertDialog; -import androidx.fragment.app.Fragment; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; - -import com.blankj.utilcode.util.ToastUtils; -import com.google.android.material.dialog.MaterialAlertDialogBuilder; -import com.google.android.material.textfield.TextInputEditText; -import com.google.android.material.textfield.TextInputLayout; - -import org.appdevforall.codeonthego.layouteditor.ProjectFile; -import org.appdevforall.codeonthego.layouteditor.R; -import org.appdevforall.codeonthego.layouteditor.adapters.FontResourceAdapter; -import org.appdevforall.codeonthego.layouteditor.adapters.models.FontItem; -import org.appdevforall.codeonthego.layouteditor.databinding.FragmentResourcesBinding; -import org.appdevforall.codeonthego.layouteditor.databinding.LayoutFontItemDialogBinding; -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.utils.FileUtil; -import org.appdevforall.codeonthego.layouteditor.utils.NameErrorChecker; -import org.appdevforall.codeonthego.layouteditor.utils.ProjectResolver; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - -public class FontFragment extends Fragment { - - private FragmentResourcesBinding binding; - private FontResourceAdapter adapter; - private ProjectFile project; - private List fontList = new ArrayList<>(); - private ExecutorService executor; - - public static FontFragment newInstance(ProjectFile project) { - FontFragment fragment = new FontFragment(); - Bundle args = new Bundle(); - args.putParcelable(Constants.EXTRA_KEY_PROJECT, project); - fragment.setArguments(args); - return fragment; - } - - @Override - public android.view.View onCreateView( - @NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - binding = FragmentResourcesBinding.inflate(inflater, container, false); - return binding.getRoot(); - } - - @Override - public void onViewCreated(@NonNull View view, Bundle savedInstanceState) { - super.onViewCreated(view, savedInstanceState); - project = ProjectResolver.getValidProjectOrShowError(getArguments(), view); - if (project == null) return; - - executor = Executors.newSingleThreadExecutor(); - adapter = new FontResourceAdapter(fontList); - RecyclerView mRecyclerView = binding.recyclerView; - mRecyclerView.setAdapter(adapter); - mRecyclerView.setLayoutManager( - new LinearLayoutManager(requireContext(), RecyclerView.VERTICAL, false)); - loadFonts(); - } - - @Override - public void onDestroyView() { - super.onDestroyView(); - if (executor != null) { - executor.shutdownNow(); - binding = null; - } - } - - private void loadFonts() { - executor.execute(() -> { - File[] files = project.getFonts(); - - if (files == null) { - requireActivity().runOnUiThread(() -> ToastUtils.showShort(getString(R.string.msg_error_load_failed))); - return; - } - - List temp = new ArrayList<>(); - for (File file : files) { - String name = file.getName(); - - if (!isValidFontFile(file)) { - requireActivity().runOnUiThread(() -> - ToastUtils.showLong(getString(R.string.msg_font_load_invalid, name)) - ); - continue; - } - temp.add(new FontItem(name, file.getPath())); - } - - requireActivity().runOnUiThread(() -> { - fontList.clear(); - fontList.addAll(temp); - if (adapter != null) adapter.notifyDataSetChanged(); - }); - }); - } - - private void postToast(String msg) { - requireActivity().runOnUiThread(() -> ToastUtils.showLong(msg)); - } - - public void addFont(final Uri uri) { - String path = FileUtil.convertUriToFilePath(this.getContext(),uri); - if (TextUtils.isEmpty(path)) { - ToastUtils.showLong(R.string.invalid_data_intent); - return; - } - final String lastSegment = FileUtil.getLastSegmentFromPath(path); - final String fileName = lastSegment.substring(0, lastSegment.lastIndexOf(".")); - final String extension = - lastSegment.substring(lastSegment.lastIndexOf(".")); - final MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(requireContext()); - final LayoutFontItemDialogBinding dialogBinding = - LayoutFontItemDialogBinding.inflate(builder.create().getLayoutInflater()); - final TextInputEditText editTextName = dialogBinding.textinputName; - final TextInputLayout inputLayoutName = dialogBinding.textInputLayoutName; - inputLayoutName.setHint(R.string.msg_enter_new_name); - editTextName.setText(fileName); - - builder.setView(dialogBinding.getRoot()); - builder.setTitle(R.string.add_font); - builder.setNegativeButton(R.string.cancel, (di, which) -> {}); - builder.setPositiveButton( - R.string.add, - (di, which) -> { - final String finalName = editTextName.getText().toString().trim(); - final String finalToPath = project.getFontPath() + finalName + extension; - final String finalFileName = finalName + extension; - - executor.execute(() -> { - String filePath = FileUtil.convertUriToFilePath(getContext(), uri); - File original = new File(filePath); - - if (!isValidFontFile(original)) { - postToast(getString(R.string.msg_font_add_invalid)); - return; - } - - boolean copySucceeded = FileUtil.copyFile(uri, finalToPath, getContext()); - - if (!copySucceeded) { - File failedFile = new File(finalToPath); - if (failedFile.exists()) failedFile.delete(); - postToast(getString(R.string.msg_font_copy_failed)); - return; - } - - requireActivity().runOnUiThread(() -> { - FontItem item = new FontItem(finalFileName + extension, finalToPath); - fontList.add(item); - adapter.notifyItemInserted(fontList.size() - 1); - }); - }); - }); - - final AlertDialog dialog = builder.create(); - dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE); - dialog.show(); - - editTextName.addTextChangedListener( - new TextWatcher() { - - @Override - public void beforeTextChanged(CharSequence p1, int p2, int p3, int p4) {} - - @Override - public void onTextChanged(CharSequence p1, int p2, int p3, int p4) {} - - @Override - public void afterTextChanged(Editable p1) { - NameErrorChecker.checkForFont( - editTextName.getText().toString(), inputLayoutName, dialog, fontList); - } - }); - - NameErrorChecker.checkForFont(fileName, inputLayoutName, dialog, fontList); - - editTextName.requestFocus(); - InputMethodManager inputMethodManager = - (InputMethodManager) requireContext().getSystemService(Context.INPUT_METHOD_SERVICE); - inputMethodManager.showSoftInput(editTextName, InputMethodManager.SHOW_IMPLICIT); - - if (!editTextName.getText().toString().isEmpty()) { - editTextName.setSelection(0, editTextName.getText().toString().length()); - } - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/fragments/resources/StringFragment.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/fragments/resources/StringFragment.java deleted file mode 100644 index 648656dede..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/fragments/resources/StringFragment.java +++ /dev/null @@ -1,146 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.fragments.resources; - -import android.os.Bundle; -import android.text.Editable; -import android.text.TextWatcher; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; - -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.appcompat.app.AlertDialog; -import androidx.fragment.app.Fragment; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; - -import com.google.android.material.dialog.MaterialAlertDialogBuilder; -import com.google.android.material.textfield.TextInputEditText; -import com.google.android.material.textfield.TextInputLayout; - -import org.appdevforall.codeonthego.layouteditor.ProjectFile; -import org.appdevforall.codeonthego.layouteditor.R; -import org.appdevforall.codeonthego.layouteditor.adapters.StringResourceAdapter; -import org.appdevforall.codeonthego.layouteditor.adapters.models.ValuesItem; -import org.appdevforall.codeonthego.layouteditor.databinding.FragmentResourcesBinding; -import org.appdevforall.codeonthego.layouteditor.databinding.LayoutValuesItemDialogBinding; -import org.appdevforall.codeonthego.layouteditor.utils.Constants; -import org.appdevforall.codeonthego.layouteditor.tools.ValuesResourceParser; -import org.appdevforall.codeonthego.layouteditor.utils.NameErrorChecker; -import org.appdevforall.codeonthego.layouteditor.utils.ProjectResolver; -import org.appdevforall.codeonthego.layouteditor.utils.SBUtils; - -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.List; - -/* - * @authors: @raredeveloperofc and @itsvks19; - */ -public class StringFragment extends Fragment { - private FragmentResourcesBinding binding; - private StringResourceAdapter adapter; - private RecyclerView mRecyclerView; - private List stringList = new ArrayList<>(); - ValuesResourceParser stringParser; - - public static StringFragment newInstance(ProjectFile project) { - StringFragment fragment = new StringFragment(); - Bundle args = new Bundle(); - args.putParcelable(Constants.EXTRA_KEY_PROJECT, project); - fragment.setArguments(args); - return fragment; - } - - @Override - public android.view.View onCreateView( - @NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - binding = FragmentResourcesBinding.inflate(inflater, container, false); - return binding.getRoot(); - } - - @Override - public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { - super.onViewCreated(view, savedInstanceState); - ProjectFile project = ProjectResolver.getValidProjectOrShowError(getArguments(), view); - if (project == null) return; - - try { - loadStringsFromXML(project.getStringsPath()); - } catch (FileNotFoundException e) { - SBUtils.make(view, "An error occured: " + e.getMessage()) - .setFadeAnimation() - .setType(SBUtils.Type.INFO) - .show(); - } - mRecyclerView = binding.recyclerView; - adapter = new StringResourceAdapter(project, stringList); - mRecyclerView.setAdapter(adapter); - mRecyclerView.setLayoutManager( - new LinearLayoutManager(requireContext(), RecyclerView.VERTICAL, false)); - } - - /* - * @param filePath = Current project strings file path; - */ - public void loadStringsFromXML(String filePath) throws FileNotFoundException { - try (InputStream stream = new FileInputStream(filePath)) { - stringParser = new ValuesResourceParser(stream, ValuesResourceParser.TAG_STRING); - stringList = stringParser.getValuesList(); - } catch (FileNotFoundException e) { - throw e; - } catch (IOException e) { - e.printStackTrace(); - } - } - - public void addString() { - MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(requireContext()); - builder.setTitle("New String"); - - LayoutValuesItemDialogBinding bind = LayoutValuesItemDialogBinding.inflate(getLayoutInflater()); - TextInputLayout ilName = bind.textInputLayoutName; - TextInputLayout ilValue = bind.textInputLayoutValue; - TextInputEditText etName = bind.textinputName; - TextInputEditText etValue = bind.textinputValue; - - builder.setView(bind.getRoot()); - - builder.setPositiveButton( - R.string.add, - (dlg, i) -> { - // Create new StringItem(ValuesItem) instance - var stringItem = - new ValuesItem(etName.getText().toString(), etValue.getText().toString()); - // Add stringItem in stringList - stringList.add(stringItem); - adapter.notifyItemInserted(stringList.indexOf(stringItem)); - // Generate code from all strings in list - adapter.generateStringsXml(); - }); - builder.setNegativeButton(R.string.cancel, null); - - AlertDialog dialog = builder.create(); - dialog.show(); - - etName.addTextChangedListener( - new TextWatcher() { - - @Override - public void beforeTextChanged(CharSequence p1, int p2, int p3, int p4) {} - - @Override - public void onTextChanged(CharSequence p1, int p2, int p3, int p4) {} - - @Override - public void afterTextChanged(Editable p1) { - NameErrorChecker.checkForValues( - etName.getText().toString(), ilName, dialog, stringList); - } - }); - NameErrorChecker.checkForValues(etName.getText().toString(), ilName, dialog, stringList); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/managers/DrawableManager.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/managers/DrawableManager.kt deleted file mode 100644 index 9ecd2e112b..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/managers/DrawableManager.kt +++ /dev/null @@ -1,44 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.managers - -import android.content.Context -import android.graphics.drawable.Drawable -import android.net.Uri -import org.appdevforall.codeonthego.layouteditor.utils.FileUtil.getLastSegmentFromPath -import org.appdevforall.codeonthego.layouteditor.utils.Utils -import java.io.File - -object DrawableManager { - private val items = HashMap() - - fun loadFromFiles(files: Array) { - items.clear() - - for (f in files) { - val path = f.path - var name = getLastSegmentFromPath(path) - val dotIndex = name.lastIndexOf(".") - if (dotIndex > 0) { - name = name.substring(0, dotIndex) - } - items.put(name, path) - } - } - - @JvmStatic - fun contains(name: String?): Boolean { - return items.containsKey(name) - } - - @JvmStatic - fun getDrawable(context: Context?, key: String?): Drawable? { - val path = items[key] ?: return null - return if (path.endsWith(".xml")) - Utils.getVectorDrawableAsync(context, Uri.fromFile(File(path))) - else - Drawable.createFromPath(path) - } - - fun clear() { - items.clear() - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/managers/FontManager.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/managers/FontManager.java deleted file mode 100644 index 7a6b4776e4..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/managers/FontManager.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.managers; - -import android.graphics.Typeface; - -import org.appdevforall.codeonthego.layouteditor.utils.FileUtil; - -import java.io.File; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -public class FontManager { - private static Map items = new HashMap<>(); - - public static void loadFromFiles(File[] files) { - items.clear(); - - for (File f : files) { - String path = f.getPath(); - String name = FileUtil.getLastSegmentFromPath(path); - name = name.substring(0, name.lastIndexOf(".")); - - items.put(name, path); - } - } - - public static boolean contains(String name) { - return items.containsKey(name); - } - - public static Typeface getFont(String key) { - return Typeface.createFromFile(items.get(key)); - } - - public static Set keySet() { - return items.keySet(); - } - - public static void clear() { - items.clear(); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/managers/IdManager.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/managers/IdManager.kt deleted file mode 100644 index 76d2468f7b..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/managers/IdManager.kt +++ /dev/null @@ -1,105 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.managers - -import android.view.View -import android.view.ViewGroup -import org.jetbrains.annotations.Contract - -/** This is IdManager class which is used for managing ids */ -object IdManager { - /** This is hashmap for storing view and its ids */ - @get:JvmStatic - val idMap = HashMap() - - /** - * This method is used to add new id to view - * - * @param view View to which id needs to be added - * @param id String id which needs to be added - */ - @JvmStatic - fun addNewId(view: View, id: String) { - if (!idMap.containsKey(view)) { - view.id = View.generateViewId() - } - idMap[view] = id.replace("@+id/", "") - } - - /** - * This method is used to add id to view with specified name and id - * - * @param view View to which id needs to be added - * @param idName String name of the id - * @param id Integer of the id - */ - @JvmStatic - fun addId(view: View, idName: String, id: Int) { - view.id = id - idMap[view] = idName.replace("@+id/", "") - } - - /** - * This method is used to remove the id for specified view - * - * @param view View to which id needs to be removed - * @param removeChilds Boolean value to remove childs of ViewGroup - */ - @JvmStatic - fun removeId(view: View, removeChilds: Boolean) { - idMap.remove(view) - if (removeChilds && view is ViewGroup) { - for (i in 0 until view.childCount) { - removeId(view.getChildAt(i), true) - } - } - } - - /** - * This method is used to check if id exists for specified name - * - * @param name String name of the id - * @return Boolean value true/false - */ - fun containsId(name: String): Boolean { - val mName = name.replace("@id/", "") - for (view in idMap.keys) { - if (idMap[view] == mName) { - return true - } - } - return false - } - - /** This method is used to clear the HashMap ids */ - @JvmStatic - fun clear() { - idMap.clear() - } - - /** - * This method is used to get the view id for specified name - * - * @param name String name of the id - * @return Integer of the view id - */ - @JvmStatic - fun getViewId(name: String): Int { - val mName = name.replace("@id/", "") - for (view in idMap.keys) { - if (idMap[view] == mName) { - return view.id - } - } - return -1 - } - - /** - * This method is used to get the list of ids - * - * @return List of ids - */ - @JvmStatic - @Contract(" -> new") - fun getIds(): ArrayList { - return ArrayList(idMap.values) - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/managers/PreferencesManager.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/managers/PreferencesManager.kt deleted file mode 100644 index 0d5d1017c5..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/managers/PreferencesManager.kt +++ /dev/null @@ -1,44 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.managers - -import android.content.Context -import android.content.SharedPreferences -import androidx.appcompat.app.AppCompatDelegate -import androidx.preference.PreferenceManager - -class PreferencesManager private constructor(context: Context) { - private val appContext = context.applicationContext - - val prefs: SharedPreferences by lazy { - PreferenceManager.getDefaultSharedPreferences(appContext) - } - - companion object { - @Volatile - private var INSTANCE: PreferencesManager? = null - fun getInstance(context: Context): PreferencesManager { - return INSTANCE ?: synchronized(this) { - INSTANCE ?: PreferencesManager(context).also { INSTANCE = it } - } - } - - operator fun invoke(context: Context): PreferencesManager { - return getInstance(context) - } - } - - val isEnableVibration: Boolean - get() = prefs.getBoolean(SharedPreferencesKeys.KEY_VIBRATION, false) - - val isShowStroke: Boolean - get() = prefs.getBoolean(SharedPreferencesKeys.KEY_TOGGLE_STROKE, true) - - val isApplyDynamicColors: Boolean - get() = prefs.getBoolean(SharedPreferencesKeys.KEY_DYNAMIC_COLORS, false) - - val currentTheme: Int - get() = when (prefs.getString(SharedPreferencesKeys.KEY_APP_THEME, "Auto")) { - "Light" -> AppCompatDelegate.MODE_NIGHT_NO - "Dark" -> AppCompatDelegate.MODE_NIGHT_YES - else -> AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/managers/ProjectManager.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/managers/ProjectManager.kt deleted file mode 100644 index 5cceaa69a0..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/managers/ProjectManager.kt +++ /dev/null @@ -1,97 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.managers - -import android.content.Context -import android.util.Log -import com.google.gson.Gson -import com.google.gson.reflect.TypeToken -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.withContext -import org.appdevforall.codeonthego.layouteditor.ProjectFile -import org.appdevforall.codeonthego.layouteditor.utils.Constants -import org.appdevforall.codeonthego.layouteditor.utils.FileUtil -import java.lang.reflect.Type -import java.util.Locale -import java.util.concurrent.CompletableFuture - -class ProjectManager private constructor() { - private lateinit var context: Context - private val paletteList: MutableList>> = ArrayList() - var openedProject: ProjectFile? = null - private set - - fun initManger(context: Context) { - this.context = context - CompletableFuture.runAsync { initPalette(context) } - } - - suspend fun openProject(project: ProjectFile?) = withContext(Dispatchers.IO) { - val safeProject = project ?: return@withContext - - val loadingResult = runCatching { - safeProject.drawables.let { DrawableManager.loadFromFiles(it) } - safeProject.layoutDesigns // just for the sake of creating folder - safeProject.fonts?.let { FontManager.loadFromFiles(it) } - } - withContext(Dispatchers.Main) { - loadingResult.onSuccess { - openedProject = safeProject - }.onFailure { - Log.e("ProjectManager", "Failed to load project resources", it) - throw it - } - } - } - - fun closeProject() { - openedProject = null - DrawableManager.clear() - FontManager.clear() - } - - val colorsXml: String - get() = FileUtil.readFile(openedProject!!.colorsPath) - val stringsXml: String - get() = FileUtil.readFile(openedProject!!.stringsPath) - val formattedProjectName: String - get() { - var projectName = openedProject!!.name.lowercase(Locale.getDefault()).trim { it <= ' ' } - if (projectName.contains(" ")) { - projectName = projectName.replace(" ".toRegex(), "_") - } - if (!projectName.endsWith(".xml")) { - projectName = "$projectName.xml" - } - return projectName - } - - fun getPalette(position: Int): List> { - return paletteList[position] - } - - private fun initPalette(context: Context) { - val gson = Gson() - val type = object : TypeToken?>?>() {}.type - paletteList.clear() - paletteList.add(convertJsonToJavaObject(gson, type, Constants.PALETTE_COMMON, context)) - paletteList.add(convertJsonToJavaObject(gson, type, Constants.PALETTE_TEXT, context)) - paletteList.add(convertJsonToJavaObject(gson, type, Constants.PALETTE_BUTTONS, context)) - paletteList.add(convertJsonToJavaObject(gson, type, Constants.PALETTE_WIDGETS, context)) - paletteList.add(convertJsonToJavaObject(gson, type, Constants.PALETTE_LAYOUTS, context)) - paletteList.add(convertJsonToJavaObject(gson, type, Constants.PALETTE_CONTAINERS, context)) - } - - private fun convertJsonToJavaObject( - gson: Gson, type: Type, filePath: String, context: Context - ): ArrayList> { - return gson.fromJson( - FileUtil.readFromAsset(filePath, context), type - ) - } - - companion object { - - @JvmStatic - @get:Synchronized - val instance: ProjectManager by lazy { ProjectManager() } - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/managers/SharedPreferencesKeys.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/managers/SharedPreferencesKeys.java deleted file mode 100644 index a16c045b37..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/managers/SharedPreferencesKeys.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.managers; - -public class SharedPreferencesKeys { - public static final String KEY_APP_THEME = "app_theme"; - public static final String KEY_DYNAMIC_COLORS = "dynamic_colors"; - public static final String KEY_VIBRATION = "vibration"; - public static final String KEY_TOGGLE_STROKE = "toggle_stroke"; -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/managers/UndoRedoManager.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/managers/UndoRedoManager.kt deleted file mode 100644 index d37b7326fc..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/managers/UndoRedoManager.kt +++ /dev/null @@ -1,99 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.managers - -import android.view.MenuItem - -/** UndoRedoManager class is used to add XML to history and Undo/Redo the previous changes. */ -class UndoRedoManager( - /** MenuItem for Undo Button */ - private val btnUndo: MenuItem?, - /** MenuItem for Redo Button */ - private val btnRedo: MenuItem? -) { - /** Max size of the history */ - private val maxSize = 20 - - /** History list to store the XMLs */ - private val history = arrayListOf() - - /** Index to track the current history */ - private var index = 0 - - /** - * Add XML to the history - * - * @param xml XML string to add to history - */ - fun addToHistory(xml: String) { - if (matchLastHistory(xml)) return - history.add(xml) - if (history.size == maxSize) { - history.removeAt(0) - } - index = history.size - 1 - updateButtons() - } - - /** - * To get the previous XML from the history - * - * @return Previous XML from the history - */ - fun undo(): String { - if (index > 0) { - index-- - updateButtons() - return history[index] - } - return "" - } - - /** - * To get the next XML from the history - * - * @return Next XML from the history - */ - fun redo(): String { - if (index < history.size - 1) { - index++ - updateButtons() - return history[index] - } - return "" - } - - /** To update the button's enabled state */ - fun updateButtons() { - if (btnRedo == null || btnUndo == null) return - btnUndo.icon!!.alpha = if (isUndoEnabled) 255 else 130 - btnUndo.setEnabled(isUndoEnabled) - btnRedo.icon!!.alpha = if (isRedoEnabled) 255 else 130 - btnRedo.setEnabled(isRedoEnabled) - } - - val isUndoEnabled: Boolean - /** - * To check if Undo is enabled or not - * - * @return true if undo is enabled - */ - get() = history.size > 1 && index > 0 - val isRedoEnabled: Boolean - /** - * To check if Redo is enabled or not - * - * @return true if redo is enabled - */ - get() = index < history.size - 1 - - /** - * To check if the last history is same as the current one - * - * @param xml Current XML - * @return true if last history is same as the current one - */ - private fun matchLastHistory(xml: String): Boolean { - val lastIndex = history.size - 1 - if (lastIndex < 0) return false - return xml == history[lastIndex] - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/managers/ValuesManager.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/managers/ValuesManager.java deleted file mode 100644 index c57675f397..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/managers/ValuesManager.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.managers; - -import org.appdevforall.codeonthego.layouteditor.adapters.models.ValuesItem; -import org.appdevforall.codeonthego.layouteditor.tools.ValuesResourceParser; - -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; - -public class ValuesManager { - - public static String getValueFromResources(String tag, String value, String path) { - String resValueName = value.substring(value.indexOf("/") + 1); - String result = null; - try (FileInputStream stream = new FileInputStream(path)) { - ValuesResourceParser parser = new ValuesResourceParser(stream, tag); - - for (ValuesItem item : parser.getValuesList()) { - if (item.name.equals(resValueName)) { - result = item.value; - } - } - } catch (IOException e) { - e.printStackTrace(); - } - return result; - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/tools/ColorPickerDialogFlag.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/tools/ColorPickerDialogFlag.kt deleted file mode 100644 index f619a8cb10..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/tools/ColorPickerDialogFlag.kt +++ /dev/null @@ -1,24 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.tools - -import android.annotation.SuppressLint -import android.content.Context -import android.widget.TextView -import com.skydoves.colorpickerview.AlphaTileView -import com.skydoves.colorpickerview.ColorEnvelope -import com.skydoves.colorpickerview.flag.FlagView -import org.appdevforall.codeonthego.layouteditor.R - -class ColorPickerDialogFlag(context: Context) : - FlagView(context, R.layout.layout_color_dialog_flag) { - - private val textView: TextView = findViewById(R.id.flag_color_code) - private val alphaTileView: AlphaTileView = findViewById(R.id.flag_color_layout) - - @SuppressLint("SetTextI18n") - override fun onRefresh(colorEnvelope: ColorEnvelope) { - textView.text = "#${colorEnvelope.hexCode}" - alphaTileView.setPaintColor(colorEnvelope.color) - } - - override fun onFlipped(isFlipped: Boolean) {} -} \ No newline at end of file diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/tools/ConvertToConstraintLayout.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/tools/ConvertToConstraintLayout.java deleted file mode 100644 index 7a80093072..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/tools/ConvertToConstraintLayout.java +++ /dev/null @@ -1,79 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.tools; - -import android.content.Context; -import android.util.AttributeSet; -import android.view.View; -import android.view.ViewGroup; -import android.widget.RelativeLayout; - -import androidx.constraintlayout.widget.ConstraintLayout; - -public class ConvertToConstraintLayout extends ConstraintLayout { - - public ConvertToConstraintLayout(Context context) { - super(context); - init(context, null); - } - - public ConvertToConstraintLayout(Context context, AttributeSet attrs) { - super(context, attrs); - init(context, attrs); - } - - public ConvertToConstraintLayout(Context context, AttributeSet attrs, int defStyleAttr) { - super(context, attrs, defStyleAttr); - init(context, attrs); - } - - private void init(Context context, AttributeSet attrs) { - setLayoutParams( - new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); - if (getChildCount() > 0) { - View view = getChildAt(0); - removeView(view); - addView( - view, - new LayoutParams( - ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); - } - } - - public static ConstraintLayout convertLayout(ViewGroup viewGroup) { - ConvertToConstraintLayout convertToConstraintLayout = - new ConvertToConstraintLayout(viewGroup.getContext()); - ViewGroup.LayoutParams params = viewGroup.getLayoutParams(); - viewGroup.removeView(viewGroup); - viewGroup.addView(convertToConstraintLayout, params); - for (int i = 0; i < viewGroup.getChildCount(); i++) { - View child = viewGroup.getChildAt(i); - ViewGroup.LayoutParams childParams = child.getLayoutParams(); - if (childParams instanceof RelativeLayout.LayoutParams) { - RelativeLayout.LayoutParams relativeParams = (RelativeLayout.LayoutParams) childParams; - int[] rules = relativeParams.getRules(); - ConstraintLayout.LayoutParams newParams = - new ConstraintLayout.LayoutParams(childParams.width, childParams.height); - if (rules[RelativeLayout.ALIGN_PARENT_TOP] == RelativeLayout.TRUE) { - newParams.topToTop = ConstraintLayout.LayoutParams.PARENT_ID; - } else if (rules[RelativeLayout.ALIGN_PARENT_BOTTOM] == RelativeLayout.TRUE) { - newParams.bottomToBottom = ConstraintLayout.LayoutParams.PARENT_ID; - } else if (rules[RelativeLayout.ALIGN_PARENT_LEFT] == RelativeLayout.TRUE) { - newParams.leftToLeft = ConstraintLayout.LayoutParams.PARENT_ID; - } else if (rules[RelativeLayout.ALIGN_PARENT_RIGHT] == RelativeLayout.TRUE) { - newParams.rightToRight = ConstraintLayout.LayoutParams.PARENT_ID; - } else if (rules[RelativeLayout.CENTER_HORIZONTAL] == RelativeLayout.TRUE) { - newParams.horizontalBias = 0.5f; - newParams.leftToLeft = ConstraintLayout.LayoutParams.PARENT_ID; - newParams.rightToRight = ConstraintLayout.LayoutParams.PARENT_ID; - } else if (rules[RelativeLayout.CENTER_VERTICAL] == RelativeLayout.TRUE) { - newParams.verticalBias = 0.5f; - newParams.topToTop = ConstraintLayout.LayoutParams.PARENT_ID; - newParams.bottomToBottom = ConstraintLayout.LayoutParams.PARENT_ID; - } - convertToConstraintLayout.addView(child, newParams); - } else { - convertToConstraintLayout.addView(child, childParams); - } - } - return convertToConstraintLayout; - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/tools/ImageConverter.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/tools/ImageConverter.java deleted file mode 100644 index 15f7dfd785..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/tools/ImageConverter.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.tools; - -import android.content.res.Resources; -import android.graphics.Bitmap; - -import org.appdevforall.codeonthego.layouteditor.managers.ProjectManager; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.Arrays; -import java.util.List; - -public class ImageConverter { - - public static void convertToDrawableDpis( - String name, Bitmap originalImage, List selectedDpis) throws IOException { - - String[] dpis = {"ldpi", "mdpi", "hdpi", "xhdpi", "xxhdpi", "xxxhdpi"}; - int[] sizes = {36, 48, 72, 96, 144, 192}; // Corresponding sizes for each DPI - - for (int i = 0; i < selectedDpis.size(); i++) { - String dpi = selectedDpis.get(i); - int dpiIndex = Arrays.asList(dpis).indexOf(dpi); - if (dpiIndex == -1) { - throw new IllegalArgumentException("Unsupported DPI: " + dpi); - } - // Calculate the new width and height for the desired DPI - int width = (int) (sizes[dpiIndex] * Resources.getSystem().getDisplayMetrics().density); - int height = (int) (sizes[dpiIndex] * Resources.getSystem().getDisplayMetrics().density); - - // Create new resized image bitmap - Bitmap resizedImage = Bitmap.createScaledBitmap(originalImage, width, height, true); - - // Save the resized image to the appropriate DPI folder - String outputDirectoryPath = - ProjectManager.getInstance().getOpenedProject().getPath() + "/drawable-" + dpi; - File outputDirectory = new File(outputDirectoryPath); - outputDirectory.mkdirs(); - FileOutputStream outputStream = - new FileOutputStream(outputDirectory.getAbsolutePath() + "/".concat(name)); - resizedImage.compress( - name.endsWith("png") ? Bitmap.CompressFormat.PNG : Bitmap.CompressFormat.JPEG, - 100, - outputStream); - outputStream.close(); - } - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/tools/ValuesResourceParser.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/tools/ValuesResourceParser.java deleted file mode 100644 index f8cc58b757..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/tools/ValuesResourceParser.java +++ /dev/null @@ -1,74 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.tools; - -import android.widget.TextView; - -import org.appdevforall.codeonthego.layouteditor.adapters.models.ValuesItem; -import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; -import org.xmlpull.v1.XmlPullParserFactory; - -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.List; - -public class ValuesResourceParser { - public static final String TAG_STRING = "string"; - public static final String TAG_COLOR = "color"; - - private List valuesList; - - public ValuesResourceParser(InputStream stream, String tag) { - valuesList = new ArrayList<>(); - parseXML(stream, tag); - } - - private void parseXML(InputStream stream, String tag) { - String name = ""; - String value = ""; - try { - XmlPullParserFactory factory = XmlPullParserFactory.newInstance(); - factory.setNamespaceAware(true); - XmlPullParser xpp = factory.newPullParser(); - - xpp.setInput(stream, null); - - int eventType = xpp.getEventType(); - while (eventType != XmlPullParser.END_DOCUMENT) { - if (eventType == XmlPullParser.START_TAG) { - String tagName = xpp.getName(); - if (tagName.equalsIgnoreCase(tag)) { - name = xpp.getAttributeValue(null, "name"); - } - } else if (eventType == XmlPullParser.TEXT) { - value = xpp.getText(); - } else if (eventType == XmlPullParser.END_TAG) { - String tagName = xpp.getName(); - if (tagName.equalsIgnoreCase(tag)) { - valuesList.add(new ValuesItem(name, value)); - } - } - eventType = xpp.next(); - } - // createTextView(textView); - } catch (XmlPullParserException | IOException e) { - e.printStackTrace(); - } - } - - public void createTextView(TextView textView) { - StringBuilder builder = new StringBuilder(); - for (ValuesItem item : valuesList) { - builder.append(item.name).append(" = ").append(item.value).append("\n"); - } - textView.setText(builder.toString()); - } - - public List getValuesList() { - return this.valuesList; - } - - public void setValuesList(List valuesList) { - this.valuesList = valuesList; - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/tools/XMLParserUtils.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/tools/XMLParserUtils.kt deleted file mode 100644 index 04cde33780..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/tools/XMLParserUtils.kt +++ /dev/null @@ -1,68 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.tools - -import android.content.Context -import android.view.View -import android.view.ViewGroup -import android.view.ViewGroup.LayoutParams.MATCH_PARENT -import android.view.ViewGroup.LayoutParams.WRAP_CONTENT -import android.widget.FrameLayout -import org.appdevforall.codeonthego.layouteditor.editor.initializer.AttributeMap -import org.xmlpull.v1.XmlPullParser - -object XmlParserUtils { - - fun extractAttributes(parser: XmlPullParser): AttributeMap { - val map = AttributeMap() - - for (i in 0 until parser.attributeCount) { - map.putValue( - parser.getAttributeName(i), - parser.getAttributeValue(i) - ) - } - - return map - } - - fun getAttribute( - parser: XmlPullParser, - name: String - ): String? = - (0 until parser.attributeCount) - .firstOrNull { parser.getAttributeName(it) == name } - ?.let { parser.getAttributeValue(it) } - - fun applyAttributes( - parser: XmlPullParser, - target: View, - attributeMap: MutableMap, - marker: String, - skip: String? = null - ) { - val map = attributeMap[target] ?: AttributeMap() - map.putValue(marker, "true") - - for (i in 0 until parser.attributeCount) { - val attrName = parser.getAttributeName(i) - if (attrName == skip) continue - map.putValue(attrName, parser.getAttributeValue(i)) - } - - attributeMap[target] = map - } - - fun createIncludePlaceholder( - context: Context, - attributeMap: MutableMap, - marker: String - ): View = View(context).also { - it.layoutParams = ViewGroup.LayoutParams(WRAP_CONTENT, WRAP_CONTENT) - val attrs = AttributeMap().apply { putValue(marker, "true") } - attributeMap[it] = attrs - } - - fun createMergeWrapper(context: Context): FrameLayout = - FrameLayout(context).apply { - layoutParams = ViewGroup.LayoutParams(MATCH_PARENT, WRAP_CONTENT) - } -} \ No newline at end of file diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/tools/XmlLayoutGenerator.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/tools/XmlLayoutGenerator.java deleted file mode 100644 index 67342a8893..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/tools/XmlLayoutGenerator.java +++ /dev/null @@ -1,202 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.tools; - -import android.view.View; -import android.view.ViewGroup; -import android.widget.CalendarView; -import android.widget.SearchView; - -import androidx.annotation.NonNull; - -import com.google.android.material.bottomnavigation.BottomNavigationView; -import com.google.android.material.navigation.NavigationView; -import com.google.android.material.tabs.TabLayout; - -import org.apache.commons.text.StringEscapeUtils; -import org.appdevforall.codeonthego.layouteditor.editor.DesignEditor; -import org.appdevforall.codeonthego.layouteditor.editor.initializer.AttributeMap; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Objects; - -public class XmlLayoutGenerator { - final StringBuilder builder = new StringBuilder(); - String TAB = "\t"; - boolean useSuperclasses; - - public String generate(@NonNull DesignEditor editor, boolean useSuperclasses) { - this.useSuperclasses = useSuperclasses; - - // Clear builder to avoid accumulating content from previous calls - builder.setLength(0); - - if (editor.getChildCount() == 0) { - return ""; - } - builder.append("\n"); - - peek(editor.getChildAt(0), editor.getViewAttributeMap(), 0); - return builder.toString().trim(); - } - - private void peek(View view, HashMap attributeMap, int depth) { - if (attributeMap == null || view == null) return; - - if (!attributeMap.containsKey(view)) { - if (!(view instanceof ViewGroup group)) return; - - for (int i = 0; i < group.getChildCount(); i++) { - peek(group.getChildAt(i), attributeMap, depth); - } - return; - } - - if (tryWriteInclude(view, attributeMap, depth)) { - return; - } - if (tryWriteFragment(view, attributeMap, depth)) { - return; - } - if (tryWriteMerge(view, attributeMap, depth)) { - return; - } - String indent = getIndent(depth); - - String className = getClassName(view, indent); - - List keys = - (attributeMap.get(view) != null) ? new ArrayList<>(Objects.requireNonNull(attributeMap.get(view)).keySet()) : new ArrayList<>(); - for (String key : keys) { - builder.append(TAB).append(indent).append(key).append("=\"").append(StringEscapeUtils.escapeXml11(Objects.requireNonNull(attributeMap.get(view)).getValue(key))).append("\"\n"); - } - - if (builder.charAt(builder.length() - 1) == '\n') { - builder.deleteCharAt(builder.length() - 1); - } - - if (!(view instanceof ViewGroup group) - || group instanceof CalendarView - || group instanceof SearchView - || group instanceof NavigationView - || group instanceof BottomNavigationView - || group instanceof TabLayout - || group.getChildCount() == 0) { - builder.append(" />\n\n"); - return; - } - - builder.append(">\n\n"); - int beforeLen = builder.length(); - - for (int i = 0; i < group.getChildCount(); i++) { - peek(group.getChildAt(i), attributeMap, depth + 1); - } - - if (builder.length() == beforeLen) { - builder.setLength(beforeLen - 3); - builder.append(" />\n\n"); - } else { - builder.append(indent).append("\n\n"); - } - } - - @NonNull - private String getClassName(View view, String indent) { - String className = - useSuperclasses ? view.getClass().getSuperclass().getName() : view.getClass().getName(); - - if (useSuperclasses) { - if (className.equals("android.widget.Toolbar")) { - className = "androidx.appcompat.widget.Toolbar"; - } - if (className.startsWith("android.widget.")) { - className = className.replace("android.widget.", ""); - } - } - - builder.append(indent).append("<").append(className).append("\n"); - return className; - } - - private boolean tryWriteInclude(View view, HashMap attributeMap, int depth) { - AttributeMap attrs = attributeMap.get(view); - - if (attrs != null && attrs.contains("tools:is_xml_include")) { - String indent = getIndent(depth); - builder.append(indent).append("\n\n"); - return true; - } - return false; - } - - private boolean tryWriteFragment(View view, HashMap attributeMap, int depth) { - AttributeMap attrs = attributeMap.get(view); - - if (attrs != null && attrs.contains("tools:is_xml_fragment")) { - String indent = getIndent(depth); - builder.append(indent).append("\n\n"); - return true; - } - return false; - } - - private boolean tryWriteMerge(View view, HashMap attributeMap, int depth) { - AttributeMap attrs = attributeMap.get(view); - - if (attrs != null && attrs.contains("tools:is_xml_merge")) { - String indent = getIndent(depth); - builder.append(indent).append(" 0) { - builder.append(">\n\n"); - - for (int i = 0; i < group.getChildCount(); i++) { - peek(group.getChildAt(i), attributeMap, depth + 1); - } - - builder.append(indent).append("\n\n"); - } else { - // Handle empty merge - builder.append(" />\n\n"); - } - return true; - } - return false; - } - - @NonNull - private String getIndent(int depth) { - return TAB.repeat(depth); - } -} \ No newline at end of file diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/tools/XmlLayoutParser.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/tools/XmlLayoutParser.kt deleted file mode 100644 index 4e656a926d..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/tools/XmlLayoutParser.kt +++ /dev/null @@ -1,503 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.tools - -import android.content.Context -import android.util.Log -import android.view.View -import android.view.ViewGroup -import android.widget.FrameLayout -import android.widget.HorizontalScrollView -import android.widget.ScrollView -import androidx.constraintlayout.widget.ConstraintLayout -import com.google.gson.Gson -import com.google.gson.reflect.TypeToken -import org.appdevforall.codeonthego.layouteditor.editor.initializer.AttributeInitializer -import org.appdevforall.codeonthego.layouteditor.editor.initializer.AttributeMap -import org.appdevforall.codeonthego.layouteditor.editor.positioning.restorePositionsAfterLoad -import org.appdevforall.codeonthego.layouteditor.managers.IdManager.addNewId -import org.appdevforall.codeonthego.layouteditor.managers.IdManager.clear -import org.appdevforall.codeonthego.layouteditor.R -import org.appdevforall.codeonthego.layouteditor.utils.Constants -import org.appdevforall.codeonthego.layouteditor.utils.Constants.ATTR_INITIAL_POS -import org.appdevforall.codeonthego.layouteditor.utils.FileUtil -import org.appdevforall.codeonthego.layouteditor.editor.convert.ConvertImportedXml -import org.appdevforall.codeonthego.layouteditor.utils.InvokeUtil.createView -import org.appdevforall.codeonthego.layouteditor.utils.InvokeUtil.invokeMethod -import org.xmlpull.v1.XmlPullParser -import org.xmlpull.v1.XmlPullParserException -import org.xmlpull.v1.XmlPullParserFactory -import java.io.IOException -import java.io.File -import java.io.StringReader -import androidx.core.view.isNotEmpty -import androidx.core.widget.NestedScrollView - - -sealed class ValidationResult { - object Success : ValidationResult() - data class Error(val errors: List) : ValidationResult() { - val formattedMessage: String get() = errors.joinToString(separator = "\n\n• ", prefix = "• ") - } -} - -class XmlLayoutParser( - context: Context, - private val basePath: String? = null, - private val isRoot: Boolean = true -) { - val viewAttributeMap: HashMap = HashMap() - private val validationErrors = mutableListOf() - - private val initializer: AttributeInitializer - private val listViews: MutableList = ArrayList() - - companion object { - const val MARKER_IS_INCLUDE = "tools:is_xml_include" - const val MARKER_IS_FRAGMENT = "tools:is_xml_fragment" - const val MARKER_IS_MERGE = "tools:is_xml_merge" - const val TAG = "XmlLayoutParser" - } - - enum class CustomAttrs(val key: String) { - INITIAL_POS(ATTR_INITIAL_POS), - } - - init { - val attributes = - Gson() - .fromJson>>>( - FileUtil.readFromAsset(Constants.ATTRIBUTES_FILE, context), - object : TypeToken>>>() {}.type, - ) - val parentAttributes = - Gson() - .fromJson>>>( - FileUtil.readFromAsset(Constants.PARENT_ATTRIBUTES_FILE, context), - object : TypeToken>>>() {}.type, - ) - initializer = AttributeInitializer(context, attributes, parentAttributes) - } - - val root: View? - get() = listViews.getOrNull(0) - - fun validateXml( - xml: String, - context: Context, - ): ValidationResult { - listViews.clear() - viewAttributeMap.clear() - validationErrors.clear() - if (isRoot) clear() - - return try { - val factory = XmlPullParserFactory.newInstance() - val parser = factory.newPullParser() - parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false) - parser.setInput(StringReader(xml)) - parseFromXml(parser, context) - - if (validationErrors.isEmpty()) { - ValidationResult.Success - } else { - ValidationResult.Error(validationErrors.toList()) - } - } catch (e: XmlPullParserException) { - ValidationResult.Error(listOf(context.getString(R.string.xml_error_parse, e.message ?: ""))) - } catch (e: IOException) { - ValidationResult.Error(listOf(context.getString(R.string.xml_error_io, e.message ?: ""))) - } catch (e: Exception) { - ValidationResult.Error(listOf(context.getString(R.string.xml_error_generic, e.message ?: ""))) - } - } - - fun parseFromXml() { - for ((view, map) in viewAttributeMap) { - if (map.contains("android:id")) { - addNewId(view, map.getValue("android:id")) - } - applyAttributes(view, map) - } - } - - fun processXml(xml: String, context: Context): ValidationResult { - val result = validateXml(xml, context) - - if (result is ValidationResult.Success) { - parseFromXml() - } else if (result is ValidationResult.Error) { - Log.e(TAG, "Failed to parse layout. Errors:\n${result.formattedMessage}") - } - - return result - } - - private fun parseFromXml( - parser: XmlPullParser, - context: Context, - ) { - while (parser.eventType != XmlPullParser.END_DOCUMENT) { - when (parser.eventType) { - XmlPullParser.START_TAG -> { - val tagName = parser.name - - // Skip NavigationView to avoid invalid parent crash - if (tagName == "com.google.android.material.navigation.NavigationView") { - Log.w( - TAG, - "Skipping NavigationView tag to avoid drawer hierarchy crash", - ) - parser.next() - continue - } - - var view: View? = null - - when (tagName) { - "fragment" -> { - val placeholder = FrameLayout(context).apply { - id = View.generateViewId() - layoutParams = ViewGroup.LayoutParams( - ViewGroup.LayoutParams.MATCH_PARENT, - ViewGroup.LayoutParams.MATCH_PARENT, - ) - } - - val attrs = AttributeMap() - for (i in 0 until parser.attributeCount) { - attrs.putValue(parser.getAttributeName(i), parser.getAttributeValue(i)) - } - attrs.putValue(MARKER_IS_FRAGMENT, "true") - - viewAttributeMap[placeholder] = attrs - listViews.add(placeholder) - - parser.next() - continue - } - - "include" -> { - val layoutAttr = - XmlParserUtils.getAttribute(parser, "layout") - - val includedView = loadIncludedLayout( - context, - basePath, - layoutAttr - ) - - val view = - includedView ?: XmlParserUtils.createIncludePlaceholder( - context, - viewAttributeMap, - MARKER_IS_INCLUDE - ) - - listViews.add(view) - - XmlParserUtils.applyAttributes( - parser = parser, - target = view, - attributeMap = viewAttributeMap, - marker = MARKER_IS_INCLUDE, - skip = if (includedView != null) null else "layout" - ) - - parser.next() - continue - } - - "merge" -> { - - val wrapper = - XmlParserUtils.createMergeWrapper(context) - - applyMergeAttributes( - parser = parser, - target = wrapper, - attributeMap = viewAttributeMap, - marker = MARKER_IS_MERGE - ) - - listViews.add(wrapper) - } - - else -> { - val result = createView(tagName, context) - if (result is Exception) { - throw result - } else { - view = result as? View - view?.let { - if (listViews.isEmpty()) { - it.layoutParams = ViewGroup.LayoutParams( - ViewGroup.LayoutParams.WRAP_CONTENT, - ViewGroup.LayoutParams.WRAP_CONTENT, - ) - } - listViews.add(it) - } - } - } - } - - if (view != null) { - val map = AttributeMap() - for (i in 0 until parser.attributeCount) { - val fullName = parser.getAttributeName(i) - val value = parser.getAttributeValue(i) - map.putValue(fullName, value) - } - viewAttributeMap[view] = map - } - } - - /** - * This method is responsible for: - * 1) Finding ViewGroups.(that's why we are looking for end tag) - * 2) Adding view to ViewGroup as a child.(viewGroup.addView) - * 3) Removing the view that was added to it's parent from the list. As it is now stored in the parent, - * and we do not need it in the list anymore. - * END_TAG event is triggered when we reach the end of each ViewGroup. Top to bottom. Root ViewGroup is - * triggered last. - * - * * Min XML depth for this scenario is 2. File = 0 -> ViewGroup = 1 -> View = 2 - * - * Therefore we are not interested in anything with depth < 2. - * - * Let's assume depth is 3. File -> LinearLayout -> ConstraintLayout -> View - * depth - 2 = 1. This will bring us to the correct parent. - * depth - 1 = 1. This will bring us to correct child. - * - * After adding View to ConstraintLayout, View is removed from the listViews and is considered finished. - * This process will repeat until all Views and ViewGroups will be added to corresponding parents and list - * view will become empty. - */ - - XmlPullParser.END_TAG -> run { - val depth = parser.depth - if (depth < 2 || listViews.size < 2) return@run - - val parent = listViews.getOrNull(depth - 2) as? ViewGroup ?: return@run - val child = listViews.getOrNull(depth - 1) ?: return@run - - parent.tryAddChild(child) - listViews.removeAt(depth - 1) - } - } - parser.next() - } - - root?.let { - restorePositionsAfterLoad(it, viewAttributeMap) - } - } - - private fun ViewGroup.tryAddChild(child: View) { - if (isSingleChildContainer() && isNotEmpty()) { - val errorMsg = context.getString( - R.string.xml_error_single_child_container, - this::class.simpleName - ) - Log.w(TAG, errorMsg) - validationErrors.add(errorMsg) - viewAttributeMap.remove(child) - return - } - - runCatching { - addView(child) - }.onFailure { e -> - val errorMsg = context.getString( - R.string.xml_error_add_child_failed, - child::class.simpleName, - this::class.simpleName - ) - Log.e(TAG, errorMsg, e) - validationErrors.add(errorMsg) - viewAttributeMap.remove(child) - } - } - - private fun ViewGroup.isSingleChildContainer(): Boolean { - return this is ScrollView || this is HorizontalScrollView || this is NestedScrollView - } - - private fun applyInitialPosition(target: View, attrs: AttributeMap) { - if (attrs.contains("android:layout_marginStart")) return - - val initialPosition = attrs.getValue(ATTR_INITIAL_POS) - if (shouldCenter(initialPosition, target)) { - applyBaseCenterConstraints(target, attrs) - centerAfterLayout(target, attrs) - } - } - - private fun applyCustomAttributes( - target: View, - attributeMap: AttributeMap - ) { - CustomAttrs.entries.forEach { attr -> - if (!attributeMap.contains(attr.key)) return@forEach - - when (attr) { - CustomAttrs.INITIAL_POS -> - applyInitialPosition(target, attributeMap) - } - } - } - - private fun applyAttributes( - target: View, - attributeMap: AttributeMap, - ) { - val allAttrs = initializer.getAllAttributesForView(target) - - val keys = attributeMap.keySet() - - applyCustomAttributes(target, attributeMap) - - for (i in keys.indices.reversed()) { - val key = keys[i] - - if (key == "android:id") { - continue - } - - val attr = initializer.getAttributeFromKey(key, allAttrs) - if (attr == null) { - Log.w( - TAG, - "Could not find attribute $key for view ${target.javaClass.simpleName}", - ) - continue - } - - val methodName = attr[Constants.KEY_METHOD_NAME].toString() - val className = attr[Constants.KEY_CLASS_NAME].toString() - val value = attributeMap.getValue(key) - - Log.d(TAG, "Applying attribute $key to view $target with value $value") - invokeMethod(methodName, className, target, value, target.context) - } - } - - private fun shouldCenter(initialPosition: String?, target: View): Boolean { - return initialPosition == "center" && target.parent is ConstraintLayout - } - - private fun applyBaseCenterConstraints( - target: View, - attributeMap: AttributeMap - ) { - val params = (target.layoutParams as? ConstraintLayout.LayoutParams) ?: return - - params.apply { - startToStart = ConstraintLayout.LayoutParams.PARENT_ID - topToTop = ConstraintLayout.LayoutParams.PARENT_ID - endToEnd = ConstraintLayout.LayoutParams.UNSET - bottomToBottom = ConstraintLayout.LayoutParams.UNSET - setMargins(0, 0, 0, 0) - } - target.layoutParams = params - - attributeMap.apply { - putValue("app:layout_constraintStart_toStartOf", "parent") - putValue("app:layout_constraintTop_toTopOf", "parent") - - removeValue("app:layout_constraintEnd_toEndOf") - removeValue("app:layout_constraintBottom_toBottomOf") - removeValue("app:layout_constraintHorizontal_bias") - removeValue("app:layout_constraintVertical_bias") - } - } - - private fun centerAfterLayout( - target: View, - attributeMap: AttributeMap - ) { - target.post { - val parent = target.parent as View - if (parent.width <= 0 || parent.height <= 0) return@post - - val centeredX = (parent.width - target.width) / 2 - val centeredY = (parent.height - target.height) / 2 - - val layoutParams = (target.layoutParams as? ConstraintLayout.LayoutParams) ?: return@post - - layoutParams.apply { - marginStart = centeredX - topMargin = centeredY - }.also { target.layoutParams = it } - - val density = target.resources.displayMetrics.density - val startDp = (centeredX / density).toInt() - val topDp = (centeredY / density).toInt() - - attributeMap.putValue("android:layout_marginStart", "${startDp}dp") - attributeMap.putValue("android:layout_marginTop", "${topDp}dp") - } - } - - fun loadIncludedLayout( - context: Context, - basePath: String?, - layoutAttr: String? - ): View? { - if (layoutAttr == null || basePath == null) { - Log.w( - TAG, - "Skipping include. layoutAttr=$layoutAttr basePath=$basePath" - ) - return null - } - - val layoutName = layoutAttr.substringAfterLast("/") - val file = File(basePath, "$layoutName.xml") - - if (!file.exists()) { - Log.e( - TAG, - "Included file not found: ${file.absolutePath}" - ) - return null - } - - return try { - val xml = file.readText() - - val converted = ConvertImportedXml(xml).getXmlConverted(context) ?: xml - - val parser = XmlLayoutParser(context, basePath, false) - - val result = parser.processXml(converted, context) - if (result is ValidationResult.Error) { - Log.e(TAG, "Included layout has errors: ${result.formattedMessage}") - return null - } - - parser.root - } catch (e: Exception) { - Log.e( - TAG, - "Failed to parse include: $layoutName", - e - ) - null - } - } - - fun applyMergeAttributes( - parser: XmlPullParser, - target: View, - attributeMap: MutableMap, - marker: String - ) { - val map = XmlParserUtils.extractAttributes(parser) - - map.putValue(marker, "true") - map.putValue("android:layout_width", "match_parent") - map.putValue("android:layout_height", "wrap_content") - - attributeMap[target] = map - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/utils/ArgumentUtil.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/utils/ArgumentUtil.kt deleted file mode 100644 index 03e6f291dd..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/utils/ArgumentUtil.kt +++ /dev/null @@ -1,40 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.utils - -import java.util.regex.Pattern - -/** This class holds all utility methods related to arguments */ -object ArgumentUtil { - /** Default color value */ - const val COLOR = "color" - - /** Default drawable value */ - const val DRAWABLE = "drawable" - const val STRING = "string" - - /** Map used to store the patterns of color and drawable */ - val patterns = HashMap() - - init { - patterns[COLOR] = "#[a-fA-F0-9]{6,8}" - patterns[DRAWABLE] = "@drawable/.*" - patterns[STRING] = "@string/.*" - } - - /** - * Method to parse the type of the value from given list of variants - * - * @param value The value to be parsed - * @param variants The list of variants from which type should be parsed - * @return The type of the value - */ - @JvmStatic - fun parseType(value: String?, variants: Array): String { - for (variant in variants) { - if (patterns.containsKey(variant)) if (Pattern.matches( - patterns[variant], value - ) - ) return variant - } - return "text" - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/utils/BitmapUtil.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/utils/BitmapUtil.kt deleted file mode 100644 index f28bee1a63..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/utils/BitmapUtil.kt +++ /dev/null @@ -1,249 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.utils - -import android.content.Context -import android.graphics.Bitmap -import android.graphics.Bitmap.Config.ARGB_8888 -import android.graphics.BitmapFactory -import android.graphics.Canvas -import android.graphics.Color -import android.graphics.drawable.AdaptiveIconDrawable -import android.graphics.drawable.BitmapDrawable -import android.graphics.drawable.ColorDrawable -import android.graphics.drawable.Drawable -import android.net.Uri -import android.view.View -import android.widget.ImageView -import android.widget.TextView -import androidx.cardview.widget.CardView -import androidx.core.content.ContextCompat -import androidx.core.graphics.ColorUtils -import androidx.palette.graphics.Palette -import java.io.IOException - -/** Utility class for manipulating bitmaps */ -object BitmapUtil { - /** - * Sets a tint on an [ImageView] according to the background color of a [View] - * - * @param imageView the ImageView whose tint will be set - * @param background the view whose background color will be used to determine the tint - */ - @JvmStatic - fun setImageTintAccordingToBackground(imageView: ImageView, background: View) { - // Check if the background View is a CardView - val backgroundColor: Int = if (background is CardView) { - // Get the color from the CardView - background.cardBackgroundColor.defaultColor - // Check if the background View is a ColorDrawable - } else if (background.background is ColorDrawable) { - (background.background as ColorDrawable).color - } else { - // Throw an exception if the background View is not a ColorDrawable - throw IllegalArgumentException("Background must be a ColorDrawable") - } - - // Calculate the luminance from the background color - val luminance = ColorUtils.calculateLuminance(backgroundColor) - // Set the image color to black or white depending on the luminance - if (luminance >= 0.5) { - imageView.setColorFilter(Color.BLACK) - } else { - imageView.setColorFilter(Color.WHITE) - } - } - - /** - * Sets a background color on a [View] according to an [ImageView] - * - * @param context the context - * @param view the view whose background color will be set - * @param image the ImageView whose color will be used to determine the background color - */ - fun setBackgroundAccordingToImage(context: Context?, view: View, image: ImageView) { - val drawable = image.drawable - setBackgroundAccordingToImage(context, view, drawable) - } - - /** - * Inverts a color by subtracting each color channel from 255 - * - * @param color the color to invert - * @return the inverted color - */ - fun invertColor(color: Int): Int { - val r = Color.red(color) - val g = Color.green(color) - val b = Color.blue(color) - return Color.rgb(255 - r, 255 - g, 255 - b) - } - - /** - * Sets the text color of the TextView according to the background color provided. - * - * @param background The background color to use to determine the text color. - * @param textView The TextView whose text color needs to be set. - */ - @JvmStatic - fun setTextColorAccordingToBackground(background: View, textView: TextView) { - val backgroundColor: Int = if (background is CardView) { - // Get the color from the CardView - background.cardBackgroundColor.defaultColor - } else if (background.background is ColorDrawable) { - (background.background as ColorDrawable).color - } else { - // Throw an exception if the background View is not a ColorDrawable - throw IllegalArgumentException("Background must be a ColorDrawable") - } - - // Calculate the luminance from the background color - val luminance = ColorUtils.calculateLuminance(backgroundColor) - // Set the text color to black or white depending on the luminance - if (luminance >= 0.5) { - textView.setTextColor(Color.BLACK) - } else { - textView.setTextColor(Color.WHITE) - } - } - - @JvmStatic - fun getLuminance(view: View): Double { - val backgroundColor: Int = if (view is CardView) { - // Get the color from the CardView - view.cardBackgroundColor.defaultColor - } else if (view.background is ColorDrawable) { - (view.background as ColorDrawable).color - } else { - // Throw an exception if the background View is not a ColorDrawable - throw IllegalArgumentException("Background must be a ColorDrawable") - } - - // Calculate the luminance from the background color - return ColorUtils.calculateLuminance(backgroundColor) - } - - /** - * Merges two bitmaps into a single bitmap - * - * @param background the background bitmap - * @param foreground the foreground bitmap - * @return the merged bitmap - */ - fun mergeBitmaps(background: Bitmap, foreground: Bitmap): Bitmap? { - // Create a new Bitmap with the width and height of the background - val width = background.width - val height = background.height - val mergedBitmap = background.config?.let { Bitmap.createBitmap(width, height, it) } - - // Create a Canvas object with the new Bitmap - val canvas = mergedBitmap?.let { - Canvas(it).apply { - // Draw the background on the Canvas - drawBitmap(background, 0f, 0f, null) - - // Draw the foreground on the Canvas in the center of the background - drawBitmap( - foreground, - ((width - foreground.width) / 2).toFloat(), - ((height - foreground.height) / 2).toFloat(), - null - ) - } - } - - // Return the merged Bitmap - return mergedBitmap - } - - /** - * Sets a background color on a [View] according to a [Drawable] - * - * @param context the context - * @param view the view whose background color will be set - * @param drawable the Drawable whose color will be used to determine the background color - */ - fun setBackgroundAccordingToImage(context: Context?, view: View, drawable: Drawable?) { - // Check the drawable type - val bitmap: Bitmap? = when (drawable) { - is BitmapDrawable -> { - // Get the bitmap from the BitmapDrawable - drawable.bitmap - } - - is AdaptiveIconDrawable -> { - // Get the background and foreground drawables from the AdaptiveIconDrawable - val backgroundDr = drawable.background - val foregroundDr = drawable.foreground - // Get the bitmaps from the drawables - val background = (backgroundDr as BitmapDrawable).bitmap - val foreground = (foregroundDr as BitmapDrawable).bitmap - // Merge the bitmaps - mergeBitmaps(background, foreground) - } - - else -> { - // Handle other drawable types as needed - return - } - } - - // Generate a palette from the bitmap - bitmap?: return - val palette = Palette.from(bitmap).generate() - - // Get the background color from the palette - val backgroundColor: Int = when { - palette.getDarkVibrantColor(0) != 0 -> { - palette.getDarkVibrantColor(0) - } - - palette.getDarkMutedColor(0) != 0 -> { - palette.getDarkMutedColor(0) - } - - palette.getLightVibrantColor(0) != 0 -> { - palette.getLightVibrantColor(0) - } - - palette.getLightMutedColor(0) != 0 -> { - palette.getLightMutedColor(0) - } - - palette.getVibrantColor(0) != 0 -> { - palette.getVibrantColor(0) - } - - palette.getMutedColor(0) != 0 -> { - palette.getMutedColor(0) - } - - else -> { - ContextCompat.getColor(context!!, android.R.color.white) - } - } - - // Set the background color of the view - if (view is CardView) { - view.setCardBackgroundColor(backgroundColor) - } else { - view.setBackgroundColor(backgroundColor) - } - } - - @JvmStatic - fun createBitmapFromView(view: View): Bitmap { - val bitmap = Bitmap.createBitmap(view.width, view.height, ARGB_8888) - val canvas = Canvas(bitmap) - view.draw(canvas) - return bitmap - } - - @Throws(IOException::class) - fun loadBitmapFromUri(context: Context, uri: Uri): Bitmap? { - val inputStream = context.contentResolver.openInputStream(uri) - val options = BitmapFactory.Options() - options.inPreferredConfig = ARGB_8888 - val bitmap = BitmapFactory.decodeStream(inputStream, null, options) - inputStream!!.close() - return bitmap - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/utils/Constants.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/utils/Constants.kt deleted file mode 100644 index 2d58be84d5..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/utils/Constants.kt +++ /dev/null @@ -1,159 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.utils - -import android.graphics.Color -import android.graphics.Typeface -import android.os.Build -import android.text.InputType -import android.view.Gravity -import android.view.View - -object Constants { - const val CURRENT_LAYOUT: String = "currentLayout" - const val CURRENT_LAYOUT_DESIGN: String = "currentLayoutDesign" - const val ATTR_INITIAL_POS = "tools:layout_initialPosition" - - @JvmField - val gravityMap = HashMap() - @JvmField - val inputTypes = HashMap() - @JvmField - val imeOptions = HashMap() - @JvmField - val visibilityMap = HashMap() - @JvmField - val textStyleMap = HashMap() - const val ATTRIBUTES_FILE = "attributes/attributes.json" - const val PARENT_ATTRIBUTES_FILE = "attributes/parent_attributes.json" - const val PALETTE_COMMON = "palette/common.json" - const val PALETTE_TEXT = "palette/text.json" - const val PALETTE_BUTTONS = "palette/buttons.json" - const val PALETTE_WIDGETS = "palette/widgets.json" - const val PALETTE_LAYOUTS = "palette/layouts.json" - const val PALETTE_CONTAINERS = "palette/containers.json" - const val TAB_TITLE_VIEWS = "Views" - const val TAB_TITLE_ANDROIDX = "AndroidX" - const val TAB_TITLE_MATERIAL = "Material Design" - const val TAB_TITLE_COMMON = "Common" - const val TAB_TITLE_TEXT = "Text" - const val TAB_TITLE_BUTTONS = "Buttons" - const val TAB_TITLE_WIDGETS = "Widgets" - const val TAB_TITLE_LAYOUTS = "Layouts" - const val TAB_TITLE_CONTAINERS = "Containers" - const val TAB_TITLE_GOOGLE = "Google" - const val TAB_TITLE_LEGACY = "Legacy" - const val KEY_ATTRIBUTE_NAME = "attributeName" - const val KEY_CLASS_NAME = "className" - const val KEY_METHOD_NAME = "methodName" - const val KEY_ARGUMENT_TYPE = "argumentType" - const val KEY_CAN_DELETE = "canDelete" - const val KEY_CONSTANT = "constant" - const val KEY_DEFAULT_VALUE = "defaultValue" - const val KEY_DEFAULT_ATTRS = "defaultAttributes" - const val ARGUMENT_TYPE_SIZE = "size" - const val ARGUMENT_TYPE_DIMENSION = "dimension" - const val ARGUMENT_TYPE_ID = "id" - const val ARGUMENT_TYPE_VIEW = "view" - const val ARGUMENT_TYPE_BOOLEAN = "boolean" - const val ARGUMENT_TYPE_DRAWABLE = "drawable" - const val ARGUMENT_TYPE_STRING = "string" - const val ARGUMENT_TYPE_TEXT = "text" - const val ARGUMENT_TYPE_INT = "int" - const val ARGUMENT_TYPE_FLOAT = "float" - const val ARGUMENT_TYPE_FLAG = "flag" - const val ARGUMENT_TYPE_ENUM = "enum" - const val ARGUMENT_TYPE_COLOR = "color" - const val BLUEPRINT_DASH_COLOR = Color.WHITE - @JvmField - val BLUEPRINT_BACKGROUND_COLOR = Color.parseColor("#235C6F") - @JvmField - val DESIGN_DASH_COLOR = Color.parseColor("#1689F6") - const val DESIGN_BACKGROUND_COLOR = Color.WHITE - const val GITHUB_URL = "https://github.com/itsvks19/LayoutEditor" - const val EXTRA_KEY_PROJECT = "project" - const val EXTRA_KEY_LAYOUT = "layout" - - //Path and project keys when passed with intend from beyound - const val EXTRA_KEY_FILE_PATH = "EXTRA_KEY_FILE_PATH" - const val EXTRA_KEY_LAYOUT_FILE_NAME = "EXTRA_KEY_LAYOUT_FILE_NAME" - - init { - gravityMap["left"] = Gravity.START - gravityMap["right"] = Gravity.END - gravityMap["top"] = Gravity.TOP - gravityMap["bottom"] = Gravity.BOTTOM - gravityMap["center"] = Gravity.CENTER - gravityMap["center_horizontal"] = Gravity.CENTER_HORIZONTAL - gravityMap["center_vertical"] = Gravity.CENTER_VERTICAL - gravityMap["fill"] = Gravity.FILL - gravityMap["fill_horizontal"] = Gravity.FILL_HORIZONTAL - gravityMap["fill_vertical"] = Gravity.FILL_VERTICAL - gravityMap["clip_horizontal"] = Gravity.CLIP_HORIZONTAL - gravityMap["clip_vertical"] = Gravity.CLIP_VERTICAL - gravityMap["start"] = Gravity.START - gravityMap["end"] = Gravity.END - - inputTypes["date"] = - InputType.TYPE_DATETIME_VARIATION_DATE - inputTypes["datetime"] = InputType.TYPE_CLASS_DATETIME - inputTypes["none"] = InputType.TYPE_NULL - inputTypes["number"] = InputType.TYPE_CLASS_NUMBER - inputTypes["numberDecimal"] = InputType.TYPE_NUMBER_FLAG_DECIMAL - inputTypes["numberSigned"] = - InputType.TYPE_NUMBER_FLAG_SIGNED - inputTypes["numberPassword"] = - InputType.TYPE_NUMBER_VARIATION_PASSWORD - inputTypes["phone"] = InputType.TYPE_CLASS_PHONE - inputTypes["text"] = InputType.TYPE_CLASS_TEXT - inputTypes["textAutoComplete"] = - InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE - inputTypes["textAutoCorrect"] = - InputType.TYPE_TEXT_FLAG_AUTO_CORRECT - inputTypes["textCapCharacters"] = - InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS - inputTypes["textCapSentences"] = InputType.TYPE_TEXT_FLAG_CAP_SENTENCES - inputTypes["textCapWords"] = InputType.TYPE_TEXT_FLAG_CAP_WORDS - inputTypes["textEmailAddress"] = InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS - inputTypes["textEmailSubject"] = InputType.TYPE_TEXT_VARIATION_EMAIL_SUBJECT - inputTypes["textFilter"] = - InputType.TYPE_TEXT_VARIATION_FILTER - inputTypes["textImeMultiLine"] = InputType.TYPE_TEXT_FLAG_IME_MULTI_LINE - inputTypes["textLongMessage"] = InputType.TYPE_TEXT_VARIATION_LONG_MESSAGE - inputTypes["textMultiLine"] = - InputType.TYPE_TEXT_FLAG_MULTI_LINE - inputTypes["textNoSuggestions"] = - InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS - inputTypes["textPassword"] = - InputType.TYPE_TEXT_VARIATION_PASSWORD - inputTypes["textPersonName"] = InputType.TYPE_TEXT_VARIATION_PERSON_NAME - inputTypes["textPhonetic"] = - InputType.TYPE_TEXT_VARIATION_PHONETIC - inputTypes["textPostalAddress"] = InputType.TYPE_TEXT_VARIATION_POSTAL_ADDRESS - inputTypes["textShortMessage"] = InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE - inputTypes["textUri"] = - InputType.TYPE_TEXT_VARIATION_URI - inputTypes["textVisiblePassword"] = InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD - inputTypes["textWebEditText"] = - InputType.TYPE_TEXT_VARIATION_WEB_EDIT_TEXT - inputTypes["textWebEmailAddress"] = - InputType.TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS - inputTypes["textWebPassword"] = - InputType.TYPE_TEXT_VARIATION_WEB_PASSWORD - inputTypes["time"] = - InputType.TYPE_DATETIME_VARIATION_TIME - - // Add Tiramisu-specific input types conditionally - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { - inputTypes["textEnableTextConversionSuggestions"] = - InputType.TYPE_TEXT_FLAG_ENABLE_TEXT_CONVERSION_SUGGESTIONS - } - - visibilityMap["visible"] = View.VISIBLE - visibilityMap["invisible"] = View.INVISIBLE - visibilityMap["gone"] = View.GONE - - textStyleMap["normal"] = Typeface.NORMAL - textStyleMap["bold"] = Typeface.BOLD - textStyleMap["italic"] = Typeface.ITALIC - textStyleMap["bold|italic"] = Typeface.BOLD_ITALIC - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/utils/DimensionUtil.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/utils/DimensionUtil.kt deleted file mode 100644 index 9b25ac791e..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/utils/DimensionUtil.kt +++ /dev/null @@ -1,96 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.utils - -import android.content.Context -import android.util.TypedValue -import android.view.ViewGroup -import java.util.regex.Pattern - -/** - * This class is used to perform Dimension Utility operations. - */ -object DimensionUtil { - /** - * Constant variable for Dimension Unit type DP - */ - const val DP: String = "dp" - - /** - * Constant variable for Dimension Unit type SP - */ - const val SP: String = "sp" - - /** - * A map containing dimension unit type and its related integer value - */ - private val dimensMap = HashMap() - - // Initializing dimensMap with Dimension Unit type and its related integer value - init { - dimensMap[DP] = TypedValue.COMPLEX_UNIT_DIP - dimensMap[SP] = TypedValue.COMPLEX_UNIT_SP - } - - /** - * Pattern for matching Dimension Unit type - */ - private val pattern: Pattern = Pattern.compile("dp|sp") - - /** - * Method to parse the input string and return the related dimension value - * - * @param input string for parsing - * @param contxt context - * @return dimension value - */ - @JvmStatic - fun parse(input: String, contxt: Context): Float { - when (input) { - "match_parent" -> return ViewGroup.LayoutParams.MATCH_PARENT.toFloat() - "wrap_content" -> return ViewGroup.LayoutParams.WRAP_CONTENT.toFloat() - else -> { - val matcher = pattern.matcher(input) - var dimen = DP - - // Finding dimension unit type from input string - while (matcher.find()) { - dimen = input.substring(matcher.start(), matcher.end()) - } - - // Getting dimension number from input string - val number = input.substring(0, input.lastIndexOf(dimen)).toFloat() - - - // Returning calculated dimension value - return TypedValue.applyDimension( - dimensMap[dimen]!!, number, contxt.resources.displayMetrics - ) - } - } - } - - /** - * Method to get the dimension value without the suffix, i.e Dimension Unit type - * - * @param input string for parsing - * @return dimension value without suffix - */ - @JvmStatic - fun getDimenWithoutSuffix(input: String): String = when { - input.endsWith(DP) -> input.removeSuffix(DP) - input.endsWith(SP) -> input.removeSuffix(SP) - else -> input - } - - /** - * Method to get the dimension value in DIP - * - * @param value dimension number - * @param ctx context - * @return dimension value in DIP - */ - fun getDip(value: Float, ctx: Context): Float { - return TypedValue.applyDimension( - TypedValue.COMPLEX_UNIT_DIP, value, ctx.resources.displayMetrics - ) - } -} \ No newline at end of file diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/utils/FileCreator.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/utils/FileCreator.kt deleted file mode 100644 index 7d4838f1e5..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/utils/FileCreator.kt +++ /dev/null @@ -1,47 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.utils - -import android.net.Uri -import androidx.activity.result.ActivityResultLauncher -import androidx.activity.result.contract.ActivityResultContracts -import androidx.appcompat.app.AppCompatActivity - -/** - * FileCreator Class is used to create a file with given name and MIME Type. - */ -abstract class FileCreator(actvty: AppCompatActivity) { - /** To create a file */ - private val createFile: ActivityResultLauncher - - /** MIME Type of file */ - private var mimeType = "*/*" - - /** - * Constructor of class - * - * @param actvty Instance of AppCompatActivity - */ - init { - // Set MIME type - // Register activity result for CreateDocument - this.createFile = - actvty.registerForActivityResult( - ActivityResultContracts.CreateDocument(mimeType) - ) { onCreateFile(it) } - } - - /** - * Abstract method onCreateFile to call on result - */ - abstract fun onCreateFile(uri: Uri) - - /** - * Method to create file - * - * @param fileName The name of the file - * @param mimeType The MIME type of the file - */ - fun create(fileName: String, mimeType: String) { - this.mimeType = mimeType // Set MIME type - createFile.launch(fileName) // Launch file - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/utils/FilePicker.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/utils/FilePicker.kt deleted file mode 100644 index 2a6034c699..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/utils/FilePicker.kt +++ /dev/null @@ -1,84 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.utils - -import android.Manifest -import android.content.pm.PackageManager -import android.net.Uri -import androidx.activity.result.ActivityResultLauncher -import androidx.activity.result.contract.ActivityResultContracts -import androidx.appcompat.app.AppCompatActivity -import org.appdevforall.codeonthego.layouteditor.LayoutEditor.Companion.instance -import org.appdevforall.codeonthego.layouteditor.R -import org.appdevforall.codeonthego.layouteditor.utils.SBUtils.Companion.make - -/** - * Class for FilePicker - */ -abstract class FilePicker(private val actvty: AppCompatActivity) { - private val getFile: ActivityResultLauncher - private val reqPermission: ActivityResultLauncher - - /** - * Constructor for FilePicker, takes in an AppCompatActivity as a parameter - * - * @param actvty AppCompatActivity instance - */ - init { - // Create an instance of ActivityResultContracts.GetContent and register it with actvty - // when the result is returned, call the onPickFile method with the returned uri - this.getFile = - actvty.registerForActivityResult( - ActivityResultContracts.GetContent() - ) { onPickFile(it) } - - // Create an instance of ActivityResultContracts.RequestPermission and register it with actvty - // when the result is returned, call the onRequestPermission method with the granted boolean - this.reqPermission = - actvty.registerForActivityResult( - ActivityResultContracts.RequestPermission() - ) { onRequestPermission(it) } - } - - private fun onRequestPermission(isGranted: Boolean) { - if (isGranted) make(actvty.findViewById(android.R.id.content), R.string.permission_granted) - .setSlideAnimation() - .showAsSuccess() - else make(actvty.findViewById(android.R.id.content), R.string.permission_denied) - .setSlideAnimation() - .showAsError() - } - - /** - * Abstract method called onPickFile, takes in a Nullable Uri as a parameter - * - * @param uri Nullable Uri - */ - abstract fun onPickFile(uri: Uri?) - - /** - * Method launch, takes in a String MIME type as a parameter - */ - fun launch(mimeType: String) { - checkPermissions(mimeType) - // If the app has the permission, launch the getFile instance - getFile.launch(mimeType) - } - - private fun checkPermissions(mimeType: String) { - val isImageType = - mimeType == "image/*" || mimeType == "image/png" || mimeType == "image/jpg" || mimeType == "image/jpeg" - - if (isImageType) { - if (instance!!.isAtLeastTiramisu) { - if (actvty.checkSelfPermission(Manifest.permission.READ_MEDIA_IMAGES) - == PackageManager.PERMISSION_DENIED - ) { - reqPermission.launch(Manifest.permission.READ_MEDIA_IMAGES) - } - } else if (actvty.checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) - == PackageManager.PERMISSION_DENIED - ) { - reqPermission.launch(Manifest.permission.READ_EXTERNAL_STORAGE) - } - } - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/utils/FileUtil.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/utils/FileUtil.kt deleted file mode 100644 index 4ea5ea8980..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/utils/FileUtil.kt +++ /dev/null @@ -1,682 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.utils - -import android.annotation.SuppressLint -import android.content.ContentResolver -import android.content.Context -import android.net.Uri -import android.os.Environment -import android.provider.DocumentsContract -import android.provider.MediaStore -import android.text.TextUtils -import com.blankj.utilcode.util.ToastUtils -import com.itsaky.androidide.eventbus.events.editor.ReportCaughtExceptionEvent -import org.appdevforall.codeonthego.layouteditor.LayoutEditor.Companion.instance -import org.greenrobot.eventbus.EventBus -import java.io.BufferedReader -import java.io.ByteArrayOutputStream -import java.io.File -import java.io.FileInputStream -import java.io.FileOutputStream -import java.io.FileReader -import java.io.FileWriter -import java.io.IOException -import java.io.InputStream -import java.io.InputStreamReader -import java.io.OutputStream -import java.net.URLDecoder -import java.nio.file.Files -import java.nio.file.Paths - -private const val BUFFER_SIZE = 1024 - -object FileUtil { - fun readFromUri(uri: Uri, context: Context): String? { - try { - val inputStream = context.contentResolver.openInputStream(uri) - - // Creates a BufferedReader to read the contents of the InputStream - val reader = BufferedReader(InputStreamReader(inputStream)) - - // Creates a StringBuilder to store the file's contents - val sb = StringBuilder() - var line: String? - - // Reads each line from the file and adds it to StringBuilder - while ((reader.readLine().also { line = it }) != null) { - sb.append(line) - } - - // Closes the InputStream and the BufferedReader - inputStream!!.close() - reader.close() - - // Returns the string containing the content of the XML file - return sb.toString() - } catch (e: Exception) { - e.printStackTrace() - } - - return null - } - - @JvmStatic - fun copyFile(uri: Uri, destinationPath: String, context: Context): Boolean { - var inputStream: InputStream? = null - var outputStream: OutputStream? = null - - try { - inputStream = context.contentResolver.openInputStream(uri) - outputStream = FileOutputStream(File(destinationPath)) - - val buffer = ByteArray(BUFFER_SIZE) - var length: Int - - while ((inputStream!!.read(buffer).also { length = it }) > 0) { - outputStream.write(buffer, 0, length) - } - - return true - } catch (e: IOException) { - e.printStackTrace() - ToastUtils.showLong(e.toString()) - - EventBus.getDefault().post( - ReportCaughtExceptionEvent( - throwable = e, - message = "copyFile failed", - extras = mapOf( - "module" to "layouteditor", - "where" to "utils.FileUtil.copyFile", - "dest" to destinationPath, - "uri" to uri.toString() - ) - ) - ) - - return false - } finally { - try { - inputStream?.close() - outputStream?.close() - } catch (e: Exception) { - e.printStackTrace() - ToastUtils.showLong(e.toString()) - EventBus.getDefault().post( - ReportCaughtExceptionEvent( - throwable = e, - message = "copyFile unexpected error", - extras = mapOf( - "module" to "layouteditor", - "where" to "utils.FileUtil.copyFile", - "dest" to destinationPath, - "uri" to uri.toString() - ) - )) - } - } - } - - /** - * Reads from an asset file and returns its content as a String. - * - * @param path The path to the asset file - * @param ctx The context from which the asset should be read - * @return The content of the asset file as a String - */ - fun readFromAsset(path: String?, ctx: Context): String { - try { - // Get the input stream from the asset - val inputStream = ctx.assets.open(path!!) - - // Create a byte array output stream to store the read bytes - val outputStream = ByteArrayOutputStream() - - // Create a buffer of 1024 bytes - val _buf = ByteArray(BUFFER_SIZE) - var i: Int - - // Read the bytes from the input stream, write them to the output stream and close the streams - while ((inputStream.read(_buf).also { i = it }) != -1) { - outputStream.write(_buf, 0, i) - } - outputStream.close() - inputStream.close() - - // Return the content of the output stream as a String - return outputStream.toString() - } catch (e: Exception) { - e.printStackTrace() - } - - // If an exception occurred, return an empty String - return "" - } - - /** - * This method is used to copy file from assets folder to target path. - * - * @param filename - File name with extension to copy from assets folder. - * @param outPath - Target path where you want to copy the file. - */ - fun copyFileFromAsset(filename: String, outPath: String) { - // Get asset manager instance from application context - val assetManager = instance!!.context.assets - - // Create streams for read and write - val `in`: InputStream - val out: OutputStream - - try { - // Create InputStream from assets folder - `in` = assetManager.open(filename) - // Create OutputStream to target path - val newFileName = "$outPath/$filename" - out = FileOutputStream(newFileName) - - // Buffer for read and write - val buffer = ByteArray(BUFFER_SIZE) - var read: Int - - // Read from InputStream and write to OutputStream - while ((`in`.read(buffer).also { read = it }) != -1) { - out.write(buffer, 0, read) - } - - // Close input and output streams - `in`.close() - out.flush() - out.close() - } catch (e: IOException) { - // Print exception stack trace - e.printStackTrace() - } - } - - /** - * Creates a new file in the specified directory path if it does not already exist - * - * @param path the directory path in which to create the new file - */ - private fun createNewFile(path: String) { - // Get the last index of the file separator - val lastSep = path.lastIndexOf(File.separator) - // If there is a path, call makeDir to create the directory - if (lastSep > 0) { - val dirPath = path.substring(0, lastSep) - makeDir(dirPath) - } - - // Create a new file in the specified path - val file = File(path) - - try { - // Only create the file if it does not already exist - if (!file.exists()) file.createNewFile() - } catch (e: IOException) { - e.printStackTrace() - } - } - - /** - * Reads the contents of a file in the specified path - * - * @param path the directory path of the file to read - * @return the contents of the file as a string - */ - @JvmStatic - fun readFile(path: String): String { - // Create the file if it does not exist - createNewFile(path) - - val sb = StringBuilder() - var fr: FileReader? = null - try { - fr = FileReader(File(path)) - - val buff = CharArray(BUFFER_SIZE) - var length = 0 - - // Read the contents of the file and append them to the StringBuilder - while ((fr.read(buff).also { length = it }) > 0) { - sb.append(String(buff, 0, length)) - } - } catch (e: IOException) { - e.printStackTrace() - } finally { - if (fr != null) { - try { - fr.close() - } catch (e: Exception) { - e.printStackTrace() - } - } - } - - // Return the contents of the file - return sb.toString() - } - - /** - * Method to write a file with the given path and string. - * - * @param path Path of the file to write. - * @param str String to write in the file. - */ - @JvmStatic - fun writeFile(path: String, str: String?) { - val filePath = Paths.get(path) - - try { - filePath.parent?.let { Files.createDirectories(it) } - - FileWriter(filePath.toFile(), false).use { writer -> - writer.write(str ?: "") - } - } catch (e: IOException) { - e.printStackTrace() - } - } - - /** - * Method to copy a file from source to destination. - * - * @param sourcePath Path of the file to copy from. - * @param destPath Path of the file to copy to. - */ - fun copyFile(sourcePath: String, destPath: String) { - // Check if file exist in source path. - if (isNotExistFile(sourcePath)) return - // Create a new file in destination path. - createNewFile(destPath) - - var fis: FileInputStream? = null - var fos: FileOutputStream? = null - - try { - // Create input and output stream objects. - fis = FileInputStream(sourcePath) - fos = FileOutputStream(destPath, false) - - val buff = ByteArray(BUFFER_SIZE) - var length = 0 - - // Read and write the bytes from source path to destination path. - while ((fis.read(buff).also { length = it }) > 0) { - fos.write(buff, 0, length) - } - } catch (e: IOException) { - e.printStackTrace() - } finally { - // Close the input and output stream objects. - if (fis != null) { - try { - fis.close() - } catch (e: IOException) { - e.printStackTrace() - } - } - if (fos != null) { - try { - fos.close() - } catch (e: IOException) { - e.printStackTrace() - } - } - } - } - - @Throws(IOException::class) - fun copyFile(`in`: InputStream, out: OutputStream) { - val buffer = ByteArray(BUFFER_SIZE) - var read: Int - while ((`in`.read(buffer).also { read = it }) != -1) { - out.write(buffer, 0, read) - } - } - - /** - * copyDir() Copies a directory from one path to another - * - * @param oldPath the path of the directory to be copied - * @param newPath the path of the directory to be created - */ - fun copyDir(oldPath: String, newPath: String) { - val oldFile = File(oldPath) - val files = oldFile.listFiles() - val newFile = File(newPath) - if (!newFile.exists()) { - newFile.mkdirs() - } - for (file in files!!) { - if (file.isFile) { - copyFile(file.path, newPath + "/" + file.name) - } else if (file.isDirectory) { - copyDir(file.path, newPath + "/" + file.name) - } - } - } - - /** - * moveFile() Moves a file from one path to another - * - * @param sourcePath the path of the file to be moved - * @param destPath the path of the destination - */ - fun moveFile(sourcePath: String, destPath: String) { - copyFile(sourcePath, destPath) - deleteFile(sourcePath) - } - - /** - * deleteFile() Deletes a file with the given path - * - * @param path the path of the file to be deleted - */ - @JvmStatic - fun deleteFile(path: String) { - val file = File(path) - - if (!file.exists()) return - - if (file.isFile) { - file.delete() - return - } - - val fileArr = file.listFiles() - - if (fileArr != null) { - for (subFile in fileArr) { - if (subFile.isDirectory) { - deleteFile(subFile.absolutePath) - } - - if (subFile.isFile) { - subFile.delete() - } - } - } - - file.delete() - } - - /** - * Checks if a file exists at the given path. - * - * @param path the path to check - * @return true if the file exists, false otherwise - */ - fun isNotExistFile(path: String): Boolean { - val file = File(path) - return !file.exists() - } - - /** - * Creates a directory at the given path, if it doesn't exist. - * - * @param path the path at which the directory should be created - */ - fun makeDir(path: String) { - if (isNotExistFile(path)) { - val file = File(path) - file.mkdirs() - } - } - - /** - * Lists all the files in the given directory, and adds them to the given list. - * - * @param path the directory to list the files from - * @param list the list to which the files should be added - */ - fun listDir(path: String, list: ArrayList?) { - val dir = File(path) - if (!dir.exists() || dir.isFile) return - - val listFiles = dir.listFiles() - if (listFiles == null || listFiles.isEmpty()) return - - if (list == null) return - list.clear() - for (file in listFiles) { - list.add(file.absolutePath) - } - } - - /** - * This method is used to convert the Uri to File Path. - * - * @param uri Uri of the file - * @return Returns the File Path of Uri - */ - @JvmStatic - fun convertUriToFilePath(context: Context, uri: Uri): String { - var path = "" - // Check if the Uri is provided by documents contract - if (DocumentsContract.isDocumentUri(context, uri)) { - // Check if Uri is External Storage Document - if (isExternalStorageDocument(uri)) { - val docId = DocumentsContract.getDocumentId(uri) - // Split the document Id into two parts - val split = docId.split(":".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray() - val type = split[0] - - // Check if it is primary storage - if ("primary".equals(type, ignoreCase = true)) { - // Append the split[1] to Environment.getExternalStorageDirectory() to get File Path - path = Environment.getExternalStorageDirectory().toString() + "/" + split[1] - } - } else if (isDownloadsDocument(uri)) { - val id = DocumentsContract.getDocumentId(uri) - - // Check if the Id is empty - if (!TextUtils.isEmpty(id)) { - // Replace 'raw:' from Id to get File Path - if (id.startsWith("raw:")) { - return id.replaceFirst("raw:".toRegex(), "") - } - } - } else if (isMediaDocument(uri)) { - val docId = DocumentsContract.getDocumentId(uri) - val split = docId.split(":".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray() - val type = split[0] - - var contentUri: Uri? = null - // Check the type of Media - when (type) { - "image" -> { - contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI - } - "video" -> { - contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI - } - "audio" -> { - contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI - } - } - - val selection = "_id=?" - val selectionArgs = arrayOf(split[1]) - - // Get Data Column from content Uri - path = getDataColumn(contentUri, selection, selectionArgs, context).toString() - } - } else if (ContentResolver.SCHEME_CONTENT.equals(uri.scheme, ignoreCase = true)) { - // Get Data Column from content Uri - path = getDataColumn(uri, null, null, context).toString() - } else if (ContentResolver.SCHEME_FILE.equals(uri.scheme, ignoreCase = true)) { - // Get File Path from Uri - path = uri.path.toString() - } - - // Check if path is not empty - return try { - // Decode the File Path using 'UTF-8' - URLDecoder.decode(path, "UTF-8") - } catch (e: Exception) { - null - }.toString() - } - - /** - * This method is used to get the data column of a particular URI. - * - * @param uri The URI of the data column to be retrieved. - * @param selection The selection argument for the query. - * @param selectionArgs The selection arguments for the query. - * @return The data column retrieved from the specified URI. - */ - @SuppressLint("Recycle") - private fun getDataColumn(uri: Uri?, selection: String?, selectionArgs: Array?, context: Context): String? { - val column = - MediaStore.Images.Media.DATA // Column name of the data column to be retrieved - val projection = arrayOf(column) // Projection of the data column to be retrieved - - try { - val cursor = - context // Get the application context - .contentResolver // Get the content resolver - .query(uri!!, projection, selection, selectionArgs, null) // Query the content resolver - if (cursor != null && cursor.moveToFirst()) { - val column_index = - cursor.getColumnIndexOrThrow(column) // Get the index of the data column - return cursor.getString(column_index) // Return the data column - } - } catch (ignored: Exception) { - } - return null - } - - /** - * Checks whether the Uri authority is ExternalStorageProvider. - * - * @param uri The Uri to check. - * @return Whether the Uri authority is ExternalStorageProvider. - */ - fun isExternalStorageDocument(uri: Uri): Boolean { - return "com.android.externalstorage.documents" == uri.authority - } - - /** - * Checks whether the Uri authority is DownloadsProvider. - * - * @param uri The Uri to check. - * @return Whether the Uri authority is DownloadsProvider. - */ - fun isDownloadsDocument(uri: Uri?): Boolean { - if (uri != null) { - return "com.android.providers.downloads.documents" == uri.authority - } - return false - } - - /** - * Checks whether the Uri authority is MediaProvider. - * - * @param uri The Uri to check. - * @return Whether the Uri authority is MediaProvider. - */ - fun isMediaDocument(uri: Uri): Boolean { - return "com.android.providers.media.documents" == uri.authority - } - - /** - * Checks whether the file is a directory. - * - * @param path The path of the file. - * @return Whether the file is a directory. - */ - fun isDirectory(path: String): Boolean { - if (isNotExistFile(path)) return false - return File(path).isDirectory - } - - /** - * Checks whether the file is a file. - * - * @param path The path of the file. - * @return Whether the file is a file. - */ - fun isFile(path: String): Boolean { - if (isNotExistFile(path)) return false - return File(path).isFile - } - - /** - * Gets the file length. - * - * @param path The path of the file. - * @return The file length. - */ - fun getFileLength(path: String): Long { - if (isNotExistFile(path)) return 0 - return File(path).length() - } - - val externalStorageDir: String - /** - * Gets the absolute path of the external storage directory. - * - * @return The absolute path of the external storage directory. - */ - get() = Environment.getExternalStorageDirectory().absolutePath - - /** - * Gets the absolute path of the application-specific directory. - * - * @param ctx The application context. - * @return The absolute path of the application-specific directory. - */ - fun getPackageDataDir(ctx: Context): String { - return ctx.getExternalFilesDir("")!!.absolutePath - } - - /** - * Gets the absolute path of the public directory. - * - * @param type The type of the public directory. - * @return The absolute path of the public directory. - */ - fun getPublicDir(type: String): String { - return Environment.getExternalStoragePublicDirectory(type).absolutePath - } - - /** - * Gets the last segment from the path. - * - * @param path The path to get the last segment. - * @return The last segment from the path. - */ - @JvmStatic - fun getLastSegmentFromPath(path: String): String { - return path.substring(path.lastIndexOf("/") + 1) - } - - /** - * Saves the file with given Uri and data. - * - * @param uri URI of the file to be saved - * @param data Data to be written in the file - * @return boolean True if file is saved successfully, else false - */ - fun saveFile(context: Context, uri: Uri, data: String): Boolean { - try { - // Open the file descriptor in read-write-truncate mode - val pfd = - context.contentResolver.openFileDescriptor(uri, "rwt") - // Initialize file output stream with the file descriptor - val fos = FileOutputStream(pfd!!.fileDescriptor) - // Write the data in the file - fos.write(data.toByteArray()) - // Close the output stream - fos.close() - // Close the file descriptor - pfd.close() - return true - } catch (e: IOException) { - // Print the stacktrace for the exception - e.printStackTrace() - return false - } - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/utils/InvokeUtil.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/utils/InvokeUtil.kt deleted file mode 100644 index 543e600d41..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/utils/InvokeUtil.kt +++ /dev/null @@ -1,73 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.utils - -import android.content.Context -import android.view.View -import org.appdevforall.codeonthego.layouteditor.R.mipmap -import java.lang.reflect.InvocationTargetException - -object InvokeUtil { - @JvmStatic - fun createView(className: String, context: Context): Any? { - try { - val clazz = Class.forName(className) - val constructor = clazz.getConstructor(Context::class.java) - return constructor.newInstance(context) - } catch (e: ClassNotFoundException) { - e.printStackTrace() - } catch (e: NoSuchMethodException) { - e.printStackTrace() - } catch (e: InstantiationException) { - e.printStackTrace() - } catch (e: InvocationTargetException) { - e.printStackTrace() - } catch (e: IllegalAccessException) { - e.printStackTrace() - } - - return null - } - - @JvmStatic - fun invokeMethod( - methodName: String, className: String, target: View, value: String, context: Context - ) { - try { - val clazz = Class.forName("org.appdevforall.codeonthego.layouteditor.editor.callers.$className") - val method = - clazz.getMethod(methodName, View::class.java, String::class.java, Context::class.java) - method.invoke(clazz, target, value, context) - } catch (e: ClassNotFoundException) { - e.printStackTrace() - } catch (e: NoSuchMethodException) { - e.printStackTrace() - } catch (e: InvocationTargetException) { - e.printStackTrace() - } catch (e: IllegalAccessException) { - e.printStackTrace() - } - } - - @JvmStatic - fun getMipmapId(name: String): Int { - try { - val cls = mipmap::class.java - val field = cls.getField(name) - return field.getInt(cls) - } catch (e: NoSuchFieldException) { - e.printStackTrace() - } catch (e: IllegalAccessException) { - e.printStackTrace() - } - - return 0 - } - - @JvmStatic - fun getSuperClassName(clazz: String): String? { - return try { - Class.forName(clazz).superclass.name - } catch (e: ClassNotFoundException) { - null - } - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/utils/LetExtension.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/utils/LetExtension.kt deleted file mode 100644 index 88d8c5bb99..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/utils/LetExtension.kt +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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 org.appdevforall.codeonthego.layouteditor.utils - -inline fun doubleArgSafeLet(p1: T1?, p2: T2?, - block: (T1, T2) -> R?): R? { - val lock = Any() - return synchronized(lock) { - if (p1 != null && p2 != null) block(p1, p2) else null - } -} \ No newline at end of file diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/utils/NameErrorChecker.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/utils/NameErrorChecker.java deleted file mode 100644 index 2f8d418c95..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/utils/NameErrorChecker.java +++ /dev/null @@ -1,248 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.utils; - -import androidx.annotation.NonNull; -import androidx.appcompat.app.AlertDialog; - -import com.google.android.material.textfield.TextInputLayout; - -import org.appdevforall.codeonthego.layouteditor.LayoutFile; -import org.appdevforall.codeonthego.layouteditor.R; -import org.appdevforall.codeonthego.layouteditor.adapters.models.DrawableFile; -import org.appdevforall.codeonthego.layouteditor.adapters.models.FontItem; -import org.appdevforall.codeonthego.layouteditor.adapters.models.ValuesItem; - -import java.util.List; -import java.util.regex.Pattern; - -/** - * This class is used to check the name error conditions. - */ -public class NameErrorChecker { - - /** - * This method checks if the name provided by the user is valid. - * - * @param name the name provided by the user - * @param inputLayout object of TextInputLayout - * @param dialog object of AlertDialog - * @param drawableList list of DrawableFile objects - */ - public static void checkForDrawable( - @NonNull String name, - TextInputLayout inputLayout, - AlertDialog dialog, - List drawableList, - int position) { - // Check if name is not empty - if (!name.isEmpty()) { - // First character should not be a number - if (Character.isDigit(name.charAt(0))) { - inputLayout.setErrorEnabled(true); - inputLayout.setError(dialog.getContext().getString(R.string.msg_first_letter_not_number)); - dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false); - return; - } - // Name should not have space - if (name.contains(" ")) { - inputLayout.setErrorEnabled(true); - inputLayout.setError(dialog.getContext().getString(R.string.msg_space_not_allowed)); - dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false); - return; - } - // Name should contain only letters and numbers - if (!Pattern.matches("[a-z][a-z0-9_]*", name)) { - inputLayout.setErrorEnabled(true); - inputLayout.setError(dialog.getContext().getString(R.string.msg_only_letters_and_numbers)); - dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false); - return; - } - } else { - // Name cannot be empty - inputLayout.setErrorEnabled(true); - inputLayout.setError(dialog.getContext().getString(R.string.msg_cannnot_empty)); - dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false); - return; - } - - // Check if the name already exists in the valuesList - for (DrawableFile item : drawableList) { - if (item.getName().substring(0, item.getName().lastIndexOf(".")).equals(name) - && drawableList.indexOf(item) != position) { - inputLayout.setErrorEnabled(true); - inputLayout.setError(dialog.getContext().getString(R.string.msg_current_name_unavailable)); - dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false); - return; - } - } - - // Name is valid - inputLayout.setErrorEnabled(false); - inputLayout.setError(""); - dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(true); - } - - public static void checkForValues( - String name, TextInputLayout inputLayout, AlertDialog dialog, List valuesList) { - checkForValues(name, inputLayout, dialog, valuesList, -1); - } - - public static void checkForFont( - String name, TextInputLayout inputLayout, AlertDialog dialog, List fontList) { - checkForFont(name, inputLayout, dialog, fontList, -1); - } - - public static void checkForDrawable( - String name, TextInputLayout inputLayout, AlertDialog dialog, List drawableList) { - checkForDrawable(name, inputLayout, dialog, drawableList, -1); - } - - public static void checkForValues( - @NonNull String name, - TextInputLayout inputLayout, - AlertDialog dialog, - List valuesList, - int position) { - // Check if name is not empty - if (!name.isEmpty()) { - // First character should not be a number - if (Character.isDigit(name.charAt(0))) { - inputLayout.setErrorEnabled(true); - inputLayout.setError(dialog.getContext().getString(R.string.msg_first_letter_not_number)); - dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false); - return; - } - // Name should not have space - if (name.contains(" ")) { - inputLayout.setErrorEnabled(true); - inputLayout.setError(dialog.getContext().getString(R.string.msg_space_not_allowed)); - dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false); - return; - } - // Name should contain only letters and numbers - if (!Pattern.matches("[a-z][a-z0-9_]*", name)) { - inputLayout.setErrorEnabled(true); - inputLayout.setError(dialog.getContext().getString(R.string.msg_only_letters_and_numbers)); - dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false); - return; - } - } else { - // Name cannot be empty - inputLayout.setErrorEnabled(true); - inputLayout.setError(dialog.getContext().getString(R.string.msg_cannnot_empty)); - dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false); - return; - } - - // Check if the name already exists in the valuesList - for (ValuesItem item : valuesList) { - if (item.name.equals(name) && valuesList.indexOf(item) != position) { - inputLayout.setErrorEnabled(true); - inputLayout.setError(dialog.getContext().getString(R.string.msg_current_name_unavailable)); - dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false); - return; - } - } - - // Name is valid - inputLayout.setErrorEnabled(false); - inputLayout.setError(""); - dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(true); - } - - public static void checkForFont( - @NonNull String name, - TextInputLayout inputLayout, - AlertDialog dialog, - List fontList, - int position) { - // Check if name is not empty - if (!name.isEmpty()) { - // First character should not be a number - if (Character.isDigit(name.charAt(0))) { - inputLayout.setErrorEnabled(true); - inputLayout.setError(dialog.getContext().getString(R.string.msg_first_letter_not_number)); - dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false); - return; - } - // Name should not have space - if (name.contains(" ")) { - inputLayout.setErrorEnabled(true); - inputLayout.setError(dialog.getContext().getString(R.string.msg_space_not_allowed)); - dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false); - return; - } - // Name should contain only letters and numbers - if (!Pattern.matches("[a-z][a-z0-9_]*", name)) { - inputLayout.setErrorEnabled(true); - inputLayout.setError(dialog.getContext().getString(R.string.msg_only_letters_and_numbers)); - dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false); - return; - } - } else { - // Name cannot be empty - inputLayout.setErrorEnabled(true); - inputLayout.setError(dialog.getContext().getString(R.string.msg_cannnot_empty)); - dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false); - return; - } - - // Check if the name already exists in the fontList - for (FontItem item : fontList) { - if (item.name.substring(0, item.name.lastIndexOf(".")).equals(name) - && fontList.indexOf(item) != position) { - inputLayout.setErrorEnabled(true); - inputLayout.setError(dialog.getContext().getString(R.string.msg_current_name_unavailable)); - dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false); - return; - } - } - - // Name is valid - inputLayout.setErrorEnabled(false); - inputLayout.setError(""); - dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(true); - } - - public static void checkForLayouts( - @NonNull String name, - TextInputLayout inputLayout, - AlertDialog dialog, - List layoutFiles, - int position) { - if (!name.isEmpty()) { - if (Character.isDigit(name.charAt(0))) { - inputLayout.setErrorEnabled(true); - inputLayout.setError(dialog.getContext().getString(R.string.msg_first_letter_not_number)); - dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false); - return; - } - if (!Pattern.matches("[a-z][A-Za-z0-9_\\s]*", name)) { - inputLayout.setErrorEnabled(true); - inputLayout.setError(dialog.getContext().getString(R.string.msg_symbol_not_allowed)); - dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false); - return; - } - } else { - inputLayout.setErrorEnabled(true); - inputLayout.setError(dialog.getContext().getString(R.string.msg_cannnot_empty)); - dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false); - return; - } - - for (LayoutFile item : layoutFiles) { - if (item.getName().contains(".")) { - if (item.getName().substring(0, item.getName().lastIndexOf(".")).equals(name) - && layoutFiles.indexOf(item) != position) { - inputLayout.setErrorEnabled(true); - inputLayout.setError(dialog.getContext().getString(R.string.msg_current_name_unavailable)); - dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false); - return; - } - } - } - - inputLayout.setErrorEnabled(false); - inputLayout.setError(""); - dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(true); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/utils/ProjectResolver.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/utils/ProjectResolver.java deleted file mode 100644 index e71ae78dbb..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/utils/ProjectResolver.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.utils; - -import android.os.Bundle; -import android.view.View; - -import androidx.annotation.Nullable; - -import org.appdevforall.codeonthego.layouteditor.ProjectFile; -import org.appdevforall.codeonthego.layouteditor.R; -import org.appdevforall.codeonthego.layouteditor.managers.ProjectManager; - -public class ProjectResolver { - @Nullable - public static ProjectFile resolveProject(@Nullable Bundle arguments) { - if (arguments != null && arguments.containsKey(Constants.EXTRA_KEY_PROJECT)) { - return arguments.getParcelable(Constants.EXTRA_KEY_PROJECT); - } - return ProjectManager.getInstance().getOpenedProject(); - } - - @Nullable - public static ProjectFile getValidProjectOrShowError(@Nullable Bundle arguments, @Nullable View view) { - ProjectFile project = resolveProject(arguments); - if (project == null && view != null) { - SBUtils.make(view, R.string.msg_error_opening_project).showAsError(); - } - return project; - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/utils/SBUtils.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/utils/SBUtils.kt deleted file mode 100644 index dca5380de0..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/utils/SBUtils.kt +++ /dev/null @@ -1,168 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.utils - -import android.view.View -import androidx.annotation.StringRes -import com.google.android.material.R -import com.google.android.material.color.MaterialColors -import com.google.android.material.snackbar.Snackbar -import org.jetbrains.annotations.Contract - -/** - * SBUtils is a utility class for creating and displaying snackbars. - */ -class SBUtils private constructor( - private val snackbar: Snackbar -) { - /** - * Enum for the types of snackbars that can be created. - */ - enum class Type { - ERROR, - SUCCESS, - INFO - } - - private var type: Type? = null - - /** - * Sets the type of the snackbar. - * - * @param type The type of snackbar to set - * @return The SBUtils instance - */ - fun setType(type: Type?): SBUtils { - this.type = type - return this - } - - /** - * Sets the background color and text color of the snackbar. - * - * @param colorBg The background color of the snackbar - * @param colorTxt The text color of the snackbar - * @return The SBUtils instance - */ - fun setColors(colorBg: Int, colorTxt: Int): SBUtils { - snackbar.setBackgroundTint(colorBg).setTextColor(colorTxt).setActionTextColor(colorTxt) - return this - } - - /** - * Sets the animation mode of the snackbar to Fade. - * - * @return The SBUtils instance - */ - fun setFadeAnimation(): SBUtils { - snackbar.setAnimationMode(Snackbar.ANIMATION_MODE_FADE) - return this - } - - /** - * Sets the animation mode of the snackbar to Slide. - * - * @return The SBUtils instance - */ - fun setSlideAnimation(): SBUtils { - snackbar.setAnimationMode(Snackbar.ANIMATION_MODE_SLIDE) - return this - } - - /** - * Sets the anchor view for the snackbar. - * - * @param anchorView The anchor view for the snackbar - * @return The SBUtils instance - */ - fun setAnchorView(anchorView: View?): SBUtils { - snackbar.setAnchorView(anchorView) - return this - } - - /** - * Shows the snackbar. The colors will be set based on the type if a type has been set. - */ - fun show() { - when (type) { - Type.ERROR -> setColors( - MaterialColors.getColor(snackbar.context, R.attr.colorErrorContainer, ""), - MaterialColors.getColor(snackbar.context, R.attr.colorOnErrorContainer, "") - ) - - Type.SUCCESS -> setColors( - MaterialColors.getColor(snackbar.context, R.attr.colorPrimaryContainer, ""), - MaterialColors.getColor(snackbar.context, R.attr.colorOnPrimaryContainer, "") - ) - - Type.INFO -> setColors( - MaterialColors.getColor(snackbar.context, R.attr.colorSecondaryContainer, ""), - MaterialColors.getColor(snackbar.context, R.attr.colorOnSecondaryContainer, "") - ) - - null -> { - showAsSuccess() - return - } - } - snackbar.show() - } - - /** - * Sets the type of snackbar to ERROR and shows it. - */ - fun showAsError() { - setType(Type.ERROR).show() - } - - /** - * Sets the type of snackbar to SUCCESS and shows it. - */ - fun showAsSuccess() { - setType(Type.SUCCESS).show() - } - - /** - * Sets the duration of snackbar to LONG and sets the type of snackbar to ERROR and shows it. - */ - fun showLongAsError() { - snackbar.setDuration(Snackbar.LENGTH_LONG) - setType(Type.ERROR).show() - } - - /** - * Sets the duration of snackbar to LONG and sets the type of snackbar to SUCCESS and shows it. - */ - fun showLongAsSuccess() { - snackbar.setDuration(Snackbar.LENGTH_LONG) - setType(Type.SUCCESS).show() - } - - companion object { - /** - * Creates and returns a new instance of SBUtils with a Snackbar with the given message for the - * given view. - * - * @param v The view where the snackbar should be displayed - * @param msg The message to display in the snackbar - * @return a new instance of SBUtils - */ - @JvmStatic - @Contract("_, _ -> new") - fun make(v: View, msg: CharSequence): SBUtils { - return SBUtils(Snackbar.make(v, msg, Snackbar.LENGTH_SHORT)) - } - - /** - * Creates and returns a new instance of SBUtils with a Snackbar with the given string resource - * ID for the given view. - * - * @param v The view where the snackbar should be displayed - * @param msgResId The string resource ID to display in the snackbar - * @return a new instance of SBUtils - */ - @JvmStatic - @Contract("_, _ -> new") - fun make(v: View, @StringRes msgResId: Int): SBUtils { - return SBUtils(Snackbar.make(v, msgResId, Snackbar.LENGTH_SHORT)) - } - } -} \ No newline at end of file diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/utils/Utils.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/utils/Utils.java deleted file mode 100644 index 4fe0aa4aaf..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/utils/Utils.java +++ /dev/null @@ -1,259 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.utils; - -import android.content.ContentResolver; -import android.content.ContentValues; -import android.content.Context; -import android.content.res.Configuration; -import android.content.res.Resources; -import android.graphics.Bitmap; -import android.graphics.Canvas; -import android.graphics.Color; -import android.graphics.DashPathEffect; -import android.graphics.Paint; -import android.net.Uri; -import android.os.Environment; -import android.provider.MediaStore; -import android.util.DisplayMetrics; -import android.util.Log; -import android.util.TypedValue; -import android.view.View; - -import androidx.annotation.NonNull; - -import com.google.android.material.R; -import com.google.android.material.color.MaterialColors; - -import org.appdevforall.codeonthego.layouteditor.R.string; -import org.appdevforall.codeonthego.vectormaster.VectorMasterDrawable; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.util.Date; -import java.util.Locale; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.FutureTask; - -public class Utils { - /** - * This method is used to convert the input into the equivalent dip value. - */ - public static int pxToDp(@NonNull Context context, int input) { - return (int) - TypedValue.applyDimension( - TypedValue.COMPLEX_UNIT_DIP, input, context.getResources().getDisplayMetrics()); - } - - public static boolean isDarkMode(@NonNull Context context) { - int uiMode = - context.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK; - return uiMode == Configuration.UI_MODE_NIGHT_YES; - } - - public static int getOnSurfaceColor(Context context) { - return MaterialColors.getColor(context, R.attr.colorOnSurface, 0); - } - - public static int getSurfaceColor(Context context) { - return MaterialColors.getColor(context, R.attr.colorSurface, 0); - } - - public static int getPrimaryColor(Context context) { - return MaterialColors.getColor(context, R.attr.colorPrimary, 0); - } - - public static int getSecondaryColor(Context context) { - return MaterialColors.getColor(context, R.attr.colorSecondary, 0); - } - - public static void drawDashPathStroke(@NonNull View view, @NonNull Canvas canvas, @NonNull Paint paint) { - paint.setAntiAlias(true); - paint.setStyle(Paint.Style.STROKE); - paint.setPathEffect(new DashPathEffect(new float[]{10, 7}, 0)); - canvas.drawRect(0, 0, view.getWidth(), view.getHeight(), paint); - } - - public static void drawDashPathStroke(View view, Canvas canvas) { - drawDashPathStroke(view, canvas, getDefaultPaint(view.getContext())); - } - - public static void drawDashPathStroke(@NonNull View view, Canvas canvas, int paintColor) { - Paint paint = getDefaultPaint(view.getContext()); - paint.setColor(paintColor); - drawDashPathStroke(view, canvas, paint); - } - - @NonNull - private static Paint getDefaultPaint(Context context) { - Paint paint = new Paint(); - paint.setColor(isDarkMode(context) ? Color.WHITE : getOnSurfaceColor(context)); - paint.setStrokeWidth(pxToDp(context, 2)); - return paint; - } - - public static boolean saveBitmapAsImageToGallery(@NonNull Context context, Bitmap bitmap, String title) { - String savedImageURL = null; - - // Get the directory for the user's public pictures directory. - File path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES); - // Create a new directory for your app - File appDir = new File(path, context.getString(string.app_name)); - if (!appDir.exists()) { - appDir.mkdir(); - } - - // Generate a unique file name for your image - String fileName = - context.getString(string.app_name).concat(" ").concat(title).concat(" ") - + new Date().getTime() - + ".jpg"; - fileName = fileName.replaceAll(" ", "_").toLowerCase(Locale.getDefault()); - File file = new File(appDir, fileName); - - // Save the image to the directory - try { - OutputStream fOut = new FileOutputStream(file); - bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fOut); - fOut.flush(); - fOut.close(); - } catch (IOException e) { - e.printStackTrace(); - Log.d("MediaUtils", "Error saving image to gallery: " + e.getMessage()); - return false; - } - - // Add the image to the Android gallery - try { - ContentResolver contentResolver = context.getContentResolver(); - ContentValues values = new ContentValues(); - values.put(MediaStore.Images.Media.TITLE, fileName); - values.put(MediaStore.Images.Media.DISPLAY_NAME, fileName); - values.put( - MediaStore.Images.Media.DESCRIPTION, - "Image saved from ".concat(context.getString(string.app_name))); - values.put(MediaStore.Images.Media.DATE_ADDED, System.currentTimeMillis()); - values.put(MediaStore.Images.Media.MIME_TYPE, "image/jpeg"); - values.put(MediaStore.Images.Media.ORIENTATION, 0); - values.put(MediaStore.Images.Media.DATA, file.getAbsolutePath()); - - Uri uri = contentResolver.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values); - savedImageURL = uri.toString(); - - Log.d("MediaUtils", "Image saved to gallery: " + savedImageURL); - return true; - } catch (Exception e) { - e.printStackTrace(); - Log.d("MediaUtils", "Error saving image to gallery: " + e.getMessage()); - return false; - } - } - - public static int getScreenWidth() { - DisplayMetrics displayMetrics = Resources.getSystem().getDisplayMetrics(); - return displayMetrics.widthPixels; - } - - /** - * Basic validation of a TTF/OTF file. - * Checks: - * 1. File exists and is not empty - * 2. Valid TTF/OTF header (scaler type) - * 3. Directory table has a reasonable number of entries - */ - public static boolean isValidFontFile(File file) { - final int MAX_FONT_TABLES = 100; - final int FONT_HEADER_SIZE = 12; - final int TABLE_DIRECTORY_ENTRY_SIZE = 16; - - if (!file.exists() || file.length() < FONT_HEADER_SIZE) { - return false; - } - - try (FileInputStream stream = new FileInputStream(file)) { - byte[] header = new byte[FONT_HEADER_SIZE]; - if (stream.read(header) != FONT_HEADER_SIZE) { - return false; - } - - ByteBuffer buf = ByteBuffer.wrap(header).order(ByteOrder.BIG_ENDIAN); - - // --- Validate scaler type --- - int scalerType = buf.getInt(); - boolean validScaler = - scalerType == 0x00010000 || // TTF - scalerType == 0x4F54544F; // OTTO - - if (!validScaler) return false; - - // --- Number of tables --- - int numTables = buf.getShort() & 0xFFFF; - if (numTables == 0 || numTables > MAX_FONT_TABLES) { - return false; - } - - int directorySize = numTables * TABLE_DIRECTORY_ENTRY_SIZE; - byte[] tableDir = new byte[directorySize]; - - return stream.read(tableDir) == directorySize; - - } catch (IOException e) { - Log.e("Utils", "Error validating font file: " + file.getName(), e); - return false; - } - } - - public static VectorMasterDrawable getVectorDrawableAsync(Context context, Uri uri) { - Callable callable = - new Callable() { - @Override - public VectorMasterDrawable call() throws Exception { - // Load the drawable from file - InputStream is = context.getContentResolver().openInputStream(uri); - VectorMasterDrawable drawable = new VectorMasterDrawable(context); - drawable.setInputStream(is); - is.close(); - return drawable; - } - }; - - FutureTask futureTask = new FutureTask<>(callable); - new Thread(futureTask).start(); - - try { - VectorMasterDrawable drawable = futureTask.get(); - return drawable; - } catch (ExecutionException | InterruptedException e) { - e.printStackTrace(); - return null; - } - } - - @NonNull - public static String toCamelCase(@NonNull String s) { - int ctr = 0; - int n = s.length(); - char[] ch = s.toCharArray(); - int c = 0; - - for (int i = 0; i < n; i++) { - if (i == 0) { - ch[i] = Character.toLowerCase(ch[i]); - } - if (ch[i] == ' ') { - ctr++; - ch[i+1] = Character.toUpperCase(ch[i+1]); - continue; - } else { - ch[c++] = ch[i]; - } - } - - return String.valueOf(ch, 0, n - ctr); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/views/AlphaPatternDrawable.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/views/AlphaPatternDrawable.kt deleted file mode 100644 index 20ed6cd9d4..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/views/AlphaPatternDrawable.kt +++ /dev/null @@ -1,91 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.views - -import android.graphics.Bitmap -import android.graphics.Canvas -import android.graphics.ColorFilter -import android.graphics.Paint -import android.graphics.PixelFormat -import android.graphics.Rect -import android.graphics.drawable.Drawable - -/** - * This drawable will draw a simple white and gray chessboard pattern. It's the pattern you will - * often see as a background behind a partly transparent image in many applications. - */ -class AlphaPatternDrawable(private val rectangleSize: Int) : Drawable() { - private val paint = Paint() - private val paintWhite = Paint() - private val paintGray = Paint() - - private var numRectanglesHorizontal = 0 - private var numRectanglesVertical = 0 - - /** - * Bitmap in which the pattern will be cached. This is so the pattern will not have to be - * recreated each time draw() gets called. Because recreating the pattern i rather expensive. I - * will only be recreated if the size changes. - */ - private var bitmap: Bitmap? = null - - init { - paintWhite.color = -0xbdbdbe - paintGray.color = -0xdededf - } - - override fun draw(canvas: Canvas) { - if (bitmap != null && !bitmap!!.isRecycled) { - canvas.drawBitmap(bitmap!!, null, bounds, paint) - } - } - - override fun setAlpha(alpha: Int) { - throw UnsupportedOperationException("Alpha is not supported by this drawable.") - } - - override fun setColorFilter(cf: ColorFilter?) { - throw UnsupportedOperationException("ColorFilter is not supported by this drawable.") - } - - override fun getOpacity(): Int { - return PixelFormat.UNKNOWN - } - - override fun onBoundsChange(bounds: Rect) { - super.onBoundsChange(bounds) - val height = bounds.height() - val width = bounds.width() - numRectanglesHorizontal = (width / rectangleSize).toDouble().toInt() - numRectanglesVertical = (height / rectangleSize).toDouble().toInt() - generatePatternBitmap() - } - - /** - * This will generate a bitmap with the pattern as big as the rectangle we were allow to draw on. - * We do this to chache the bitmap so we don't need to recreate it each time draw() is called - * since it takes a few milliseconds - */ - private fun generatePatternBitmap() { - if (bounds.width() <= 0 || bounds.height() <= 0) { - return - } - - bitmap = - Bitmap.createBitmap(bounds.width(), bounds.height(), Bitmap.Config.ARGB_8888) - val canvas = Canvas(bitmap!!) - - val r = Rect() - var verticalStartWhite = true - for (i in 0..numRectanglesVertical) { - var isWhite = verticalStartWhite - for (j in 0..numRectanglesHorizontal) { - r.top = i * rectangleSize - r.left = j * rectangleSize - r.bottom = r.top + rectangleSize - r.right = r.left + rectangleSize - canvas.drawRect(r, if (isWhite) paintWhite else paintGray) - isWhite = !isWhite - } - verticalStartWhite = !verticalStartWhite - } - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/views/ColorView.java b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/views/ColorView.java deleted file mode 100644 index 983dd2f9ae..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/views/ColorView.java +++ /dev/null @@ -1,167 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.views; - -import android.content.Context; -import android.graphics.Canvas; -import android.graphics.Color; -import android.graphics.Paint; -import android.graphics.drawable.Drawable; -import android.util.AttributeSet; -import android.view.View; - -import androidx.annotation.NonNull; - -import java.util.Locale; - -/** ColorView extends View class. It is used to draw a colored rectangle. */ -public class ColorView extends View { - /** Alpha, red, green, blue value of the color. */ - private int a = 255, r = 255, g = 255, b = 255; - - /** Drawable object to draw transparent background. */ - private final Drawable transparent; - /** Paint object to draw color bitmap. */ - private Paint bitmapPaint; - /** Paint object to draw color. */ - private final Paint colorPaint; - - /** - * Constructor for ColorView class. - * - * @param context The Context the view is running in, through which it can access the current - * theme, resources, etc. - * @param attrs The attributes of the XML tag that is inflating the view. - */ - public ColorView(Context context, AttributeSet attrs) { - super(context, attrs); - - transparent = new AlphaPatternDrawable(16); - - colorPaint = new Paint(); - colorPaint.setARGB(a, r, g, b); - } - - /** - * This is called during layout when the size of this view has changed. - * - * @param w Current width of this view. - * @param h Current height of this view. - * @param oldw Old width of this view. - * @param oldh Old height of this view. - */ - @Override - protected void onSizeChanged(int w, int h, int oldw, int oldh) { - super.onSizeChanged(w, h, oldw, oldh); - transparent.setBounds(0, 0, w, h); - } - - /** - * Called when the view should render its content. - * - * @param canvas the Canvas object on which the view will draw. - */ - @Override - protected void onDraw(Canvas canvas) { - super.onDraw(canvas); - transparent.draw(canvas); - canvas.drawRect(0, 0, getWidth(), getHeight(), colorPaint); - } - - /** - * Set the color of the rectangle. - * - * @param color The color, packed as ARGB in a 32-bit int. - */ - public void setColor(int color) { - a = Color.alpha(color); - r = Color.red(color); - g = Color.green(color); - b = Color.blue(color); - - colorPaint.setARGB(a, r, g, b); - invalidate(); - } - - /** - * Set the alpha value of the color. - * - * @param value The value of alpha. - */ - public void setAlpha(int value) { - a = value; - colorPaint.setARGB(a, r, g, b); - invalidate(); - } - - /** - * Set the red value of the color. - * - * @param value The value of red. - */ - public void setRed(int value) { - r = value; - colorPaint.setARGB(a, r, g, b); - invalidate(); - } - - /** - * Set the green value of the color. - * - * @param value The value of green. - */ - public void setGreen(int value) { - g = value; - colorPaint.setARGB(a, r, g, b); - invalidate(); - } - - /** - * Set the blue value of the color. - * - * @param value The value of blue. - */ - public void setBlue(int value) { - b = value; - colorPaint.setARGB(a, r, g, b); - invalidate(); - } - - /** - * Get the color. - * - * @return The color, packed as ARGB in a 32-bit int. - */ - public int getColor() { - return Color.argb(a, r, g, b); - } - - /** - * Get the inverted rgb color. - * - * @return The inverted color, packed as RGB in a 32-bit int. - */ - public int getInvertedRGB() { - return 0xFFFFFF ^ Color.rgb(r, g, b); - } - - /** - * Get the hex value of the color. - * - * @return The hex value of the color. - */ - public String getHexColor() { - return getHex(Color.argb(a, r, g, b)); - } - - /** - * Get the hex value of the given color. - * - * @param c The color, packed as ARGB in a 32-bit int. - * @return The hex value of the given color. - */ - @NonNull - private String getHex(int c) { - return String.format( - "%02x%02x%02x%02x", Color.alpha(c), Color.red(c), Color.green(c), Color.blue(c)) - .toUpperCase(Locale.US); - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/views/CustomDrawerLayout.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/views/CustomDrawerLayout.kt deleted file mode 100644 index d1ca432399..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/views/CustomDrawerLayout.kt +++ /dev/null @@ -1,71 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.views - -import android.content.Context -import android.graphics.Rect -import android.util.AttributeSet -import android.view.MotionEvent -import android.view.View -import android.view.ViewGroup -import androidx.drawerlayout.widget.DrawerLayout - -/** Allows horizontally scrolling child of drawer layouts to intercept the touch event. */ -class CustomDrawerLayout : DrawerLayout { - private val rect = Rect() - - constructor(context: Context) : super(context) - - constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) - - constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super( - context, - attrs, - defStyleAttr - ) - - override fun onInterceptTouchEvent(ev: MotionEvent): Boolean { - val scrollingChild = findScrollingChild(this, ev.x, ev.y) - if (scrollingChild != null) { - return false - } - return super.onInterceptTouchEvent(ev) - } - - /** - * Recursively finds the view that can scroll horizontally to the end - * - * @param parent The starting parent to search - * @param x The x point in the screen - * @param y The y point in the screen - * @return The scrolling view, null if no view is found - */ - private fun findScrollingChild(parent: ViewGroup, x: Float, y: Float): View? { - val n = parent.childCount - if (parent === this && n <= 1) { - return null - } - - var start = 0 - if (parent === this) { - start = 1 - } - - for (i in start until n) { - val child = parent.getChildAt(i) - if (child.visibility != VISIBLE) { - continue - } - child.getHitRect(rect) - if (rect.contains(x.toInt(), y.toInt())) { - if (child.canScrollHorizontally(1)) { - return child - } else if (child is ViewGroup) { - val v = findScrollingChild(child, x - rect.left, y - rect.top) - if (v != null) { - return v - } - } - } - } - return null - } -} diff --git a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/views/StructureView.kt b/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/views/StructureView.kt deleted file mode 100644 index 982884fbb9..0000000000 --- a/layouteditor/src/main/java/org/appdevforall/codeonthego/layouteditor/views/StructureView.kt +++ /dev/null @@ -1,408 +0,0 @@ -package org.appdevforall.codeonthego.layouteditor.views - -import android.content.Context -import android.graphics.Canvas -import android.graphics.Paint -import android.util.AttributeSet -import android.util.TypedValue -import android.view.LayoutInflater -import android.view.SurfaceView -import android.view.TextureView -import android.view.View -import android.view.ViewGroup -import android.view.ViewStub -import android.webkit.WebView -import android.widget.AutoCompleteTextView -import android.widget.Button -import android.widget.CalendarView -import android.widget.CheckBox -import android.widget.CheckedTextView -import android.widget.EditText -import android.widget.FrameLayout -import android.widget.GridLayout -import android.widget.GridView -import android.widget.HorizontalScrollView -import android.widget.ImageButton -import android.widget.ImageView -import android.widget.LinearLayout -import android.widget.ListView -import android.widget.MultiAutoCompleteTextView -import android.widget.ProgressBar -import android.widget.RadioButton -import android.widget.RadioGroup -import android.widget.RatingBar -import android.widget.RelativeLayout -import android.widget.ScrollView -import android.widget.SearchView -import android.widget.SeekBar -import android.widget.Space -import android.widget.Spinner -import android.widget.Switch -import android.widget.TabHost -import android.widget.TableLayout -import android.widget.TableRow -import android.widget.TextClock -import android.widget.TextView -import android.widget.ToggleButton -import android.widget.VideoView -import androidx.appcompat.widget.LinearLayoutCompat -import androidx.cardview.widget.CardView -import androidx.constraintlayout.widget.ConstraintLayout -import androidx.coordinatorlayout.widget.CoordinatorLayout -import androidx.core.widget.NestedScrollView -import androidx.drawerlayout.widget.DrawerLayout -import androidx.recyclerview.widget.RecyclerView -import androidx.viewpager.widget.ViewPager -import androidx.viewpager2.widget.ViewPager2 -import com.google.android.material.appbar.AppBarLayout -import com.google.android.material.bottomnavigation.BottomNavigationView -import com.google.android.material.chip.Chip -import com.google.android.material.chip.ChipGroup -import com.google.android.material.color.MaterialColors -import com.google.android.material.textfield.TextInputLayout -import com.google.android.material.floatingactionbutton.FloatingActionButton -import com.google.android.material.navigation.NavigationView -import com.google.android.material.tabs.TabLayout -import com.google.android.material.textfield.TextInputEditText -import org.appdevforall.codeonthego.layouteditor.R -import org.appdevforall.codeonthego.layouteditor.databinding.LayoutStructureViewItemBinding -import org.appdevforall.codeonthego.layouteditor.managers.IdManager.idMap - -class StructureView( - context: Context?, - attrs: AttributeSet?, -) : LinearLayoutCompat( - context!!, - attrs, - ), - View.OnClickListener, - View.OnLongClickListener { - private val inflater: LayoutInflater = LayoutInflater.from(context) - private val paint = Paint() - private val pointRadius: Int - private val textViewMap: MutableMap = HashMap() - private val viewTextMap: MutableMap = HashMap() - - var onItemClickListener: ((View) -> Unit)? = null - var onItemLongClickListener: ((View) -> Unit)? = null - - /** - * This is the constructor of the StructureView class which takes context and attributeSet as - * parameters. It creates a new Paint object, sets its color and anti-alias. It also sets the - * orientation of this view to VERTICAL and sets the default OnItemClickListener. - */ - init { - val primaryColor = - MaterialColors.getColor(this, com.google.android.material.R.attr.colorPrimary) - paint.color = primaryColor - paint.isAntiAlias = true - paint.strokeWidth = getDip(1).toFloat() - - pointRadius = getDip(3) - - orientation = VERTICAL - } - - /** This method clears all Views and HashMaps stored in this view. */ - fun clear() { - removeAllViews() - textViewMap.clear() - viewTextMap.clear() - } - - /** - * This method sets a View to this view. It clears all the stored views and hashmaps, and then - * calls the peek() method to peek into the View. - */ - fun setView(view: View) { - textViewMap.clear() - viewTextMap.clear() - removeAllViews() - peek(view, 1) - } - - /** - * This method recursively calls itself to add TextViews for each View inside the ViewGroup. It - * also stores the TextViews and Views in their respective hashmaps. - */ - private fun peek( - view: View, - depth: Int, - ) { - var nextDepth = depth - val binding = - LayoutStructureViewItemBinding.inflate(inflater, null, false) - val viewName = binding.viewName - val viewId = binding.viewId - val icon = binding.icon - if (view.id == -1 || idMap[view] == null) { - viewId.visibility = GONE - viewName.translationY = 0f - viewId.translationY = 0f - } else { - viewName.translationY = getDip(-7).toFloat() - viewId.translationY = getDip(-3).toFloat() - viewId.visibility = VISIBLE - viewId.text = idMap[view] - } - if (view is LinearLayout && view !is RadioGroup && view !is TextInputLayout) { - val orientation = - if (view.orientation == LinearLayout.HORIZONTAL) "horizontal" else "vertical" - val imgResId = imgMap[LinearLayout::class.java.simpleName + orientation]!! - - icon.setImageResource(imgResId) - viewName.text = String.format("%s (%s)", LinearLayout::class.java.simpleName, orientation) - } else { - val viewSimpleName = view.javaClass.superclass.simpleName - var imageResource = imgMap[viewSimpleName] - if (imageResource == null) { - imageResource = imgMap["_unknown"] - } - icon.setImageResource(imageResource!!) - viewName.text = viewSimpleName - } - - binding.mainView.setOnClickListener(this) - binding.mainView.setOnLongClickListener(this) - - addView(binding.root) - - val params = - binding.root.layoutParams as LayoutParams - params.leftMargin = depth * getDip(15) - - textViewMap[viewName] = view - viewTextMap[view] = viewName - - if (view is ViewGroup) { - val group = view - if (group !is CalendarView && - group !is SearchView && - group !is NavigationView && - group !is BottomNavigationView && - group !is TabLayout && - group !is TextInputLayout - ) { - nextDepth++ - - for (i in 0 until group.childCount) { - val child = group.getChildAt(i) - peek(child, nextDepth) - } - } else if (group is TextInputLayout) { - nextDepth++ - val editText = group.editText - if (editText != null) { - peek(editText, nextDepth) - } - } - } - } - - /** This method is called to draw rectangles, lines, and circles for each TextView in the view. */ - override fun dispatchDraw(canvas: Canvas) { - super.dispatchDraw(canvas) - - for (text in textViewMap.keys) { - val view = textViewMap[text] ?: continue - val parent = (text.parent?.parent as? ViewGroup) ?: continue - - val centerX = parent.x - val centerY = parent.y + parent.height.toFloat() / 2 - - fun drawCircle() { - canvas.drawCircle( - centerX, - centerY, - pointRadius.toFloat(), - paint, - ) - } - - fun drawRectangle() { - canvas.drawRect( - centerX - pointRadius, - centerY - pointRadius, - centerX + pointRadius, - centerY + pointRadius, - paint, - ) - } - - fun drawLine(targetParent: ViewGroup) { - val targetY = targetParent.y + targetParent.height.toFloat() / 2 - - canvas.drawLine( - centerX, - centerY, - centerX, - targetY, - paint, - ) - - canvas.drawLine( - centerX, - targetY, - targetParent.x, - targetY, - paint, - ) - } - - if (view !is ViewGroup || view.childCount <= 0) { - drawCircle() - continue - } - - when (view) { - is CalendarView, - is SearchView, - is NavigationView, - is BottomNavigationView, - is TabLayout -> { drawCircle() } - is TextInputLayout -> { - drawRectangle() - - val editText = view.editText ?: continue - val current = viewTextMap[editText] ?: continue - val currentParent = (current.parent?.parent as? ViewGroup) ?: continue - - drawLine(currentParent) - } - - else -> { - drawRectangle() - - for (i in 0 until view.childCount) { - val child = view.getChildAt(i) - val current = viewTextMap[child] ?: continue - val currentParent = (current.parent?.parent as? ViewGroup) ?: continue - - drawLine(currentParent) - } - } - } - } - } - - /** - * This method is called when a TextView is clicked, and it calls the OnItemClickListener's - * onItemClick method. - */ - override fun onClick(v: View) { - if (v is ViewGroup) { - for (i in 0 until v.childCount) { - val child = v.getChildAt(i) - if (child.id == R.id.view_name) { - textViewMap[child as TextView]?.let { - onItemClickListener?.invoke( - it, - ) - } - } - } - } - } - - override fun onLongClick(view: View): Boolean { - val parent = view as? ViewGroup ?: return false - val textView = parent.findViewById(R.id.view_name) ?: return false - - val associatedView = textViewMap[textView] ?: return false - - onItemLongClickListener?.invoke(associatedView) - - return true - } - - /** This method is used to convert the input into the equivalent dip value. */ - private fun getDip(input: Int): Int = - TypedValue - .applyDimension( - TypedValue.COMPLEX_UNIT_DIP, - input.toFloat(), - context.resources.displayMetrics, - ).toInt() - - companion object { - var imgMap: MutableMap = HashMap() - - init { - imgMap["_unknown"] = R.mipmap.ic_palette_unknown_view - imgMap[TextView::class.java.simpleName] = R.mipmap.ic_palette_text_view - imgMap[EditText::class.java.simpleName] = R.mipmap.ic_palette_edit_text - imgMap[Button::class.java.simpleName] = - R.mipmap.ic_palette_button - imgMap[ImageButton::class.java.simpleName] = - R.mipmap.ic_palette_image_button - imgMap[ImageView::class.java.simpleName] = R.mipmap.ic_palette_image_view - imgMap[VideoView::class.java.simpleName] = R.mipmap.ic_palette_video_view - imgMap[AutoCompleteTextView::class.java.simpleName] = - R.mipmap.ic_palette_auto_complete_text_view - imgMap[MultiAutoCompleteTextView::class.java.simpleName] = - R.mipmap.ic_palette_multi_auto_complete_text_view - imgMap[CheckedTextView::class.java.simpleName] = - R.mipmap.ic_palette_checked_text_view - imgMap[CheckBox::class.java.simpleName] = R.mipmap.ic_palette_check_box - imgMap[RadioButton::class.java.simpleName] = R.mipmap.ic_palette_radio_button - imgMap[RadioGroup::class.java.simpleName] = - R.mipmap.ic_palette_radio_group - imgMap[ToggleButton::class.java.simpleName] = R.mipmap.ic_palette_toggle_button - imgMap[Switch::class.java.simpleName] = R.mipmap.ic_palette_switch - imgMap[View::class.java.simpleName] = R.mipmap.ic_palette_view - imgMap[WebView::class.java.simpleName] = R.mipmap.ic_palette_web_view - imgMap[CalendarView::class.java.simpleName] = R.mipmap.ic_palette_calendar_view - imgMap[ProgressBar::class.java.simpleName] = R.mipmap.ic_palette_progress_bar - imgMap[ProgressBar::class.java.simpleName + "horizontal"] = - R.mipmap.ic_palette_progress_bar_horizontal - imgMap[SeekBar::class.java.simpleName] = R.mipmap.ic_palette_seek_bar - imgMap[RatingBar::class.java.simpleName] = R.mipmap.ic_palette_rating_bar - imgMap[TextureView::class.java.simpleName] = - R.mipmap.ic_palette_texture_view - imgMap[SurfaceView::class.java.simpleName] = R.mipmap.ic_palette_surface_view - imgMap[SearchView::class.java.simpleName] = - R.mipmap.ic_palette_search_view - imgMap[LinearLayout::class.java.simpleName + "horizontal"] = - R.mipmap.ic_palette_linear_layout_horz - imgMap[LinearLayout::class.java.simpleName + "vertical"] = - R.mipmap.ic_palette_linear_layout_vert - imgMap[FrameLayout::class.java.simpleName] = R.mipmap.ic_palette_frame_layout - imgMap[TableLayout::class.java.simpleName] = R.mipmap.ic_palette_table_layout - imgMap[TableRow::class.java.simpleName] = R.mipmap.ic_palette_table_row - imgMap[Space::class.java.simpleName] = R.mipmap.ic_palette_space - imgMap[Spinner::class.java.simpleName] = R.mipmap.ic_palette_spinner - imgMap[ScrollView::class.java.simpleName] = R.mipmap.ic_palette_scroll_view - imgMap[HorizontalScrollView::class.java.simpleName] = - R.mipmap.ic_palette_horizontal_scroll_view - imgMap[ViewStub::class.java.simpleName] = R.mipmap.ic_palette_view_stub - imgMap["include"] = R.mipmap.ic_palette_include - imgMap[GridLayout::class.java.simpleName] = - R.mipmap.ic_palette_grid_layout - imgMap[GridView::class.java.simpleName] = R.mipmap.ic_palette_grid_view - imgMap[RecyclerView::class.java.simpleName] = R.mipmap.ic_palette_recycler_view - imgMap[ListView::class.java.simpleName] = R.mipmap.ic_palette_list_view - imgMap[TabHost::class.java.simpleName] = R.mipmap.ic_palette_tab_host - imgMap[RelativeLayout::class.java.simpleName] = R.mipmap.ic_palette_relative_layout - imgMap[Chip::class.java.simpleName] = R.mipmap.ic_palette_chip - imgMap[ChipGroup::class.java.simpleName] = R.mipmap.ic_palette_chip_group - imgMap[FloatingActionButton::class.java.simpleName] = - R.mipmap.ic_palette_floating_action_button - imgMap[NestedScrollView::class.java.simpleName] = R.mipmap.ic_palette_nested_scroll_view - imgMap[ViewPager::class.java.simpleName] = R.mipmap.ic_palette_view_pager - imgMap[ViewPager2::class.java.simpleName] = R.mipmap.ic_palette_view_pager - imgMap[CardView::class.java.simpleName] = R.mipmap.ic_palette_card_view - imgMap[TextClock::class.java.simpleName] = R.mipmap.ic_palette_text_clock - imgMap[AppBarLayout::class.java.simpleName] = R.mipmap.ic_palette_app_bar_layout - imgMap[NavigationView::class.java.simpleName] = R.mipmap.ic_palette_navigation_view - imgMap[ConstraintLayout::class.java.simpleName] = - R.mipmap.ic_palette_constraint_layout - imgMap[BottomNavigationView::class.java.simpleName] = - R.mipmap.ic_palette_bottom_navigation_view - imgMap[CoordinatorLayout::class.java.simpleName] = - R.mipmap.ic_palette_coordinator_layout - imgMap[DrawerLayout::class.java.simpleName] = R.mipmap.ic_palette_drawer_layout - imgMap[TextInputLayout::class.java.simpleName] = R.mipmap.ic_palette_linear_layout_vert - imgMap[TextInputEditText::class.java.simpleName] = R.mipmap.ic_palette_edit_text - } - } -} diff --git a/layouteditor/src/main/play_store.png b/layouteditor/src/main/play_store.png deleted file mode 100644 index 72c8bd4250..0000000000 Binary files a/layouteditor/src/main/play_store.png and /dev/null differ diff --git a/layouteditor/src/main/res/drawable/android.xml b/layouteditor/src/main/res/drawable/android.xml deleted file mode 100644 index c622e01a5c..0000000000 --- a/layouteditor/src/main/res/drawable/android.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/drawable/backburger.xml b/layouteditor/src/main/res/drawable/backburger.xml deleted file mode 100644 index bc464a5d48..0000000000 --- a/layouteditor/src/main/res/drawable/backburger.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/drawable/background_drawer_left.xml b/layouteditor/src/main/res/drawable/background_drawer_left.xml deleted file mode 100644 index 41f0590796..0000000000 --- a/layouteditor/src/main/res/drawable/background_drawer_left.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/drawable/background_drawer_right.xml b/layouteditor/src/main/res/drawable/background_drawer_right.xml deleted file mode 100644 index 59aebdf358..0000000000 --- a/layouteditor/src/main/res/drawable/background_drawer_right.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/drawable/background_stroke_dash.xml b/layouteditor/src/main/res/drawable/background_stroke_dash.xml deleted file mode 100644 index d1937be6ba..0000000000 --- a/layouteditor/src/main/res/drawable/background_stroke_dash.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - diff --git a/layouteditor/src/main/res/drawable/brightness_4.xml b/layouteditor/src/main/res/drawable/brightness_4.xml deleted file mode 100644 index fb3b4fb1da..0000000000 --- a/layouteditor/src/main/res/drawable/brightness_4.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/drawable/cellphone_play.xml b/layouteditor/src/main/res/drawable/cellphone_play.xml deleted file mode 100644 index af0447db84..0000000000 --- a/layouteditor/src/main/res/drawable/cellphone_play.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/drawable/cellphone_screenshot.xml b/layouteditor/src/main/res/drawable/cellphone_screenshot.xml deleted file mode 100644 index 9eeba90b68..0000000000 --- a/layouteditor/src/main/res/drawable/cellphone_screenshot.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/drawable/close.xml b/layouteditor/src/main/res/drawable/close.xml deleted file mode 100644 index 05119ad73c..0000000000 --- a/layouteditor/src/main/res/drawable/close.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/drawable/cog.xml b/layouteditor/src/main/res/drawable/cog.xml deleted file mode 100644 index 1ed8446423..0000000000 --- a/layouteditor/src/main/res/drawable/cog.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - diff --git a/layouteditor/src/main/res/drawable/content_copy.xml b/layouteditor/src/main/res/drawable/content_copy.xml deleted file mode 100644 index dafde37b39..0000000000 --- a/layouteditor/src/main/res/drawable/content_copy.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/drawable/content_save.xml b/layouteditor/src/main/res/drawable/content_save.xml deleted file mode 100644 index e802c413d3..0000000000 --- a/layouteditor/src/main/res/drawable/content_save.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/drawable/content_save_outline.xml b/layouteditor/src/main/res/drawable/content_save_outline.xml deleted file mode 100644 index 538de28947..0000000000 --- a/layouteditor/src/main/res/drawable/content_save_outline.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/drawable/delete.xml b/layouteditor/src/main/res/drawable/delete.xml deleted file mode 100644 index 0ba99555b9..0000000000 --- a/layouteditor/src/main/res/drawable/delete.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/drawable/delete_outline.xml b/layouteditor/src/main/res/drawable/delete_outline.xml deleted file mode 100644 index ba1b7df0eb..0000000000 --- a/layouteditor/src/main/res/drawable/delete_outline.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/drawable/drawer_home_selected_item.xml b/layouteditor/src/main/res/drawable/drawer_home_selected_item.xml deleted file mode 100644 index 2871b1c317..0000000000 --- a/layouteditor/src/main/res/drawable/drawer_home_selected_item.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/drawable/drawer_home_unselected_item.xml b/layouteditor/src/main/res/drawable/drawer_home_unselected_item.xml deleted file mode 100644 index 9408e86288..0000000000 --- a/layouteditor/src/main/res/drawable/drawer_home_unselected_item.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/drawable/file_export.xml b/layouteditor/src/main/res/drawable/file_export.xml deleted file mode 100644 index f96f387566..0000000000 --- a/layouteditor/src/main/res/drawable/file_export.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/drawable/file_import.xml b/layouteditor/src/main/res/drawable/file_import.xml deleted file mode 100644 index 4e60665039..0000000000 --- a/layouteditor/src/main/res/drawable/file_import.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/drawable/file_tree.xml b/layouteditor/src/main/res/drawable/file_tree.xml deleted file mode 100644 index 43608f8544..0000000000 --- a/layouteditor/src/main/res/drawable/file_tree.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/drawable/folder_outline.xml b/layouteditor/src/main/res/drawable/folder_outline.xml deleted file mode 100644 index a61e015ab2..0000000000 --- a/layouteditor/src/main/res/drawable/folder_outline.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/drawable/folder_settings_outline.xml b/layouteditor/src/main/res/drawable/folder_settings_outline.xml deleted file mode 100644 index 4087c74a63..0000000000 --- a/layouteditor/src/main/res/drawable/folder_settings_outline.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/drawable/format_font.xml b/layouteditor/src/main/res/drawable/format_font.xml deleted file mode 100644 index ecdad7babe..0000000000 --- a/layouteditor/src/main/res/drawable/format_font.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/drawable/format_letter_case.xml b/layouteditor/src/main/res/drawable/format_letter_case.xml deleted file mode 100644 index 603b6013b8..0000000000 --- a/layouteditor/src/main/res/drawable/format_letter_case.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/drawable/home_outline.xml b/layouteditor/src/main/res/drawable/home_outline.xml deleted file mode 100644 index d2923822e1..0000000000 --- a/layouteditor/src/main/res/drawable/home_outline.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/drawable/ic_card.xml b/layouteditor/src/main/res/drawable/ic_card.xml deleted file mode 100644 index 25bab598c4..0000000000 --- a/layouteditor/src/main/res/drawable/ic_card.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/drawable/ic_checkbox_marked.xml b/layouteditor/src/main/res/drawable/ic_checkbox_marked.xml deleted file mode 100644 index 646f26703d..0000000000 --- a/layouteditor/src/main/res/drawable/ic_checkbox_marked.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/drawable/ic_color_picker.xml b/layouteditor/src/main/res/drawable/ic_color_picker.xml deleted file mode 100644 index 2f0ecdf61b..0000000000 --- a/layouteditor/src/main/res/drawable/ic_color_picker.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/layouteditor/src/main/res/drawable/ic_constraint.xml b/layouteditor/src/main/res/drawable/ic_constraint.xml deleted file mode 100644 index 791196e5a8..0000000000 --- a/layouteditor/src/main/res/drawable/ic_constraint.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/drawable/ic_coordinator.xml b/layouteditor/src/main/res/drawable/ic_coordinator.xml deleted file mode 100644 index 213f930207..0000000000 --- a/layouteditor/src/main/res/drawable/ic_coordinator.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/drawable/ic_cursor_text.xml b/layouteditor/src/main/res/drawable/ic_cursor_text.xml deleted file mode 100644 index a1590429af..0000000000 --- a/layouteditor/src/main/res/drawable/ic_cursor_text.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/drawable/ic_edittext.xml b/layouteditor/src/main/res/drawable/ic_edittext.xml deleted file mode 100644 index 837c0ef786..0000000000 --- a/layouteditor/src/main/res/drawable/ic_edittext.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/drawable/ic_frame.xml b/layouteditor/src/main/res/drawable/ic_frame.xml deleted file mode 100644 index 703c598c61..0000000000 --- a/layouteditor/src/main/res/drawable/ic_frame.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/drawable/ic_image_outline.xml b/layouteditor/src/main/res/drawable/ic_image_outline.xml deleted file mode 100644 index f99da1a7cf..0000000000 --- a/layouteditor/src/main/res/drawable/ic_image_outline.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/drawable/ic_linear_vertical.xml b/layouteditor/src/main/res/drawable/ic_linear_vertical.xml deleted file mode 100644 index 011acf3682..0000000000 --- a/layouteditor/src/main/res/drawable/ic_linear_vertical.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/drawable/ic_progress_check.xml b/layouteditor/src/main/res/drawable/ic_progress_check.xml deleted file mode 100644 index f6a763e844..0000000000 --- a/layouteditor/src/main/res/drawable/ic_progress_check.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/drawable/ic_radiobox_marked.xml b/layouteditor/src/main/res/drawable/ic_radiobox_marked.xml deleted file mode 100644 index 58e2f3129a..0000000000 --- a/layouteditor/src/main/res/drawable/ic_radiobox_marked.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/drawable/ic_radiogroup.xml b/layouteditor/src/main/res/drawable/ic_radiogroup.xml deleted file mode 100644 index 0e1430f245..0000000000 --- a/layouteditor/src/main/res/drawable/ic_radiogroup.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/drawable/ic_relative_layout_outline.xml b/layouteditor/src/main/res/drawable/ic_relative_layout_outline.xml deleted file mode 100644 index 56eb3a7676..0000000000 --- a/layouteditor/src/main/res/drawable/ic_relative_layout_outline.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/drawable/ic_seekbar.xml b/layouteditor/src/main/res/drawable/ic_seekbar.xml deleted file mode 100644 index e211677427..0000000000 --- a/layouteditor/src/main/res/drawable/ic_seekbar.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/drawable/ic_textview.xml b/layouteditor/src/main/res/drawable/ic_textview.xml deleted file mode 100644 index 603b6013b8..0000000000 --- a/layouteditor/src/main/res/drawable/ic_textview.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/drawable/ic_toggle_switch.xml b/layouteditor/src/main/res/drawable/ic_toggle_switch.xml deleted file mode 100644 index 0488e5de1f..0000000000 --- a/layouteditor/src/main/res/drawable/ic_toggle_switch.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/drawable/image_broken.xml b/layouteditor/src/main/res/drawable/image_broken.xml deleted file mode 100644 index 77fa647a6a..0000000000 --- a/layouteditor/src/main/res/drawable/image_broken.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/drawable/image_filter_center_focus.xml b/layouteditor/src/main/res/drawable/image_filter_center_focus.xml deleted file mode 100644 index 8cc7a36448..0000000000 --- a/layouteditor/src/main/res/drawable/image_filter_center_focus.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/drawable/image_outline.xml b/layouteditor/src/main/res/drawable/image_outline.xml deleted file mode 100644 index f99da1a7cf..0000000000 --- a/layouteditor/src/main/res/drawable/image_outline.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/drawable/information.xml b/layouteditor/src/main/res/drawable/information.xml deleted file mode 100644 index b0bdf2e1e8..0000000000 --- a/layouteditor/src/main/res/drawable/information.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/drawable/menu.xml b/layouteditor/src/main/res/drawable/menu.xml deleted file mode 100644 index 2d9b5deca6..0000000000 --- a/layouteditor/src/main/res/drawable/menu.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/drawable/palette_advanced.xml b/layouteditor/src/main/res/drawable/palette_advanced.xml deleted file mode 100644 index 05a96b3ae0..0000000000 --- a/layouteditor/src/main/res/drawable/palette_advanced.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/drawable/palette_outline.xml b/layouteditor/src/main/res/drawable/palette_outline.xml deleted file mode 100644 index e584cefde7..0000000000 --- a/layouteditor/src/main/res/drawable/palette_outline.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/drawable/plus.xml b/layouteditor/src/main/res/drawable/plus.xml deleted file mode 100644 index ff301507fc..0000000000 --- a/layouteditor/src/main/res/drawable/plus.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/drawable/redo_variant.xml b/layouteditor/src/main/res/drawable/redo_variant.xml deleted file mode 100644 index 9c0076a3b9..0000000000 --- a/layouteditor/src/main/res/drawable/redo_variant.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/drawable/rounded_rect.xml b/layouteditor/src/main/res/drawable/rounded_rect.xml deleted file mode 100644 index 72b647b349..0000000000 --- a/layouteditor/src/main/res/drawable/rounded_rect.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/drawable/shape.xml b/layouteditor/src/main/res/drawable/shape.xml deleted file mode 100644 index 60bdd1ae3f..0000000000 --- a/layouteditor/src/main/res/drawable/shape.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/drawable/shape_outline.xml b/layouteditor/src/main/res/drawable/shape_outline.xml deleted file mode 100644 index 0123e6e3c6..0000000000 --- a/layouteditor/src/main/res/drawable/shape_outline.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/drawable/share_variant.xml b/layouteditor/src/main/res/drawable/share_variant.xml deleted file mode 100644 index 4a647bc88d..0000000000 --- a/layouteditor/src/main/res/drawable/share_variant.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/drawable/source_merge.xml b/layouteditor/src/main/res/drawable/source_merge.xml deleted file mode 100644 index 36922a75e1..0000000000 --- a/layouteditor/src/main/res/drawable/source_merge.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/drawable/transparent.png b/layouteditor/src/main/res/drawable/transparent.png deleted file mode 100644 index 84daafbfc0..0000000000 Binary files a/layouteditor/src/main/res/drawable/transparent.png and /dev/null differ diff --git a/layouteditor/src/main/res/drawable/transparent_background.xml b/layouteditor/src/main/res/drawable/transparent_background.xml deleted file mode 100644 index 838534f6b5..0000000000 --- a/layouteditor/src/main/res/drawable/transparent_background.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - diff --git a/layouteditor/src/main/res/drawable/undo_variant.xml b/layouteditor/src/main/res/drawable/undo_variant.xml deleted file mode 100644 index cb3faa8bfc..0000000000 --- a/layouteditor/src/main/res/drawable/undo_variant.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/drawable/view_type.xml b/layouteditor/src/main/res/drawable/view_type.xml deleted file mode 100644 index dc180fa857..0000000000 --- a/layouteditor/src/main/res/drawable/view_type.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/drawable/xml.xml b/layouteditor/src/main/res/drawable/xml.xml deleted file mode 100644 index 2e06675660..0000000000 --- a/layouteditor/src/main/res/drawable/xml.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/font/jetbrains_mono_regular.ttf b/layouteditor/src/main/res/font/jetbrains_mono_regular.ttf deleted file mode 100644 index 8da8aa4051..0000000000 Binary files a/layouteditor/src/main/res/font/jetbrains_mono_regular.ttf and /dev/null differ diff --git a/layouteditor/src/main/res/font/poppins_regular.ttf b/layouteditor/src/main/res/font/poppins_regular.ttf deleted file mode 100644 index 9f0c71b70a..0000000000 Binary files a/layouteditor/src/main/res/font/poppins_regular.ttf and /dev/null differ diff --git a/layouteditor/src/main/res/font/source_sans_pro_regular.ttf b/layouteditor/src/main/res/font/source_sans_pro_regular.ttf deleted file mode 100644 index 98e8579745..0000000000 Binary files a/layouteditor/src/main/res/font/source_sans_pro_regular.ttf and /dev/null differ diff --git a/layouteditor/src/main/res/font/ubuntu_regular.ttf b/layouteditor/src/main/res/font/ubuntu_regular.ttf deleted file mode 100644 index f98a2dab85..0000000000 Binary files a/layouteditor/src/main/res/font/ubuntu_regular.ttf and /dev/null differ diff --git a/layouteditor/src/main/res/layout/activity_crash.xml b/layouteditor/src/main/res/layout/activity_crash.xml deleted file mode 100644 index 1a434aab9f..0000000000 --- a/layouteditor/src/main/res/layout/activity_crash.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/layout/activity_drawable_manager.xml b/layouteditor/src/main/res/layout/activity_drawable_manager.xml deleted file mode 100644 index afa4060407..0000000000 --- a/layouteditor/src/main/res/layout/activity_drawable_manager.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/layouteditor/src/main/res/layout/activity_editor.xml b/layouteditor/src/main/res/layout/activity_editor.xml deleted file mode 100644 index 5d1cd610fe..0000000000 --- a/layouteditor/src/main/res/layout/activity_editor.xml +++ /dev/null @@ -1,164 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/layouteditor/src/main/res/layout/activity_help.xml b/layouteditor/src/main/res/layout/activity_help.xml deleted file mode 100644 index 7caf6c2f6c..0000000000 --- a/layouteditor/src/main/res/layout/activity_help.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - diff --git a/layouteditor/src/main/res/layout/activity_layout_editor.xml b/layouteditor/src/main/res/layout/activity_layout_editor.xml deleted file mode 100644 index 163e49a5a1..0000000000 --- a/layouteditor/src/main/res/layout/activity_layout_editor.xml +++ /dev/null @@ -1,182 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/layouteditor/src/main/res/layout/activity_preview_drawable.xml b/layouteditor/src/main/res/layout/activity_preview_drawable.xml deleted file mode 100644 index 6d044bbd49..0000000000 --- a/layouteditor/src/main/res/layout/activity_preview_drawable.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/layouteditor/src/main/res/layout/activity_preview_layout.xml b/layouteditor/src/main/res/layout/activity_preview_layout.xml deleted file mode 100644 index 93de36df12..0000000000 --- a/layouteditor/src/main/res/layout/activity_preview_layout.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/layout/activity_resource_manager.xml b/layouteditor/src/main/res/layout/activity_resource_manager.xml deleted file mode 100644 index c6db09b81f..0000000000 --- a/layouteditor/src/main/res/layout/activity_resource_manager.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - diff --git a/layouteditor/src/main/res/layout/activity_show_x_m_l.xml b/layouteditor/src/main/res/layout/activity_show_x_m_l.xml deleted file mode 100644 index aefc1001c9..0000000000 --- a/layouteditor/src/main/res/layout/activity_show_x_m_l.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/layouteditor/src/main/res/layout/dialog_available_attributes.xml b/layouteditor/src/main/res/layout/dialog_available_attributes.xml deleted file mode 100644 index fe0ed562fe..0000000000 --- a/layouteditor/src/main/res/layout/dialog_available_attributes.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/layout/dialog_select_dpis.xml b/layouteditor/src/main/res/layout/dialog_select_dpis.xml deleted file mode 100644 index 66db0135b7..0000000000 --- a/layouteditor/src/main/res/layout/dialog_select_dpis.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - diff --git a/layouteditor/src/main/res/layout/fragment_resources.xml b/layouteditor/src/main/res/layout/fragment_resources.xml deleted file mode 100644 index 221b5205ac..0000000000 --- a/layouteditor/src/main/res/layout/fragment_resources.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - diff --git a/layouteditor/src/main/res/layout/layout_boolean_dialog.xml b/layouteditor/src/main/res/layout/layout_boolean_dialog.xml deleted file mode 100644 index 1da7463608..0000000000 --- a/layouteditor/src/main/res/layout/layout_boolean_dialog.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - diff --git a/layouteditor/src/main/res/layout/layout_color_dialog.xml b/layouteditor/src/main/res/layout/layout_color_dialog.xml deleted file mode 100644 index 4e5a26f8ad..0000000000 --- a/layouteditor/src/main/res/layout/layout_color_dialog.xml +++ /dev/null @@ -1,194 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/layouteditor/src/main/res/layout/layout_color_dialog_flag.xml b/layouteditor/src/main/res/layout/layout_color_dialog_flag.xml deleted file mode 100644 index 28548e438b..0000000000 --- a/layouteditor/src/main/res/layout/layout_color_dialog_flag.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/layout/layout_color_item.xml b/layouteditor/src/main/res/layout/layout_color_item.xml deleted file mode 100644 index b011cc88af..0000000000 --- a/layouteditor/src/main/res/layout/layout_color_item.xml +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/layouteditor/src/main/res/layout/layout_drawable_grid_item.xml b/layouteditor/src/main/res/layout/layout_drawable_grid_item.xml deleted file mode 100644 index 70f85775d6..0000000000 --- a/layouteditor/src/main/res/layout/layout_drawable_grid_item.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/layout/layout_drawable_item.xml b/layouteditor/src/main/res/layout/layout_drawable_item.xml deleted file mode 100644 index 203241aaa6..0000000000 --- a/layouteditor/src/main/res/layout/layout_drawable_item.xml +++ /dev/null @@ -1,81 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/layouteditor/src/main/res/layout/layout_font_item.xml b/layouteditor/src/main/res/layout/layout_font_item.xml deleted file mode 100644 index b8f34ee778..0000000000 --- a/layouteditor/src/main/res/layout/layout_font_item.xml +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - - - - - - - - diff --git a/layouteditor/src/main/res/layout/layout_font_item_dialog.xml b/layouteditor/src/main/res/layout/layout_font_item_dialog.xml deleted file mode 100644 index ec9f05067b..0000000000 --- a/layouteditor/src/main/res/layout/layout_font_item_dialog.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - diff --git a/layouteditor/src/main/res/layout/layout_navigation_header.xml b/layouteditor/src/main/res/layout/layout_navigation_header.xml deleted file mode 100644 index 3aa46beb54..0000000000 --- a/layouteditor/src/main/res/layout/layout_navigation_header.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - diff --git a/layouteditor/src/main/res/layout/layout_palette_item.xml b/layouteditor/src/main/res/layout/layout_palette_item.xml deleted file mode 100644 index a0b94f7f06..0000000000 --- a/layouteditor/src/main/res/layout/layout_palette_item.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/layout/layout_preview_drawable.xml b/layouteditor/src/main/res/layout/layout_preview_drawable.xml deleted file mode 100644 index fcf654f5e1..0000000000 --- a/layouteditor/src/main/res/layout/layout_preview_drawable.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - diff --git a/layouteditor/src/main/res/layout/layout_project_layout_item.xml b/layouteditor/src/main/res/layout/layout_project_layout_item.xml deleted file mode 100644 index d1e46cfab7..0000000000 --- a/layouteditor/src/main/res/layout/layout_project_layout_item.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/layout/layout_select_dpi_item.xml b/layouteditor/src/main/res/layout/layout_select_dpi_item.xml deleted file mode 100644 index e0b7226f50..0000000000 --- a/layouteditor/src/main/res/layout/layout_select_dpi_item.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/layouteditor/src/main/res/layout/layout_size_dialog.xml b/layouteditor/src/main/res/layout/layout_size_dialog.xml deleted file mode 100644 index ee8e00bb1d..0000000000 --- a/layouteditor/src/main/res/layout/layout_size_dialog.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/layout/layout_structure_view_item.xml b/layouteditor/src/main/res/layout/layout_structure_view_item.xml deleted file mode 100644 index 065d70d51d..0000000000 --- a/layouteditor/src/main/res/layout/layout_structure_view_item.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - - - diff --git a/layouteditor/src/main/res/layout/layout_values_item.xml b/layouteditor/src/main/res/layout/layout_values_item.xml deleted file mode 100644 index f420fcb38b..0000000000 --- a/layouteditor/src/main/res/layout/layout_values_item.xml +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/layout/layout_values_item_dialog.xml b/layouteditor/src/main/res/layout/layout_values_item_dialog.xml deleted file mode 100644 index 48a845d884..0000000000 --- a/layouteditor/src/main/res/layout/layout_values_item_dialog.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - diff --git a/layouteditor/src/main/res/layout/list_project_file.xml b/layouteditor/src/main/res/layout/list_project_file.xml deleted file mode 100644 index 32630b3be3..0000000000 --- a/layouteditor/src/main/res/layout/list_project_file.xml +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/layouteditor/src/main/res/layout/preference_switch_style.xml b/layouteditor/src/main/res/layout/preference_switch_style.xml deleted file mode 100644 index fbae8da4d9..0000000000 --- a/layouteditor/src/main/res/layout/preference_switch_style.xml +++ /dev/null @@ -1,9 +0,0 @@ - - diff --git a/layouteditor/src/main/res/layout/show_attribute_item.xml b/layouteditor/src/main/res/layout/show_attribute_item.xml deleted file mode 100644 index bd2b653e42..0000000000 --- a/layouteditor/src/main/res/layout/show_attribute_item.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - diff --git a/layouteditor/src/main/res/layout/show_attributes_dialog.xml b/layouteditor/src/main/res/layout/show_attributes_dialog.xml deleted file mode 100644 index 7e4f18d701..0000000000 --- a/layouteditor/src/main/res/layout/show_attributes_dialog.xml +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/layouteditor/src/main/res/menu/menu_device_size.xml b/layouteditor/src/main/res/menu/menu_device_size.xml deleted file mode 100644 index aafeb256fa..0000000000 --- a/layouteditor/src/main/res/menu/menu_device_size.xml +++ /dev/null @@ -1,16 +0,0 @@ - -

- - - - - - - - diff --git a/layouteditor/src/main/res/menu/menu_drawable.xml b/layouteditor/src/main/res/menu/menu_drawable.xml deleted file mode 100644 index 1d03c79dca..0000000000 --- a/layouteditor/src/main/res/menu/menu_drawable.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - diff --git a/layouteditor/src/main/res/menu/menu_editor.xml b/layouteditor/src/main/res/menu/menu_editor.xml deleted file mode 100644 index d428e82c75..0000000000 --- a/layouteditor/src/main/res/menu/menu_editor.xml +++ /dev/null @@ -1,86 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/layouteditor/src/main/res/menu/menu_font.xml b/layouteditor/src/main/res/menu/menu_font.xml deleted file mode 100644 index 75c96a17a4..0000000000 --- a/layouteditor/src/main/res/menu/menu_font.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - diff --git a/layouteditor/src/main/res/menu/menu_layout_file_options.xml b/layouteditor/src/main/res/menu/menu_layout_file_options.xml deleted file mode 100644 index 89f768a871..0000000000 --- a/layouteditor/src/main/res/menu/menu_layout_file_options.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/menu/menu_project_file_options.xml b/layouteditor/src/main/res/menu/menu_project_file_options.xml deleted file mode 100644 index 813444b1f5..0000000000 --- a/layouteditor/src/main/res/menu/menu_project_file_options.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - diff --git a/layouteditor/src/main/res/menu/menu_resource_manager.xml b/layouteditor/src/main/res/menu/menu_resource_manager.xml deleted file mode 100644 index cd33152e37..0000000000 --- a/layouteditor/src/main/res/menu/menu_resource_manager.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - diff --git a/layouteditor/src/main/res/menu/menu_values.xml b/layouteditor/src/main/res/menu/menu_values.xml deleted file mode 100644 index 135d330d9a..0000000000 --- a/layouteditor/src/main/res/menu/menu_values.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - diff --git a/layouteditor/src/main/res/menu/menu_view_type.xml b/layouteditor/src/main/res/menu/menu_view_type.xml deleted file mode 100644 index f66be375e4..0000000000 --- a/layouteditor/src/main/res/menu/menu_view_type.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - diff --git a/layouteditor/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/layouteditor/src/main/res/mipmap-anydpi-v26/ic_launcher.xml deleted file mode 100644 index 345888d26e..0000000000 --- a/layouteditor/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-hdpi/ic_launcher.png b/layouteditor/src/main/res/mipmap-hdpi/ic_launcher.png deleted file mode 100644 index d7b1dd9872..0000000000 Binary files a/layouteditor/src/main/res/mipmap-hdpi/ic_launcher.png and /dev/null differ diff --git a/layouteditor/src/main/res/mipmap-hdpi/ic_launcher_background.png b/layouteditor/src/main/res/mipmap-hdpi/ic_launcher_background.png deleted file mode 100644 index 4b2d3f253c..0000000000 Binary files a/layouteditor/src/main/res/mipmap-hdpi/ic_launcher_background.png and /dev/null differ diff --git a/layouteditor/src/main/res/mipmap-hdpi/ic_launcher_foreground.png b/layouteditor/src/main/res/mipmap-hdpi/ic_launcher_foreground.png deleted file mode 100644 index c38d468b5b..0000000000 Binary files a/layouteditor/src/main/res/mipmap-hdpi/ic_launcher_foreground.png and /dev/null differ diff --git a/layouteditor/src/main/res/mipmap-hdpi/ic_launcher_monochrome.png b/layouteditor/src/main/res/mipmap-hdpi/ic_launcher_monochrome.png deleted file mode 100644 index 17ed15807b..0000000000 Binary files a/layouteditor/src/main/res/mipmap-hdpi/ic_launcher_monochrome.png and /dev/null differ diff --git a/layouteditor/src/main/res/mipmap-mdpi/ic_launcher.png b/layouteditor/src/main/res/mipmap-mdpi/ic_launcher.png deleted file mode 100644 index eb187334f8..0000000000 Binary files a/layouteditor/src/main/res/mipmap-mdpi/ic_launcher.png and /dev/null differ diff --git a/layouteditor/src/main/res/mipmap-mdpi/ic_launcher_background.png b/layouteditor/src/main/res/mipmap-mdpi/ic_launcher_background.png deleted file mode 100644 index 179cc6a9cf..0000000000 Binary files a/layouteditor/src/main/res/mipmap-mdpi/ic_launcher_background.png and /dev/null differ diff --git a/layouteditor/src/main/res/mipmap-mdpi/ic_launcher_foreground.png b/layouteditor/src/main/res/mipmap-mdpi/ic_launcher_foreground.png deleted file mode 100644 index 37b6039c8c..0000000000 Binary files a/layouteditor/src/main/res/mipmap-mdpi/ic_launcher_foreground.png and /dev/null differ diff --git a/layouteditor/src/main/res/mipmap-mdpi/ic_launcher_monochrome.png b/layouteditor/src/main/res/mipmap-mdpi/ic_launcher_monochrome.png deleted file mode 100644 index 5279ae622a..0000000000 Binary files a/layouteditor/src/main/res/mipmap-mdpi/ic_launcher_monochrome.png and /dev/null differ diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_button.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_button.xml deleted file mode 100644 index 20803056bd..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_button.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_button_2.png b/layouteditor/src/main/res/mipmap-xhdpi/ic_button_2.png deleted file mode 100644 index 040475f069..0000000000 Binary files a/layouteditor/src/main/res/mipmap-xhdpi/ic_button_2.png and /dev/null differ diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_card.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_card.xml deleted file mode 100644 index 25bab598c4..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_card.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_checkbox_marked.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_checkbox_marked.xml deleted file mode 100644 index 646f26703d..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_checkbox_marked.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_constraint.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_constraint.xml deleted file mode 100644 index 791196e5a8..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_constraint.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_coordinator.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_coordinator.xml deleted file mode 100644 index 213f930207..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_coordinator.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_cursor_text.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_cursor_text.xml deleted file mode 100644 index a1590429af..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_cursor_text.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_edittext.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_edittext.xml deleted file mode 100644 index 837c0ef786..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_edittext.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_fab.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_fab.xml deleted file mode 100644 index 5acd65552b..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_fab.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_frame.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_frame.xml deleted file mode 100644 index 703c598c61..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_frame.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_image_outline.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_image_outline.xml deleted file mode 100644 index f99da1a7cf..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_image_outline.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_launcher.png b/layouteditor/src/main/res/mipmap-xhdpi/ic_launcher.png deleted file mode 100644 index bfaa9441dd..0000000000 Binary files a/layouteditor/src/main/res/mipmap-xhdpi/ic_launcher.png and /dev/null differ diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_launcher_background.png b/layouteditor/src/main/res/mipmap-xhdpi/ic_launcher_background.png deleted file mode 100644 index 51c90d02d1..0000000000 Binary files a/layouteditor/src/main/res/mipmap-xhdpi/ic_launcher_background.png and /dev/null differ diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png b/layouteditor/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png deleted file mode 100644 index 1db3fb4e00..0000000000 Binary files a/layouteditor/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png and /dev/null differ diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_launcher_monochrome.png b/layouteditor/src/main/res/mipmap-xhdpi/ic_launcher_monochrome.png deleted file mode 100644 index d03c861263..0000000000 Binary files a/layouteditor/src/main/res/mipmap-xhdpi/ic_launcher_monochrome.png and /dev/null differ diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_linear_horizontal.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_linear_horizontal.xml deleted file mode 100644 index 011acf3682..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_linear_horizontal.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_linear_vertical.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_linear_vertical.xml deleted file mode 100644 index 5e68373af8..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_linear_vertical.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_ad_view.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_ad_view.xml deleted file mode 100644 index 05312e9d72..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_ad_view.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_adapter_view_flipper.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_adapter_view_flipper.xml deleted file mode 100644 index 02242dd25f..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_adapter_view_flipper.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_analog_clock.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_analog_clock.xml deleted file mode 100644 index ced0f38bb2..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_analog_clock.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_app_bar_layout.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_app_bar_layout.xml deleted file mode 100644 index 0b057db07d..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_app_bar_layout.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_auto_complete_text_view.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_auto_complete_text_view.xml deleted file mode 100644 index 18837fe2b5..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_auto_complete_text_view.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_barrier_horizontal.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_barrier_horizontal.xml deleted file mode 100644 index 531e353c2a..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_barrier_horizontal.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_barrier_vertical.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_barrier_vertical.xml deleted file mode 100644 index 1831e9d2f1..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_barrier_vertical.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_bottom_app_bar.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_bottom_app_bar.xml deleted file mode 100644 index 14724ec5d7..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_bottom_app_bar.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_bottom_navigation_view.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_bottom_navigation_view.xml deleted file mode 100644 index 16235931ab..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_bottom_navigation_view.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_button.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_button.xml deleted file mode 100644 index e3f6465bfa..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_button.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_calendar_view.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_calendar_view.xml deleted file mode 100644 index 2445f9618d..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_calendar_view.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_card_view.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_card_view.xml deleted file mode 100644 index ed10102233..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_card_view.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_check_box.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_check_box.xml deleted file mode 100644 index c394bfd4bb..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_check_box.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_checked_text_view.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_checked_text_view.xml deleted file mode 100644 index 25bf610adf..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_checked_text_view.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_chip.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_chip.xml deleted file mode 100644 index f01ea32f14..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_chip.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_chip_group.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_chip_group.xml deleted file mode 100644 index e38ac73959..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_chip_group.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_chronometer.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_chronometer.xml deleted file mode 100644 index c4692397a3..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_chronometer.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_collapsing_toolbar_layout.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_collapsing_toolbar_layout.xml deleted file mode 100644 index 345aa5e385..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_collapsing_toolbar_layout.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_constraint_layout.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_constraint_layout.xml deleted file mode 100644 index 1b547edfe9..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_constraint_layout.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_coordinator_layout.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_coordinator_layout.xml deleted file mode 100644 index e31c5960ad..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_coordinator_layout.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_custom_view.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_custom_view.xml deleted file mode 100644 index 0d61589ebd..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_custom_view.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_date_picker.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_date_picker.xml deleted file mode 100644 index f0735aa114..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_date_picker.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_date_textfield.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_date_textfield.xml deleted file mode 100644 index e887fc368d..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_date_textfield.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_drawer_layout.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_drawer_layout.xml deleted file mode 100644 index a928815923..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_drawer_layout.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_edit_text.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_edit_text.xml deleted file mode 100644 index b93f4a4959..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_edit_text.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_email_textfield.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_email_textfield.xml deleted file mode 100644 index b93f4a4959..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_email_textfield.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_expandable_list_view.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_expandable_list_view.xml deleted file mode 100644 index b7064ab9fe..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_expandable_list_view.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_floating_action_button.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_floating_action_button.xml deleted file mode 100644 index 1376a96456..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_floating_action_button.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_fragment.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_fragment.xml deleted file mode 100644 index f3a9357437..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_fragment.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_frame_layout.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_frame_layout.xml deleted file mode 100644 index fb3418b888..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_frame_layout.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_grid_layout.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_grid_layout.xml deleted file mode 100644 index f2e68ddeb1..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_grid_layout.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_grid_layout_compat.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_grid_layout_compat.xml deleted file mode 100644 index 21affadca0..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_grid_layout_compat.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_grid_view.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_grid_view.xml deleted file mode 100644 index f2e68ddeb1..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_grid_view.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_guideline_horizontal.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_guideline_horizontal.xml deleted file mode 100644 index 8b98e2466c..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_guideline_horizontal.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_guideline_vertical.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_guideline_vertical.xml deleted file mode 100644 index 56a6570a03..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_guideline_vertical.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_horizontal_divider.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_horizontal_divider.xml deleted file mode 100644 index d7f1a9890a..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_horizontal_divider.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_horizontal_scroll_view.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_horizontal_scroll_view.xml deleted file mode 100644 index d1f6d3fc54..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_horizontal_scroll_view.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_image_button.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_image_button.xml deleted file mode 100644 index 19758b08a4..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_image_button.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_image_switcher.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_image_switcher.xml deleted file mode 100644 index db1262b2df..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_image_switcher.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_image_view.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_image_view.xml deleted file mode 100644 index 1595fc7b60..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_image_view.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_include.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_include.xml deleted file mode 100644 index adca2f8892..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_include.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_linear_layout_horz.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_linear_layout_horz.xml deleted file mode 100644 index ed88a79413..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_linear_layout_horz.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_linear_layout_vert.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_linear_layout_vert.xml deleted file mode 100644 index e72d689d7a..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_linear_layout_vert.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_list_view.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_list_view.xml deleted file mode 100644 index 50a6ca4598..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_list_view.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_map_fragment.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_map_fragment.xml deleted file mode 100644 index bd80588ce9..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_map_fragment.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_map_view.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_map_view.xml deleted file mode 100644 index bd80588ce9..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_map_view.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_menu.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_menu.xml deleted file mode 100644 index cd84a135b5..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_menu.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_merge.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_merge.xml deleted file mode 100644 index 19f2c596ea..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_merge.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_multi_auto_complete_text_view.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_multi_auto_complete_text_view.xml deleted file mode 100644 index 06de5285d8..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_multi_auto_complete_text_view.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_nav_host_fragment.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_nav_host_fragment.xml deleted file mode 100644 index 6be5ae89d1..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_nav_host_fragment.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_navigation_view.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_navigation_view.xml deleted file mode 100644 index ffa6052bf0..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_navigation_view.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_nested_scroll_view.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_nested_scroll_view.xml deleted file mode 100644 index 984ece13ec..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_nested_scroll_view.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_number_decimal_textfield.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_number_decimal_textfield.xml deleted file mode 100644 index b93f4a4959..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_number_decimal_textfield.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_number_picker.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_number_picker.xml deleted file mode 100644 index dea32a0a64..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_number_picker.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_number_signed_textfield.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_number_signed_textfield.xml deleted file mode 100644 index b93f4a4959..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_number_signed_textfield.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_number_textfield.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_number_textfield.xml deleted file mode 100644 index b93f4a4959..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_number_textfield.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_password_numeric_textfield.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_password_numeric_textfield.xml deleted file mode 100644 index b93f4a4959..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_password_numeric_textfield.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_password_textfield.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_password_textfield.xml deleted file mode 100644 index b93f4a4959..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_password_textfield.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_phone_textfield.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_phone_textfield.xml deleted file mode 100644 index b93f4a4959..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_phone_textfield.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_postal_address_textfield.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_postal_address_textfield.xml deleted file mode 100644 index b93f4a4959..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_postal_address_textfield.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_progress_bar.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_progress_bar.xml deleted file mode 100644 index 28399e86ce..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_progress_bar.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_progress_bar_horizontal.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_progress_bar_horizontal.xml deleted file mode 100644 index e345d22257..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_progress_bar_horizontal.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_quick_contact_badge.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_quick_contact_badge.xml deleted file mode 100644 index 9d7df61b37..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_quick_contact_badge.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_radio_button.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_radio_button.xml deleted file mode 100644 index 6b2a1e19ea..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_radio_button.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_radio_group.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_radio_group.xml deleted file mode 100644 index 6b2a1e19ea..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_radio_group.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_rating_bar.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_rating_bar.xml deleted file mode 100644 index d30d97ec34..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_rating_bar.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_recycler_view.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_recycler_view.xml deleted file mode 100644 index 50a6ca4598..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_recycler_view.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_relative_layout.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_relative_layout.xml deleted file mode 100644 index 3b42668499..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_relative_layout.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_request_focus.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_request_focus.xml deleted file mode 100644 index 040e325c7a..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_request_focus.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_scroll_view.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_scroll_view.xml deleted file mode 100644 index 984ece13ec..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_scroll_view.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_search_view.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_search_view.xml deleted file mode 100644 index 0c158379e9..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_search_view.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_seek_bar.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_seek_bar.xml deleted file mode 100644 index a347677c43..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_seek_bar.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_seek_bar_discrete.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_seek_bar_discrete.xml deleted file mode 100644 index 09beeb2143..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_seek_bar_discrete.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_space.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_space.xml deleted file mode 100644 index d6bc801e3c..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_space.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_spinner.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_spinner.xml deleted file mode 100644 index 961b20cbf7..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_spinner.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_stack_view.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_stack_view.xml deleted file mode 100644 index dc2e214105..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_stack_view.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_surface_view.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_surface_view.xml deleted file mode 100644 index d18386d9cf..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_surface_view.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_switch.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_switch.xml deleted file mode 100644 index 8c536c42a2..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_switch.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_tab_host.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_tab_host.xml deleted file mode 100644 index c87e009044..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_tab_host.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_tab_item.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_tab_item.xml deleted file mode 100644 index c87e009044..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_tab_item.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_tab_layout.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_tab_layout.xml deleted file mode 100644 index 37f0db11db..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_tab_layout.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_tab_widget.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_tab_widget.xml deleted file mode 100644 index c87e009044..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_tab_widget.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_table_layout.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_table_layout.xml deleted file mode 100644 index 6923f90d1e..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_table_layout.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_table_row.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_table_row.xml deleted file mode 100644 index f981552adf..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_table_row.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_text_clock.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_text_clock.xml deleted file mode 100644 index ced0f38bb2..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_text_clock.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_text_input_layout.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_text_input_layout.xml deleted file mode 100644 index b93f4a4959..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_text_input_layout.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_text_switcher.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_text_switcher.xml deleted file mode 100644 index d0daa1eee9..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_text_switcher.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_text_view.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_text_view.xml deleted file mode 100644 index 7388b61cb5..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_text_view.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_textfield.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_textfield.xml deleted file mode 100644 index b93f4a4959..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_textfield.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_textfield_multiline.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_textfield_multiline.xml deleted file mode 100644 index b93f4a4959..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_textfield_multiline.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_texture_view.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_texture_view.xml deleted file mode 100644 index e26bb95ad2..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_texture_view.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_time_picker.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_time_picker.xml deleted file mode 100644 index 31916ccb4e..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_time_picker.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_time_textfield.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_time_textfield.xml deleted file mode 100644 index b93f4a4959..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_time_textfield.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_toggle_button.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_toggle_button.xml deleted file mode 100644 index 4aca3b91d0..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_toggle_button.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_toolbar.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_toolbar.xml deleted file mode 100644 index 345aa5e385..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_toolbar.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_unknown_view.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_unknown_view.xml deleted file mode 100644 index 3729867c14..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_unknown_view.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_vertical_divider.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_vertical_divider.xml deleted file mode 100644 index 448ef0d1dd..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_vertical_divider.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_video_view.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_video_view.xml deleted file mode 100644 index d49bd74320..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_video_view.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_view.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_view.xml deleted file mode 100644 index 7c1bf8ff55..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_view.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_view_animator.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_view_animator.xml deleted file mode 100644 index 863ef54ff2..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_view_animator.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_view_flipper.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_view_flipper.xml deleted file mode 100644 index 1892371d26..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_view_flipper.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_view_pager.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_view_pager.xml deleted file mode 100644 index 87b1b9de59..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_view_pager.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_view_stub.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_view_stub.xml deleted file mode 100644 index f9a5c95939..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_view_stub.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_view_switcher.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_view_switcher.xml deleted file mode 100644 index 9d646fff43..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_view_switcher.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_web_view.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_web_view.xml deleted file mode 100644 index 3af3f71a64..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_palette_web_view.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_progress_check.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_progress_check.xml deleted file mode 100644 index f6a763e844..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_progress_check.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_radiobox_marked.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_radiobox_marked.xml deleted file mode 100644 index 58e2f3129a..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_radiobox_marked.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_radiogroup.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_radiogroup.xml deleted file mode 100644 index 0e1430f245..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_radiogroup.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_relative_layout_outline.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_relative_layout_outline.xml deleted file mode 100644 index 56eb3a7676..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_relative_layout_outline.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_seekbar.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_seekbar.xml deleted file mode 100644 index e211677427..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_seekbar.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_textview.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_textview.xml deleted file mode 100644 index 603b6013b8..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_textview.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xhdpi/ic_toggle_switch.xml b/layouteditor/src/main/res/mipmap-xhdpi/ic_toggle_switch.xml deleted file mode 100644 index 0488e5de1f..0000000000 --- a/layouteditor/src/main/res/mipmap-xhdpi/ic_toggle_switch.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/mipmap-xxhdpi/ic_launcher.png b/layouteditor/src/main/res/mipmap-xxhdpi/ic_launcher.png deleted file mode 100644 index 59d9dc79ef..0000000000 Binary files a/layouteditor/src/main/res/mipmap-xxhdpi/ic_launcher.png and /dev/null differ diff --git a/layouteditor/src/main/res/mipmap-xxhdpi/ic_launcher_background.png b/layouteditor/src/main/res/mipmap-xxhdpi/ic_launcher_background.png deleted file mode 100644 index c7292b5e72..0000000000 Binary files a/layouteditor/src/main/res/mipmap-xxhdpi/ic_launcher_background.png and /dev/null differ diff --git a/layouteditor/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png b/layouteditor/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png deleted file mode 100644 index e85a7253e4..0000000000 Binary files a/layouteditor/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png and /dev/null differ diff --git a/layouteditor/src/main/res/mipmap-xxhdpi/ic_launcher_monochrome.png b/layouteditor/src/main/res/mipmap-xxhdpi/ic_launcher_monochrome.png deleted file mode 100644 index b57baeb1ed..0000000000 Binary files a/layouteditor/src/main/res/mipmap-xxhdpi/ic_launcher_monochrome.png and /dev/null differ diff --git a/layouteditor/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/layouteditor/src/main/res/mipmap-xxxhdpi/ic_launcher.png deleted file mode 100644 index d860a598eb..0000000000 Binary files a/layouteditor/src/main/res/mipmap-xxxhdpi/ic_launcher.png and /dev/null differ diff --git a/layouteditor/src/main/res/mipmap-xxxhdpi/ic_launcher_background.png b/layouteditor/src/main/res/mipmap-xxxhdpi/ic_launcher_background.png deleted file mode 100644 index 88ae25587c..0000000000 Binary files a/layouteditor/src/main/res/mipmap-xxxhdpi/ic_launcher_background.png and /dev/null differ diff --git a/layouteditor/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png b/layouteditor/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png deleted file mode 100644 index 3d99fa7794..0000000000 Binary files a/layouteditor/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png and /dev/null differ diff --git a/layouteditor/src/main/res/mipmap-xxxhdpi/ic_launcher_monochrome.png b/layouteditor/src/main/res/mipmap-xxxhdpi/ic_launcher_monochrome.png deleted file mode 100644 index 8647c63b83..0000000000 Binary files a/layouteditor/src/main/res/mipmap-xxxhdpi/ic_launcher_monochrome.png and /dev/null differ diff --git a/layouteditor/src/main/res/values-in/strings.xml b/layouteditor/src/main/res/values-in/strings.xml deleted file mode 100644 index 4ba18df7b4..0000000000 --- a/layouteditor/src/main/res/values-in/strings.xml +++ /dev/null @@ -1,178 +0,0 @@ - - TENTANG - Preferensi - Tentang - Buka laci navigasi - Tutup laci navigasi - Proyek telah disimpan. - Proyek baru - Layout telah disimpan - Gagal menyimpan layout - Layout baru - Layout kosong! Tambahkan tampilan sebelum menyimpan… - Tambah baru - Hapus - Salin - Pengelola Drawable - Pratinjau XML - Klik ikon + untuk membuat proyek baru. - Izin diberikan… - Izin ditolak… - Pratinjau Layout - Telah disalin ke papan klip - Apakah Anda yakin ingin menghapus proyek ini? - Apakah Anda yakin ingin menghapus layout ini? - Hapus proyek - Buat proyek - Hapus layout - Buat layout - Ya - Tidak - Ubah nama - Batal - Buat - Masukkan nama proyek baru - Ubah nama proyek - Masukkan nama layout baru - Ubah nama Layout - Nama saat ini tidak tersedia! - Kolom ini tidak boleh kosong! - Opsi - Hapus drawable - Hapus font - Apakah Anda yakin ingin menghapus drawable ini? - Apakah Anda yakin ingin menghapus font ini? - Masukkan nama baru - Tambah drawable - Tambah - Hanya huruf kecil (a–z) dan angka! - Anda tidak dapat mengubah nama %1$s yang sudah ditentukan secara default… - Anda tidak dapat menghapus %1$s yang sudah ditentukan secara default… - Fitur ini belum tersedia. Akan segera tersedia. - Tidak ada… - Tambahkan beberapa widget - Catatan - Oke - Aplikasi crash (rusak) - Tutup - Tutup aplikasi - Urung - Ulang - Simpan - Tampilkan struktur - Keluar - Tampilkan XML - Simpan XML - Hapus tampilan - Apakah Anda yakin ingin menghapus tampilan ini? - Layout ini tidak mendukung %1$s di dalam %2$s. Pindahkan ke induk yang lain. - %1$s di dalam %2$s mungkin berperilaku tidak seperti yang diharapkan di editor. - Pilih tipe argumen - Pilih tipe drawable - Gelap - Terang - Otomatis - Ini akan menutup aplikasi beserta semua tugasnya! - Ekspor Layout - Data yang diterima tidak valid. - Pilih file dari Penyimpanan Utama. - Huruf pertama tidak boleh berisi angka! - Nama tersebut tidak boleh mengandung spasi. - Konfirmasi - Konfirmasi - Apakah Anda yakin ingin menyimpan proyek ini? - Jangan simpan - Pengelola Resources - Font - String - Drawable - Color - Edit XML - Pratinjau Drawable - Ubah nama Drawable - Salin nama - Impor - Skema Warna - Warna baru - Hapus warna - Apakah Anda yakin ingin menghapus %1$s? - Pilih warna - Edit warna - Warna tidak valid - Nama wajib diisi - Pilih - Palette - Common - Texts - Buttons - Widgets - Layouts - Containers - Google - Legacy - Pratinjau Drawable - Ekspor sebagai Gambar - Tambah font - Ubah nama font - Desain - Blueprint - Kecil - Sedang - Besar - Nama tidak valid - ¯⁠\\⁠_⁠(⁠ツ⁠)⁠_⁠/⁠¯ - Nama tersebut tidak boleh mengandung simbol. - Simpan layout - Apakah Anda yakin ingin menyimpan layout ini? - Apakah Anda yakin ingin mengekspor layout atau gambar? - Nilai - Nama - Simpan perubahan - Apakah Anda yakin ingin menyimpan perubahan pada layout? - Simpan perubahan dan keluar - Batalkan perubahan dan keluar - Batalkan dan tetap di Editor Layout - Gagal memuat font %1$s. File kosong atau tidak valid. - Gagal menambahkan font. File kosong atau rusak. - Gagal memuat daftar file. - - - File yang dipilih bukan file layout XML Android - Gagal memuat palet - Gagal menginisialisasi palet - Gagal memuat layout - Anda tidak dapat menghapus layout utama. - Diimpor! - Gagal mengimpor! - Berhasil! - Gagal menyimpan! - Tambahkan beberapa tampilan… - Telah disimpan ke galeri. - Gagal menyimpan… - Dimuat! - Palette - Layouts - Buat layout baru - Tipe tampilan - Ukuran - *Perlu diperhatikan bahwa proses impor akan gagal jika Anda mencoba mengimpor file layout dengan tampilan yang berbeda dari set tampilan LayoutEditor! - layout_new - - Kunci API Gemini - Simpan kunci - Hapus - Edit - Kunci API Gemini telah disimpan di %s - - Agen AI - Obrolan baru - Histori - Pengaturan AI - Tutup - Kunci API telah disimpan. - - Kunci API telah dihapus. - Kunci API tidak boleh kosong. - Kunci API telah disimpan dengan aman. - •••••••••••••••••••• - \ No newline at end of file diff --git a/layouteditor/src/main/res/values-night/themes.xml b/layouteditor/src/main/res/values-night/themes.xml deleted file mode 100644 index dffa2bc70f..0000000000 --- a/layouteditor/src/main/res/values-night/themes.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/values-pt-rBR/strings.xml b/layouteditor/src/main/res/values-pt-rBR/strings.xml deleted file mode 100644 index e0c95fb805..0000000000 --- a/layouteditor/src/main/res/values-pt-rBR/strings.xml +++ /dev/null @@ -1,65 +0,0 @@ - - SOBRE - Preferências - Sobre - Abra a gaveta de navegação - Fechar gaveta de navegação - Projeto salvo. - Novo projeto - Projeto vazio! Adicionar uma visualização antes de salvar… - Adicionar novo - Excluir - Copiar - Gerenciador de drawable - Visualização XML - Clique no ícone + para criar um novo projeto. - Permissão garantida… - Permissão negada… - Visualizar o Layout - Copiado para a área de transferência - Tem certeza de que deseja excluir o projeto? - Excluir projeto - Criar projeto - Sim - Não - Renomear - Cancelar - Criar - Digite o novo nome do projeto - Renomear projeto - O nome atual não está disponível! - O campo não pode estar vazio! - Opções - Comum - Remover drawable - Deseja remover os drawables? - Digite o novo nome - Adicionar drawable - Adicionar - Apenas letras minúsculas (a-z) e números! - Este recurso ainda não está disponível. Estará disponível em breve. - Nada… - Adicionar alguns widgets - Ok - O aplicativo travou - Fechar - Fechar aplicativo - Desfazer - refazer - Salvar - Mostrar estrutura - Mostrar xml - Salvar xml - Excluir visualização - Deseja excluir a visualização? - Selecione o tipo de argumento - Escuro - Claro - Auto - Tema - Exportar Layout - ¯⁠\\⁠_⁠(⁠ツ⁠)⁠_⁠/⁠¯ - Você deseja exportar layout ou imagem - diff --git a/layouteditor/src/main/res/values-ru/strings.xml b/layouteditor/src/main/res/values-ru/strings.xml deleted file mode 100644 index 7baff8b85f..0000000000 --- a/layouteditor/src/main/res/values-ru/strings.xml +++ /dev/null @@ -1,105 +0,0 @@ - - О ПРИЛОЖЕНИИ - Настройки - О приложении - Открыть блок навигации - Закрыть блок навигации - Проект сохранен. - Новый проект - Проект пуст! Добавьте обзор перед сохранением… - Добавить новый - Удаление - Копирование - Управление отрисовкой - Предпросмотр XML - Клик + значок для создания нового проекта. - Разрешение предоставлено… - Разрешения нет… - Просмотр макета - Скопировано в буфер - Удалить проект? Вы уверены? - Удалить проект - Создать проект - Да - Нет - Переименовать - Отменить - Создать - Введите имя нового проекта - Переименовать проект - Текущее имя недоступно! - Поле не может быть пустым! - Возможности - Удалить отрисовку - Удалить шрифт - Удалить отрисовку? - Удалить шрифт? - Введите новое имя - Добавить отрисовку - Добавить - Только строчные буквы(a-z) и цифры! - Нельзя удалить по уиолчанию %1$s… - Эта функция пока не доступна, скоро будет. - Ничего… - Добавить виджеты - Ок - Аварийное завершение - Закрыть - Закрыть приложение - Вернуть - Заново - Сохранить - Показать структуру - Показать XML - Сохранить XML - Удаление представлния - Удалить представление? - Выбор типа аргумента - Выбор типа отрисовки - Темная - Светлая - Авто - Тема - Экспорт макета - Интент вернул некорректные данные. - Выберите файл из основного хранилища. - Первый символ не должен быть цифрой! - Имя не может содержать пробелы. - Подтверждение - Сохранить проект? - Не сохранять - Менеджер ресурсов - Шрифт - Строка - Отрисовка - Цвет - Правка XML - Предпросмотр отрисовки - Переименовать отрисовку - Копия имени - Импорт - цветовой схемы - Выбор - Палитра - Общее - Текст - Кнопки - Виджеты - Макеты - Контейнеры - Гугл - Наследование - Смотреть Отрисовку - Экспорт картинки - Добавить шрифт - Переименовать шрифт - Дизайн - Чертеж - Малый - Средний - Большой - ¯⁠\\⁠_⁠(⁠ツ⁠)⁠_⁠/⁠¯ - Вы хотите экспортировать макет или изображение? - \ No newline at end of file diff --git a/layouteditor/src/main/res/values-tr/strings.xml b/layouteditor/src/main/res/values-tr/strings.xml deleted file mode 100644 index 8876059f99..0000000000 --- a/layouteditor/src/main/res/values-tr/strings.xml +++ /dev/null @@ -1,119 +0,0 @@ - - HAKKINDA - Tercihler - Hakkında - Gezinme çekmecesini aç - Gezinme çekmecesini kapat - Proje kaydedildi. - Yeni proje - Düzen Kaydedildi - Yeni Düzen - Düzen boş! Kaydetmeden önce bir görünüm ekle… - Yeni ekle - Sil - Kopyala - Çizilebilir Yönetici - XML Önizlemesi - Yeni bir proje oluşturmak için + simgesine tıklayın. - İzin verildi… - İzin reddedildi… - Düzeni Önizle - Panoya kopyalandı - Projeyi kaldırmak istediğinizden emin misiniz? - Düzeni kaldırmak istediğinizden emin misiniz? - Projeyi sil - Proje oluştur - Düzeni Sil - Düzen oluştur - Evet - Hayır - Yeniden adlandır - İptal - Oluştur - Yeni proje adı girin - Projeyi yeniden adlandır - Yeni düzen adı girin - Düzeni Yeniden Adlandır - Geçerli ad kullanılamıyor! - Alan boş bırakılamaz! - Seçenekler - Çizilebiliri kaldır - Yazı tipini kaldır - Çizilebiliri kaldırmak istiyor musunuz? - Yazı tipini kaldırmak istiyor musunuz? - Yeni ad girin - Çizilebilir ekle - Ekle - Yalnızca küçük harfler (a-z) ve sayılar! - Varsayılan %1$s öğesini yeniden adlandıramazsınız… - Varsayılan %1$s\'ı silemezsiniz… - Bu özellik henüz mevcut değil. Yakında hazır olacak. - Boş… - Bazı widget\'lar ekleyin - Not - Tamam - Uygulama çöktü - Kapat - Uygulamayı kapat - Geri al - Yinele - Kaydet - Yapıyı göster - XML göster - XML olarak kaydet - Görünümü sil - Görünümü kaldırmak istiyor musunuz? - Bağımsız değişken türünü seçin - Çizilebilir türü seçin - Koyu - Açık - Otomatik - Bu, uygulamayı tüm görevlerle kapatacak!. - Düzeni Dışa Aktar - Intent tarafından döndürülen Geçersiz Veri. - Birincil Depolama\'dan dosya seçin. - İlk harf bir sayı olmamalıdır! - Ad boşluk içermemelidir. - Onayla - Onay - Bu projeyi kaydetmek istiyor musunuz? - Kaydetme - Kaynaklar Yöneticisi - Yazı tipi - Dizi - Çizilebilir - Renk - XML\'i düzenle - Çizilebilir Önizleme - Çizilebiliri Yeniden Adlandır - Adı Kopyala - İçe Aktar - Renk uyumu - Seç - Palet - Yaygın - Metinler - Butonlar - Widget\'lar - Düzenler - Kaplar - Google - Miras - Çizilebilir Önizleme - Görüntü Olarak Dışa Aktar - Yazı tipi ekle - Yazı tipini yeniden adlandır - Tasarım - Taslak - Küçük - Orta - Büyük - Geçersiz İsim - ¯⁠\\⁠_⁠(⁠ツ⁠)⁠_⁠/⁠¯ - Ad sembol içermemelidir. - Düzeni kaydet - Düzeni kaydetmek istiyor musunuz? - Düzeni mi yoksa görüntüyü mi dışa aktarmak istiyorsunuz? - \ No newline at end of file diff --git a/layouteditor/src/main/res/values-zh-rCN/strings.xml b/layouteditor/src/main/res/values-zh-rCN/strings.xml deleted file mode 100644 index c121df426c..0000000000 --- a/layouteditor/src/main/res/values-zh-rCN/strings.xml +++ /dev/null @@ -1,119 +0,0 @@ - - 关于 - 偏好 - 关于 - 打开导航抽屉 - 关闭导航抽屉 - 项目已保存。 - 新项目 - 布局已保存 - 新布局 - 布局是空的!请在保存前添加视图… - 添加新的 - 删除 - 复制 - 绘制资源管理 - XML 预览 - 点击 + 图标创建一个新项目 - 已授予权限… - 没有权限… - 预览布局 - 已复制到剪贴板 - 确定要删除这个项目吗? - 确定要删除这个布局吗? - 删除项目 - 创建项目 - 删除布局 - 创建布局 - 是的 - 不了 - 重命名 - 取消 - 创建 - 输入新项目名称 - 重命名项目 - 输入新布局名称 - 重命名布局 - 当前名称不可用! - 字段不能为空! - 选项 - 删除drawable - 删除字体 - 您想删除绘制资源吗? - 您想删除字体吗? - 输入新名称 - 添加绘制资源 - 添加 - 仅限小写字母 (a-z) 和数字! - 无法重命名默认的 %1$s… - 无法删除默认的 %1$s… - 此功能尚不可用。即将推出。 - 啥都没有… - 添加一些小部件 - 注意 - 好的 - 程序崩溃了): - 关闭 - 关闭程序 - 撤消 - 重做 - 保存 - 显示结构 - 显示 XML - 保存 XML - 删除视图 - 您想删除视图吗? - 选择参数类型 - 选择绘制资源类型 - 暗色 - 亮色 - 自动 - 这将关闭包含所有任务的应用程序! - 导出布局 - Intent 返回的数据无效。 - 从内部存储中选择文件。 - 第一个字符不能是数字! - 这个名称不能包含空格。 - 确认 - 确认 - 您想保存该项目吗? - 不保存 - 资源管理 - 字体 - 字符串 - Drawable - 颜色 - 编辑XML - 绘制资源预览 - 重命名绘制资源 - 复制名字 - 导入 - 配色方案 - 选择 - 调色板 - 常规 - 文本 - 按钮 - 部件 - 布局 - 容器 - Google - Legacy - 预览绘制资源 - 导出为图像 - 添加字体 - 重命名字体 - 设计 - 蓝图 - - - - 名称无效 - ¯⁠\\⁠_⁠(⁠ツ⁠)⁠_⁠/⁠¯ - 这个名字不能包含符号。 - 保存布局 - 您想保存布局吗? - 您要导出布局还是图像 - diff --git a/layouteditor/src/main/res/values-zh-rTW/strings.xml b/layouteditor/src/main/res/values-zh-rTW/strings.xml deleted file mode 100644 index 5d9f8edf7c..0000000000 --- a/layouteditor/src/main/res/values-zh-rTW/strings.xml +++ /dev/null @@ -1,23 +0,0 @@ - - 關於 - 偏好設定 - 關於 - 開啟導航欄 - 關閉導航欄 - 專案已儲存。 - 新增專案 - 專案是空的! 請於儲存前添加視圖… - 新增 - 刪除 - 複製 - 繪圖管理器 - 點擊 + 圖示創建一個新專案。 - 已准許權限… - 沒有權限… - 預覽佈局 - 已複製到剪貼簿 - ¯⁠\\⁠_⁠(⁠ツ⁠)⁠_⁠/⁠¯ - 您要匯出佈局還是圖像 - diff --git a/layouteditor/src/main/res/values/arrays.xml b/layouteditor/src/main/res/values/arrays.xml deleted file mode 100644 index a8b391dccf..0000000000 --- a/layouteditor/src/main/res/values/arrays.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - @string/theme_light - @string/theme_dark - @string/theme_auto - - - - 1 - 2 - -1 - - \ No newline at end of file diff --git a/layouteditor/src/main/res/values/colors.xml b/layouteditor/src/main/res/values/colors.xml deleted file mode 100644 index afced4215a..0000000000 --- a/layouteditor/src/main/res/values/colors.xml +++ /dev/null @@ -1,64 +0,0 @@ - - - #666666 - #555555 - #FFFFFF - #E0E0E0 - #1A1A1A - #666666 - #FFFFFF - #E8E8E8 - #1A1A1A - #666666 - #FFFFFF - #E8E8E8 - #1A1A1A - #B3261E - #FFFFFF - #F9DEDC - #410E0B - #79747E - #FFFBFE - #1C1B1F - #FFFBFE - #1C1B1F - #E7E0EC - #49454F - #313033 - #F4EFF4 - #AAAAAA - #000000 - #555555 - #CAC4D0 - #000000 - #AAAAAA - #1A1A1A - #404040 - #E8E8E8 - #999999 - #1A1A1A - #4A4A4A - #E8E8E8 - #AAAAAA - #1A1A1A - #333333 - #E8E8E8 - #F2B8B5 - #601410 - #8C1D18 - #F9DEDC - #938F99 - #1C1B1F - #E6E1E5 - #1C1B1F - #E6E1E5 - #49454F - #CAC4D0 - #E6E1E5 - #313033 - #555555 - #000000 - #AAAAAA - #49454F - #000000 - diff --git a/layouteditor/src/main/res/values/dimens.xml b/layouteditor/src/main/res/values/dimens.xml deleted file mode 100644 index ef6925a9bb..0000000000 --- a/layouteditor/src/main/res/values/dimens.xml +++ /dev/null @@ -1,10 +0,0 @@ - - 8dp - 16dp - - 16dp - 16dp - 8dp - 176dp - 16dp - \ No newline at end of file diff --git a/layouteditor/src/main/res/values/strings.xml b/layouteditor/src/main/res/values/strings.xml deleted file mode 100644 index be4e7a84fc..0000000000 --- a/layouteditor/src/main/res/values/strings.xml +++ /dev/null @@ -1,178 +0,0 @@ - - ABOUT - Preferences - About - Open navigation drawer - Close navigation drawer - Project saved. - New project - Layout Saved - Failed to save layout - New Layout - Layout empty! Add a view before saving… - Add new - Delete - Copy - Drawable Manager - XML Preview - Click + icon to create a new project. - Permission granted… - Permission denied… - Preview Layout - Copied to clipboard - Are you sure want to remove the project? - Are you sure, want to remove the layout? - Delete project - Create project - Delete Layout - Create layout - Yes - No - Rename - Cancel - Create - Enter new project name - Rename project - Enter new layout name - Rename Layout - Current name is unavailable! - Field cannot be empty! - Options - Remove drawable - Remove font - Do you want to remove the drawable? - Do you want to remove the font? - Enter new name - Add drawable - Add - Only small letters(a-z) and numbers! - You cannot rename the default %1$s… - You cannot delete the default %1$s… - This feature is not available yet. Will be available soon. - Nothing… - Add some widgets - Note - Okay - App crashed - Close - Close app - Undo - Redo - Save - Show structure - Exit - Show XML - Save XML - Delete view - Do you want to remove the view? - This layout doesn’t support %1$s inside %2$s. Move it to another parent. - %1$s inside %2$s may behave unexpectedly in the editor. - Select argument type - Select drawable type - Dark - Light - Auto - This will close the application with all tasks! - Export Layout - Invalid Data returned by Intent. - Select file from Primary Storage. - The first letter must not be a number! - The name must not contain spaces. - Confirm - Confirmation - Do you want to save this project? - Don\'t Save - Resources Manager - Font - String - Drawable - Color - Edit XML - Drawable Preview - Rename Drawable - Copy Name - Import - Color Scheme - New Color - Remove Color - Do you want to remove %1$s? - Choose Color - Edit Color - Invalid color - Name required - Select - Palette - Common - Texts - Buttons - Widgets - Layouts - Containers - Google - Legacy - Preview Drawable - Export as Image - Add font - Rename font - Design - Blueprint - Small - Medium - Large - Invalid Name - ¯⁠\\⁠_⁠(⁠ツ⁠)⁠_⁠/⁠¯ - The name must not contain symbols. - Save layout - Do you want to save the layout? - Do you want to export layout or image? - Value - Name - Save Changes - Do you want to save changes to the layout? - Save changes and exit - Discard changes and exit - Cancel and stay in Layout Editor - Failed to load font %1$s. File is empty or invalid. - Failed to add font. The file is empty or corrupt. - Failed to load file list. - - - Selected file is not an Android XML layout file - Failed to load palette - Failed to initialize palette - Failed to load layouts - You can\'t delete main layout. - Imported! - Failed to import! - Success! - Failed to save! - Add some views… - Saved to gallery. - Failed to save… - Loaded! - Palette - Layouts - Create new layout - View Type - Size - *Be aware it will fail to import when you try to import the layout file with view, different from LayoutEditor view set! - layout_new - - Gemini API Key - Save Key - Clear - Edit - Gemini API Key saved on %s - - AI Agent - New Chat - History - AI Settings - Close - API Key is saved. - - API Key cleared. - API Key cannot be empty. - API Key saved securely. - •••••••••••••••••••• - \ No newline at end of file diff --git a/layouteditor/src/main/res/values/themes.xml b/layouteditor/src/main/res/values/themes.xml deleted file mode 100644 index 0683c0b3a0..0000000000 --- a/layouteditor/src/main/res/values/themes.xml +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/layouteditor/src/main/res/anim/project_list_animation.xml b/resources/src/main/res/anim/project_list_animation.xml similarity index 100% rename from layouteditor/src/main/res/anim/project_list_animation.xml rename to resources/src/main/res/anim/project_list_animation.xml diff --git a/layouteditor/src/main/res/drawable/arrow_left.xml b/resources/src/main/res/drawable/arrow_left.xml similarity index 100% rename from layouteditor/src/main/res/drawable/arrow_left.xml rename to resources/src/main/res/drawable/arrow_left.xml diff --git a/layouteditor/src/main/res/drawable/circle_shape.xml b/resources/src/main/res/drawable/circle_shape.xml similarity index 100% rename from layouteditor/src/main/res/drawable/circle_shape.xml rename to resources/src/main/res/drawable/circle_shape.xml diff --git a/layouteditor/src/main/res/drawable/dots_vertical.xml b/resources/src/main/res/drawable/dots_vertical.xml similarity index 100% rename from layouteditor/src/main/res/drawable/dots_vertical.xml rename to resources/src/main/res/drawable/dots_vertical.xml diff --git a/layouteditor/src/main/res/drawable/edit.xml b/resources/src/main/res/drawable/edit.xml similarity index 100% rename from layouteditor/src/main/res/drawable/edit.xml rename to resources/src/main/res/drawable/edit.xml diff --git a/layouteditor/src/main/res/drawable/ic_launcher.xml b/resources/src/main/res/drawable/ic_launcher.xml similarity index 100% rename from layouteditor/src/main/res/drawable/ic_launcher.xml rename to resources/src/main/res/drawable/ic_launcher.xml diff --git a/resources/src/main/res/values/layouteditor_migrated.xml b/resources/src/main/res/values/layouteditor_migrated.xml new file mode 100644 index 0000000000..2f1f85f00d --- /dev/null +++ b/resources/src/main/res/values/layouteditor_migrated.xml @@ -0,0 +1,42 @@ + + + + AI Agent + Cancel + Clear + Delete + Edit + Gemini API Key + Gemini API Key saved on %s + ¯\\_(ツ)_/¯ + Rename + Save Key + AI Settings + History + Delete project + Rename project + Options + Create + Enter new project name + Are you sure want to remove the project? + Current name is unavailable! + Field cannot be empty! + •••••••••••••••••••• + API Key saved securely. + API Key is saved. + API Key cleared. + API Key cannot be empty. + + 8dp + + + diff --git a/settings.gradle.kts b/settings.gradle.kts index cba17f59b1..b6dc38b9bb 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -128,7 +128,6 @@ include( ":gradle-plugin", ":gradle-plugin-config", ":idetooltips", - ":layouteditor", ":lexers", ":logger", ":logsender", @@ -141,7 +140,6 @@ include( ":templates-impl", ":treeview", ":uidesigner", - ":vectormaster", ":xml-inflater", ":lsp:api", ":lsp:models",