From 57081114bbf1fa87a8b8388fc3c66584c1e9b64e Mon Sep 17 00:00:00 2001 From: marina Date: Sun, 29 Nov 2020 16:44:01 +0200 Subject: [PATCH] Translate truforms views and handle json schema to dispaly views with the mobile app language --- .idea/modules.xml | 3 + .../trufla/androidtruforms/SharedData.java | 28 +- .../androidtruforms/TruFormActivity.java | 18 +- .../androidtruforms/TruFormFragment.java | 14 +- .../DataEnumNamesDeserializer.java | 41 +- .../ObjectPropertiesDeserializer.java | 21 +- .../androidtruforms/models/EnumInstance.java | 53 +- .../models/SchemaInstance.java | 48 +- .../androidtruforms/models/TitleInstance.java | 35 + .../truviews/TruEnumDataView.java | 4 +- .../androidtruforms/truviews/TruEnumView.java | 4 +- .../truviews/TruSectionView.java | 6 +- .../androidtruforms/utils/TruUtils.java | 4 + .../utils/ValueToSchemaMapper.java | 38 +- .../src/main/res/layout/activity_tru_form.xml | 2 +- .../src/main/res/values-fr/strings.xml | 2 + .../src/main/res/values/strings.xml | 1 + app/src/main/res/raw/claims.json | 243 +----- app/src/main/res/raw/claims_edited.json | 772 ++++++++++++++---- 19 files changed, 919 insertions(+), 418 deletions(-) create mode 100644 android-tru-forms/src/main/java/com/trufla/androidtruforms/models/TitleInstance.java diff --git a/.idea/modules.xml b/.idea/modules.xml index 6e93290..ac81081 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -5,6 +5,9 @@ + + + diff --git a/android-tru-forms/src/main/java/com/trufla/androidtruforms/SharedData.java b/android-tru-forms/src/main/java/com/trufla/androidtruforms/SharedData.java index 6fb5e0b..fdd5805 100644 --- a/android-tru-forms/src/main/java/com/trufla/androidtruforms/SharedData.java +++ b/android-tru-forms/src/main/java/com/trufla/androidtruforms/SharedData.java @@ -1,21 +1,32 @@ package com.trufla.androidtruforms; +import com.trufla.androidtruforms.utils.TruUtils; + /** * Created by Mohamed Salah on 10,March,2020 * Trufla Technology, * Cairo, Egypt. */ -public class SharedData { +public class SharedData +{ private static SharedData instance; // Global variable private String data; + private String defaultLanguage; // Restrict the constructor from being instantiated private SharedData() { } + public static synchronized SharedData getInstance() { + if (instance == null) { + instance = new SharedData(); + } + return instance; + } + public void setData(String d) { this.data = d; } @@ -24,10 +35,15 @@ public String getData() { return this.data; } - public static synchronized SharedData getInstance() { - if (instance == null) { - instance = new SharedData(); - } - return instance; + public void setLanguage(String language) + { + this.defaultLanguage = language; + } + + public String getDefaultLanguage() + { + //Check if default language is null or empty I'll return "en" as a default language + return TruUtils.setDefaultUserLanguage(this.defaultLanguage); } + } diff --git a/android-tru-forms/src/main/java/com/trufla/androidtruforms/TruFormActivity.java b/android-tru-forms/src/main/java/com/trufla/androidtruforms/TruFormActivity.java index 981ab54..4da75de 100644 --- a/android-tru-forms/src/main/java/com/trufla/androidtruforms/TruFormActivity.java +++ b/android-tru-forms/src/main/java/com/trufla/androidtruforms/TruFormActivity.java @@ -46,7 +46,8 @@ * Created by ohefny on 8/13/18. */ -public class TruFormActivity extends AppCompatActivity implements FormContract { +public class TruFormActivity extends AppCompatActivity implements FormContract +{ private static final int PICK_IMAGE_CODE = 1; private static final int CAPTURE_IMAGE_CODE = 2; private static final int PERMISSION_REQUEST_CODE = 1; @@ -61,7 +62,6 @@ public class TruFormActivity extends AppCompatActivity implements FormContract { private boolean isHistory = false; BottomSheetDialog dialog; - String currentCameraPhotoPath; //create a single thread pool to our image compression class. @@ -76,10 +76,14 @@ public static void startActivityForFormResult(Activity context, String jsonStr) context.startActivityForResult(intent, SchemaBuilder.REQUEST_CODE); } - public static void startActivityForFormResult(Fragment hostFragment, String jsonStr) { + public static void startActivityForFormResult(Fragment hostFragment, String jsonStr) + { Intent intent = new Intent(hostFragment.getActivity(), TruFormActivity.class); intent.putExtra(SCHEMA_KEY, jsonStr); sharedData = null; +// sharedData = SharedData.getInstance(); +// sharedData.setLanguage("fr"); + hostFragment.startActivityForResult(intent, SchemaBuilder.REQUEST_CODE); } @@ -113,9 +117,11 @@ protected void onCreate(Bundle savedInstanceState) { try { String jsonVal = ""; - if (sharedData != null) { + if (sharedData != null) jsonVal = sharedData.getData(); - } + + sharedData = SharedData.getInstance(); + sharedData.setLanguage("fr"); if (TextUtils.isEmpty(jsonVal)) truFormView = SchemaBuilder.getInstance().buildSchemaView(Objects.requireNonNull(getIntent().getExtras()).getString(SCHEMA_KEY), this); @@ -322,4 +328,4 @@ protected void onDestroy() { mExecutorService = null; imageCompressTask = null; } -} +} \ No newline at end of file diff --git a/android-tru-forms/src/main/java/com/trufla/androidtruforms/TruFormFragment.java b/android-tru-forms/src/main/java/com/trufla/androidtruforms/TruFormFragment.java index acef913..50dce18 100644 --- a/android-tru-forms/src/main/java/com/trufla/androidtruforms/TruFormFragment.java +++ b/android-tru-forms/src/main/java/com/trufla/androidtruforms/TruFormFragment.java @@ -78,7 +78,6 @@ public class TruFormFragment extends Fragment implements FormContract, CollectDa private static SharedData sharedData; private String currentCameraPhotoPath; - //create a single thread pool to our image compression class. private ExecutorService mExecutorService = Executors.newFixedThreadPool(1); @@ -87,12 +86,16 @@ public class TruFormFragment extends Fragment implements FormContract, CollectDa public TruFormFragment() { } - public static TruFormFragment newInstance(int schemaType, String schemaString) { + public static TruFormFragment newInstance(int schemaType, String schemaString) + { TruFormFragment fragment = new TruFormFragment(); Bundle args = new Bundle(); args.putString(SCHEMA_KEY, schemaString); args.putInt(SCHEMA_TYPE, schemaType); sharedData = null; +// sharedData = SharedData.getInstance(); +// sharedData.setLanguage("fr"); + fragment.setArguments(args); return fragment; } @@ -127,9 +130,12 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, try { String jsonVal = ""; - if (sharedData != null) { + if (sharedData != null) jsonVal = sharedData.getData(); - } + + //Will Change those lines when upload the new schema + sharedData = SharedData.getInstance(); + sharedData.setLanguage("fr"); if (TextUtils.isEmpty(jsonVal)) truFormView = SchemaBuilder.getInstance().buildSchemaView(schemaString, getContext()); diff --git a/android-tru-forms/src/main/java/com/trufla/androidtruforms/adapters/deserializers/DataEnumNamesDeserializer.java b/android-tru-forms/src/main/java/com/trufla/androidtruforms/adapters/deserializers/DataEnumNamesDeserializer.java index dc23828..1c29e85 100644 --- a/android-tru-forms/src/main/java/com/trufla/androidtruforms/adapters/deserializers/DataEnumNamesDeserializer.java +++ b/android-tru-forms/src/main/java/com/trufla/androidtruforms/adapters/deserializers/DataEnumNamesDeserializer.java @@ -8,26 +8,53 @@ import com.google.gson.JsonObject; import com.google.gson.JsonParseException; import com.google.gson.JsonPrimitive; +import com.trufla.androidtruforms.SharedData; import com.trufla.androidtruforms.models.DataEnumNames; -import org.json.JSONStringer; - import java.lang.reflect.Type; import java.util.ArrayList; -public class DataEnumNamesDeserializer implements JsonDeserializer { + +public class DataEnumNamesDeserializer implements JsonDeserializer +{ @Override public DataEnumNames deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { ArrayList names = new ArrayList<>(); Gson gson = new Gson(); - if (json instanceof JsonArray) { - names = gson.fromJson(json, names.getClass()); - } else if (json instanceof JsonPrimitive) { + if (json instanceof JsonArray) + { + names = getEnumList(json); +// names = gson.fromJson(json, names.getClass()); + + } else if (json instanceof JsonPrimitive) names.add(gson.fromJson(json, String.class)); - } + return new DataEnumNames(names); } + public ArrayList getEnumList(JsonElement json) + { + SharedData sharedData = SharedData.getInstance(); + String myLanguage = sharedData.getDefaultLanguage(); + ArrayList newEnumList = new ArrayList<>(); + JsonArray parentArray = json.getAsJsonArray(); + + for (int x= 0; x schemaTitle = new ArrayList<>(); + schemaTitle.add(titleInstance); + schemaInstance.setTitle(schemaTitle); + } schemaInstance.setKey(key); return schemaInstance; } diff --git a/android-tru-forms/src/main/java/com/trufla/androidtruforms/models/EnumInstance.java b/android-tru-forms/src/main/java/com/trufla/androidtruforms/models/EnumInstance.java index f4628a8..2916e00 100644 --- a/android-tru-forms/src/main/java/com/trufla/androidtruforms/models/EnumInstance.java +++ b/android-tru-forms/src/main/java/com/trufla/androidtruforms/models/EnumInstance.java @@ -5,6 +5,7 @@ import androidx.annotation.Keep; import com.google.gson.annotations.SerializedName; +import com.trufla.androidtruforms.SharedData; import com.trufla.androidtruforms.truviews.TruEnumDataView; import com.trufla.androidtruforms.truviews.TruEnumView; @@ -21,11 +22,19 @@ public class EnumInstance extends SchemaInstance protected ArrayList enumVals; //instance of String or Number or Boolean @SerializedName("enumNames") - protected ArrayList enumNames; //instance of String or Number or Boolean + protected ArrayList> enumNamesList; //instance of String or Number or Boolean @SerializedName("_data") protected DataInstance dataInstance; + protected ArrayList myEnumNa; + + private static SharedData sharedData; + +// @SerializedName("enumNames") +// protected ArrayList enumNames; //instance of String or Number or Boolean + + public EnumInstance(){ } @@ -38,18 +47,20 @@ public EnumInstance(EnumInstance copyInstance) { super(copyInstance); this.enumVals= new ArrayList<>(copyInstance.enumVals); - this.enumNames=new ArrayList<>(copyInstance.enumNames); + this.myEnumNa =new ArrayList<>(copyInstance.myEnumNa); this.dataInstance=new DataInstance(copyInstance.getDataInstance()); } - public boolean enumExists() { + public boolean enumExists() + { + myEnumNa = getEnumList(enumNamesList); return enumVals != null && !enumVals.isEmpty(); } @Override public TruEnumView getViewBuilder(Context context) { - if (dataInstance == null) + if (dataInstance == null) return new TruEnumView(context, this); else return new TruEnumDataView(context, this); @@ -58,8 +69,8 @@ public TruEnumView getViewBuilder(Context context) public ArrayList getEnumDisplayedNames() { ArrayList displayedNames = new ArrayList<>(); - if (enumNames != null && !enumNames.isEmpty()) - return enumNames; + if (myEnumNa != null && !myEnumNa.isEmpty()) + return myEnumNa; if(enumVals.size() > 0) { @@ -77,6 +88,28 @@ public ArrayList getEnumDisplayedNames() return displayedNames; } + public ArrayList getEnumList(ArrayList> myEnumsList) + { + sharedData = SharedData.getInstance(); + String myLanguage = sharedData.getDefaultLanguage(); + + ArrayList newEnumList = new ArrayList<>(); + + if(myEnumsList != null) + { + for(int listIndex = 0; listIndex< myEnumsList.size(); listIndex++) + { + for (TitleInstance titleInstance: myEnumsList.get(listIndex)) + { + if(titleInstance.getLanguage().equals(myLanguage)) + newEnumList.add(titleInstance.getTitleValue()); + } + } + } + + return newEnumList; + } + public DataInstance getDataInstance() { return dataInstance; } @@ -89,11 +122,11 @@ public ArrayList getEnumVals() { return enumVals; } - public void setEnumNames(ArrayList enumNames) { - this.enumNames = enumNames; + public void setMyEnumNa(ArrayList myEnumNa) { + this.myEnumNa = myEnumNa; } - public ArrayList getEnumNames() { - return enumNames; + public ArrayList getMyEnumNa() { + return myEnumNa; } } diff --git a/android-tru-forms/src/main/java/com/trufla/androidtruforms/models/SchemaInstance.java b/android-tru-forms/src/main/java/com/trufla/androidtruforms/models/SchemaInstance.java index 310bee1..9665b81 100644 --- a/android-tru-forms/src/main/java/com/trufla/androidtruforms/models/SchemaInstance.java +++ b/android-tru-forms/src/main/java/com/trufla/androidtruforms/models/SchemaInstance.java @@ -6,30 +6,36 @@ import androidx.annotation.NonNull; import com.google.gson.annotations.SerializedName; +import com.trufla.androidtruforms.SharedData; import com.trufla.androidtruforms.utils.TruUtils; import com.trufla.androidtruforms.truviews.SchemaBaseView; +import java.util.List; + /** * Created by ohefny on 6/26/18. */ @Keep -public abstract class SchemaInstance implements Comparable, Cloneable { +public abstract class SchemaInstance implements Comparable, Cloneable +{ //the parsed key of the instance .. used in the returned data protected String key; - //the key of the object ex: "date_of_loss":{} here we use data_of_loss as title + @SerializedName("title") - protected String title; + protected List title; + @SerializedName("type") protected String type = ""; + @SerializedName("const") protected Object constItem; protected boolean requiredField; - public SchemaInstance() { + private static SharedData sharedData; - } + public SchemaInstance() {} public abstract Object getDefaultConst(); @@ -40,16 +46,37 @@ public SchemaInstance(SchemaInstance instance) { this.constItem = instance.getConstItem(); } - public String getTitle() { + public List getTitle() + { return title; } - public void setTitle(String title) { + public void setTitle(List title) { this.title = title; } - public String getPresentationTitle() { - return TruUtils.removeUnderscoresAndCapitalize(title); + public String getTittleValue() + { + sharedData = SharedData.getInstance(); + String myLanguage = sharedData.getDefaultLanguage(); + + if(getTitle() != null) + { + for (TitleInstance titleInstance: getTitle()) + { + if(titleInstance != null) + { + if(titleInstance.getLanguage().equals(myLanguage)) + return titleInstance.getTitleValue(); + } + } + } + return "" ; + } + + public String getPresentationTitle() + { + return TruUtils.removeUnderscoresAndCapitalize(getTittleValue()); } public String getType() { @@ -71,7 +98,8 @@ public void setConstItem(Object constItem) { public abstract T getViewBuilder(Context context); @Override - public int compareTo(@NonNull SchemaInstance o) { + public int compareTo(@NonNull SchemaInstance o) + { //instances then array then objects if (this.getType().equals(SchemaKeywords.InstanceTypes.OBJECT)) return 1; diff --git a/android-tru-forms/src/main/java/com/trufla/androidtruforms/models/TitleInstance.java b/android-tru-forms/src/main/java/com/trufla/androidtruforms/models/TitleInstance.java new file mode 100644 index 0000000..88b893a --- /dev/null +++ b/android-tru-forms/src/main/java/com/trufla/androidtruforms/models/TitleInstance.java @@ -0,0 +1,35 @@ +package com.trufla.androidtruforms.models; + +import com.google.gson.annotations.SerializedName; +import com.trufla.androidtruforms.utils.TruUtils; + +/** + * Created by Marina Wageed on 01,November,2020 + * Trufla Technology, + * Cairo, Egypt. + */ + +public class TitleInstance +{ + @SerializedName("language") + protected String language; + + @SerializedName("value") + protected String titleValue; + + public String getLanguage() { + return TruUtils.checkIfStringIsEmpty(language); + } + + public void setLanguage(String language) { + this.language = language; + } + + public String getTitleValue() { + return TruUtils.checkIfStringIsEmpty(titleValue); + } + + public void setTitleValue(String titleValue) { + this.titleValue = titleValue; + } +} diff --git a/android-tru-forms/src/main/java/com/trufla/androidtruforms/truviews/TruEnumDataView.java b/android-tru-forms/src/main/java/com/trufla/androidtruforms/truviews/TruEnumDataView.java index a26cfed..97cd02f 100644 --- a/android-tru-forms/src/main/java/com/trufla/androidtruforms/truviews/TruEnumDataView.java +++ b/android-tru-forms/src/main/java/com/trufla/androidtruforms/truviews/TruEnumDataView.java @@ -87,7 +87,7 @@ private TruConsumer>> getDataLoadedListener() { names.add(pair.second); } instance.setEnumVals(ids); - instance.setEnumNames(names); + instance.setMyEnumNa(names); if (!hasConstValue()) { setButtonClickListener(); showChooserDialogAction(); @@ -107,7 +107,7 @@ private Object getItemNameForItemValue() { else valIdx = instance.getEnumVals().indexOf(Double.parseDouble(instance.getConstItem().toString())); if (valIdx >= 0) - return instance.getEnumNames().get(valIdx); + return instance.getMyEnumNa().get(valIdx); else return instance.getConstItem(); //to pervent any unpredictable crashes } diff --git a/android-tru-forms/src/main/java/com/trufla/androidtruforms/truviews/TruEnumView.java b/android-tru-forms/src/main/java/com/trufla/androidtruforms/truviews/TruEnumView.java index cbd2fe0..3e34809 100644 --- a/android-tru-forms/src/main/java/com/trufla/androidtruforms/truviews/TruEnumView.java +++ b/android-tru-forms/src/main/java/com/trufla/androidtruforms/truviews/TruEnumView.java @@ -156,8 +156,8 @@ protected void setNonEditableValues(Object constItem) { enumStr = String.valueOf(enumStr).replace(".0", ""); if (enumStr.equals(constStr)) { String textToDisplay = ""; - if (instance.getEnumNames() != null) - textToDisplay = (String) instance.getEnumNames().get(i); + if (instance.getMyEnumNa() != null) + textToDisplay = (String) instance.getMyEnumNa().get(i); else textToDisplay = enumStr; diff --git a/android-tru-forms/src/main/java/com/trufla/androidtruforms/truviews/TruSectionView.java b/android-tru-forms/src/main/java/com/trufla/androidtruforms/truviews/TruSectionView.java index 3bb2c70..1350496 100644 --- a/android-tru-forms/src/main/java/com/trufla/androidtruforms/truviews/TruSectionView.java +++ b/android-tru-forms/src/main/java/com/trufla/androidtruforms/truviews/TruSectionView.java @@ -15,8 +15,6 @@ import com.trufla.androidtruforms.models.SchemaInstance; import com.trufla.androidtruforms.utils.ValueToSchemaMapper; -import org.json.JSONObject; - /** * Created by ohefny on 6/26/18. */ @@ -32,7 +30,7 @@ public TruSectionView(Context context, ObjectInstance instance) { @Override protected void buildSubview() { super.buildSubview(); - if (TruUtils.isEmpty(instance.getTitle())) { + if (TruUtils.isEmpty(instance.getTittleValue())) { mView.findViewById(R.id.section_header).setVisibility(View.GONE); } else { handleExpandBehavior(); @@ -112,4 +110,4 @@ protected void setNonEditableValues(Object constItem) { } mView.setEnabled(false); } -} +} \ No newline at end of file diff --git a/android-tru-forms/src/main/java/com/trufla/androidtruforms/utils/TruUtils.java b/android-tru-forms/src/main/java/com/trufla/androidtruforms/utils/TruUtils.java index 4f1208c..2913a56 100644 --- a/android-tru-forms/src/main/java/com/trufla/androidtruforms/utils/TruUtils.java +++ b/android-tru-forms/src/main/java/com/trufla/androidtruforms/utils/TruUtils.java @@ -36,6 +36,10 @@ public static String checkIfStringIsEmpty(String myString) { return (myString == null) ? "" : myString; } + public static String setDefaultUserLanguage(String myString) { + return (myString == null || myString.isEmpty()) ? "en" : myString; + } + public static String getText(EditText et) { return et.getText().toString().trim(); } diff --git a/android-tru-forms/src/main/java/com/trufla/androidtruforms/utils/ValueToSchemaMapper.java b/android-tru-forms/src/main/java/com/trufla/androidtruforms/utils/ValueToSchemaMapper.java index 56073ca..d4db358 100644 --- a/android-tru-forms/src/main/java/com/trufla/androidtruforms/utils/ValueToSchemaMapper.java +++ b/android-tru-forms/src/main/java/com/trufla/androidtruforms/utils/ValueToSchemaMapper.java @@ -1,6 +1,5 @@ package com.trufla.androidtruforms.utils; -import android.util.Pair; import android.util.SparseArray; import com.google.gson.JsonArray; @@ -10,6 +9,7 @@ import com.google.gson.JsonPrimitive; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonToken; +import com.trufla.androidtruforms.SharedData; import java.io.IOException; import java.io.StringReader; @@ -17,8 +17,8 @@ import java.util.HashMap; import java.util.Map; -public class ValueToSchemaMapper { - +public class ValueToSchemaMapper +{ public static String map(String schema, String schemaValue) throws IOException { String schemaWithValueAsConst = ""; JsonParser parser = new JsonParser(); @@ -37,15 +37,39 @@ public static HashMap flatJsonObject(JsonObject jsonObject) { JsonElement jsonElement = ((JsonArray) pair.getValue()).get(i); if (jsonElement instanceof JsonObject) flatList.put(pair.getKey() + "[" + i + "]", jsonElement.toString()); - else { + + else if(jsonElement instanceof JsonArray) + { + SharedData sharedData = SharedData.getInstance(); + String myLanguage = sharedData.getDefaultLanguage(); + + JsonArray parentArray = jsonElement.getAsJsonArray(); + for (int x= 0; x \ No newline at end of file diff --git a/android-tru-forms/src/main/res/values-fr/strings.xml b/android-tru-forms/src/main/res/values-fr/strings.xml index d2457cc..361efc1 100644 --- a/android-tru-forms/src/main/res/values-fr/strings.xml +++ b/android-tru-forms/src/main/res/values-fr/strings.xml @@ -26,5 +26,7 @@ Ajouter Plus Galerie Caméra + Soumettre + diff --git a/android-tru-forms/src/main/res/values/strings.xml b/android-tru-forms/src/main/res/values/strings.xml index e7075a9..39db468 100644 --- a/android-tru-forms/src/main/res/values/strings.xml +++ b/android-tru-forms/src/main/res/values/strings.xml @@ -26,5 +26,6 @@ Add More Gallery Camera + Submit diff --git a/app/src/main/res/raw/claims.json b/app/src/main/res/raw/claims.json index cfd0d31..f9ce08f 100644 --- a/app/src/main/res/raw/claims.json +++ b/app/src/main/res/raw/claims.json @@ -1,218 +1,45 @@ { - "title":"Auto Claim - Vehicle Accident", - "type":"object", - "properties":{ - "driver_information":{ - "type":"object", - "properties":{ - "description":{ - "type":"string" - }, - "date_time_of_accident":{ - "title":"Date and Time of Accident", - "type":"object", - "properties":{ - "date":{ - "title":"Date of Accident", - "type":"string", - "format":"date" - }, - "time":{ - "title":"Time of Accident", - "type":"string", - "format":"time" - } - }, - "required":[ - "date", - "time" - ] - }, - "location_of_accident":{ - "type":"string", - "format":"map_lat_long" - }, - "description_of_accident":{ - "type":"string", - "format":"textarea" - }, - "were_you_driving":{ - "type":"string", - "enum":[ - "Yes", - "No" - ] - }, - "who_was_driving":{ - "type":"string" - }, - "your_damage_photos":{ - "type":"array", - "items":{ - "type":"object", - "properties":{ - "photo":{ - "type":"string", - "format":"photo" - } - } - } - } - }, - "required":[ - "description_of_accident", - "were_you_driving", - "date_time_of_accident" - ], - "oneOf":[ + "title": [ + { + "language": "en", + "value": "login form" + }, + { + "language": "fr", + "value": "Formulaire de connexion" + } + ], + "type": "object", + "properties": { + "first_name": { + "type": "string", + "title": [ { - "properties":{ - "were_you_driving":{ - "enum":[ - "Yes" - ] - } - } + "language": "en", + "value": "first_name" }, { - "properties":{ - "were_you_driving":{ - "enum":[ - "No" - ] - } - }, - "required":[ - "who_was_driving" - ] + "language": "fr", + "value": "leprénom" } ] }, - "other_driver_information":{ - "type":"object", - "properties":{ - "other_driver_information":{ - "type":"array", - "items":{ - "type":"object", - "properties":{ - "document_photos":{ - "description":"Photos of other driver's documentation", - "type":"object", - "properties":{ - "pink_card":{ - "type":"string", - "format":"photo" - }, - "drivers_license":{ - "type":"string", - "format":"photo" - }, - "license_plate":{ - "type":"string", - "format":"photo" - }, - "registration":{ - "type":"string", - "format":"photo" - } - } - }, - "document_details":{ - "description":"Other driver's information if no photos taken", - "type":"object", - "properties":{ - "first_name":{ - "type":"string" - }, - "last_name":{ - "type":"string" - }, - "address":{ - "type":"string" - }, - "city":{ - "type":"string" - }, - "province":{ - "type":"string" - }, - "postal_code":{ - "type":"string" - }, - "home_phone_number":{ - "type":"string", - "format":"tel" - }, - "cell_phone_number":{ - "type":"string", - "format":"tel" - }, - "email":{ - "type":"string", - "format":"email" - }, - "drivers_license_number":{ - "type":"string" - }, - "license_plate":{ - "type":"string" - }, - "other_drivers_car":{ - "title":"Other Drivers Car", - "type":"object", - "properties":{ - "year":{ - "type":"string" - }, - "make":{ - "type":"string" - }, - "model":{ - "type":"string" - } - } - }, - "policy_number":{ - "type":"string" - }, - "insurance_company":{ - "type":"string" - } - } - } - } - } - } - } - }, - "witness_information":{ - "type":"object", - "properties":{ - "witnesses":{ - "type":"array", - "items":{ - "type":"object", - "properties":{ - "name":{ - "type":"string" - }, - "email":{ - "type":"string", - "format":"email" - }, - "home_phone_number":{ - "type":"string", - "format":"tel" - }, - "cell_phone_number":{ - "type":"string", - "format":"tel" - } - } - } + "last_name": { + "type": "string", + "title": [ + { + "language": "en", + "value": "last_name" + }, + { + "language": "fr", + "value": "lenom de famille" } - } + ] } - } + }, + "required": [ + "first_name", + "last_name" + ] } \ No newline at end of file diff --git a/app/src/main/res/raw/claims_edited.json b/app/src/main/res/raw/claims_edited.json index cfd0d31..ee15ae7 100644 --- a/app/src/main/res/raw/claims_edited.json +++ b/app/src/main/res/raw/claims_edited.json @@ -1,183 +1,613 @@ { - "title":"Auto Claim - Vehicle Accident", - "type":"object", - "properties":{ - "driver_information":{ - "type":"object", - "properties":{ - "description":{ - "type":"string" + "title": [ + { + "language": "en", + "value": "Auto Claim - Vehicle Accident" + }, + { + "language": "fr", + "value": "Réclamation automobile - Accident automobile" + } + ], + "type": "object", + "properties": { + "vehicle": { + "type": "number", + "title": [ + { + "language": "en", + "value": "Select Vehicle" + }, + { + "language": "fr", + "value": "Sélectionnez Véhicule" + } + ], + "_data": { + "href": "/vehicles", + "enum": "id", + "enumNames": [ + "vehicle_make", + "vehicle_model" + ] + } + }, + "driver_information": { + "type": "object", + "title": [ + { + "language": "en", + "value": "Driver information" + }, + { + "language": "fr", + "value": "Informations du conducteur" + } + ], + "properties": { + "description": { + "type": "string", + "title": [ + { + "language": "en", + "value": "Description" + }, + { + "language": "fr", + "value": "Description" + } + ], + "pattern": "^[\r\n0-9a-zA-Z /_:,.?@;-]*$" }, - "date_time_of_accident":{ - "title":"Date and Time of Accident", - "type":"object", - "properties":{ - "date":{ - "title":"Date of Accident", - "type":"string", - "format":"date" + "date_time_of_accident": { + "title": [ + { + "language": "en", + "value": "Date and Time of Accident" }, - "time":{ - "title":"Time of Accident", - "type":"string", - "format":"time" + { + "language": "fr", + "value": "Date et heure de l’accident" + } + ], + "type": "object", + "properties": { + "date": { + "title": [ + { + "language": "en", + "value": "Date of Accident" + }, + { + "language": "fr", + "value": "Date de l’accident" + } + ], + "type": "string", + "format": "date" + }, + "time": { + "title": [ + { + "language": "en", + "value": "Time of Accident" + }, + { + "language": "fr", + "value": "Heure de l’accident" + } + ], + "type": "string", + "format": "time" } }, - "required":[ + "required": [ "date", "time" ] }, - "location_of_accident":{ - "type":"string", - "format":"map_lat_long" + "location_of_accident": { + "type": "string", + "title": [ + { + "language": "en", + "value": "Location of Accident" + }, + { + "language": "fr", + "value": "Lieu de l’accident" + } + ], + "format": "map_lat_long", + "pattern": "^[\r\n0-9a-zA-Z /_:,.?@;-]*$" }, - "description_of_accident":{ - "type":"string", - "format":"textarea" + "description_of_accident": { + "type": "string", + "title": [ + { + "language": "en", + "value": "Description of accident" + }, + { + "language": "fr", + "value": "Description de l’accident" + } + ], + "format": "textarea", + "pattern": "^[\r\n0-9a-zA-Z /_:,.?@;-]*$" }, - "were_you_driving":{ - "type":"string", - "enum":[ + "were_you_driving": { + "type": "string", + "title": [ + { + "language": "en", + "value": "Were you driving" + }, + { + "language": "fr", + "value": "Étiez-vous au volant" + } + ], + "enum": [ + "Yes", + "No" + ], + "enumNames": [ "Yes", "No" ] }, - "who_was_driving":{ - "type":"string" + "who_was_driving": { + "type": "string", + "title": [ + { + "language": "en", + "value": "who was driving" + }, + { + "language": "fr", + "value": "" + } + ], + "pattern": "^[\r\n0-9a-zA-Z /_:,.?@;-]*$" }, - "your_damage_photos":{ - "type":"array", - "items":{ - "type":"object", - "properties":{ - "photo":{ - "type":"string", - "format":"photo" + "your_damage_photos": { + "type": "array", + "title": [ + { + "language": "en", + "value": "Your damage photos" + }, + { + "language": "fr", + "value": "Vos photos endommagées" + } + ], + "items": { + "type": "object", + "properties": { + "photo": { + "type": "string", + "title": [ + { + "language": "en", + "value": "photo" + }, + { + "language": "fr", + "value": "photo" + } + ], + "format": "photo", + "pattern": "^data:([a-zA-Z0-9]+/[a-zA-Z0-9-.+]+).base64,.*" } } } } }, - "required":[ + "required": [ "description_of_accident", "were_you_driving", "date_time_of_accident" ], - "oneOf":[ + "oneOf": [ { - "properties":{ - "were_you_driving":{ - "enum":[ + "properties": { + "were_you_driving": { + "enum": [ "Yes" ] } } }, { - "properties":{ - "were_you_driving":{ - "enum":[ + "properties": { + "were_you_driving": { + "enum": [ "No" ] } }, - "required":[ + "required": [ "who_was_driving" ] } ] }, - "other_driver_information":{ - "type":"object", - "properties":{ - "other_driver_information":{ - "type":"array", - "items":{ - "type":"object", - "properties":{ - "document_photos":{ - "description":"Photos of other driver's documentation", - "type":"object", - "properties":{ - "pink_card":{ - "type":"string", - "format":"photo" - }, - "drivers_license":{ - "type":"string", - "format":"photo" - }, - "license_plate":{ - "type":"string", - "format":"photo" - }, - "registration":{ - "type":"string", - "format":"photo" + "other_driver_information": { + "type": "object", + "title": [ + { + "language": "en", + "value": "other_driver_information" + }, + { + "language": "fr", + "value": "Autre voiture de conducteur" + } + ], + "properties": { + "other_driver_information": { + "type": "array", + "title": [ + { + "language": "en", + "value": "Other driver information" + }, + { + "language": "fr", + "value": "Autre voiture de conducteur" + } + ], + "items": { + "type": "object", + "properties": { + "document_photos": { + "description": [ + { + "language": "en", + "value": "Photos of other driver's documentation" + }, + { + "language": "fr", + "value": "Photos de la documentation des autres conducteurs" + } + ], + "type": "object", + "title": [ + { + "language": "en", + "value": "description" + }, + { + "language": "fr", + "value": "description" + } + ], + "properties": { + "pink_card": { + "type": "string", + "title": [ + { + "language": "en", + "value": "pink card" + }, + { + "language": "fr", + "value": "pink card" + } + ], + "format": "photo", + "pattern": "^data:([a-zA-Z0-9]+/[a-zA-Z0-9-.+]+).base64,.*" + }, + "drivers_license": { + "type": "string", + "title": [ + { + "language": "en", + "value": "drivers license" + }, + { + "language": "fr", + "value": "Numéro de permis de conduire" + } + ], + "format": "photo", + "pattern": "^data:([a-zA-Z0-9]+/[a-zA-Z0-9-.+]+).base64,.*" + }, + "license_plate": { + "type": "string", + "title": [ + { + "language": "en", + "value": "license plate" + }, + { + "language": "fr", + "value": "Plaque d'immatriculation" + } + ], + "format": "photo", + "pattern": "^data:([a-zA-Z0-9]+/[a-zA-Z0-9-.+]+).base64,.*" + }, + "registration": { + "type": "string", + "title": [ + { + "language": "en", + "value": "registration" + }, + { + "language": "fr", + "value": "enregistrement" + } + ], + "format": "photo", + "pattern": "^data:([a-zA-Z0-9]+/[a-zA-Z0-9-.+]+).base64,.*" } } }, - "document_details":{ - "description":"Other driver's information if no photos taken", - "type":"object", - "properties":{ - "first_name":{ - "type":"string" + "document_details": { + "description": [ + { + "language": "en", + "value": "Other driver's information if no photos taken" }, - "last_name":{ - "type":"string" + { + "language": "fr", + "value": "Autres renseignements sur le conducteur si aucune photo n’a été prise" + } + ], + "type": "object", + "title": [ + { + "language": "en", + "value": "Documents details" }, - "address":{ - "type":"string" + { + "language": "fr", + "value": "Documents" + } + ], + "properties": { + "first_name": { + "title": [ + { + "language": "en", + "value": "First name" + }, + { + "language": "fr", + "value": "Prénom" + } + ], + "type": "string", + "pattern": "^[\r\n0-9a-zA-Z /_:,.?@;-]*$" }, - "city":{ - "type":"string" + "last_name": { + "type": "string", + "title": [ + { + "language": "en", + "value": "Last name" + }, + { + "language": "fr", + "value": "Nom de famille" + } + ], + "pattern": "^[\r\n0-9a-zA-Z /_:,.?@;-]*$" }, - "province":{ - "type":"string" + "address": { + "type": "string", + "title": [ + { + "language": "en", + "value": "address" + }, + { + "language": "fr", + "value": "Adresse" + } + ], + "pattern": "^[\r\n0-9a-zA-Z /_:,.?@;-]*$" }, - "postal_code":{ - "type":"string" + "city": { + "type": "string", + "title": [ + { + "language": "en", + "value": "City" + }, + { + "language": "fr", + "value": "Ville" + } + ], + "pattern": "^[\r\n0-9a-zA-Z /_:,.?@;-]*$" }, - "home_phone_number":{ - "type":"string", - "format":"tel" + "province": { + "type": "string", + "title": [ + { + "language": "en", + "value": "province" + }, + { + "language": "fr", + "value": "Province" + } + ], + "pattern": "^[\r\n0-9a-zA-Z /_:,.?@;-]*$" }, - "cell_phone_number":{ - "type":"string", - "format":"tel" + "postal_code": { + "type": "string", + "title": [ + { + "language": "en", + "value": "postal code" + }, + { + "language": "fr", + "value": "Code Postal" + } + ], + "pattern": "^[\r\n0-9a-zA-Z /_:,.?@;-]*$" }, - "email":{ - "type":"string", - "format":"email" + "home_phone_number": { + "type": "string", + "title": [ + { + "language": "en", + "value": "Home Phone Number" + }, + { + "language": "fr", + "value": "numéro de téléphone résidentiel" + } + ], + "format": "tel" }, - "drivers_license_number":{ - "type":"string" + "cell_phone_number": { + "type": "string", + "title": [ + { + "language": "en", + "value": "cell phone number" + }, + { + "language": "fr", + "value": "Numéro de téléphone portable" + } + ], + "format": "tel" }, - "license_plate":{ - "type":"string" + "email": { + "type": "string", + "title": [ + { + "language": "en", + "value": "email" + }, + { + "language": "fr", + "value": "Courriel" + } + ], + "format": "email" }, - "other_drivers_car":{ - "title":"Other Drivers Car", - "type":"object", - "properties":{ - "year":{ - "type":"string" + "drivers_license_number": { + "type": "string", + "title": [ + { + "language": "en", + "value": "drivers license number" }, - "make":{ - "type":"string" + { + "language": "fr", + "value": "Numéro de permis de conduire" + } + ], + "pattern": "^[\r\n0-9a-zA-Z /_:,.?@;-]*$" + }, + "license_plate": { + "type": "string", + "title": [ + { + "language": "en", + "value": "license plate" }, - "model":{ - "type":"string" + { + "language": "fr", + "value": "Plaque d'immatriculation" + } + ], + "pattern": "^[\r\n0-9a-zA-Z /_:,.?@;-]*$" + }, + "other_drivers_car": { + "title": [ + { + "language": "en", + "value": "Other Drivers Car" + }, + { + "language": "fr", + "value": "Autre voiture de conducteur" + } + ], + "type": "object", + "properties": { + "year": { + "type": "string", + "title": [ + { + "language": "en", + "value": "year" + }, + { + "language": "fr", + "value": "Année" + } + ], + "pattern": "^[\r\n0-9a-zA-Z /_:,.?@;-]*$" + }, + "make": { + "type": "string", + "title": [ + { + "language": "en", + "value": "Make" + }, + { + "language": "fr", + "value": "Marque de voiture" + } + ], + "pattern": "^[\r\n0-9a-zA-Z /_:,.?@;-]*$" + }, + "model": { + "type": "string", + "title": [ + { + "language": "en", + "value": "Model" + }, + { + "language": "fr", + "value": "Modèle de voiture" + } + ], + "pattern": "^[\r\n0-9a-zA-Z /_:,.?@;-]*$" } } }, - "policy_number":{ - "type":"string" + "policy_number": { + "type": "string", + "title": [ + { + "language": "en", + "value": "policy number" + }, + { + "language": "fr", + "value": "Numéro de politique" + } + ], + "pattern": "^[\r\n0-9a-zA-Z /_:,.?@;-]*$" }, - "insurance_company":{ - "type":"string" + "insurance_company": { + "type": "string", + "title": [ + { + "language": "en", + "value": "insurance company" + }, + { + "language": "fr", + "value": "compagnie d'assurance" + } + ], + "pattern": "^[\r\n0-9a-zA-Z /_:,.?@;-]*$" } } } @@ -186,33 +616,97 @@ } } }, - "witness_information":{ - "type":"object", - "properties":{ - "witnesses":{ - "type":"array", - "items":{ - "type":"object", - "properties":{ - "name":{ - "type":"string" + "witness_information": { + "type": "object", + "title": [ + { + "language": "en", + "value": "witness information" + }, + { + "language": "fr", + "value": "les témoins" + } + ], + "properties": { + "witnesses": { + "type": "array", + "title": [ + { + "language": "en", + "value": "witnesses" + }, + { + "language": "fr", + "value": "les témoins" + } + ], + "items": { + "type": "object", + "properties": { + "name": { + "type": "string", + "title": [ + { + "language": "en", + "value": "name" + }, + { + "language": "fr", + "value": "Nom" + } + ], + "pattern": "^[\r\n0-9a-zA-Z /_:,.?@;-]*$" }, - "email":{ - "type":"string", - "format":"email" + "email": { + "type": "string", + "title": [ + { + "language": "en", + "value": "Email" + }, + { + "language": "fr", + "value": "Courriel" + } + ], + "format": "email" }, - "home_phone_number":{ - "type":"string", - "format":"tel" + "home_phone_number": { + "type": "string", + "title": [ + { + "language": "en", + "value": "home phone number" + }, + { + "language": "fr", + "value": "numéro de téléphone résidentiel" + } + ], + "format": "tel" }, - "cell_phone_number":{ - "type":"string", - "format":"tel" + "cell_phone_number": { + "type": "string", + "title": [ + { + "language": "en", + "value": "cell phone number" + }, + { + "language": "fr", + "value": "Numéro de téléphone portable" + } + ], + "format": "tel" } } } } } } - } + }, + "required": [ + "vehicle" + ] } \ No newline at end of file