Permalink
Browse files

Merge branch 'develop'

  • Loading branch information...
2 parents 5983328 + 7ca99b8 commit 4e69246f512a21e133553ee46da3ce4007defe31 @gliechtenstein gliechtenstein committed Jan 5, 2017
Showing with 80 additions and 3 deletions.
  1. +15 −0 .codeclimate.yml
  2. +4 −1 README.md
  3. +61 −2 app/src/main/java/com/jasonette/seed/Action/JasonUtilAction.java
View
@@ -0,0 +1,15 @@
+engines:
+ fixme:
+ enabled: true
+ pmd:
+ enabled: true
+ channel: "beta"
+
+ratings:
+ paths:
+ - "**.java"
+
+exclude_paths:
+- "/.idea/"
+- "/app/.idea/"
+- "/app/src/main/assets/"
View
@@ -1,5 +1,8 @@
[![logo](https://raw.githubusercontent.com/gliechtenstein/images/master/jasonette.png)](http://www.jasonette.com)
-
+[![Code Climate](https://codeclimate.com/github/Jasonette/JASONETTE-Android/badges/gpa.svg)](https://codeclimate.com/github/Jasonette/JASONETTE-Android)
+[![Issue Count](https://codeclimate.com/github/Jasonette/JASONETTE-Android/badges/issue_count.svg)](https://codeclimate.com/github/Jasonette/JASONETTE-Android)
+[![codebeat badge](https://codebeat.co/badges/14fec9aa-70dc-4459-8d62-e64c2c5e750f)](https://codebeat.co/projects/github-com-jasonette-jasonette-android)
+[![roadmap badge](https://img.shields.io/badge/visit%20the-roadmap-blue.svg)](https://github.com/Jasonette/JASONETTE-android/projects/1)
# [Jasonette](https://www.jasonette.com)
[https://www.jasonette.com](https://www.jasonette.com)
@@ -6,12 +6,24 @@
import android.os.Looper;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AlertDialog;
+import android.text.InputType;
import android.util.Log;
+import android.view.WindowManager;
+import android.view.inputmethod.InputMethodManager;
+import android.widget.EditText;
+import android.widget.LinearLayout;
import android.widget.Toast;
-import com.jasonette.seed.Helper.JasonHelper;
+
import com.jasonette.seed.Core.JasonViewActivity;
+import com.jasonette.seed.Helper.JasonHelper;
+
+import org.json.JSONArray;
import org.json.JSONObject;
+import java.util.ArrayList;
+
+import static android.media.CamcorderProfile.get;
+
public class JasonUtilAction {
public void banner(final JSONObject action, final JSONObject data, final Context context) {
new Handler(Looper.getMainLooper()).post(new Runnable() {
@@ -60,20 +72,67 @@ public void run() {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
try {
JSONObject options = new JSONObject();
+ final ArrayList<EditText> textFields = new ArrayList<EditText>();
if (action.has("options")) {
options = action.getJSONObject("options");
String title = options.getString("title");
String description = options.getString("description");
builder.setTitle(title);
builder.setMessage(description);
+
+ if(options.has("form"))
+ {
+ LinearLayout lay = new LinearLayout(context);
+ lay.setOrientation(LinearLayout.VERTICAL);
+ lay.setPadding(20,5,20,5);
+ JSONArray formArr = options.getJSONArray("form");
+ for (int i=0; i<formArr.length();i++) {
+ JSONObject obj = formArr.getJSONObject(i);
+ final EditText textBox = new EditText(context);
+ if(obj.has("placeholder")){
+ textBox.setHint(obj.getString("placeholder"));
+ }
+ if(obj.has("type") && obj.getString("type").equals("secure")){
+ textBox.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
+ }
+ if(obj.has("value")){
+ textBox.setText(obj.getString("value"));
+ }
+ textBox.setTag(obj.get("name"));
+ lay.addView(textBox);
+ textFields.add(textBox);
+ builder.setView(lay);
+ }
+ // Set focous on first text field
+ final EditText focousedTextField = (EditText)textFields.get(0);
+ focousedTextField.post(new Runnable() {
+ public void run() {
+ focousedTextField.requestFocus();
+ InputMethodManager lManager = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
+ lManager.showSoftInput(focousedTextField, 0);
+ }
+ });
+
+
+ }
+
+
}
builder.setPositiveButton("OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int which) {
try {
if (action.has("success")) {
- JasonHelper.next("success", action, new JSONObject(), context);
+ JSONObject postObject = new JSONObject();
+ if(action.getJSONObject("options").has("form")){
+ for(int i = 0; i<textFields.size();i++){
+
+ EditText textField = (EditText) textFields.get(i);
+ postObject.put(textField.getTag().toString(),textField.getText().toString());
+ }
+ }
+ JasonHelper.next("success", action, postObject, context);
}
} catch (Exception err) {

0 comments on commit 4e69246

Please sign in to comment.