Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion formbuilder-android/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="9"
android:minSdkVersion="17"
android:targetSdkVersion="19" />

<application
Expand Down
68 changes: 29 additions & 39 deletions formbuilder-android/src/com/vertis/formbuilder/Address.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
import android.widget.TextView;

import com.google.gson.annotations.Expose;
import com.vertis.formbuilder.Listeners.CustomTextChangeListener;
import com.vertis.formbuilder.parser.FieldConfig;
import com.vertis.formbuilder.util.FormBuilderUtil;

public class Address implements IField {

private FieldConfig config;

//Views
LinearLayout ad;
EditText streetEditText;
Expand All @@ -40,25 +40,24 @@ public class Address implements IField {
Spinner countriesSpinner;
TextView countryTextView;
TextView title;

//Values
@Expose
String cid;

@Expose
String country="";
int countryPosition=0;
String country = "";
int countryPosition = 0;
@Expose
String street="";
String street = "";
@Expose
String city="";
String city = "";
@Expose
String state="";
String state = "";
@Expose
String zip="";

String fullAddress="";
private Typeface mFont;
String zip = "";
String fullAddress = "";

private Typeface mFont;
//constructor to populate config
public Address(FieldConfig fcg){
this.config=fcg;
Expand All @@ -69,6 +68,7 @@ public void createForm(Activity context) {
mFont = new FormBuilderUtil().getFontFromRes(context);
getViesByID(context);
setTextSizeAndTypeFace();
addTextChangeListeners();
defineViewSettings(context);
setViewValues();
mapView();
Expand Down Expand Up @@ -165,6 +165,7 @@ private void mapView() {
ViewLookup.mapField(this.config.getCid() + "_1_4", zipEditText);
ViewLookup.mapField(this.config.getCid() + "_1_5", countriesSpinner);
}

private void setViewValues() {
title.setText(this.config.getLabel() + (this.config.getRequired() ? "*" : ""));
streetEditText.setText(street);
Expand All @@ -173,10 +174,9 @@ private void setViewValues() {
zipEditText.setText(zip);
countriesSpinner.setSelection(countryPosition);
}

private ArrayList<SelectElement> getCountryList() {
Locale[] locale = Locale.getAvailableLocales();
ArrayList<SelectElement> countries = new ArrayList<SelectElement>();
ArrayList<SelectElement> countries = new ArrayList<>();
String country;
int i = 0;
for (Locale loc : locale) {
Expand All @@ -188,7 +188,7 @@ private ArrayList<SelectElement> getCountryList() {
.getDisplayCountry(), 1));
}
}
i = i++;
i++;
}
Collections.sort(countries);
return countries;
Expand Down Expand Up @@ -218,29 +218,19 @@ public boolean validate() {
return valid;
}

private boolean checkEmpty(TextView view, String street, String errorMessage) {
if(config.getRequired() && street.equals("")){
errorMessage(view, errorMessage);
return false;
} else{
noErrorMessage(view);
return true;
}
}

@SuppressLint("ResourceAsColor")
private void errorMessage(TextView view ,String message) {
if(view==null)return;
view.setText((this.config.getRequired()?"*":"") );
view.setText(view.getText() + message);
view.setTextColor(R.color.ErrorMessage);
view.setTextColor(view.getContext().getResources().getColor(R.color.ErrorMessage));
}

@SuppressLint("ResourceAsColor")
private void noErrorMessage(TextView view ) {
if(view==null)return;
view.setText(this.config.getRequired()?"Street*":"" );
view.setTextColor(R.color.TextViewNormal);
view.setTextColor(view.getContext().getResources().getColor(R.color.TextViewNormal));
}

@Override
Expand Down Expand Up @@ -295,20 +285,20 @@ public void showField() {
}

public boolean validateDisplay(String value,String condition) {
if(condition.equals("equals")){
if(fullAddress.toLowerCase().contains(value.toLowerCase()) || fullAddress.trim().equals("")){
return true;
}
return !condition.equals("equals") || fullAddress.toLowerCase().contains(value.toLowerCase()) || fullAddress.trim().equals("");
}

public boolean isHidden() {
return ad != null && !ad.isShown();
}

private boolean checkEmpty(TextView view, String actual_value, String errorMessage) {
if(config.getRequired() && actual_value.equals("")){
errorMessage(view, errorMessage);
return false;
} else{
noErrorMessage(view);
return true;
}
return true;
}

public boolean isHidden(){
if(ad!=null) {
return !ad.isShown();
} else {
return false;
}
}
}
24 changes: 8 additions & 16 deletions formbuilder-android/src/com/vertis/formbuilder/Capture.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class Capture implements IField{
TextView tvCapture;
Button buttonCaptureImage, buttonCaptureVideo, buttonCaptureAudio;
ArrayAdapter<String> contentAdapter;
ArrayList<String> captureList= new ArrayList<String>();
ArrayList<String> captureList= new ArrayList<>();
ListView lvCapture;

//Values
Expand All @@ -57,7 +57,7 @@ public Capture(FieldConfig fcg){
@Override
public void createForm(final Activity context) {
this.context = context;
LayoutInflater inflater = (LayoutInflater) context.getLayoutInflater();
LayoutInflater inflater =context.getLayoutInflater();
llCapture=(LinearLayout) inflater.inflate(R.layout.capture,null);
tvCapture = (TextView) llCapture.findViewById(R.id.textViewCapture);
buttonCaptureImage=(Button) llCapture.findViewById(R.id.buttonImage);
Expand Down Expand Up @@ -138,7 +138,7 @@ private void modifyListViewHeight(){
private void noErrorMessage() {
if(tvCapture==null)return;
tvCapture.setText(this.config.getLabel() + (this.config.getRequired()?"*":"") );
tvCapture.setTextColor(R.color.TextViewNormal);
tvCapture.setTextColor(tvCapture.getContext().getResources().getColor(R.color.TextViewNormal));
}

private void mapView() {
Expand Down Expand Up @@ -178,7 +178,7 @@ private void errorMessage(String message) {
if(tvCapture==null)return;
tvCapture.setText(this.config.getLabel() + (this.config.getRequired()?"*":"") );
tvCapture.setText(tvCapture.getText() + message);
tvCapture.setTextColor(R.color.ErrorMessage);
tvCapture.setTextColor(tvCapture.getContext().getResources().getColor(R.color.ErrorMessage));
}

@Override
Expand Down Expand Up @@ -218,21 +218,13 @@ public void showField() {

public boolean validateDisplay(String value,String condition) {
if(condition.equals("equals")) {
for (String capture : captureList) {
if (capture.equals(value)) {
return true;
}
}
for (String capture : captureList) if (capture.equals(value)) return true;
return false;
}
return true;
}

public boolean isHidden(){
if(llCapture!=null) {
return !llCapture.isShown();
} else {
return false;
}
}
public boolean isHidden() {
return llCapture != null && !llCapture.isShown();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

public class CaptureContentAdapter extends ArrayAdapter<String> {
Expand All @@ -21,7 +20,6 @@ public int getCount() {

private ArrayList<String> capturedObject;
private Context context;
private Button cross;
private Capture c;

public CaptureContentAdapter(Context context, int resource, ArrayList<String> objects, Capture c) {
Expand All @@ -39,7 +37,7 @@ public View getView(final int position, View convertView, ViewGroup parent) {
}
TextView tv = (TextView)return_view.findViewById(R.id.tvCapturedFile);
tv.setText(this.capturedObject.get(position));
cross= (Button)return_view.findViewById(R.id.crossImage);
Button cross= (Button)return_view.findViewById(R.id.crossImage);
cross.setTag(position);
cross.setOnClickListener(new OnClickListener (){
@Override
Expand Down
59 changes: 31 additions & 28 deletions formbuilder-android/src/com/vertis/formbuilder/Checkbox.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,27 @@
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class Checkbox implements IField {

private FieldConfig config;
// Views
LinearLayout llCheckBox;
TextView tvCheckBox;
EditText otherTextBox;
ArrayList<String> checkedValues= new ArrayList<String>();
ArrayList<CheckBox> cbValues = new ArrayList<CheckBox>();
ArrayList<String> checkedValues= new ArrayList<>();
ArrayList<CheckBox> cbValues = new ArrayList<>();

//Values
@Expose
String cid;
@Expose
String optionSelected;
int checked = 0;
@Expose
String other;

Expand All @@ -44,12 +45,12 @@ public Checkbox(FieldConfig fcg){

@Override
public void createForm(Activity context) {
LayoutInflater inflater = (LayoutInflater) context.getLayoutInflater();
LayoutInflater inflater = context.getLayoutInflater();
llCheckBox=(LinearLayout) inflater.inflate(R.layout.checkbox,null);
tvCheckBox = (TextView) llCheckBox.findViewById(R.id.tvCheckbox);
tvCheckBox.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14f);
tvCheckBox.setTypeface(new FormBuilderUtil().getFontFromRes(context));
int i = 0;
int i ;
if(cbValues != null)
cbValues.clear();
for (i = 0; i < this.config.getField_options().getOptions().size(); i++) {
Expand Down Expand Up @@ -118,29 +119,37 @@ public boolean validate() {
private void noErrorMessage() {
if(tvCheckBox==null)return;
tvCheckBox.setText(this.config.getLabel() + (this.config.getRequired()?"*":"") );
tvCheckBox.setTextColor(R.color.TextViewNormal);
tvCheckBox.setTextColor(tvCheckBox.getContext().getResources().getColor(R.color.TextViewNormal));
}

@SuppressLint("ResourceAsColor")
private void errorMessage(String message) {
if(tvCheckBox==null)return;
tvCheckBox.setText(this.config.getLabel() + (this.config.getRequired()?"*":"") );
// tvCheckBox.setText(tvCheckBox.getText() + " " + message);
tvCheckBox.setTextColor(R.color.ErrorMessage);
tvCheckBox.setText(tvCheckBox.getText() + " " + message);
tvCheckBox.setTextColor(tvCheckBox.getContext().getResources().getColor(R.color.ErrorMessage));
}

@Override
public void setValues() {
this.cid=config.getCid();
if(llCheckBox!=null){
checkedValues.clear();
for (CheckBox tempCheck : cbValues) {
if(tempCheck.isChecked()){
checkedValues.add(tempCheck.getText().toString());
try {
this.cid=config.getCid();
JSONArray jsonArray = new JSONArray();
if(llCheckBox!=null){
checkedValues.clear();
for (CheckBox tempCheck : cbValues) {
if (tempCheck.isChecked())
checkedValues.add(tempCheck.getText().toString());
JSONObject jsonObject = new JSONObject();
jsonObject.put(tempCheck.getText().toString(), tempCheck.isChecked());
jsonArray.put(jsonObject);
}
}
validate();
optionSelected = jsonArray.toString();
} catch (JSONException e) {
e.printStackTrace();
}
validate();
}

@Override
Expand Down Expand Up @@ -172,20 +181,14 @@ public void showField() {
@Override
public boolean validateDisplay(String value,String condition) {
if(condition.equals("equals")){
for (String checkedValue : checkedValues) {
if(checkedValue.toLowerCase().equals(value.toLowerCase())){
}
}
for (String checkedValue : checkedValues)
if (checkedValue.toLowerCase().equals(value.toLowerCase())) return true;
return false;
}
return true;
}

public boolean isHidden(){
if(llCheckBox!=null) {
return !llCheckBox.isShown();
} else {
return false;
}
}
public boolean isHidden() {
return llCheckBox != null && !llCheckBox.isShown();
}
}
Loading