├── .travis.yml
├── LICENSE
├── README.md
├── app
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── quemb
│ │ └── qmbform
│ │ └── sample
│ │ ├── controller
│ │ ├── SampleActivity.java
│ │ ├── SampleAnnotationFormFragment.java
│ │ ├── SampleFormFragment.java
│ │ ├── SampleMultivalueSectionFormFragment.java
│ │ └── SamplePageAdapter.java
│ │ └── model
│ │ ├── Entry.java
│ │ └── TabItem.java
│ └── res
│ ├── drawable-hdpi
│ └── ic_launcher.png
│ ├── drawable-mdpi
│ └── ic_launcher.png
│ ├── drawable-xhdpi
│ └── ic_launcher.png
│ ├── drawable-xxhdpi
│ └── ic_launcher.png
│ ├── drawable
│ └── textlines.xml
│ ├── layout
│ ├── activity_page_view.xml
│ └── form_sample.xml
│ ├── menu
│ └── sample.xml
│ ├── values-w820dp
│ └── dimens.xml
│ └── values
│ ├── colors.xml
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── lib
└── QMBForm
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── quemb
│ │ │ └── qmbform
│ │ │ ├── CellViewFactory.java
│ │ │ ├── FormManager.java
│ │ │ ├── OnFormRowClickListener.java
│ │ │ ├── adapter
│ │ │ ├── FormAdapter.java
│ │ │ └── FormOptionsObjectAdapter.java
│ │ │ ├── annotation
│ │ │ ├── FormDescriptorAnnotationFactory.java
│ │ │ ├── FormElement.java
│ │ │ ├── FormElementDelegate.java
│ │ │ ├── FormOptionsObjectElement.java
│ │ │ ├── FormValidator.java
│ │ │ └── validators
│ │ │ │ ├── BlankStringValidator.java
│ │ │ │ ├── EmailValidator.java
│ │ │ │ └── PositiveNumberValidator.java
│ │ │ ├── descriptor
│ │ │ ├── CellDescriptor.java
│ │ │ ├── DataSource.java
│ │ │ ├── DataSourceListener.java
│ │ │ ├── FormDescriptor.java
│ │ │ ├── FormItemDescriptor.java
│ │ │ ├── FormOptionsObject.java
│ │ │ ├── FormValidation.java
│ │ │ ├── OnFormRowChangeListener.java
│ │ │ ├── OnFormRowValueChangedListener.java
│ │ │ ├── OnFormValidationChangeListener.java
│ │ │ ├── OnValueChangeListener.java
│ │ │ ├── RowDescriptor.java
│ │ │ ├── RowValidationError.java
│ │ │ ├── SectionDescriptor.java
│ │ │ └── Value.java
│ │ │ ├── exceptions
│ │ │ └── NoDataSourceException.java
│ │ │ └── view
│ │ │ ├── Cell.java
│ │ │ ├── FormBaseCell.java
│ │ │ ├── FormBooleanFieldCell.java
│ │ │ ├── FormButtonFieldCell.java
│ │ │ ├── FormButtonInlineFieldCell.java
│ │ │ ├── FormCheckFieldCell.java
│ │ │ ├── FormDateDialogFieldCell.java
│ │ │ ├── FormDateFieldCell.java
│ │ │ ├── FormDateInlineFieldCell.java
│ │ │ ├── FormDetailHtmlTextVerticalFieldCell.java
│ │ │ ├── FormDetailTextFieldCell.java
│ │ │ ├── FormDetailTextInlineFieldCell.java
│ │ │ ├── FormDetailTextVerticalFieldCell.java
│ │ │ ├── FormEditCurrencyFieldCell.java
│ │ │ ├── FormEditEmailFieldCell.java
│ │ │ ├── FormEditEmailInlineFieldCell.java
│ │ │ ├── FormEditHTMLTextViewFieldCell.java
│ │ │ ├── FormEditIntegerFieldCell.java
│ │ │ ├── FormEditIntegerInlineFieldCell.java
│ │ │ ├── FormEditNumberFieldCell.java
│ │ │ ├── FormEditNumberInlineFieldCell.java
│ │ │ ├── FormEditPasswordFieldCell.java
│ │ │ ├── FormEditPasswordInlineFieldCell.java
│ │ │ ├── FormEditPhoneFieldCell.java
│ │ │ ├── FormEditTextFieldCell.java
│ │ │ ├── FormEditTextInlineFieldCell.java
│ │ │ ├── FormEditTextViewFieldCell.java
│ │ │ ├── FormEditTextViewInlineFieldCell.java
│ │ │ ├── FormEditURLFieldCell.java
│ │ │ ├── FormExternalButtonFieldCell.java
│ │ │ ├── FormIntegerSliderFieldCell.java
│ │ │ ├── FormMultipleDialogFieldCell.java
│ │ │ ├── FormPickerDialogFieldCell.java
│ │ │ ├── FormPickerDialogVerticalFieldCell.java
│ │ │ ├── FormSpinnerFieldCell.java
│ │ │ ├── FormSpinnerInlineFieldCell.java
│ │ │ ├── FormTextPickerDialogFieldCell.java
│ │ │ ├── FormTimeDialogFieldCell.java
│ │ │ ├── FormTimeFieldCell.java
│ │ │ ├── FormTimeInlineFieldCell.java
│ │ │ ├── FormTitleFieldCell.java
│ │ │ ├── SectionCell.java
│ │ │ └── SeperatorSectionCell.java
│ └── res
│ │ ├── drawable-hdpi
│ │ ├── ic_action_about.png
│ │ ├── ic_action_new.png
│ │ ├── ic_action_remove.png
│ │ └── ic_launcher.png
│ │ ├── drawable-mdpi
│ │ ├── ic_action_about.png
│ │ ├── ic_action_new.png
│ │ ├── ic_action_remove.png
│ │ └── ic_launcher.png
│ │ ├── drawable-xhdpi
│ │ ├── ic_action_about.png
│ │ ├── ic_action_new.png
│ │ ├── ic_action_remove.png
│ │ └── ic_launcher.png
│ │ ├── drawable-xxhdpi
│ │ ├── ic_action_about.png
│ │ ├── ic_action_new.png
│ │ ├── ic_action_remove.png
│ │ └── ic_launcher.png
│ │ ├── drawable
│ │ └── section_seperator_background.xml
│ │ ├── layout
│ │ ├── boolean_field_cell.xml
│ │ ├── button_field_cell.xml
│ │ ├── button_inline_field_cell.xml
│ │ ├── check_field_cell.xml
│ │ ├── date_field_cell.xml
│ │ ├── date_inline_field_cell.xml
│ │ ├── detail_html_text_vertical_field_cell.xml
│ │ ├── detail_text_field_cell.xml
│ │ ├── detail_text_inline_field_cell.xml
│ │ ├── detail_text_vertical_field_cell.xml
│ │ ├── edit_text_field_cell.xml
│ │ ├── edit_text_inline_field_cell.xml
│ │ ├── edit_text_view_field_cell.xml
│ │ ├── edit_text_view_inline_field_cell.xml
│ │ ├── integer_slider_field_cell.xml
│ │ ├── section_cell.xml
│ │ ├── section_seperator_cell.xml
│ │ ├── spinner_field_cell.xml
│ │ ├── spinner_inline_field_cell.xml
│ │ ├── text_field_cell.xml
│ │ ├── text_picker_field_cell.xml
│ │ └── time_inline_field_cell.xml
│ │ ├── values-de
│ │ └── strings.xml
│ │ └── values
│ │ ├── attr.xml
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ └── strings.xml
│ └── test
│ ├── java
│ └── com
│ │ └── quemb
│ │ └── qmbform
│ │ ├── AnnotationFormTest.java
│ │ ├── FormBooleanFieldCellTest.java
│ │ ├── FormButtonFieldCellTest.java
│ │ ├── FormCheckFieldCellTest.java
│ │ ├── FormDateFieldCellTest.java
│ │ ├── FormEditFieldCellTest.java
│ │ ├── FormIntegerSliderCellTest.java
│ │ ├── FormManagerTest.java
│ │ ├── FormPickerFieldCellTest.java
│ │ ├── ValidationTest.java
│ │ ├── ValueTest.java
│ │ └── view
│ │ └── FormBaseCellTest.java
│ └── resources
│ └── com
│ └── quemb
│ └── qmbform
│ └── robolectric.properties
├── resources
└── sample_cast.gif
└── settings.gradle
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: android
2 | jdk: oraclejdk8
3 | android:
4 | components:
5 | # Uncomment the lines below if you want to
6 | # use the latest revision of Android SDK Tools
7 | - platform-tools
8 | - tools
9 |
10 | # The BuildTools version used by your project
11 | - build-tools-25.0.2
12 |
13 | # The SDK version used to compile your project
14 | - android-25
15 |
16 | # Design Support Library
17 | - extra-android-m2repository
18 |
19 | # Specify at least one system image,
20 | # if you need to run emulator(s) during your tests
21 | - sys-img-armeabi-v7a-android-25
22 |
23 | before_install:
24 | - chmod +x gradlew
25 |
26 | script:
27 | # - TERM=dumb ./gradlew -i test
28 | - ./gradlew build connectedCheck
29 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Toni Moeckel
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 |
3 | repositories {
4 | mavenCentral()
5 | jcenter()
6 | }
7 |
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:2.3.0'
10 | }
11 | }
12 |
13 | apply plugin: 'com.android.application'
14 |
15 | android {
16 | compileSdkVersion 25
17 | buildToolsVersion '25.0.2'
18 |
19 | defaultConfig {
20 | applicationId "com.quemb.qmbform.sample"
21 | minSdkVersion 14
22 | targetSdkVersion 25
23 | versionCode 2
24 | versionName "1.1"
25 | }
26 | buildTypes {
27 | release {
28 | minifyEnabled false
29 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
30 | }
31 | }
32 | lintOptions {
33 | abortOnError false
34 | }
35 | }
36 | dependencies {
37 | compile fileTree(dir: 'libs', include: ['*.jar'])
38 | compile project(':lib:QMBForm')
39 | }
40 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/tonimoeckel/Development/adt-bundle-mac/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
10 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/java/com/quemb/qmbform/sample/controller/SampleActivity.java:
--------------------------------------------------------------------------------
1 | package com.quemb.qmbform.sample.controller;
2 |
3 | import com.quemb.qmbform.sample.R;
4 | import com.quemb.qmbform.sample.model.TabItem;
5 |
6 | import android.os.Bundle;
7 | import android.support.v4.view.ViewPager;
8 | import android.support.v7.app.AppCompatActivity;
9 |
10 | import java.util.ArrayList;
11 | import java.util.List;
12 |
13 |
14 | public class SampleActivity extends AppCompatActivity {
15 |
16 | public static String TAG = "SampleActivity";
17 |
18 | SamplePageAdapter pageAdapter;
19 |
20 |
21 | @Override
22 | protected void onCreate(Bundle savedInstanceState) {
23 |
24 | super.onCreate(savedInstanceState);
25 |
26 | setContentView(R.layout.activity_page_view);
27 | List fragments = getTabItems();
28 | pageAdapter = new SamplePageAdapter(getSupportFragmentManager(), fragments);
29 | ViewPager pager = (ViewPager)findViewById(R.id.viewpager);
30 | pager.setOffscreenPageLimit(1);
31 | pager.setAdapter(pageAdapter);
32 |
33 | }
34 |
35 | private List getTabItems() {
36 | List fList = new ArrayList();
37 |
38 | fList.add(new TabItem("Annotation",SampleAnnotationFormFragment.newInstance()));
39 | fList.add(new TabItem("Multi Value Section", SampleMultivalueSectionFormFragment.newInstance()));
40 | fList.add(new TabItem("Manual", SampleFormFragment.newInstance()));
41 |
42 | return fList;
43 | }
44 |
45 |
46 |
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/app/src/main/java/com/quemb/qmbform/sample/controller/SampleAnnotationFormFragment.java:
--------------------------------------------------------------------------------
1 | package com.quemb.qmbform.sample.controller;
2 |
3 | import com.quemb.qmbform.FormManager;
4 | import com.quemb.qmbform.OnFormRowClickListener;
5 | import com.quemb.qmbform.annotation.FormDescriptorAnnotationFactory;
6 | import com.quemb.qmbform.descriptor.CellDescriptor;
7 | import com.quemb.qmbform.descriptor.FormDescriptor;
8 | import com.quemb.qmbform.descriptor.FormItemDescriptor;
9 | import com.quemb.qmbform.descriptor.OnFormRowValueChangedListener;
10 | import com.quemb.qmbform.descriptor.RowDescriptor;
11 | import com.quemb.qmbform.descriptor.Value;
12 | import com.quemb.qmbform.sample.R;
13 | import com.quemb.qmbform.sample.model.Entry;
14 |
15 | import android.os.Bundle;
16 | import android.support.v4.app.Fragment;
17 | import android.util.Log;
18 | import android.view.LayoutInflater;
19 | import android.view.Menu;
20 | import android.view.MenuInflater;
21 | import android.view.MenuItem;
22 | import android.view.View;
23 | import android.view.ViewGroup;
24 | import android.widget.ListView;
25 |
26 | import java.util.ArrayList;
27 | import java.util.Date;
28 | import java.util.HashMap;
29 |
30 | /**
31 | * Created by tonimoeckel on 17.07.14.
32 | */
33 | public class SampleAnnotationFormFragment extends Fragment implements OnFormRowValueChangedListener,
34 | OnFormRowClickListener{
35 |
36 | private ListView mListView;
37 | private HashMap> mChangesMap = new HashMap>();;
38 | private MenuItem mSaveMenuItem;
39 |
40 | public static String TAG = "SampleFormFragment";
41 |
42 | public static final SampleAnnotationFormFragment newInstance()
43 | {
44 | SampleAnnotationFormFragment f = new SampleAnnotationFormFragment();
45 |
46 | return f;
47 | }
48 |
49 | @Override
50 | public void onCreate(Bundle savedInstanceState) {
51 | super.onCreate(savedInstanceState);
52 |
53 | setHasOptionsMenu(true);
54 | }
55 |
56 | @Override
57 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
58 | Bundle savedInstanceState) {
59 |
60 | View v = inflater.inflate(R.layout.form_sample, container, false);
61 |
62 | mListView = (ListView) v.findViewById(R.id.list);
63 |
64 | return v;
65 | }
66 |
67 | @Override
68 | public void onViewCreated(View view, Bundle savedInstanceState) {
69 | super.onViewCreated(view, savedInstanceState);
70 |
71 | Entry entry = new Entry();
72 | entry.display = "Its me";
73 | entry.title = "Hello";
74 | entry.description = "World";
75 | entry.date = new Date();
76 | entry.dateInline = new Date();
77 | entry.multiValue = new ArrayList();
78 | entry.multiValue.add("multiple");
79 | entry.multiValue.add("tags");
80 | entry.multiValue.add("allowed");
81 |
82 | // More styles and colors for cells
83 | //HashMap cellConfig = new HashMap<>(8);
84 |
85 | // TextAppearance for section, label, value and button
86 | //cellConfig.put(CellDescriptor.APPEARANCE_SECTION, Integer.valueOf(R.style.TextAppearance_Form_Section));
87 | //cellConfig.put(CellDescriptor.APPEARANCE_TEXT_LABEL, Integer.valueOf(R.style.TextAppearance_Form_Label));
88 | //cellConfig.put(CellDescriptor.APPEARANCE_TEXT_VALUE, Integer.valueOf(R.style.TextAppearance_Form_Value));
89 | //cellConfig.put(CellDescriptor.APPEARANCE_BUTTON, Integer.valueOf(R.style.TextAppearance_Form_Button));
90 |
91 | // color for label and value
92 | //cellConfig.put(CellDescriptor.COLOR_LABEL, Integer.valueOf(0x80C0FFC0));
93 | //cellConfig.put(CellDescriptor.COLOR_VALUE, Integer.valueOf(0xC0C0FFC0));
94 |
95 | // Disabled color for label and value
96 | //cellConfig.put(CellDescriptor.COLOR_LABEL_DISABLED, Integer.valueOf(0x80FFC0C0));
97 | //cellConfig.put(CellDescriptor.COLOR_VALUE_DISABLED, Integer.valueOf(0xC0FFC0C0));
98 |
99 | FormDescriptorAnnotationFactory factory = new FormDescriptorAnnotationFactory(getActivity());
100 | FormDescriptor descriptor = factory.createFormDescriptorFromAnnotatedClass(entry);
101 | //FormDescriptor descriptor = factory.createFormDescriptorFromAnnotatedClass(entry, cellConfig);
102 |
103 | FormManager formManager = new FormManager();
104 | formManager.setup(descriptor, mListView, getActivity());
105 | formManager.setOnFormRowClickListener(this);
106 | formManager.setOnFormRowValueChangedListener(this);
107 | }
108 |
109 | @Override
110 | public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
111 | super.onCreateOptionsMenu(menu, inflater);
112 |
113 | inflater.inflate(R.menu.sample, menu);
114 | mSaveMenuItem = menu.findItem(R.id.action_save);
115 | }
116 |
117 |
118 |
119 | @Override
120 | public void onPrepareOptionsMenu(Menu menu) {
121 | updateSaveItem();
122 | }
123 |
124 | @Override
125 | public boolean onOptionsItemSelected(MenuItem item) {
126 | if (item == mSaveMenuItem){
127 | mChangesMap.clear();
128 | updateSaveItem();
129 | }
130 | return super.onOptionsItemSelected(item);
131 | }
132 |
133 | @Override
134 | public void onFormRowClick(FormItemDescriptor itemDescriptor) {
135 |
136 | }
137 |
138 | @Override
139 | public void onValueChanged(RowDescriptor rowDescriptor, Value> oldValue, Value> newValue) {
140 | Log.d(TAG, "Value Changed: " + rowDescriptor.getTitle());
141 | // Log.d(TAG, "Old Value: "+oldValue);
142 | // Log.d(TAG, "New Value: "+newValue);
143 |
144 | mChangesMap.put(rowDescriptor.getTag(), newValue);
145 | updateSaveItem();
146 | }
147 |
148 | private void updateSaveItem() {
149 | mSaveMenuItem.setVisible(mChangesMap.size()>0);
150 | }
151 | }
152 |
--------------------------------------------------------------------------------
/app/src/main/java/com/quemb/qmbform/sample/controller/SamplePageAdapter.java:
--------------------------------------------------------------------------------
1 | package com.quemb.qmbform.sample.controller;
2 |
3 | import com.quemb.qmbform.sample.model.TabItem;
4 |
5 | import android.support.v4.app.Fragment;
6 | import android.support.v4.app.FragmentManager;
7 | import android.support.v4.app.FragmentPagerAdapter;
8 |
9 | import java.util.List;
10 |
11 | /**
12 | * Created by tonimoeckel on 17.07.14.
13 | */
14 | public class SamplePageAdapter extends FragmentPagerAdapter {
15 | private List mTabItems;
16 |
17 | public SamplePageAdapter(FragmentManager fm, List tabItems) {
18 | super(fm);
19 | mTabItems = tabItems;
20 | }
21 | @Override
22 | public Fragment getItem(int position) {
23 | return mTabItems.get(position).getFragment();
24 | }
25 |
26 | @Override
27 | public int getCount() {
28 | return mTabItems.size();
29 | }
30 |
31 | @Override
32 | public CharSequence getPageTitle (int position) {
33 | return mTabItems.get(position).getTitle();
34 | }
35 |
36 |
37 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/quemb/qmbform/sample/model/Entry.java:
--------------------------------------------------------------------------------
1 | package com.quemb.qmbform.sample.model;
2 |
3 | import com.quemb.qmbform.annotation.FormElement;
4 | import com.quemb.qmbform.annotation.FormElementDelegate;
5 | import com.quemb.qmbform.descriptor.RowDescriptor;
6 | import com.quemb.qmbform.sample.R;
7 |
8 | import java.lang.reflect.Field;
9 | import java.util.ArrayList;
10 | import java.util.Date;
11 |
12 | /**
13 | * Created by tonimoeckel on 30.07.14.
14 | */
15 | public class Entry implements FormElementDelegate {
16 |
17 | @FormElement(
18 | label = R.string.lb_display,
19 | rowDescriptorType = RowDescriptor.FormRowDescriptorTypeDetail,
20 | sortId = 0,
21 | section = R.string.section_general
22 | )
23 | public String display;
24 |
25 | @FormElement(
26 | label = R.string.lb_title,
27 | rowDescriptorType = RowDescriptor.FormRowDescriptorTypeText,
28 | sortId = 1,
29 | section = R.string.section_general
30 | )
31 | public String title;
32 |
33 | @FormElement(
34 | label = R.string.lb_description,
35 | rowDescriptorType = RowDescriptor.FormRowDescriptorTypeTextView,
36 | sortId = 2,
37 | section = R.string.section_general
38 | )
39 | public String description;
40 |
41 | @FormElement(
42 | label = R.string.lb_date_dialog,
43 | rowDescriptorType = RowDescriptor.FormRowDescriptorTypeDate,
44 | sortId = 4,
45 | section = R.string.section_date
46 | )
47 | public Date date;
48 |
49 | @FormElement(
50 | label = R.string.lb_date_inline,
51 | rowDescriptorType = RowDescriptor.FormRowDescriptorTypeDateInline,
52 | tag = "customDateInlineTag",
53 | sortId = 3,
54 | section = R.string.section_date
55 | )
56 | public Date dateInline;
57 |
58 | @FormElement(
59 | label = R.string.lb_boolean_check,
60 | rowDescriptorType = RowDescriptor.FormRowDescriptorTypeBooleanSwitch,
61 | disabled = true,
62 | tag = "checkSwitch",
63 | sortId = 5,
64 | section = R.string.section_boolean
65 | )
66 | public Boolean checkSwitch;
67 |
68 | @FormElement(
69 | rowDescriptorType = RowDescriptor.FormRowDescriptorTypeText,
70 | sortId = 6,
71 | section = R.string.section_multiValue,
72 | hint = R.string.lb_add_new_tag,
73 | multiValue = true
74 | )
75 | public ArrayList multiValue;
76 |
77 | /**
78 | * Use this interface method to decide at runtime if the generate rowDescriptor should be added to the form descriptor
79 | * Also use this as a hook, to manual set RowDescriptor properties
80 | *
81 | * @param rowDescriptor
82 | * @param field
83 | * @return
84 | */
85 | @Override
86 | public boolean shouldAddRowDescriptorForField(RowDescriptor rowDescriptor, Field field) {
87 |
88 | // For some reason you don't want "description" to be added
89 | if (field.getName().equals("description")){
90 | return false;
91 | }
92 |
93 | return true;
94 |
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/app/src/main/java/com/quemb/qmbform/sample/model/TabItem.java:
--------------------------------------------------------------------------------
1 | package com.quemb.qmbform.sample.model;
2 |
3 | import android.support.v4.app.Fragment;
4 |
5 | /**
6 | * Created by tonimoeckel on 31.07.14.
7 | */
8 | public class TabItem {
9 |
10 | private String mTitle;
11 | private Fragment mFragment;
12 |
13 | public TabItem(String title, Fragment fragment){
14 | mTitle = title;
15 | mFragment = fragment;
16 | }
17 |
18 |
19 | public Fragment getFragment() {
20 | return mFragment;
21 | }
22 |
23 | public String getTitle() {
24 | return mTitle;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quemb/QMBForm/95ddd131669531e61d75a7515b29f374fb557272/app/src/main/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quemb/QMBForm/95ddd131669531e61d75a7515b29f374fb557272/app/src/main/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quemb/QMBForm/95ddd131669531e61d75a7515b29f374fb557272/app/src/main/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quemb/QMBForm/95ddd131669531e61d75a7515b29f374fb557272/app/src/main/res/drawable-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/textlines.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | -
13 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_page_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
12 |
13 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/form_sample.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/sample.xml:
--------------------------------------------------------------------------------
1 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | #000000
6 | #404040
7 | #808080
8 | #c0c0c0
9 | #FFFFFF
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | QMBForm Sample
5 | Hello world!
6 | Settings
7 | Save
8 | Title
9 | General
10 | Description
11 | Date
12 | Date
13 | Date Dialog
14 | Date Inline
15 | Boolean
16 | Check
17 | Multiple Value
18 | Multiple Value
19 | Add new tag
20 | Display
21 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
16 |
17 |
29 |
30 |
33 |
36 |
39 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | mavenCentral()
6 | jcenter()
7 | }
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:2.3.0'
10 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
11 |
12 | // NOTE: Do not place your application dependencies here; they belong
13 | // in the individual module build.gradle files
14 | }
15 | }
16 |
17 | allprojects {
18 | repositories {
19 | mavenCentral()
20 | }
21 | gradle.projectsEvaluated {
22 | tasks.withType(JavaCompile) {
23 | options.compilerArgs << "-Xlint:unchecked"
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Settings specified in this file will override any Gradle settings
5 | # configured through the IDE.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quemb/QMBForm/95ddd131669531e61d75a7515b29f374fb557272/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Tue Mar 14 15:01:01 CET 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/lib/QMBForm/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | maven {
7 | url "https://plugins.gradle.org/m2/"
8 | }
9 | }
10 | dependencies {
11 |
12 | classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.2.1"
13 | }
14 | }
15 |
16 | android {
17 | compileSdkVersion 25
18 | buildToolsVersion '25.0.2'
19 |
20 | defaultConfig {
21 | minSdkVersion 14
22 | targetSdkVersion 25
23 | versionCode 2
24 | versionName "1.1"
25 |
26 | // Gradle Plugin 1.5 vectorDrawables support: stop the Gradle plugin’s automatic rasterization of vectors
27 | generatedDensities = []
28 | }
29 | aaptOptions {
30 | // Gradle Plugin 1.5 vectorDrawables support: tell aapt to keep the attribute ids around
31 | additionalParameters "--no-version-vectors"
32 | }
33 | buildTypes {
34 | release {
35 | minifyEnabled false
36 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
37 | }
38 | }
39 | lintOptions {
40 | abortOnError false
41 | }
42 |
43 | sourceSets {
44 |
45 | test {
46 | setRoot('src/test')
47 | res.srcDirs = [ 'src/test/resources' ]
48 | }
49 |
50 | test.java.srcDirs += 'build/generated/source/r/debug'
51 | }
52 |
53 | lintOptions {
54 | abortOnError false
55 | }
56 |
57 | testOptions {
58 | unitTests.returnDefaultValues = true
59 | }
60 | }
61 |
62 | dependencies {
63 | compile fileTree(dir: 'libs', include: ['*.jar'])
64 | compile 'com.android.support:appcompat-v7:25.2.0'
65 |
66 | testCompile 'junit:junit:4.12'
67 | testCompile 'org.hamcrest:hamcrest-core:1.2.1'
68 | testCompile "org.robolectric:robolectric:3.2.2"
69 |
70 | }
71 |
72 | apply plugin: 'idea'
73 |
74 | idea {
75 | module {
76 | testOutputDir = file('build/test-classes/debug')
77 | }
78 | }
79 |
80 | apply plugin: 'org.sonarqube'
81 |
82 | sonarqube {
83 | properties {
84 | property "sonar.host.url", "http://localhost:9000"
85 | property "sonar.jdbc.url", "jdbc:mysql://localhost/sonar"
86 | property "sonar.jdbc.driverClassName", "com.mysql.jdbc.Driver"
87 | property "sonar.jdbc.username", "sonar"
88 | property "sonar.jdbc.password", "sonar"
89 |
90 | property "sonar.java.binaries", "$buildDir"
91 | property "sonar.sources", "src/main/java"
92 | property "sonar.tests", "src/test/java"
93 |
94 | property 'sonar.junit.reportsPath', "$buildDir/test-results/release/"
95 | property "sonar.jacoco.reportPath", "$buildDir/jacoco/testDebugUnitTest.exec"
96 | }
97 | }
98 |
99 |
100 | apply plugin: "jacoco"
101 |
102 | jacoco {
103 | toolVersion = "0.7.1.201405082137"
104 | reportsDir = file("$buildDir/reports/jacoco")
105 | }
106 |
107 | task jacocoTestReport(type: JacocoReport ) {
108 | description = "Generates Jacoco coverage reports: XML and HTML"
109 | group = "Reporting"
110 |
111 | jacocoClasspath = project.configurations['androidJacocoAnt']
112 |
113 | def fileFilter = ['**/R.class',
114 | '**/R$*.class',
115 | '**/BuildConfig.*',
116 | '**/Manifest*.*',
117 | '**/*Test*.*',
118 | 'android/**/*.*']
119 |
120 | def debugTree = fileTree(dir: "${project.buildDir}/intermediates/classes/debug", excludes: fileFilter)
121 | def mainSrc = "${project.projectDir}/src/main/java"
122 |
123 | sourceDirectories = files([mainSrc])
124 | classDirectories = files([debugTree])
125 | executionData = fileTree(dir: project.projectDir, includes: ['**/*.exec', '**/*.ec'])
126 |
127 | reports {
128 | xml {
129 | enabled = true
130 | destination = "${project.buildDir}/reports/jacoco/test/jacocoTestReport.xml"
131 | }
132 | csv.enabled false
133 | html {
134 | enabled = true
135 | destination = "${project.buildDir}/reports/jacoco"
136 | }
137 | }
138 | }
139 |
140 |
141 | apply plugin: 'com.github.dcendents.android-maven'
142 |
143 | group='com.github.quemb'
--------------------------------------------------------------------------------
/lib/QMBForm/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/tonimoeckel/Development/adt-bundle-mac/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/lib/QMBForm/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/lib/QMBForm/src/main/java/com/quemb/qmbform/FormManager.java:
--------------------------------------------------------------------------------
1 | package com.quemb.qmbform;
2 |
3 | import com.quemb.qmbform.adapter.FormAdapter;
4 | import com.quemb.qmbform.descriptor.FormDescriptor;
5 | import com.quemb.qmbform.descriptor.FormItemDescriptor;
6 | import com.quemb.qmbform.descriptor.OnFormRowChangeListener;
7 | import com.quemb.qmbform.descriptor.OnFormRowValueChangedListener;
8 | import com.quemb.qmbform.descriptor.RowDescriptor;
9 | import com.quemb.qmbform.descriptor.SectionDescriptor;
10 | import com.quemb.qmbform.descriptor.Value;
11 | import com.quemb.qmbform.view.Cell;
12 |
13 | import android.app.Activity;
14 | import android.content.Context;
15 | import android.view.View;
16 | import android.view.ViewGroup;
17 | import android.widget.AdapterView;
18 | import android.widget.ListView;
19 |
20 | import java.util.ArrayList;
21 |
22 | /**
23 | * Created by tonimoeckel on 15.07.14.
24 | */
25 | public class FormManager implements OnFormRowChangeListener, OnFormRowValueChangedListener {
26 |
27 | private FormDescriptor mFormDescriptor;
28 | protected ListView mListView;
29 | protected OnFormRowClickListener mOnFormRowClickListener;
30 | private OnFormRowChangeListener mOnFormRowChangeListener;
31 | private OnFormRowValueChangedListener mOnFormRowValueChangedListener;
32 |
33 | public FormManager(){
34 |
35 | }
36 |
37 |
38 | public void setup(FormDescriptor formDescriptor, final ListView listView, Activity activity){
39 |
40 | Context context = activity;
41 |
42 | // activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
43 | mFormDescriptor = formDescriptor;
44 | mFormDescriptor.setOnFormRowChangeListener(this);
45 | mFormDescriptor.setOnFormRowValueChangedListener(this);
46 |
47 | final FormAdapter adapter = FormAdapter.newInstance(mFormDescriptor, context);
48 | listView.setAdapter(adapter);
49 | listView.setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
50 | listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
51 | @Override
52 | public void onItemClick(AdapterView> parent, View view, int position, long id) {
53 | FormItemDescriptor itemDescriptor = adapter.getItem(position);
54 |
55 | Cell cell = itemDescriptor.getCell();
56 | if (cell != null && itemDescriptor instanceof RowDescriptor){
57 | RowDescriptor rowDescriptor = (RowDescriptor) itemDescriptor;
58 | if (!rowDescriptor.getDisabled()){
59 | cell.onCellSelected();
60 | }
61 | }
62 |
63 | OnFormRowClickListener descriptorListener = itemDescriptor.getOnFormRowClickListener();
64 | if (descriptorListener != null){
65 | descriptorListener.onFormRowClick(itemDescriptor);
66 | }
67 |
68 | if (mOnFormRowClickListener != null){
69 | mOnFormRowClickListener.onFormRowClick(itemDescriptor);
70 | }
71 | }
72 | });
73 | mListView = listView;
74 |
75 | }
76 |
77 | public OnFormRowClickListener getOnFormRowClickListener() {
78 | return mOnFormRowClickListener;
79 | }
80 |
81 | public void setOnFormRowClickListener(OnFormRowClickListener onFormRowClickListener) {
82 | mOnFormRowClickListener = onFormRowClickListener;
83 | }
84 |
85 | public void updateRows(){
86 | FormAdapter adapter = (FormAdapter) mListView.getAdapter();
87 | if (adapter != null){
88 | adapter.notifyDataSetChanged();
89 | }
90 | }
91 |
92 |
93 | public OnFormRowChangeListener getOnFormRowChangeListener() {
94 | return mOnFormRowChangeListener;
95 | }
96 |
97 | public void setOnFormRowChangeListener(OnFormRowChangeListener onFormRowChangeListener) {
98 | mOnFormRowChangeListener = onFormRowChangeListener;
99 | }
100 |
101 | @Override
102 | public void onRowAdded(RowDescriptor rowDescriptor, SectionDescriptor sectionDescriptor) {
103 | updateRows();
104 | if (mOnFormRowChangeListener != null){
105 | mOnFormRowChangeListener.onRowAdded(rowDescriptor, sectionDescriptor);
106 | }
107 | }
108 |
109 | @Override
110 | public void onRowRemoved(RowDescriptor rowDescriptor, SectionDescriptor sectionDescriptor) {
111 | updateRows();
112 | if (mOnFormRowChangeListener != null){
113 | mOnFormRowChangeListener.onRowRemoved(rowDescriptor, sectionDescriptor);
114 | }
115 | }
116 |
117 | @Override
118 | public void onRowChanged(RowDescriptor rowDescriptor, SectionDescriptor sectionDescriptor) {
119 | updateRows();
120 | if (mOnFormRowChangeListener != null){
121 | mOnFormRowChangeListener.onRowChanged(rowDescriptor, sectionDescriptor);
122 | }
123 | }
124 |
125 | @Override
126 | public void onValueChanged(RowDescriptor rowDescriptor, Value> oldValue, Value> newValue) {
127 | if (mOnFormRowValueChangedListener != null){
128 | mOnFormRowValueChangedListener.onValueChanged(rowDescriptor, oldValue, newValue);
129 | }
130 |
131 | ArrayList updateWhiteList = new ArrayList();
132 | updateWhiteList.add(RowDescriptor.FormRowDescriptorTypeDatePicker);
133 | updateWhiteList.add(RowDescriptor.FormRowDescriptorTypeSelectorPickerDialog);
134 | updateWhiteList.add(RowDescriptor.FormRowDescriptorTypeSelectorPickerDialogVertical);
135 | updateWhiteList.add(RowDescriptor.FormRowDescriptorTypePicker);
136 |
137 | if (updateWhiteList.contains(rowDescriptor.getRowType())){
138 | updateRows();
139 | }
140 |
141 | }
142 |
143 | public void setOnFormRowValueChangedListener(
144 | OnFormRowValueChangedListener onFormRowValueChangedListener) {
145 | mOnFormRowValueChangedListener = onFormRowValueChangedListener;
146 | }
147 | }
148 |
--------------------------------------------------------------------------------
/lib/QMBForm/src/main/java/com/quemb/qmbform/OnFormRowClickListener.java:
--------------------------------------------------------------------------------
1 | package com.quemb.qmbform;
2 |
3 | import com.quemb.qmbform.descriptor.FormItemDescriptor;
4 |
5 | /**
6 | * Created by tonimoeckel on 15.07.14.
7 | */
8 | public interface OnFormRowClickListener {
9 |
10 | public void onFormRowClick(FormItemDescriptor itemDescriptor);
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/lib/QMBForm/src/main/java/com/quemb/qmbform/adapter/FormAdapter.java:
--------------------------------------------------------------------------------
1 | package com.quemb.qmbform.adapter;
2 |
3 | import com.quemb.qmbform.descriptor.FormDescriptor;
4 | import com.quemb.qmbform.descriptor.FormItemDescriptor;
5 | import com.quemb.qmbform.descriptor.RowDescriptor;
6 | import com.quemb.qmbform.descriptor.SectionDescriptor;
7 | import com.quemb.qmbform.CellViewFactory;
8 | import com.quemb.qmbform.view.Cell;
9 |
10 | import android.content.Context;
11 | import android.view.View;
12 | import android.view.ViewGroup;
13 | import android.widget.BaseAdapter;
14 |
15 | import java.util.ArrayList;
16 |
17 | /**
18 | * Created by tonimoeckel on 14.07.14.
19 | */
20 | public class FormAdapter extends BaseAdapter {
21 |
22 | private FormDescriptor mFormDescriptor;
23 | private ArrayList mItems;
24 | private Context mContext;
25 | private Boolean mEnableSectionSeperator;
26 |
27 | public static FormAdapter newInstance(FormDescriptor formDescriptor, Context context){
28 | FormAdapter formAdapter = new FormAdapter();
29 | formAdapter.mFormDescriptor = formDescriptor;
30 | formAdapter.mContext = context;
31 | formAdapter.setEnableSectionSeperator(true);
32 | return formAdapter;
33 | }
34 |
35 | @Override
36 | public int getCount() {
37 | mItems = new ArrayList();
38 | int sectionCount = 1;
39 | for (SectionDescriptor sectionDescriptor : mFormDescriptor.getSections()){
40 |
41 | if (sectionDescriptor.hasTitle()){
42 | mItems.add(sectionDescriptor);
43 | }
44 |
45 | mItems.addAll(sectionDescriptor.getRows());
46 |
47 | if (getEnableSectionSeperator() && sectionCount < mFormDescriptor.getSections().size()) {
48 |
49 | FormItemDescriptor itemDescriptor = mItems.get(mItems.size() - 1);
50 | if (itemDescriptor instanceof RowDescriptor)
51 | ((RowDescriptor) itemDescriptor).setLastRowInSection(true);
52 |
53 | mItems.add(RowDescriptor.newInstance(null, RowDescriptor.FormRowDescriptorTypeSectionSeperator));
54 | }
55 | sectionCount++;
56 | }
57 |
58 | return mItems.size();
59 | }
60 |
61 | @Override
62 | public FormItemDescriptor getItem(int position) {
63 |
64 | return mItems.get(position);
65 | }
66 |
67 | @Override
68 | public long getItemId(int position) {
69 | return position;
70 | }
71 |
72 | @Override
73 | public View getView(int position, View convertView, ViewGroup parent) {
74 |
75 |
76 | return CellViewFactory.getInstance().createViewForFormItemDescriptor(mContext,getItem(position));
77 | }
78 |
79 |
80 | public Boolean getEnableSectionSeperator() {
81 | return mEnableSectionSeperator;
82 | }
83 |
84 | public void setEnableSectionSeperator(Boolean enableSectionSeperator) {
85 | mEnableSectionSeperator = enableSectionSeperator;
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/lib/QMBForm/src/main/java/com/quemb/qmbform/adapter/FormOptionsObjectAdapter.java:
--------------------------------------------------------------------------------
1 | package com.quemb.qmbform.adapter;
2 |
3 | import com.quemb.qmbform.descriptor.FormOptionsObject;
4 |
5 | import android.content.Context;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.ArrayAdapter;
10 | import android.widget.TextView;
11 |
12 | import java.util.List;
13 |
14 | /**
15 | * Created by pmaccamp on 9/9/2015.
16 | */
17 | public class FormOptionsObjectAdapter extends ArrayAdapter {
18 | private List mOptions;
19 | private int mResource;
20 | private int mDropDownResource;
21 |
22 | public FormOptionsObjectAdapter(Context context, int resource) {
23 | super(context, resource);
24 | this.mResource = resource;
25 | }
26 |
27 | public FormOptionsObjectAdapter(Context context, int resource, int dropDownResource, List options) {
28 | super(context, resource);
29 | this.mOptions = options;
30 | this.mResource = resource;
31 | this.mDropDownResource = dropDownResource;
32 | }
33 |
34 | @Override
35 | public int getCount() {
36 | return mOptions.size();
37 | }
38 |
39 | @Override
40 | public Object getItem(int position) {
41 | return mOptions.get(position);
42 | }
43 |
44 |
45 | @Override
46 | public long getItemId(int position) {
47 | return position;
48 | }
49 |
50 | public View inflateView(int position, View convertView, ViewGroup parent, int resource) {
51 | TextView textView = null;
52 | if (convertView == null) {
53 | LayoutInflater inflator = (LayoutInflater) parent.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
54 | textView = (TextView) inflator.inflate(resource, parent, false);
55 | } else {
56 | textView = (TextView) convertView;
57 | }
58 | textView.setText(mOptions.get(position).getDisplayText());
59 | return textView;
60 | }
61 |
62 | @Override
63 | public View getView(int position, View convertView, ViewGroup parent) {
64 | return inflateView(position, convertView, parent, this.mResource);
65 | }
66 |
67 | @Override
68 | public View getDropDownView(int position, View convertView, ViewGroup parent) {
69 | return inflateView(position, convertView, parent, this.mDropDownResource);
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/lib/QMBForm/src/main/java/com/quemb/qmbform/annotation/FormElement.java:
--------------------------------------------------------------------------------
1 | package com.quemb.qmbform.annotation;
2 |
3 | import com.quemb.qmbform.descriptor.RowDescriptor;
4 |
5 | import java.lang.annotation.ElementType;
6 | import java.lang.annotation.Retention;
7 | import java.lang.annotation.RetentionPolicy;
8 | import java.lang.annotation.Target;
9 |
10 | /**
11 | * Created by tonimoeckel on 06.02.14.
12 | */
13 |
14 | @Target(ElementType.FIELD)
15 | @Retention(RetentionPolicy.RUNTIME)
16 | public @interface FormElement {
17 | public int label() default android.R.string.untitled;
18 |
19 | public String rowDescriptorType() default RowDescriptor.FormRowDescriptorTypeDetailInline;
20 |
21 | public String tag() default "";
22 |
23 | public int hint() default android.R.string.untitled;
24 |
25 | public int sortId() default 100;
26 |
27 | public boolean required() default false;
28 |
29 | public String dateFormat() default "yyyy-MM-dd HH:mm:ss";
30 |
31 | public int section() default android.R.string.untitled;
32 |
33 | public boolean disabled() default false;
34 |
35 | public boolean multiValue() default false;
36 |
37 | public Class>[] validatorClasses() default {};
38 |
39 | public FormOptionsObjectElement[] selectorOptions() default {};
40 | }
41 |
--------------------------------------------------------------------------------
/lib/QMBForm/src/main/java/com/quemb/qmbform/annotation/FormElementDelegate.java:
--------------------------------------------------------------------------------
1 | package com.quemb.qmbform.annotation;
2 |
3 | import com.quemb.qmbform.descriptor.RowDescriptor;
4 |
5 | import java.lang.reflect.Field;
6 |
7 | /**
8 | * Created by tonimoeckel on 03.09.14.
9 | */
10 | public interface FormElementDelegate {
11 |
12 | public boolean shouldAddRowDescriptorForField(RowDescriptor rowDescriptor, Field field);
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/lib/QMBForm/src/main/java/com/quemb/qmbform/annotation/FormOptionsObjectElement.java:
--------------------------------------------------------------------------------
1 | package com.quemb.qmbform.annotation;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | /**
9 | * Created by pmaccamp on 9/8/2015.
10 | */
11 |
12 | @Target(ElementType.FIELD)
13 | @Retention(RetentionPolicy.RUNTIME)
14 | public @interface FormOptionsObjectElement {
15 | enum ValueTypes {
16 | INT, DOUBLE, STRING
17 | }
18 |
19 | public String value() default "";
20 |
21 | public ValueTypes valueType() default ValueTypes.STRING;
22 |
23 | public String displayText();
24 | }
25 |
--------------------------------------------------------------------------------
/lib/QMBForm/src/main/java/com/quemb/qmbform/annotation/FormValidator.java:
--------------------------------------------------------------------------------
1 | package com.quemb.qmbform.annotation;
2 |
3 | import com.quemb.qmbform.descriptor.RowDescriptor;
4 | import com.quemb.qmbform.descriptor.RowValidationError;
5 |
6 | /**
7 | * Created by pmaccamp on 8/26/2015.
8 | */
9 | public interface FormValidator {
10 | /**
11 | * @return {@link RowValidationError} if there is an error else null
12 | */
13 | public RowValidationError validate(RowDescriptor descriptor);
14 | }
15 |
--------------------------------------------------------------------------------
/lib/QMBForm/src/main/java/com/quemb/qmbform/annotation/validators/BlankStringValidator.java:
--------------------------------------------------------------------------------
1 | package com.quemb.qmbform.annotation.validators;
2 |
3 |
4 | import com.quemb.qmbform.R;
5 | import com.quemb.qmbform.annotation.FormValidator;
6 | import com.quemb.qmbform.descriptor.RowDescriptor;
7 | import com.quemb.qmbform.descriptor.RowValidationError;
8 | import com.quemb.qmbform.descriptor.Value;
9 |
10 | /**
11 | * Created by pmaccamp on 8/26/2015.
12 | */
13 | public class BlankStringValidator implements FormValidator {
14 | @Override
15 | public RowValidationError validate(RowDescriptor descriptor) {
16 | Value value = descriptor.getValue();
17 | if (value.getValue() != null &&
18 | value.getValue() instanceof String) {
19 | String str = (String) value.getValue();
20 |
21 | // if a valid string return null
22 | if (str.replace(" ", "").length() > 0) {
23 | return null;
24 | }
25 | }
26 | return new RowValidationError(descriptor, R.string.validation_is_required);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/lib/QMBForm/src/main/java/com/quemb/qmbform/annotation/validators/EmailValidator.java:
--------------------------------------------------------------------------------
1 | package com.quemb.qmbform.annotation.validators;
2 |
3 |
4 | import com.quemb.qmbform.R;
5 | import com.quemb.qmbform.annotation.FormValidator;
6 | import com.quemb.qmbform.descriptor.RowDescriptor;
7 | import com.quemb.qmbform.descriptor.RowValidationError;
8 | import com.quemb.qmbform.descriptor.Value;
9 |
10 | /**
11 | * Created by pmaccamp on 8/26/2015.
12 | */
13 |
14 |
15 | public class EmailValidator implements FormValidator {
16 | private static final String EMAIL_PATTERN =
17 | "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@"
18 | + "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";
19 |
20 | @Override
21 | public RowValidationError validate(RowDescriptor descriptor) {
22 |
23 | RowValidationError result = null;
24 |
25 | Value value = descriptor.getValue();
26 | if (value.getValue() != null && value.getValue() instanceof String) {
27 | String val = (String) value.getValue();
28 | if (!val.matches(EMAIL_PATTERN)){
29 | result = new RowValidationError(descriptor, R.string.validation_invalid_email);
30 | }
31 | }else {
32 | result = new RowValidationError(descriptor, R.string.validation_invalid_email);
33 | }
34 | return result;
35 | }
36 | }
37 |
38 |
39 |
--------------------------------------------------------------------------------
/lib/QMBForm/src/main/java/com/quemb/qmbform/annotation/validators/PositiveNumberValidator.java:
--------------------------------------------------------------------------------
1 | package com.quemb.qmbform.annotation.validators;
2 |
3 |
4 | import com.quemb.qmbform.R;
5 | import com.quemb.qmbform.annotation.FormValidator;
6 | import com.quemb.qmbform.descriptor.RowDescriptor;
7 | import com.quemb.qmbform.descriptor.RowValidationError;
8 |
9 | /**
10 | * Created by pmaccamp on 8/26/2015.
11 | */
12 | public class PositiveNumberValidator implements FormValidator {
13 | @Override
14 | public RowValidationError validate(RowDescriptor descriptor) {
15 | Object valueData = descriptor.getValue().getValue();
16 | if (valueData != null) {
17 | if (valueData instanceof Number && ((Number) valueData).doubleValue() > 0) {
18 | return null;
19 | } else if (valueData instanceof Double && ((Double) valueData) > 0) {
20 | return null;
21 | } else if (valueData instanceof Float && ((Float) valueData) > 0) {
22 | return null;
23 | } else if (valueData instanceof Integer && ((Integer) valueData) > 0) {
24 | return null;
25 | }
26 | }
27 | return new RowValidationError(descriptor, R.string.nonpositive_number_error);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/lib/QMBForm/src/main/java/com/quemb/qmbform/descriptor/CellDescriptor.java:
--------------------------------------------------------------------------------
1 | package com.quemb.qmbform.descriptor;
2 |
3 | /**
4 | * Colors and TextAppearance to be used by RowDescriptor.
5 | * Added by MTL / PTN on 02/07/2016
6 | */
7 | public class CellDescriptor
8 | {
9 | // TextAppearance style ID
10 |
11 | public static final String APPEARANCE_SECTION = "FORM_APPEARANCE_SECTION"; // value is an attribute ID as Integer.valueOf(R.attr.xxx)
12 | public static final String APPEARANCE_TEXT_LABEL = "FORM_APPEARANCE_TEXT_LABEL"; // value is an attribute ID as Integer.valueOf(R.attr.xxx)
13 | public static final String APPEARANCE_TEXT_VALUE = "FORM_APPEARANCE_TEXT_VALUE"; // value is an attribute ID as Integer.valueOf(R.attr.xxx)
14 | public static final String APPEARANCE_BUTTON = "FORM_APPEARANCE_BUTTON"; // value is an attribute ID as Integer.valueOf(R.attr.xxx)
15 |
16 | // Text colors (if TextAppearance styles are not defined)
17 |
18 | // Note: default TextView color is style android:textColor,
19 | // default EditText color is android:editTextColor (Lollipop+) or android:textColorPrimary (pre-Lollipop)
20 |
21 | public static final String COLOR_LABEL = "FORM_COLOR_LABEL"; // value is color as Integer.valueOf(OxAARRGGBB)
22 | public static final String COLOR_VALUE = "FORM_COLOR_VALUE"; // value is color as Integer.valueOf(OxAARRGGBB)
23 |
24 | // Disabled text colors
25 |
26 | public static final String COLOR_LABEL_DISABLED = "FORM_COLOR_LABEL_DISABLED"; // value is color as Integer.valueOf(OxAARRGGBB)
27 | public static final String COLOR_VALUE_DISABLED = "FORM_COLOR_VALUE_DISABLED"; // value is color as Integer.valueOf(OxAARRGGBB)
28 | }
29 |
--------------------------------------------------------------------------------
/lib/QMBForm/src/main/java/com/quemb/qmbform/descriptor/DataSource.java:
--------------------------------------------------------------------------------
1 | package com.quemb.qmbform.descriptor;
2 |
3 | /**
4 | * Created by tonimoeckel on 22.07.14.
5 | */
6 | public abstract class DataSource {
7 | /**
8 | * Call the listener for callback actions
9 | */
10 | public abstract void loadData(DataSourceListener listener);
11 | }
12 |
--------------------------------------------------------------------------------
/lib/QMBForm/src/main/java/com/quemb/qmbform/descriptor/DataSourceListener.java:
--------------------------------------------------------------------------------
1 | package com.quemb.qmbform.descriptor;
2 |
3 | import java.util.List;
4 |
5 | /**
6 | * Created by tonimoeckel on 22.07.14.
7 | */
8 | public interface DataSourceListener {
9 |
10 | public void onDataSourceLoaded(List list);
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/lib/QMBForm/src/main/java/com/quemb/qmbform/descriptor/FormDescriptor.java:
--------------------------------------------------------------------------------
1 | package com.quemb.qmbform.descriptor;
2 |
3 | import android.content.Context;
4 |
5 | import java.util.ArrayList;
6 | import java.util.HashMap;
7 | import java.util.Map;
8 |
9 | /**
10 | * Created by tonimoeckel on 14.07.14.
11 | */
12 | public class FormDescriptor {
13 |
14 | private String mTitle;
15 | private HashMap mCellConfig;
16 | private ArrayList mSections;
17 | private OnFormRowValueChangedListener mOnFormRowValueChangedListener;
18 | private OnFormRowChangeListener mOnFormRowChangeListener;
19 |
20 | public static FormDescriptor newInstance(){
21 | return FormDescriptor.newInstance(null);
22 | }
23 |
24 | public static FormDescriptor newInstance(String title){
25 |
26 | FormDescriptor descriptor = new FormDescriptor();
27 | descriptor.mTitle = title;
28 | return descriptor;
29 |
30 | }
31 |
32 | public FormDescriptor(){
33 | mSections = new ArrayList();
34 | }
35 |
36 | /**
37 | * Set CellConfig member
38 | */
39 | public void setCellConfig(HashMap cellConfig) {
40 | mCellConfig = cellConfig;
41 | }
42 |
43 |
44 |
45 | public void addSection(SectionDescriptor sectionDescriptor){
46 | insertSectionAtIndex(sectionDescriptor, mSections.size());
47 | }
48 |
49 | public void removeSection(SectionDescriptor sectionDescriptor){
50 | int index = mSections.indexOf(sectionDescriptor);
51 | if (index>=0){
52 | removeSectionAtIndex(index);
53 | }
54 | }
55 |
56 | public int countOfSections(){
57 | return mSections.size();
58 | }
59 |
60 | public SectionDescriptor sectionAtIndex(int index){
61 | if (mSections.size()>index){
62 | return mSections.get(index);
63 | }
64 | return null;
65 | }
66 |
67 | public SectionDescriptor sectionByTag(String tag) {
68 | for (SectionDescriptor sectionDescriptor : mSections) {
69 | if (sectionDescriptor.getTag().equals(tag)) {
70 | return sectionDescriptor;
71 | }
72 | }
73 | return null;
74 | }
75 |
76 | public SectionDescriptor getSectionWithTitle(String title) {
77 | for (SectionDescriptor sectionDescriptor : mSections) {
78 | if (sectionDescriptor.getTitle().equals(title)) {
79 | return sectionDescriptor;
80 | }
81 | }
82 | return null;
83 | }
84 |
85 | public ArrayList getSections(){
86 | return mSections;
87 | }
88 |
89 | public void insertSectionAtIndex(SectionDescriptor section, int index){
90 | section.setFormDescriptor(this);
91 | mSections.add(index, section);
92 | }
93 |
94 | private void removeSectionAtIndex(int index){
95 | mSections.remove(index);
96 | }
97 |
98 | public String getTitle() {
99 | return mTitle;
100 | }
101 |
102 | public OnFormRowValueChangedListener getOnFormRowValueChangedListener() {
103 | return mOnFormRowValueChangedListener;
104 | }
105 |
106 | public RowDescriptor findRowDescriptor(String tag){
107 | RowDescriptor rowDescriptor = null;
108 |
109 | for (SectionDescriptor sectionDescriptor:getSections()){
110 | rowDescriptor = sectionDescriptor.findRowDescriptor(tag);
111 | if (rowDescriptor != null) break;
112 | }
113 |
114 | return rowDescriptor;
115 | }
116 |
117 | public void setOnFormRowValueChangedListener(
118 | OnFormRowValueChangedListener onFormRowValueChangedListener) {
119 | mOnFormRowValueChangedListener = onFormRowValueChangedListener;
120 | }
121 |
122 | public boolean isValid(Context context){
123 |
124 | FormValidation formValidation = getFormValidation(context);
125 |
126 | if (formValidation.getRowValidationErrors().size()>0){
127 | return false;
128 | }
129 | return true;
130 | }
131 |
132 | public FormValidation getFormValidation(Context context) {
133 |
134 | FormValidation formValidation = new FormValidation(context);
135 | for (SectionDescriptor sectionDescriptor : getSections()){
136 | for (RowDescriptor rowDescriptor : sectionDescriptor.getRows()){
137 | if (!rowDescriptor.isValid()){
138 | formValidation.getRowValidationErrors().addAll(rowDescriptor.getValidationErrors());
139 | }
140 | }
141 | }
142 | return formValidation;
143 |
144 | }
145 |
146 | protected void didInsertRow(RowDescriptor rowDescriptor, SectionDescriptor sectionDescriptor){
147 | if (mOnFormRowChangeListener != null){
148 | mOnFormRowChangeListener.onRowAdded(rowDescriptor, sectionDescriptor);
149 | }
150 | }
151 |
152 | protected void didRemoveRow(RowDescriptor rowDescriptor, SectionDescriptor sectionDescriptor){
153 | if (mOnFormRowChangeListener != null){
154 | mOnFormRowChangeListener.onRowRemoved(rowDescriptor, sectionDescriptor);
155 | }
156 | }
157 |
158 |
159 | protected OnFormRowChangeListener getOnFormRowChangeListener() {
160 | return mOnFormRowChangeListener;
161 | }
162 |
163 | public void setOnFormRowChangeListener(OnFormRowChangeListener onFormRowChangeListener) {
164 | mOnFormRowChangeListener = onFormRowChangeListener;
165 | }
166 |
167 | public Map getFormValues() {
168 | Map m = new HashMap();
169 | for (SectionDescriptor section : getSections()) {
170 | for (RowDescriptor row : section.getRows()) {
171 | m.put(row.getTag(), row.getValueData());
172 | }
173 | }
174 | return m;
175 | }
176 |
177 | }
--------------------------------------------------------------------------------
/lib/QMBForm/src/main/java/com/quemb/qmbform/descriptor/FormItemDescriptor.java:
--------------------------------------------------------------------------------
1 | package com.quemb.qmbform.descriptor;
2 |
3 | import com.quemb.qmbform.OnFormRowClickListener;
4 | import com.quemb.qmbform.view.Cell;
5 |
6 | import java.util.HashMap;
7 |
8 | /**
9 | * Created by tonimoeckel on 14.07.14.
10 | */
11 | public class FormItemDescriptor {
12 |
13 | protected Cell mCell;
14 |
15 | protected String mTag;
16 |
17 |
18 | protected String mTitle;
19 | private OnFormRowClickListener mOnFormRowClickListener;
20 | private HashMap mCellConfig;
21 |
22 |
23 | public String getTitle() {
24 | return mTitle;
25 | }
26 |
27 | public void setTitle(String title) {
28 | this.mTitle = title;
29 | }
30 |
31 | public String getTag() {
32 | return mTag;
33 | }
34 |
35 | public void setTag(String tag) {
36 | mTag = tag;
37 | }
38 |
39 | public Cell getCell() {
40 | return mCell;
41 | }
42 |
43 | public void setCell(Cell cell) {
44 | mCell = cell;
45 | }
46 |
47 |
48 | public OnFormRowClickListener getOnFormRowClickListener() {
49 | return mOnFormRowClickListener;
50 | }
51 |
52 | public void setOnFormRowClickListener(OnFormRowClickListener onFormRowClickListener) {
53 | mOnFormRowClickListener = onFormRowClickListener;
54 | }
55 |
56 | public HashMap getCellConfig() {
57 | return mCellConfig;
58 | }
59 |
60 | public void setCellConfig(HashMap cellConfig) {
61 | mCellConfig = cellConfig;
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/lib/QMBForm/src/main/java/com/quemb/qmbform/descriptor/FormOptionsObject.java:
--------------------------------------------------------------------------------
1 | package com.quemb.qmbform.descriptor;
2 |
3 | import java.util.List;
4 |
5 | /**
6 | * Created by pmaccamp on 9/8/2015.
7 | */
8 | public class FormOptionsObject {
9 | private Object mValue;
10 | private String mFormDisplayText;
11 |
12 | private FormOptionsObject(Object value, String formDisplayText) {
13 | mFormDisplayText = formDisplayText;
14 | mValue = value;
15 | }
16 |
17 | public static FormOptionsObject createFormOptionsObject(Object value, String displayText) {
18 | return new FormOptionsObject(value, displayText);
19 | }
20 |
21 | public static FormOptionsObject formOptionsObjectFromArrayWithValue(Object searchValue, List options) {
22 | for (FormOptionsObject option : options) {
23 | if (option.mValue.equals(searchValue)) {
24 | return option;
25 | }
26 | }
27 | return null;
28 | }
29 |
30 | public static int indexOfFormOptionsObjectFromArrayWithValue(Object searchValue, List options) {
31 | int counter = 0;
32 | for (FormOptionsObject option : options) {
33 | if (option.mValue.equals(searchValue)) {
34 | return counter;
35 | }
36 | counter++;
37 | }
38 | return -1;
39 | }
40 |
41 | public static FormOptionsObject formOptionsObjectFromArrayWithDisplayText(String searchText, List options) {
42 | for (FormOptionsObject option : options) {
43 | if (option.mFormDisplayText.equals(searchText)) {
44 | return option;
45 | }
46 | }
47 | return null;
48 | }
49 |
50 | public static int indexOfFormOptionsObjectFromArrayWithDisplayText(String searchText, List options) {
51 | int counter = 0;
52 | for (FormOptionsObject option : options) {
53 | if (option.mFormDisplayText.equals(searchText)) {
54 | return counter;
55 | }
56 | counter++;
57 | }
58 | return -1;
59 | }
60 |
61 | public Object getValue() {
62 | return mValue;
63 | }
64 |
65 | public String getDisplayText() {
66 | return mFormDisplayText;
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/lib/QMBForm/src/main/java/com/quemb/qmbform/descriptor/FormValidation.java:
--------------------------------------------------------------------------------
1 | package com.quemb.qmbform.descriptor;
2 |
3 | import android.content.Context;
4 |
5 | import java.util.ArrayList;
6 | import java.util.List;
7 |
8 | /**
9 | * Created by tonimoeckel on 01.12.14.
10 | */
11 | public class FormValidation {
12 | private Context mContext;
13 |
14 | public FormValidation(Context context) {
15 | mContext = context;
16 | }
17 |
18 | private List mRowValidationErrors = new ArrayList();
19 |
20 | public List getRowValidationErrors() {
21 | return mRowValidationErrors;
22 | }
23 |
24 | public List getRowValidationErrorsAsStrings() {
25 | ArrayList errors = new ArrayList();
26 | for (RowValidationError error : mRowValidationErrors) {
27 | errors.add(error.getMessage(mContext));
28 | }
29 |
30 | return errors;
31 | }
32 |
33 | public boolean isValid() {
34 |
35 | return getRowValidationErrors().size() == 0;
36 | }
37 |
38 | public RowValidationError getFirstValidationError() {
39 | if (getRowValidationErrors().size() > 0) {
40 | return getRowValidationErrors().get(0);
41 | }
42 |
43 | return null;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/lib/QMBForm/src/main/java/com/quemb/qmbform/descriptor/OnFormRowChangeListener.java:
--------------------------------------------------------------------------------
1 | package com.quemb.qmbform.descriptor;
2 |
3 | /**
4 | * Created by tonimoeckel on 18.02.15.
5 | */
6 | public interface OnFormRowChangeListener {
7 |
8 | public void onRowAdded(RowDescriptor rowDescriptor, SectionDescriptor sectionDescriptor);
9 |
10 | public void onRowRemoved(RowDescriptor rowDescriptor, SectionDescriptor sectionDescriptor);
11 |
12 | public void onRowChanged(RowDescriptor rowDescriptor, SectionDescriptor sectionDescriptor);
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/lib/QMBForm/src/main/java/com/quemb/qmbform/descriptor/OnFormRowValueChangedListener.java:
--------------------------------------------------------------------------------
1 | package com.quemb.qmbform.descriptor;
2 |
3 | /**
4 | * Created by tonimoeckel on 15.07.14.
5 | */
6 | public interface OnFormRowValueChangedListener {
7 |
8 | public void onValueChanged(RowDescriptor rowDescriptor, Value> oldValue, Value> newValue);
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/lib/QMBForm/src/main/java/com/quemb/qmbform/descriptor/OnFormValidationChangeListener.java:
--------------------------------------------------------------------------------
1 | package com.quemb.qmbform.descriptor;
2 |
3 | /**
4 | * Created by tonimoeckel on 01.12.14.
5 | */
6 | public interface OnFormValidationChangeListener {
7 |
8 | public void onValidationChange(FormValidation formValidation);
9 | }
10 |
--------------------------------------------------------------------------------
/lib/QMBForm/src/main/java/com/quemb/qmbform/descriptor/OnValueChangeListener.java:
--------------------------------------------------------------------------------
1 | package com.quemb.qmbform.descriptor;
2 |
3 | /**
4 | * Created by tonimoeckel on 28.08.14.
5 | */
6 | public interface OnValueChangeListener {
7 |
8 | public void onChange(T value);
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/lib/QMBForm/src/main/java/com/quemb/qmbform/descriptor/RowValidationError.java:
--------------------------------------------------------------------------------
1 | package com.quemb.qmbform.descriptor;
2 |
3 | import android.content.Context;
4 |
5 | /**
6 | * Created by tonimoeckel on 01.12.14.
7 | */
8 | public class RowValidationError {
9 |
10 | private int mResourceMessage;
11 | private RowDescriptor mRowDescriptor;
12 |
13 | public RowValidationError(RowDescriptor tRowDescriptor, int resourceMessage) {
14 | mResourceMessage = resourceMessage;
15 | mRowDescriptor = tRowDescriptor;
16 | }
17 |
18 | public int getResourceMessage() {
19 | return mResourceMessage;
20 | }
21 |
22 | public String getMessage(Context context) {
23 | return getRowDescriptor().getTitle() + " " +
24 | context.getString(getResourceMessage());
25 | }
26 |
27 | public RowDescriptor getRowDescriptor() {
28 | return mRowDescriptor;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/lib/QMBForm/src/main/java/com/quemb/qmbform/descriptor/SectionDescriptor.java:
--------------------------------------------------------------------------------
1 | package com.quemb.qmbform.descriptor;
2 |
3 | import java.util.ArrayList;
4 | import java.util.HashMap;
5 | import java.util.List;
6 |
7 | /**
8 | * Created by tonimoeckel on 14.07.14.
9 | */
10 | public class SectionDescriptor extends FormItemDescriptor {
11 |
12 | private FormDescriptor mFormDescriptor;
13 | private ArrayList mRows;
14 | private Boolean mMultivalueSection = false;
15 |
16 | public static SectionDescriptor newInstance(String tag) {
17 |
18 | return SectionDescriptor.newInstance(tag, null);
19 |
20 | }
21 |
22 | public static SectionDescriptor newInstance(String tag, String title) {
23 |
24 | SectionDescriptor descriptor = new SectionDescriptor();
25 | descriptor.mTitle = title;
26 | descriptor.mTag = tag;
27 | return descriptor;
28 |
29 | }
30 |
31 | public SectionDescriptor() {
32 |
33 | mRows = new ArrayList();
34 |
35 | }
36 |
37 | public FormDescriptor getFormDescriptor() {
38 | return mFormDescriptor;
39 | }
40 |
41 | public void setFormDescriptor(FormDescriptor formDescriptor) {
42 | mFormDescriptor = formDescriptor;
43 | }
44 |
45 | public String getTitle() {
46 | return mTitle;
47 | }
48 |
49 | public void addRow(RowDescriptor row) {
50 | addRow(row, mRows.size());
51 | }
52 |
53 | public void addRow(RowDescriptor row, int index) {
54 | insertRowAtIndex(row, index);
55 |
56 | // Propagate the CellConfig from Section to Row
57 |
58 | HashMap cellConfig = getCellConfig();
59 | if (cellConfig != null)
60 | row.setCellConfig(cellConfig);
61 | }
62 |
63 | public void addRow(RowDescriptor row, HashMap cellConfig) {
64 | addRow(row, mRows.size());
65 |
66 | if (cellConfig != null)
67 | row.setCellConfig(cellConfig);
68 | }
69 |
70 | public void removeRow(RowDescriptor row) {
71 | int index = mRows.indexOf(row);
72 | removeRowAtIndex(index);
73 | }
74 |
75 | public int getRowCount() {
76 | return mRows.size();
77 | }
78 |
79 | public List getRows() {
80 | return mRows;
81 | }
82 |
83 | private void insertRowAtIndex(RowDescriptor row, int index) {
84 | if (mRows.size() >= index) {
85 | row.setSectionDescriptor(this);
86 | mRows.add(index, row);
87 | if (getFormDescriptor() != null) {
88 | getFormDescriptor().didInsertRow(row, this);
89 | }
90 |
91 | }
92 | }
93 |
94 | private void removeRowAtIndex(int index) {
95 | RowDescriptor rowDescriptor = mRows.get(index);
96 | mRows.remove(index);
97 | if (getFormDescriptor() != null) {
98 | getFormDescriptor().didRemoveRow(rowDescriptor, this);
99 | }
100 |
101 | }
102 |
103 | public boolean hasTitle() {
104 | return getTitle() != null && getTitle().length() > 0;
105 | }
106 |
107 | public RowDescriptor findRowDescriptor(String tag) {
108 | RowDescriptor rowDescriptor = null;
109 |
110 | for (RowDescriptor iRowDescriptor : getRows()) {
111 | if (tag.equals(iRowDescriptor.getTag())) {
112 | rowDescriptor = iRowDescriptor;
113 | break;
114 | }
115 | }
116 |
117 | return rowDescriptor;
118 | }
119 |
120 | public int getIndexOfRowDescriptor(RowDescriptor rowDescriptor) {
121 | return mRows.indexOf(rowDescriptor);
122 | }
123 |
124 | public Boolean isMultivalueSection() {
125 | return mMultivalueSection;
126 | }
127 |
128 | public void setMultivalueSection(Boolean multivalueSection) {
129 | mMultivalueSection = multivalueSection;
130 | }
131 |
132 | public List getRowValues() {
133 |
134 | ArrayList