diff --git a/app/build.gradle b/app/build.gradle
index 43cc1c9bc..3e557c638 100755
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -154,6 +154,7 @@ dependencies {
implementation project (':preferences')
implementation project (':resources')
implementation project (':treeview')
+ implementation project (':uidesigner')
implementation project (':xml-inflater')
implementation fileTree (dir: 'libs', include: ['*.jar'])
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index c36eba060..7b0af4219 100755
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -50,7 +50,7 @@
android:configChanges="orientation|screenSize|uiMode"
android:windowSoftInputMode="adjustResize" />
//www.gnu.org/licenses/>.
+ * You should have received a copy of the GNU General Public License
+ * along with AndroidIDE. If not, see .
*/
+
package com.itsaky.androidide.app
-import android.Manifest.permission
-import android.content.pm.PackageManager
-import android.os.Bundle
-import android.view.View
-import androidx.appcompat.app.AppCompatActivity
-import androidx.core.app.ActivityCompat
-import androidx.core.content.ContextCompat
-import androidx.core.view.WindowCompat
-import androidx.fragment.app.Fragment
-import com.itsaky.androidide.utils.ILogger
-
-abstract class IDEActivity : AppCompatActivity() {
- fun loadFragment(fragment: Fragment?, id: Int) {
- val transaction = supportFragmentManager.beginTransaction()
- transaction.replace(id, fragment!!)
- transaction.commit()
- }
-
+abstract class IDEActivity : BaseIDEActivity() {
val app: IDEApplication
get() = application as IDEApplication
-
- override fun onCreate(savedInstanceState: Bundle?) {
- super.onCreate(savedInstanceState)
- preSetContentLayout()
- setContentView(bindLayout())
- if (!isStoragePermissionGranted) {
- requestStorage()
- return
- }
- if (isStoragePermissionGranted) {
- onStorageAlreadyGranted()
- } else {
- onStorageDenied()
- }
- }
-
- val isStoragePermissionGranted: Boolean
- get() =
- (ContextCompat.checkSelfPermission(this, permission.READ_EXTERNAL_STORAGE) ==
- PackageManager.PERMISSION_GRANTED &&
- ContextCompat.checkSelfPermission(this, permission.WRITE_EXTERNAL_STORAGE) ==
- PackageManager.PERMISSION_GRANTED)
-
- protected fun requestStorage() {
- if (isStoragePermissionGranted) {
- onStorageGranted()
- return
- }
- ActivityCompat.requestPermissions(
- this,
- arrayOf(permission.WRITE_EXTERNAL_STORAGE, permission.READ_EXTERNAL_STORAGE),
- REQCODE_STORAGE
- )
- }
-
- protected open fun onStorageGranted() {}
- override fun onRequestPermissionsResult(
- requestCode: Int,
- permissions: Array,
- grantResults: IntArray
- ) {
- super.onRequestPermissionsResult(requestCode, permissions, grantResults)
- if (requestCode == REQCODE_STORAGE) {
- if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED)
- onStorageGranted()
- else onStorageDenied()
- }
- }
-
- protected open fun onStorageAlreadyGranted() {}
- protected open fun onStorageDenied() {}
- protected open fun preSetContentLayout() {}
-
- protected abstract fun bindLayout(): View
-
- companion object {
- const val REQCODE_STORAGE = 1009
- protected var LOG = ILogger.newInstance("StudioActivity")
- }
}
diff --git a/changelogs/v2.1.3-beta.md b/changelogs/v2.1.3-beta.md
index 382244343..2be284343 100644
--- a/changelogs/v2.1.3-beta.md
+++ b/changelogs/v2.1.3-beta.md
@@ -4,7 +4,7 @@ This release brings various improvements and bug fixes to AndroidIDE.
## Important notes
-> _No notes_
+> _The UI designer has been TEMPORARILY removed as we are working on integrating it with the new projects API for better and improved layout inflation/preview._
## Additions
- The IDE now creates `.nomedia` file in the `PROJECTS` directory if the file does not already exist. Thanks to @jayx003 (#489).
@@ -14,7 +14,7 @@ This release brings various improvements and bug fixes to AndroidIDE.
- Readded `Clear Gradle cache` preference. Thanks to @deepkrg17 (#587).
## Removals
-> _No removals_
+- The UI designer.
## Fixes
- Some classes not being shown in completion (#500).
diff --git a/common/src/main/java/com/itsaky/androidide/app/BaseIDEActivity.kt b/common/src/main/java/com/itsaky/androidide/app/BaseIDEActivity.kt
new file mode 100755
index 000000000..b5d684c2f
--- /dev/null
+++ b/common/src/main/java/com/itsaky/androidide/app/BaseIDEActivity.kt
@@ -0,0 +1,111 @@
+/*
+ * 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 .
+ */
+
+/**
+ * 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 //www.gnu.org/licenses/>.
+ */
+package com.itsaky.androidide.app
+
+import android.Manifest.permission
+import android.content.pm.PackageManager
+import android.os.Bundle
+import android.view.View
+import androidx.appcompat.app.AppCompatActivity
+import androidx.core.app.ActivityCompat
+import androidx.core.content.ContextCompat
+import androidx.fragment.app.Fragment
+import com.itsaky.androidide.utils.ILogger
+
+abstract class BaseIDEActivity : AppCompatActivity() {
+ fun loadFragment(fragment: Fragment?, id: Int) {
+ val transaction = supportFragmentManager.beginTransaction()
+ transaction.replace(id, fragment!!)
+ transaction.commit()
+ }
+
+
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ preSetContentLayout()
+ setContentView(bindLayout())
+ if (!isStoragePermissionGranted) {
+ requestStorage()
+ return
+ }
+ if (isStoragePermissionGranted) {
+ onStorageAlreadyGranted()
+ } else {
+ onStorageDenied()
+ }
+ }
+
+ val isStoragePermissionGranted: Boolean
+ get() =
+ (ContextCompat.checkSelfPermission(this, permission.READ_EXTERNAL_STORAGE) ==
+ PackageManager.PERMISSION_GRANTED &&
+ ContextCompat.checkSelfPermission(this, permission.WRITE_EXTERNAL_STORAGE) ==
+ PackageManager.PERMISSION_GRANTED)
+
+ protected fun requestStorage() {
+ if (isStoragePermissionGranted) {
+ onStorageGranted()
+ return
+ }
+ ActivityCompat.requestPermissions(
+ this,
+ arrayOf(permission.WRITE_EXTERNAL_STORAGE, permission.READ_EXTERNAL_STORAGE),
+ REQCODE_STORAGE
+ )
+ }
+
+ protected open fun onStorageGranted() {}
+ override fun onRequestPermissionsResult(
+ requestCode: Int,
+ permissions: Array,
+ grantResults: IntArray
+ ) {
+ super.onRequestPermissionsResult(requestCode, permissions, grantResults)
+ if (requestCode == REQCODE_STORAGE) {
+ if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED)
+ onStorageGranted()
+ else onStorageDenied()
+ }
+ }
+
+ protected open fun onStorageAlreadyGranted() {}
+ protected open fun onStorageDenied() {}
+ protected open fun preSetContentLayout() {}
+
+ protected abstract fun bindLayout(): View
+
+ companion object {
+ const val REQCODE_STORAGE = 1009
+ protected var LOG = ILogger.newInstance("StudioActivity")
+ }
+}
diff --git a/app/src/main/java/com/itsaky/androidide/fragments/BaseFragment.kt b/common/src/main/java/com/itsaky/androidide/fragments/BaseFragment.kt
similarity index 84%
rename from app/src/main/java/com/itsaky/androidide/fragments/BaseFragment.kt
rename to common/src/main/java/com/itsaky/androidide/fragments/BaseFragment.kt
index f3fc7940f..92e12a3f1 100755
--- a/app/src/main/java/com/itsaky/androidide/fragments/BaseFragment.kt
+++ b/common/src/main/java/com/itsaky/androidide/fragments/BaseFragment.kt
@@ -1,3 +1,20 @@
+/*
+ * 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 .
+ */
+
/**
* This file is part of AndroidIDE.
*
diff --git a/app/src/main/java/com/itsaky/androidide/views/ContentTranslatingDrawerLayout.kt b/common/src/main/java/com/itsaky/androidide/views/ContentTranslatingDrawerLayout.kt
similarity index 100%
rename from app/src/main/java/com/itsaky/androidide/views/ContentTranslatingDrawerLayout.kt
rename to common/src/main/java/com/itsaky/androidide/views/ContentTranslatingDrawerLayout.kt
diff --git a/app/src/main/java/com/itsaky/androidide/views/InterceptableDrawerLayout.kt b/common/src/main/java/com/itsaky/androidide/views/InterceptableDrawerLayout.kt
similarity index 100%
rename from app/src/main/java/com/itsaky/androidide/views/InterceptableDrawerLayout.kt
rename to common/src/main/java/com/itsaky/androidide/views/InterceptableDrawerLayout.kt
diff --git a/settings.gradle b/settings.gradle
index 4dec1640e..befa62167 100755
--- a/settings.gradle
+++ b/settings.gradle
@@ -47,3 +47,4 @@ include ':resources'
include ':xml-inflater'
include ':annotation-processors'
include ':annotations'
+include ':uidesigner'
diff --git a/tests/test-home/.androidide/init/model.jar b/tests/test-home/.androidide/init/model.jar
index 5fcf1a357..fe65ecd7d 100644
Binary files a/tests/test-home/.androidide/init/model.jar and b/tests/test-home/.androidide/init/model.jar differ
diff --git a/uidesigner/.gitignore b/uidesigner/.gitignore
new file mode 100644
index 000000000..42afabfd2
--- /dev/null
+++ b/uidesigner/.gitignore
@@ -0,0 +1 @@
+/build
\ No newline at end of file
diff --git a/uidesigner/build.gradle b/uidesigner/build.gradle
new file mode 100644
index 000000000..b5050a6a0
--- /dev/null
+++ b/uidesigner/build.gradle
@@ -0,0 +1,50 @@
+apply plugin: 'com.android.library'
+apply plugin: 'kotlin-android'
+
+android {
+ namespace "com.itsaky.androidide.uidesigner"
+ compileSdkVersion rootProject.ext.compileSdk
+ buildToolsVersion rootProject.ext.buildTools
+
+ defaultConfig {
+ minSdkVersion rootProject.ext.minSdk
+ targetSdkVersion rootProject.ext.targetSdk
+ }
+
+ buildFeatures.viewBinding true
+
+ compileOptions {
+ sourceCompatibility rootProject.ext.javaSourceVersion
+ targetCompatibility rootProject.ext.javaTargetVersion
+ }
+
+ kotlinOptions {
+ jvmTarget = "11"
+ }
+
+ buildTypes {
+ release {
+ minifyEnabled true
+ }
+ }
+
+ testOptions {
+ unitTests {
+ includeAndroidResources = true
+ }
+ }
+}
+
+dependencies {
+
+ implementation androidx.appcompat
+ implementation google.material
+
+ implementation project(path: ':common')
+ implementation project(path: ':logger')
+ implementation project(path: ':xml-inflater')
+
+ testImplementation tests.junit
+ testImplementation tests.google_truth
+ testImplementation tests.robolectric
+}
\ No newline at end of file
diff --git a/uidesigner/consumer-rules.pro b/uidesigner/consumer-rules.pro
new file mode 100644
index 000000000..e69de29bb
diff --git a/uidesigner/proguard-rules.pro b/uidesigner/proguard-rules.pro
new file mode 100644
index 000000000..481bb4348
--- /dev/null
+++ b/uidesigner/proguard-rules.pro
@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
\ No newline at end of file
diff --git a/uidesigner/src/main/AndroidManifest.xml b/uidesigner/src/main/AndroidManifest.xml
new file mode 100644
index 000000000..e62e7b210
--- /dev/null
+++ b/uidesigner/src/main/AndroidManifest.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/com/itsaky/androidide/UIDesignerActivity.kt b/uidesigner/src/main/java/com/itsaky/androidide/uidesigner/UIDesignerActivity.kt
similarity index 80%
rename from app/src/main/java/com/itsaky/androidide/UIDesignerActivity.kt
rename to uidesigner/src/main/java/com/itsaky/androidide/uidesigner/UIDesignerActivity.kt
index 33facf490..c58e5e230 100644
--- a/app/src/main/java/com/itsaky/androidide/UIDesignerActivity.kt
+++ b/uidesigner/src/main/java/com/itsaky/androidide/uidesigner/UIDesignerActivity.kt
@@ -15,22 +15,19 @@
* along with AndroidIDE. If not, see .
*/
-package com.itsaky.androidide
+package com.itsaky.androidide.uidesigner
import android.os.Bundle
import android.view.View
-import androidx.constraintlayout.widget.ConstraintLayout
-import androidx.core.view.updateLayoutParams
-import com.blankj.utilcode.util.SizeUtils
-import com.itsaky.androidide.app.IDEActivity
-import com.itsaky.androidide.databinding.ActivityUiDesignerBinding
+import com.itsaky.androidide.app.BaseIDEActivity
+import com.itsaky.androidide.uidesigner.databinding.ActivityUiDesignerBinding
/**
* The UI Designer activity allows the user to design XML layouts with a drag-n-drop interface.
*
* @author Akash Yadav
*/
-class UIDesignerActivity : IDEActivity() {
+class UIDesignerActivity : BaseIDEActivity() {
private var binding: ActivityUiDesignerBinding? = null
diff --git a/app/src/main/java/com/itsaky/androidide/fragments/WidgetsListFragment.kt b/uidesigner/src/main/java/com/itsaky/androidide/uidesigner/fragments/WidgetsListFragment.kt
similarity index 81%
rename from app/src/main/java/com/itsaky/androidide/fragments/WidgetsListFragment.kt
rename to uidesigner/src/main/java/com/itsaky/androidide/uidesigner/fragments/WidgetsListFragment.kt
index 82b52e5cf..d5abbfb50 100644
--- a/app/src/main/java/com/itsaky/androidide/fragments/WidgetsListFragment.kt
+++ b/uidesigner/src/main/java/com/itsaky/androidide/uidesigner/fragments/WidgetsListFragment.kt
@@ -15,13 +15,14 @@
* along with AndroidIDE. If not, see .
*/
-package com.itsaky.androidide.fragments
+package com.itsaky.androidide.uidesigner.fragments
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
-import com.itsaky.androidide.databinding.FragmentUiWidgetsBinding
+import com.itsaky.androidide.fragments.BaseFragment
+import com.itsaky.androidide.uidesigner.databinding.FragmentUiWidgetsBinding
/**
* A fragment that shows the list of widgets available to use in the UI designer.
@@ -29,20 +30,24 @@ import com.itsaky.androidide.databinding.FragmentUiWidgetsBinding
* @author Akash Yadav
*/
class WidgetsListFragment : BaseFragment() {
-
+
private var binding: FragmentUiWidgetsBinding? = null
-
- override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
+
+ override fun onCreateView(
+ inflater: LayoutInflater,
+ container: ViewGroup?,
+ savedInstanceState: Bundle?
+ ): View? {
this.binding = FragmentUiWidgetsBinding.inflate(inflater, container, false)
return this.binding!!.root
}
-
+
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
}
-
+
override fun onDestroyView() {
super.onDestroyView()
binding = null
}
-}
\ No newline at end of file
+}
diff --git a/app/src/main/res/layout/activity_ui_designer.xml b/uidesigner/src/main/res/layout/activity_ui_designer.xml
similarity index 70%
rename from app/src/main/res/layout/activity_ui_designer.xml
rename to uidesigner/src/main/res/layout/activity_ui_designer.xml
index 2a59bd955..7c6c02159 100644
--- a/app/src/main/res/layout/activity_ui_designer.xml
+++ b/uidesigner/src/main/res/layout/activity_ui_designer.xml
@@ -1,4 +1,21 @@
+
+
diff --git a/app/src/main/res/layout/fragment_ui_widgets.xml b/uidesigner/src/main/res/layout/fragment_ui_widgets.xml
similarity index 100%
rename from app/src/main/res/layout/fragment_ui_widgets.xml
rename to uidesigner/src/main/res/layout/fragment_ui_widgets.xml
diff --git a/app/src/main/res/layout/fragment_ui_widgets_item.xml b/uidesigner/src/main/res/layout/fragment_ui_widgets_item.xml
similarity index 100%
rename from app/src/main/res/layout/fragment_ui_widgets_item.xml
rename to uidesigner/src/main/res/layout/fragment_ui_widgets_item.xml
diff --git a/app/src/main/res/layout/layout_ui_widgets_category.xml b/uidesigner/src/main/res/layout/layout_ui_widgets_category.xml
similarity index 100%
rename from app/src/main/res/layout/layout_ui_widgets_category.xml
rename to uidesigner/src/main/res/layout/layout_ui_widgets_category.xml
diff --git a/uidesigner/src/test/java/com/itsaky/androidide/uidesigner/ExampleUnitTest.kt b/uidesigner/src/test/java/com/itsaky/androidide/uidesigner/ExampleUnitTest.kt
new file mode 100644
index 000000000..c4ad25727
--- /dev/null
+++ b/uidesigner/src/test/java/com/itsaky/androidide/uidesigner/ExampleUnitTest.kt
@@ -0,0 +1,34 @@
+/*
+ * 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.uidesigner
+
+import org.junit.Test
+
+import org.junit.Assert.*
+
+/**
+ * Example local unit test, which will execute on the development machine (host).
+ *
+ * See [testing documentation](http://d.android.com/tools/testing).
+ */
+class ExampleUnitTest {
+ @Test
+ fun addition_isCorrect() {
+ assertEquals(4, 2 + 2)
+ }
+}
\ No newline at end of file