diff --git a/.gitignore b/.gitignore
new file mode 100644
index 00000000..aca7d486
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+/.metadata
+/.recommenders
diff --git a/Dependencies/.gitignore b/Dependencies/.gitignore
new file mode 100644
index 00000000..6b95a456
--- /dev/null
+++ b/Dependencies/.gitignore
@@ -0,0 +1,4 @@
+/saripaar
+/ActiveAndroid
+/androidannotations
+/evo-inflector
diff --git a/Dependencies/README.md b/Dependencies/README.md
new file mode 100644
index 00000000..99407b87
--- /dev/null
+++ b/Dependencies/README.md
@@ -0,0 +1,7 @@
+/ActiveAndroid => https://github.com/smaugho/ActiveAndroid.git :branch = declex
+
+/androidannotations => https://github.com/smaugho/androidannotations.git :branch = declex
+
+/sapiraar => https://github.com/smaugho/android-saripaar.git :branch = declex
+
+/evo-inflector => https://github.com/atteo/evo-inflector.git :branch = master
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 00000000..26bd39bc
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,37 @@
+************************************
+This project is available under the following license:
+************************************
+Copyright (C) 2016 DSpot Sp. z o.o
+
+Licensed under the Apache License, Version 2.0 (the "License"); you may not
+use this file except in compliance with the License. You may obtain a copy of
+the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+License for the specific language governing permissions and limitations under
+the License.
+
+This project uses CodeModel (http://codemodel.java.net/), which is
+distributed under the GlassFish Dual License, which means CodeModel is
+subject to the terms of either the GNU General Public License Version 2 only
+("GPL") or the Common Development and Distribution License("CDDL").
+
+You may obtain a copy of the "CDDL" License at
+
+http://www.opensource.org/licenses/cddl1.php
+
+As per section 3.6 ("Larger Works") of the "CDDL" License, we may create a
+Larger Work by combining Covered Software with other code not governed by
+the terms of this License and distribute the Larger Work as a single
+product.
+
+We are therefore allowed to distribute CodeModel without Modification as
+part of AndroidAnnotations.
+
+About AndroidAnnotations generated files: if you create a larger work that
+contains files generated by AndroidAnnotations, you can distribute that work
+under terms of your choice.
diff --git a/README.md b/README.md
new file mode 100644
index 00000000..54282019
--- /dev/null
+++ b/README.md
@@ -0,0 +1,57 @@
+# DecleX
+
+DecleX is a framework that aims to get closer to the idea of a fully Declarative Language for Android Development.
+It is totally based on AndroidAnnotations; in a similar fashion, we want to facilitate the writing and the maintenance of
+Android applications to the highest level which has not been achieved up to now.
+
+
+## Documentation
+
+Please consult our Wiki in https://github.com/smaugho/declex/wiki
+
+## Configuration
+
+Download the library jar files from [here](https://github.com/smaugho/declex/releases/tag/v1.0):
+
+* Place the core processor declex-v1.0.jar in a folder named compile-libs in your project.
+
+* Place the API file declex-api.jar in a folder named libs in your project.
+
+* Place the following lines in your build.graddle file:
+
+```graddle
+apply plugin: 'com.neenbedankt.android-apt'
+
+buildscript {
+ repositories {
+ mavenCentral()
+ }
+ dependencies {
+ classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
+ }
+}
+
+apt {
+ arguments {
+ androidManifestFile variant.outputs[0].processResources.manifestFile
+ resourcePackageName 'YOUR PROJECT PACKAGE'
+ }
+}
+
+```
+You should replace "YOUR PROJECT PACKAGE" by your project package name (Ex. com.company.example).
+
+* And finally add to your dependencies the framework libraries:
+
+```graddle
+dependencies {
+ compile fileTree(dir: 'libs', include: ['*.jar'])
+ apt files('compile-libs/declex-v1.0.jar')
+
+ ...
+```
+
+And that's it!...
+
+-----------
+Sponsored by DSpot Sp. z o.o. Contact us at info@dspot.com.pl
diff --git a/declex-api/.classpath b/declex-api/.classpath
new file mode 100644
index 00000000..a6fd6cd4
--- /dev/null
+++ b/declex-api/.classpath
@@ -0,0 +1,37 @@
+
+
+ *
+ * @Action
+ * S2
+ *
+ * here, "btnFacebookLogin" is the id of the button in the layout.
+ *
+ *
+ * for UIActions, in the declaration name you can use postfix to select a specific action over the View...
+ * By default, it's assumed that the action will be executed after the user clicks the View. But you can use the following
+ * postfixes to indicate different kind of actions:
+ *
+ * -Click, Press, Clicked or Pressed + * -LongClick, LongPress, LongClicked or LongPressed + * + * -ItemClick, ItemPress, ItemClicked, or ItemPressed + * -ItemLongClick, ItemLongPress, ItemLongClicked or ItemLongPressed + *+ * all these postfixes are valid. For instance: + * + * @Action("user=model") + * MainActivity gridViewItemClicked; + * + * In this case we also pass a parameter. In this case, MainActivity should accept an extra parameter named "user". + * "model" references the default model of the gridView... This is used because typically GridViews (or any other AdapterView) + * are used together a model to populate the View Items. + * + * Each action has its specific parameters, but some of them are globals. + *
+ * ;instruction; This executes the "instruction" code before the Action + * instruction; Executes the "instruction" code after the Action. + *+ * + * @author Smaugh + * + */ +@Retention(RetentionPolicy.CLASS) +@Target({ElementType.FIELD, ElementType.METHOD}) +public @interface Action { + String[] value() default ""; + + boolean debug() default false; +} diff --git a/declex-api/src/com/dspot/declex/api/action/PutOnAction.java b/declex-api/src/com/dspot/declex/api/action/PutOnAction.java new file mode 100644 index 00000000..4d288bb7 --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/action/PutOnAction.java @@ -0,0 +1,29 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.action; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.CLASS) +@Target(ElementType.FIELD) +public @interface PutOnAction { + int[] value(); + + boolean debug() default false; +} diff --git a/declex-api/src/com/dspot/declex/api/action/annotation/ActionFor.java b/declex-api/src/com/dspot/declex/api/action/annotation/ActionFor.java new file mode 100644 index 00000000..ff133f09 --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/action/annotation/ActionFor.java @@ -0,0 +1,30 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.action.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import com.dspot.declex.api.action.process.ActionProcessor; + +@Retention(RetentionPolicy.CLASS) +@Target(ElementType.TYPE) +public @interface ActionFor { + String[] value(); + Class extends ActionProcessor>[] processors() default {}; +} diff --git a/declex-api/src/com/dspot/declex/api/action/annotation/Assignable.java b/declex-api/src/com/dspot/declex/api/action/annotation/Assignable.java new file mode 100644 index 00000000..060d980f --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/action/annotation/Assignable.java @@ -0,0 +1,27 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.action.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.CLASS) +@Target(ElementType.PARAMETER) +public @interface Assignable { + String value(); +} diff --git a/declex-api/src/com/dspot/declex/api/action/annotation/Field.java b/declex-api/src/com/dspot/declex/api/action/annotation/Field.java new file mode 100644 index 00000000..a943affd --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/action/annotation/Field.java @@ -0,0 +1,27 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.action.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.CLASS) +@Target(ElementType.PARAMETER) +public @interface Field { + +} diff --git a/declex-api/src/com/dspot/declex/api/action/annotation/FormattedExpression.java b/declex-api/src/com/dspot/declex/api/action/annotation/FormattedExpression.java new file mode 100644 index 00000000..790c5575 --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/action/annotation/FormattedExpression.java @@ -0,0 +1,27 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.action.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.CLASS) +@Target(ElementType.PARAMETER) +public @interface FormattedExpression { + +} diff --git a/declex-api/src/com/dspot/declex/api/action/builtin/AlertDialogActionHolder.java b/declex-api/src/com/dspot/declex/api/action/builtin/AlertDialogActionHolder.java new file mode 100644 index 00000000..4416da19 --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/action/builtin/AlertDialogActionHolder.java @@ -0,0 +1,204 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.action.builtin; + +import java.util.List; + +import org.androidannotations.annotations.EBean; +import org.androidannotations.annotations.RootContext; + +import android.app.AlertDialog; +import android.app.Dialog; +import android.content.Context; +import android.content.DialogInterface; + +import com.dspot.declex.api.action.annotation.ActionFor; +import com.dspot.declex.api.action.annotation.Assignable; +import com.dspot.declex.api.action.annotation.FormattedExpression; + +@EBean +@ActionFor("AlertDialog") +public class AlertDialogActionHolder { + AlertDialog.Builder builder; + + String positiveButtonText; + int positiveButtonRes; + + String negativeButtonText; + int negativeButtonRes; + + String[] multiChoiceItems; + int multiChoiceRes; + + String[] items; + int itemsRes; + + AlertDialog dialog; + + @RootContext + Context context; + + void init() { + builder = new AlertDialog.Builder(context); + } + + //Here you can infer any parameter, the first parameter is the next listener + void build(final DialogClickRunnable PositiveButtonPressed, final DialogClickRunnable NegativeButtonPressed, + final DialogClickRunnable ItemSelected, final MultiChoiceClickRunnable MultiChoiceSelected, + final Runnable Dismissed) { + + if (negativeButtonText != null) { + builder.setNegativeButton(negativeButtonText, NegativeButtonPressed); + } else if (negativeButtonRes != 0) { + builder.setNegativeButton(negativeButtonRes, NegativeButtonPressed); + } + + if (positiveButtonText != null) { + builder.setPositiveButton(positiveButtonText, PositiveButtonPressed); + } else if (positiveButtonRes != 0) { + builder.setPositiveButton(positiveButtonRes, PositiveButtonPressed); + } + + if (items != null) { + builder.setItems(items, ItemSelected); + } else if (itemsRes != 0) { + builder.setItems(itemsRes, ItemSelected); + } + + if (multiChoiceItems != null) { + builder.setMultiChoiceItems(multiChoiceItems, null, MultiChoiceSelected); + } else if (multiChoiceRes != 0) { + builder.setMultiChoiceItems(multiChoiceRes, null, MultiChoiceSelected); + } + + if (Dismissed != null) { + dialog.setOnDismissListener(new DialogInterface.OnDismissListener() { + + @Override + public void onDismiss(DialogInterface arg0) { + if (Dismissed != null) Dismissed.run(); + } + }); + } + + dialog = builder.create(); + }; + + void execute() { + dialog.show(); + } + + Dialog dialog() { + return this.dialog; + } + + public AlertDialog.Builder builder() { + return this.builder; + } + + public AlertDialogActionHolder title(@FormattedExpression String title) { + builder.setTitle(title); + return this; + } + + public AlertDialogActionHolder message(@FormattedExpression String message) { + builder.setMessage(message); + return this; + } + + public AlertDialogActionHolder positiveButton(@FormattedExpression String title) { + positiveButtonText = title; + return this; + } + + public AlertDialogActionHolder positiveButton(int res) { + positiveButtonRes = res; + return this; + } + + public AlertDialogActionHolder negativeButton(@FormattedExpression String title) { + negativeButtonText = title; + return this; + } + + public AlertDialogActionHolder negativeButton(int res) { + negativeButtonRes = res; + return this; + } + + public AlertDialogActionHolder multiChoice(String ... items) { + multiChoiceItems = items; + return this; + } + + public AlertDialogActionHolder multiChoice(List