├── .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 | 5 | 9 | 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 values = new ArrayList<>(); 135 | for (RowDescriptor rowDescriptor : mRows) { 136 | if (rowDescriptor.getValue() != null && rowDescriptor.getValue().getValue() != null) { 137 | values.add(rowDescriptor.getValue().getValue()); 138 | } 139 | } 140 | return values; 141 | 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/java/com/quemb/qmbform/descriptor/Value.java: -------------------------------------------------------------------------------- 1 | package com.quemb.qmbform.descriptor; 2 | 3 | /** 4 | * Created by tonimoeckel on 14.07.14. 5 | */ 6 | public class Value { 7 | private T mValue; 8 | private OnValueChangeListener mOnValueChangeListener; 9 | 10 | public Value(T value) { 11 | mValue = value; 12 | } 13 | 14 | public T getValue() { 15 | return mValue; 16 | } 17 | 18 | @SuppressWarnings("unchecked") 19 | public void setValue(T value) { 20 | mValue = value; 21 | if (mOnValueChangeListener != null) { 22 | mOnValueChangeListener.onChange(value); 23 | } 24 | } 25 | 26 | 27 | public void setOnValueChangeListener(OnValueChangeListener listener) { 28 | this.mOnValueChangeListener = listener; 29 | } 30 | 31 | public OnValueChangeListener getOnValueChangeListener() { 32 | return this.mOnValueChangeListener; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/java/com/quemb/qmbform/exceptions/NoDataSourceException.java: -------------------------------------------------------------------------------- 1 | package com.quemb.qmbform.exceptions; 2 | 3 | /** 4 | * Created by tonimoeckel on 01.08.14. 5 | */ 6 | public class NoDataSourceException extends RuntimeException { 7 | 8 | public NoDataSourceException(){ 9 | super("No Data Source Defined"); 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/java/com/quemb/qmbform/view/Cell.java: -------------------------------------------------------------------------------- 1 | package com.quemb.qmbform.view; 2 | 3 | import com.quemb.qmbform.descriptor.CellDescriptor; 4 | import com.quemb.qmbform.descriptor.FormItemDescriptor; 5 | 6 | import android.content.Context; 7 | import android.content.res.Resources; 8 | import android.os.Build; 9 | import android.support.annotation.StyleRes; 10 | import android.util.TypedValue; 11 | import android.view.Gravity; 12 | import android.view.View; 13 | import android.view.ViewGroup; 14 | import android.widget.LinearLayout; 15 | import android.widget.TextView; 16 | 17 | import java.util.HashMap; 18 | 19 | /** 20 | * Created by tonimoeckel on 14.07.14. 21 | */ 22 | public abstract class Cell extends LinearLayout { 23 | 24 | private FormItemDescriptor mFormItemDescriptor; 25 | 26 | private View mDividerView; 27 | 28 | public Cell(Context context, FormItemDescriptor formItemDescriptor) { 29 | super(context); 30 | setFormItemDescriptor(formItemDescriptor); 31 | 32 | init(); 33 | update(); 34 | afterInit(); 35 | 36 | } 37 | 38 | protected void afterInit() { 39 | 40 | } 41 | 42 | protected void init() { 43 | 44 | setOrientation(LinearLayout.VERTICAL); 45 | setGravity(Gravity.CENTER); 46 | 47 | int resource = getResource(); 48 | if (resource > 0) { 49 | inflate(getContext(), getResource(), getSuperViewForLayoutInflation()); 50 | } 51 | 52 | if (shouldAddDivider()) { 53 | addView(getDividerView()); 54 | } 55 | 56 | } 57 | 58 | protected ViewGroup getSuperViewForLayoutInflation() { 59 | return this; 60 | } 61 | 62 | protected abstract int getResource(); 63 | 64 | protected abstract void update(); 65 | 66 | public FormItemDescriptor getFormItemDescriptor() { 67 | return mFormItemDescriptor; 68 | } 69 | 70 | public void setFormItemDescriptor(FormItemDescriptor formItemDescriptor) { 71 | 72 | mFormItemDescriptor = formItemDescriptor; 73 | mFormItemDescriptor.setCell(this); 74 | 75 | } 76 | 77 | public void onCellSelected() { 78 | 79 | } 80 | 81 | protected View getDividerView() { 82 | if (mDividerView == null) { 83 | mDividerView = new View(getContext()); 84 | configDivider(mDividerView); 85 | } 86 | return mDividerView; 87 | } 88 | 89 | private void configDivider(View dividerView) { 90 | 91 | dividerView.setLayoutParams(new LayoutParams( 92 | LayoutParams.MATCH_PARENT, 93 | 1 94 | )); 95 | 96 | dividerView.setBackgroundColor(getThemeValue(android.R.attr.listDivider)); 97 | 98 | } 99 | 100 | protected int getThemeValue(int resource) { 101 | TypedValue typedValue = new TypedValue(); 102 | Resources.Theme theme = getContext().getTheme(); 103 | theme.resolveAttribute(resource, typedValue, true); 104 | 105 | return typedValue.data; 106 | } 107 | 108 | public boolean shouldAddDivider() { 109 | return true; 110 | } 111 | 112 | public void lastInSection() { 113 | 114 | } 115 | 116 | protected void setDividerView(View dividerView) { 117 | mDividerView = dividerView; 118 | } 119 | 120 | // ===== Colors =========== 121 | 122 | /** 123 | * Set the style ID for the specified 'styleConfig' parameter if defined in CellDescriptor, 124 | * or apply the default Style Id and the default android:textColor. 125 | */ 126 | protected boolean setStyleId(final TextView textView, final String styleConfig, final String colorConfig) //, final @StyleRes int defaultStyleId 127 | { 128 | boolean styleFound = false; 129 | 130 | // Get textAppearance from the cellConfig (APPEARANCE_XXX) in FormItemDescriptor 131 | 132 | HashMap cellConfig = null; 133 | FormItemDescriptor itemDescriptor = getFormItemDescriptor(); 134 | if (itemDescriptor != null) 135 | { 136 | cellConfig = itemDescriptor.getCellConfig(); 137 | if (cellConfig != null && cellConfig.containsKey(styleConfig)) 138 | { 139 | Object configId = cellConfig.get(styleConfig); 140 | if (configId instanceof Integer) 141 | { 142 | // Apply style if exists 143 | 144 | @StyleRes int styleId = ((Integer) configId).intValue(); 145 | setTextAppearance(textView, styleId); 146 | 147 | styleFound = true; 148 | } 149 | } 150 | } 151 | 152 | // If defined, default color is set from cellConfig 'COLOR_XXX' parameter. 153 | // Otherwise, save the default android color (before applying style). 154 | 155 | int defaultColor; 156 | if (cellConfig != null && colorConfig != null && cellConfig.containsKey(colorConfig)) 157 | { 158 | Object configId = cellConfig.get(colorConfig); 159 | if (configId instanceof Integer) 160 | defaultColor = ((Integer) configId).intValue(); 161 | else 162 | defaultColor = getDefaultColor(colorConfig); 163 | } 164 | else 165 | defaultColor = getDefaultColor(colorConfig); 166 | 167 | textView.setTextColor(defaultColor); 168 | 169 | return styleFound; 170 | } 171 | 172 | @SuppressWarnings("deprecation") 173 | private void setTextAppearance(final TextView textView, final int styleId) 174 | { 175 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) 176 | textView.setTextAppearance(styleId); 177 | else 178 | textView.setTextAppearance(textView.getContext(), styleId); 179 | } 180 | 181 | /** 182 | * Get the default color for TextView (android:textColor in theme). 183 | * Note that default EditText color is android:editTextColor in theme. 184 | * Force to default TextView color for CheckBox and Switch views. 185 | */ 186 | private int getDefaultColor(final String colorConfig) 187 | { 188 | if (colorConfig != null && colorConfig.equals(CellDescriptor.COLOR_VALUE)) 189 | { 190 | return getThemeValue(android.R.attr.editTextColor); 191 | } 192 | return getThemeValue(android.R.attr.textColor); 193 | } 194 | 195 | /** 196 | * Set the TextView color from the cellConfig using 'colorConfig' parameter, if defined in CellDescriptor. 197 | * Only used for COLOR_XXX_DISABLED colors. 198 | */ 199 | protected void setTextColor(final TextView textView, final String colorConfig) 200 | { 201 | // Get color from the cellConfig in FormItemDescriptor 202 | 203 | FormItemDescriptor itemDescriptor = getFormItemDescriptor(); 204 | if (itemDescriptor != null) 205 | { 206 | HashMap config = itemDescriptor.getCellConfig(); 207 | if (config != null && config.containsKey(colorConfig)) 208 | { 209 | Object configColor = config.get(colorConfig); 210 | if (configColor instanceof Integer) 211 | { 212 | textView.setTextColor(((Integer) configColor).intValue()); 213 | } 214 | } 215 | } 216 | } 217 | } 218 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/java/com/quemb/qmbform/view/FormBaseCell.java: -------------------------------------------------------------------------------- 1 | package com.quemb.qmbform.view; 2 | 3 | import com.quemb.qmbform.R; 4 | import com.quemb.qmbform.descriptor.OnFormRowValueChangedListener; 5 | import com.quemb.qmbform.descriptor.OnValueChangeListener; 6 | import com.quemb.qmbform.descriptor.RowDescriptor; 7 | import com.quemb.qmbform.descriptor.SectionDescriptor; 8 | import com.quemb.qmbform.descriptor.Value; 9 | 10 | import android.content.Context; 11 | import android.graphics.Color; 12 | import android.graphics.PorterDuff; 13 | import android.graphics.drawable.Drawable; 14 | import android.support.v7.widget.AppCompatDrawableManager; 15 | import android.view.View; 16 | import android.view.ViewGroup; 17 | import android.widget.ImageButton; 18 | import android.widget.LinearLayout; 19 | 20 | /** 21 | * Created by tonimoeckel on 14.07.14. 22 | */ 23 | public abstract class FormBaseCell extends Cell { 24 | 25 | 26 | private static final int REMOVE_BUTTON_ID = R.id.end; 27 | private static final int ADD_BUTTON_ID = R.id.beginning; 28 | 29 | 30 | private LinearLayout mMultiValueWrapper; 31 | 32 | public FormBaseCell(Context context, RowDescriptor rowDescriptor) { 33 | 34 | super(context, rowDescriptor); 35 | 36 | } 37 | 38 | @Override 39 | protected void init() { 40 | super.init(); 41 | 42 | if (getRowDescriptor() != null && getRowDescriptor().getValue() != null) { 43 | getRowDescriptor().getValue().setOnValueChangeListener(new OnValueChangeListener() { 44 | @Override 45 | public void onChange(Object value) { 46 | update(); 47 | } 48 | }); 49 | } 50 | 51 | 52 | } 53 | 54 | protected ViewGroup getSuperViewForLayoutInflation() { 55 | 56 | if (getRowDescriptor().getSectionDescriptor() != null && this.getRowDescriptor().getSectionDescriptor().isMultivalueSection()) { 57 | LinearLayout linearLayout = createMultiValueWrapper(); 58 | addView(linearLayout); 59 | return linearLayout; 60 | } 61 | return super.getSuperViewForLayoutInflation(); 62 | } 63 | 64 | protected LinearLayout createMultiValueWrapper() { 65 | 66 | LinearLayout linearLayout = new LinearLayout(getContext()); 67 | linearLayout.setOrientation(LinearLayout.HORIZONTAL); 68 | linearLayout.setId(R.id.wrap_content); 69 | linearLayout.setFocusable(false); 70 | linearLayout.setFocusableInTouchMode(false); 71 | 72 | ImageButton deleteButton = new ImageButton(getContext()); 73 | deleteButton.setId(REMOVE_BUTTON_ID); 74 | deleteButton.setFocusableInTouchMode(false); 75 | deleteButton.setFocusable(false); 76 | 77 | Drawable removeIcon = AppCompatDrawableManager.get().getDrawable(getContext(), R.drawable.ic_action_remove); 78 | removeIcon.setColorFilter(0xffff0000, PorterDuff.Mode.MULTIPLY); 79 | 80 | deleteButton.setImageDrawable(removeIcon); 81 | deleteButton.setBackgroundColor(Color.TRANSPARENT); 82 | deleteButton.setVisibility(VISIBLE); 83 | deleteButton.setOnClickListener(new OnClickListener() { 84 | @Override 85 | public void onClick(View v) { 86 | 87 | RowDescriptor rowDescriptor = getRowDescriptor(); 88 | 89 | SectionDescriptor sectionDescriptor = rowDescriptor.getSectionDescriptor(); 90 | sectionDescriptor.removeRow(rowDescriptor); 91 | sectionDescriptor.getFormDescriptor().getOnFormRowValueChangedListener().onValueChanged(rowDescriptor, rowDescriptor.getValue(), null); 92 | 93 | } 94 | }); 95 | linearLayout.addView(deleteButton); 96 | 97 | ImageButton addButton = new ImageButton(getContext()); 98 | addButton.setId(ADD_BUTTON_ID); 99 | addButton.setFocusableInTouchMode(false); 100 | addButton.setFocusable(false); 101 | 102 | Drawable addIcon = AppCompatDrawableManager.get().getDrawable(getContext(), R.drawable.ic_action_new); 103 | addIcon.setColorFilter(0xff00ff00, PorterDuff.Mode.MULTIPLY); 104 | 105 | 106 | addButton.setImageDrawable(addIcon); 107 | addButton.setBackgroundColor(Color.TRANSPARENT); 108 | addButton.setVisibility(GONE); 109 | addButton.setOnClickListener(new OnClickListener() { 110 | @Override 111 | public void onClick(View v) { 112 | 113 | SectionDescriptor sectionDescriptor = getRowDescriptor().getSectionDescriptor(); 114 | sectionDescriptor.addRow(RowDescriptor.newInstance(getRowDescriptor())); 115 | 116 | } 117 | }); 118 | linearLayout.addView(addButton); 119 | 120 | SectionDescriptor sectionDescriptor = getRowDescriptor().getSectionDescriptor(); 121 | int index = sectionDescriptor.getIndexOfRowDescriptor(getRowDescriptor()); 122 | if (index == sectionDescriptor.getRowCount() - 1) { 123 | addButton.setVisibility(VISIBLE); 124 | deleteButton.setVisibility(GONE); 125 | } else { 126 | addButton.setVisibility(GONE); 127 | deleteButton.setVisibility(VISIBLE); 128 | } 129 | 130 | mMultiValueWrapper = linearLayout; 131 | 132 | return mMultiValueWrapper; 133 | } 134 | 135 | @Override 136 | public boolean shouldAddDivider() { 137 | 138 | RowDescriptor rowDescriptor = (RowDescriptor) getFormItemDescriptor(); 139 | if (rowDescriptor.isLastRowInSection()) 140 | return false; 141 | 142 | return super.shouldAddDivider(); 143 | } 144 | 145 | @Override 146 | public void lastInSection() { 147 | 148 | 149 | } 150 | 151 | public RowDescriptor getRowDescriptor() { 152 | return (RowDescriptor) getFormItemDescriptor(); 153 | } 154 | 155 | public void onValueChanged(Value newValue) { 156 | RowDescriptor row = getRowDescriptor(); 157 | Value oldValue = row.getValue(); 158 | if (oldValue == null || newValue == null || !newValue.getValue().equals(oldValue.getValue())) { 159 | OnFormRowValueChangedListener listener = getRowDescriptor().getSectionDescriptor().getFormDescriptor().getOnFormRowValueChangedListener(); 160 | row.setValue(newValue); 161 | if (listener != null) { 162 | listener.onValueChanged(row, oldValue, newValue); 163 | } 164 | } 165 | 166 | } 167 | 168 | 169 | } 170 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/java/com/quemb/qmbform/view/FormBooleanFieldCell.java: -------------------------------------------------------------------------------- 1 | package com.quemb.qmbform.view; 2 | 3 | import com.quemb.qmbform.R; 4 | import com.quemb.qmbform.descriptor.CellDescriptor; 5 | import com.quemb.qmbform.descriptor.RowDescriptor; 6 | import com.quemb.qmbform.descriptor.Value; 7 | 8 | import android.annotation.TargetApi; 9 | import android.content.Context; 10 | import android.os.Build; 11 | import android.widget.CompoundButton; 12 | import android.widget.Switch; 13 | 14 | /** 15 | * Created by tonimoeckel on 15.07.14. 16 | */ 17 | public class FormBooleanFieldCell extends FormBaseCell { 18 | 19 | private Switch mSwitch; 20 | 21 | public FormBooleanFieldCell(Context context, 22 | RowDescriptor rowDescriptor) { 23 | super(context, rowDescriptor); 24 | } 25 | 26 | @Override 27 | protected void init() { 28 | 29 | super.init(); 30 | 31 | mSwitch = (Switch) findViewById(R.id.switchControl); 32 | setStyleId(mSwitch, CellDescriptor.APPEARANCE_TEXT_LABEL, CellDescriptor.COLOR_LABEL); 33 | 34 | mSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { 35 | @Override 36 | public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { 37 | onValueChanged(new Value(isChecked)); 38 | } 39 | }); 40 | 41 | } 42 | 43 | @Override 44 | protected int getResource() { 45 | return R.layout.boolean_field_cell; 46 | } 47 | 48 | @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) 49 | @Override 50 | protected void update() { 51 | 52 | String title = getFormItemDescriptor().getTitle(); 53 | 54 | mSwitch.setText(title); 55 | if (getRowDescriptor().getDisabled()) 56 | { 57 | mSwitch.setEnabled(false); 58 | setTextColor(mSwitch, CellDescriptor.COLOR_LABEL_DISABLED); 59 | } 60 | else 61 | mSwitch.setEnabled(true); 62 | 63 | @SuppressWarnings("unchecked") Value value = (Value) getRowDescriptor().getValue(); 64 | if (value != null && value.getValue() != null) { 65 | mSwitch.setChecked(value.getValue()); 66 | } 67 | 68 | } 69 | 70 | public Switch getSwitch() { 71 | return mSwitch; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/java/com/quemb/qmbform/view/FormButtonFieldCell.java: -------------------------------------------------------------------------------- 1 | package com.quemb.qmbform.view; 2 | 3 | import com.quemb.qmbform.R; 4 | import com.quemb.qmbform.descriptor.CellDescriptor; 5 | import com.quemb.qmbform.descriptor.RowDescriptor; 6 | 7 | import android.content.Context; 8 | import android.widget.TextView; 9 | 10 | /** 11 | * Created by tonimoeckel on 15.07.14. 12 | */ 13 | public class FormButtonFieldCell extends FormTitleFieldCell { 14 | 15 | 16 | public FormButtonFieldCell(Context context, 17 | RowDescriptor rowDescriptor) { 18 | super(context, rowDescriptor); 19 | } 20 | 21 | 22 | @Override 23 | protected int getResource() { 24 | return R.layout.button_field_cell; 25 | } 26 | 27 | @Override 28 | protected void update() { 29 | super.update(); 30 | 31 | TextView textView = getTextView(); 32 | setStyleId(getTextView(), CellDescriptor.APPEARANCE_BUTTON, CellDescriptor.COLOR_VALUE); 33 | 34 | if (getRowDescriptor().getDisabled()) 35 | { 36 | setTextColor(textView, CellDescriptor.COLOR_VALUE_DISABLED); 37 | textView.setClickable(false); 38 | textView.setEnabled(false); 39 | 40 | setClickable(false); 41 | setEnabled(false); 42 | } 43 | } 44 | 45 | @Override 46 | public void onCellSelected() { 47 | super.onCellSelected(); 48 | 49 | 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/java/com/quemb/qmbform/view/FormButtonInlineFieldCell.java: -------------------------------------------------------------------------------- 1 | package com.quemb.qmbform.view; 2 | 3 | 4 | import com.quemb.qmbform.R; 5 | import com.quemb.qmbform.descriptor.RowDescriptor; 6 | 7 | import android.content.Context; 8 | 9 | /** 10 | * Created by pmaccamp on 8/28/2015. 11 | */ 12 | public class FormButtonInlineFieldCell extends FormButtonFieldCell { 13 | 14 | 15 | public FormButtonInlineFieldCell(Context context, 16 | RowDescriptor rowDescriptor) { 17 | super(context, rowDescriptor); 18 | } 19 | 20 | @Override 21 | protected int getResource() { 22 | return R.layout.button_inline_field_cell; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/java/com/quemb/qmbform/view/FormCheckFieldCell.java: -------------------------------------------------------------------------------- 1 | package com.quemb.qmbform.view; 2 | 3 | import com.quemb.qmbform.R; 4 | import com.quemb.qmbform.descriptor.CellDescriptor; 5 | import com.quemb.qmbform.descriptor.RowDescriptor; 6 | import com.quemb.qmbform.descriptor.Value; 7 | 8 | import android.content.Context; 9 | import android.widget.CheckBox; 10 | import android.widget.CompoundButton; 11 | 12 | /** 13 | * Created by tonimoeckel on 15.07.14. 14 | */ 15 | public class FormCheckFieldCell extends FormBaseCell { 16 | 17 | private CheckBox mCheckBox; 18 | 19 | public FormCheckFieldCell(Context context, 20 | RowDescriptor rowDescriptor) { 21 | super(context, rowDescriptor); 22 | } 23 | 24 | @Override 25 | protected void init() { 26 | 27 | super.init(); 28 | 29 | mCheckBox = (CheckBox) findViewById(R.id.checkBox); 30 | setStyleId(mCheckBox, CellDescriptor.APPEARANCE_TEXT_LABEL, CellDescriptor.COLOR_LABEL); 31 | 32 | mCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { 33 | @Override 34 | public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { 35 | onValueChanged(new Value(isChecked)); 36 | } 37 | }); 38 | 39 | } 40 | 41 | @Override 42 | protected int getResource() { 43 | return R.layout.check_field_cell; 44 | } 45 | 46 | @Override 47 | protected void update() { 48 | 49 | String title = getFormItemDescriptor().getTitle(); 50 | 51 | mCheckBox.setText(title); 52 | if (getRowDescriptor().getDisabled()) 53 | { 54 | mCheckBox.setEnabled(false); 55 | setTextColor(mCheckBox, CellDescriptor.COLOR_LABEL_DISABLED); 56 | } 57 | else 58 | mCheckBox.setEnabled(true); 59 | 60 | @SuppressWarnings("unchecked") Value value = (Value) getRowDescriptor().getValue(); 61 | if (value != null) { 62 | mCheckBox.setChecked(value.getValue()); 63 | } 64 | 65 | } 66 | 67 | public CheckBox getCheckBox() { 68 | return mCheckBox; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/java/com/quemb/qmbform/view/FormDateDialogFieldCell.java: -------------------------------------------------------------------------------- 1 | package com.quemb.qmbform.view; 2 | 3 | import com.quemb.qmbform.R; 4 | import com.quemb.qmbform.descriptor.RowDescriptor; 5 | 6 | import android.app.DatePickerDialog; 7 | import android.content.Context; 8 | import android.widget.DatePicker; 9 | 10 | import java.util.Calendar; 11 | import java.util.Date; 12 | 13 | /** 14 | * Created by tonimoeckel on 15.07.14. 15 | */ 16 | public class FormDateDialogFieldCell extends FormDateFieldCell implements 17 | DatePickerDialog.OnDateSetListener { 18 | 19 | private Calendar mCalendar; 20 | 21 | public FormDateDialogFieldCell(Context context, 22 | RowDescriptor rowDescriptor) { 23 | super(context, rowDescriptor); 24 | } 25 | 26 | 27 | @Override 28 | protected int getResource() { 29 | return R.layout.date_field_cell; 30 | } 31 | 32 | 33 | @Override 34 | protected void initDatePicker(Calendar calendar) { 35 | 36 | mCalendar = calendar; 37 | } 38 | 39 | @Override 40 | public void onCellSelected() { 41 | super.onCellSelected(); 42 | 43 | DatePickerDialog datePickerDialog = new DatePickerDialog(getContext(), this, mCalendar.get(Calendar.YEAR), mCalendar.get(Calendar.MONTH), mCalendar.get(Calendar.DAY_OF_MONTH)); 44 | datePickerDialog.show(); 45 | 46 | } 47 | 48 | @Override 49 | public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { 50 | 51 | Calendar calendar = Calendar.getInstance(); 52 | calendar.set(year, monthOfYear, dayOfMonth); 53 | Date date = new Date(calendar.getTimeInMillis()); 54 | 55 | onDateChanged(date); 56 | 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/java/com/quemb/qmbform/view/FormDateFieldCell.java: -------------------------------------------------------------------------------- 1 | package com.quemb.qmbform.view; 2 | 3 | import com.quemb.qmbform.R; 4 | import com.quemb.qmbform.descriptor.CellDescriptor; 5 | import com.quemb.qmbform.descriptor.RowDescriptor; 6 | import com.quemb.qmbform.descriptor.Value; 7 | 8 | import android.content.Context; 9 | import android.widget.TextView; 10 | 11 | import java.text.DateFormat; 12 | import java.util.Calendar; 13 | import java.util.Date; 14 | 15 | /** 16 | * Created by tonimoeckel on 15.07.14. 17 | */ 18 | public class FormDateFieldCell extends FormDetailTextInlineFieldCell { 19 | 20 | private TextView mTextView; 21 | 22 | public FormDateFieldCell(Context context, 23 | RowDescriptor rowDescriptor) { 24 | super(context, rowDescriptor); 25 | } 26 | 27 | @Override 28 | protected void init() { 29 | 30 | super.init(); 31 | mTextView = (TextView) findViewById(R.id.textView); 32 | 33 | setStyleId(mTextView, CellDescriptor.APPEARANCE_TEXT_LABEL, CellDescriptor.COLOR_LABEL); 34 | 35 | } 36 | 37 | @Override 38 | protected int getResource() { 39 | return R.layout.date_field_cell; 40 | } 41 | 42 | @Override 43 | protected void update() { 44 | 45 | String title = getFormItemDescriptor().getTitle(); 46 | mTextView.setText(title); 47 | mTextView.setVisibility(title == null ? GONE : VISIBLE); 48 | mTextView.setEnabled(!getRowDescriptor().getDisabled()); 49 | 50 | @SuppressWarnings("unchecked") Value value = (Value) getRowDescriptor().getValue(); 51 | if (value == null || value.getValue() == null) { 52 | value = new Value(new Date()); 53 | } else { 54 | updateDateLabel(value.getValue(), getRowDescriptor().getDisabled()); 55 | } 56 | 57 | final Calendar calendar = Calendar.getInstance(); 58 | Date date = value.getValue(); 59 | calendar.setTime(date); 60 | 61 | initDatePicker(calendar); 62 | 63 | if (getRowDescriptor().getDisabled()) 64 | { 65 | setTextColor(mTextView, CellDescriptor.COLOR_LABEL_DISABLED); 66 | 67 | setClickable(false); 68 | setEnabled(false); 69 | } 70 | 71 | } 72 | 73 | protected void initDatePicker(Calendar calendar) { 74 | 75 | } 76 | 77 | public void onDateChanged(Date date) { 78 | 79 | // Calendar calendar = Calendar.getInstance(); 80 | // calendar.set(year, monthOfYear, dayOfMonth); 81 | // Date date = new Date(calendar.getTimeInMillis()); 82 | 83 | updateDateLabel(date, getRowDescriptor().getDisabled()); 84 | 85 | onValueChanged(new Value(date)); 86 | 87 | } 88 | 89 | protected void updateDateLabel(Date date, boolean disabled) { 90 | 91 | DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(getContext()); 92 | String s = dateFormat.format(date); 93 | 94 | TextView editView = getDetailTextView(); 95 | editView.setText(s); 96 | 97 | if (disabled) 98 | { 99 | editView.setEnabled(false); 100 | setTextColor(editView, CellDescriptor.COLOR_VALUE_DISABLED); 101 | } 102 | 103 | } 104 | 105 | @Override 106 | public void onCellSelected() { 107 | super.onCellSelected(); 108 | 109 | 110 | } 111 | 112 | public TextView getTextView() { 113 | return mTextView; 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/java/com/quemb/qmbform/view/FormDateInlineFieldCell.java: -------------------------------------------------------------------------------- 1 | package com.quemb.qmbform.view; 2 | 3 | import com.quemb.qmbform.R; 4 | import com.quemb.qmbform.descriptor.RowDescriptor; 5 | 6 | import android.content.Context; 7 | import android.widget.DatePicker; 8 | 9 | import java.util.Calendar; 10 | import java.util.Date; 11 | 12 | /** 13 | * Created by pmaccamp on 9/4/2015. 14 | */ 15 | public class FormDateInlineFieldCell extends FormDateFieldCell implements 16 | DatePicker.OnDateChangedListener { 17 | 18 | private DatePicker mDatePicker; 19 | 20 | public FormDateInlineFieldCell(Context context, 21 | RowDescriptor rowDescriptor) { 22 | super(context, rowDescriptor); 23 | } 24 | 25 | @Override 26 | protected void init() { 27 | 28 | super.init(); 29 | mDatePicker = (DatePicker) findViewById(R.id.datePicker); 30 | 31 | 32 | } 33 | 34 | @Override 35 | protected int getResource() { 36 | return R.layout.date_inline_field_cell; 37 | } 38 | 39 | 40 | @Override 41 | protected void initDatePicker(Calendar calendar) { 42 | mDatePicker.init(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH), this); 43 | } 44 | 45 | @Override 46 | public void onDateChanged(DatePicker view, int year, int monthOfYear, int dayOfMonth) { 47 | 48 | Calendar calendar = Calendar.getInstance(); 49 | calendar.set(year, monthOfYear, dayOfMonth); 50 | Date date = new Date(calendar.getTimeInMillis()); 51 | 52 | onDateChanged(date); 53 | 54 | } 55 | 56 | @Override 57 | public void onCellSelected() { 58 | super.onCellSelected(); 59 | 60 | mDatePicker.setVisibility(mDatePicker.getVisibility() == VISIBLE ? GONE : VISIBLE); 61 | // ensureVisible(); 62 | } 63 | 64 | // public void ensureVisible() 65 | // { 66 | // ListView listView = (ListView) getParent(); 67 | // int lastSelectedIndex = listView.getSelectedItemPosition(); 68 | // listView.setSelection(lastSelectedIndex); 69 | // 70 | // } 71 | } 72 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/java/com/quemb/qmbform/view/FormDetailHtmlTextVerticalFieldCell.java: -------------------------------------------------------------------------------- 1 | package com.quemb.qmbform.view; 2 | 3 | import com.quemb.qmbform.R; 4 | import com.quemb.qmbform.descriptor.RowDescriptor; 5 | import com.quemb.qmbform.descriptor.Value; 6 | 7 | import android.content.Context; 8 | 9 | /** 10 | * Created by schmidtma on 19.02.15. 11 | */ 12 | public class FormDetailHtmlTextVerticalFieldCell extends FormDetailTextFieldCell { 13 | 14 | public FormDetailHtmlTextVerticalFieldCell(Context context, 15 | RowDescriptor rowDescriptor) { 16 | super(context, rowDescriptor); 17 | } 18 | 19 | @Override 20 | protected void update() { 21 | 22 | super.update(); 23 | 24 | if (getRowDescriptor().getHint(getContext()) != null) { 25 | getDetailTextView().setHint(getRowDescriptor().getHint(getContext())); 26 | } 27 | 28 | Value value = getRowDescriptor().getValue(); 29 | if (value != null && value.getValue() != null) { 30 | if (value.getValue() instanceof Integer) { 31 | getDetailTextView().setText(String.valueOf(value.getValue())); 32 | } else { 33 | getDetailTextView().setText((CharSequence) value.getValue()); 34 | } 35 | } 36 | } 37 | 38 | @Override 39 | protected int getResource() { 40 | return R.layout.detail_html_text_vertical_field_cell; 41 | } 42 | } -------------------------------------------------------------------------------- /lib/QMBForm/src/main/java/com/quemb/qmbform/view/FormDetailTextFieldCell.java: -------------------------------------------------------------------------------- 1 | package com.quemb.qmbform.view; 2 | 3 | import com.quemb.qmbform.R; 4 | import com.quemb.qmbform.descriptor.CellDescriptor; 5 | import com.quemb.qmbform.descriptor.RowDescriptor; 6 | 7 | import android.content.Context; 8 | 9 | /** 10 | * Created by tonimoeckel on 15.07.14. 11 | */ 12 | public class FormDetailTextFieldCell extends FormDetailTextInlineFieldCell { 13 | 14 | public FormDetailTextFieldCell(Context context, 15 | RowDescriptor rowDescriptor) { 16 | super(context, rowDescriptor); 17 | } 18 | 19 | @Override 20 | protected int getResource() { 21 | return R.layout.detail_text_field_cell; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/java/com/quemb/qmbform/view/FormDetailTextInlineFieldCell.java: -------------------------------------------------------------------------------- 1 | package com.quemb.qmbform.view; 2 | 3 | import com.quemb.qmbform.R; 4 | import com.quemb.qmbform.descriptor.CellDescriptor; 5 | import com.quemb.qmbform.descriptor.RowDescriptor; 6 | import com.quemb.qmbform.descriptor.Value; 7 | 8 | import android.content.Context; 9 | import android.content.res.TypedArray; 10 | import android.util.DisplayMetrics; 11 | import android.util.TypedValue; 12 | import android.widget.TextView; 13 | 14 | /** 15 | * Created by pmaccamp on 9/4/2015. 16 | */ 17 | public class FormDetailTextInlineFieldCell extends FormTitleFieldCell { 18 | 19 | private TextView mDetailTextView; 20 | 21 | public FormDetailTextInlineFieldCell(Context context, 22 | RowDescriptor rowDescriptor) { 23 | super(context, rowDescriptor); 24 | } 25 | 26 | @Override 27 | protected void init() { 28 | 29 | super.init(); 30 | mDetailTextView = (TextView) findViewById(R.id.detailTextView); 31 | if (setStyleId(mDetailTextView, CellDescriptor.APPEARANCE_TEXT_VALUE, CellDescriptor.COLOR_VALUE) == false) 32 | { 33 | // If no specific style is defined for APPEARANCE_TEXT_VALUE, 34 | // set inline text size to the default EditText size. 35 | 36 | // Get the android:textAppearance item from R.style.Widget_AppCompat_EditText (default EditText style) 37 | int editTextAppearanceId = getStyleItemResourceId(mDetailTextView.getContext(), 38 | R.style.Widget_AppCompat_EditText, android.R.attr.textAppearance, android.R.attr.textAppearanceMediumInverse); 39 | 40 | // Get the android:textSize item from retrieved textAppearance style 41 | DisplayMetrics displayMetrics = mDetailTextView.getContext().getResources().getDisplayMetrics(); 42 | float editSize = getStyleItemDimension(mDetailTextView.getContext(), 43 | editTextAppearanceId, android.R.attr.textSize, 18f * (displayMetrics.densityDpi / 160f)); 44 | 45 | // Set inline text size 46 | mDetailTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, editSize); 47 | } 48 | } 49 | 50 | @Override 51 | protected int getResource() { 52 | return R.layout.detail_text_inline_field_cell; 53 | } 54 | 55 | @Override 56 | protected void update() { 57 | super.update(); 58 | 59 | if (getRowDescriptor().getHint(getContext()) != null) { 60 | getDetailTextView().setHint(getRowDescriptor().getHint(getContext())); 61 | } 62 | 63 | Value value = getRowDescriptor().getValue(); 64 | if (value != null && value.getValue() != null) { 65 | if (value.getValue() instanceof String) { 66 | getDetailTextView().setText((String) value.getValue()); 67 | } else { 68 | getDetailTextView().setText(String.valueOf(value.getValue())); 69 | 70 | } 71 | } 72 | 73 | } 74 | 75 | public TextView getDetailTextView() { 76 | return mDetailTextView; 77 | } 78 | 79 | /** 80 | * Get a item defined as resource ID from an android style 81 | */ 82 | private int getStyleItemResourceId(final Context context, final int styleId, final int attributeId, final int defValue) 83 | { 84 | // attribute to retrieve 85 | int[] attrs = {attributeId}; // {android.R.attr.textColor, android.R.attr.text}; 86 | 87 | // Parse the style, using Context.obtainStyledAttributes() 88 | TypedArray ta = context.obtainStyledAttributes(styleId, attrs); 89 | 90 | // Fetch the resource, color or text defined in your style 91 | int styleItem = ta.getResourceId(0, defValue); // android.R.attr.textAppearanceMediumInverse); 92 | //int textColor = ta.getColor(1, Color.BLACK); 93 | //String text = ta.getString(2); 94 | 95 | // Recycle the TypedArray 96 | ta.recycle(); 97 | 98 | return styleItem; 99 | } 100 | 101 | /** 102 | * Get a item defined as dimension from an android style 103 | */ 104 | private float getStyleItemDimension(final Context context, final int styleId, final int attributeId, final float defValue) 105 | { 106 | // attribute to retrieve 107 | int[] attrs = {attributeId}; 108 | 109 | // Parse the style, using Context.obtainStyledAttributes() 110 | TypedArray ta = context.obtainStyledAttributes(styleId, attrs); 111 | 112 | // Fetch the text from your style like this. 113 | float dimensionItem = ta.getDimension(0, defValue); 114 | 115 | // Recycle the TypedArray 116 | ta.recycle(); 117 | 118 | return dimensionItem; 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/java/com/quemb/qmbform/view/FormDetailTextVerticalFieldCell.java: -------------------------------------------------------------------------------- 1 | package com.quemb.qmbform.view; 2 | 3 | import com.quemb.qmbform.R; 4 | import com.quemb.qmbform.descriptor.RowDescriptor; 5 | 6 | import android.content.Context; 7 | 8 | /** 9 | * Created by tonimoeckel on 15.07.14. 10 | */ 11 | public class FormDetailTextVerticalFieldCell extends FormDetailTextFieldCell { 12 | 13 | public FormDetailTextVerticalFieldCell(Context context, 14 | RowDescriptor rowDescriptor) { 15 | super(context, rowDescriptor); 16 | } 17 | 18 | @Override 19 | protected int getResource() { 20 | return R.layout.detail_text_vertical_field_cell; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/java/com/quemb/qmbform/view/FormEditCurrencyFieldCell.java: -------------------------------------------------------------------------------- 1 | package com.quemb.qmbform.view; 2 | 3 | import com.quemb.qmbform.descriptor.RowDescriptor; 4 | import com.quemb.qmbform.descriptor.Value; 5 | 6 | import android.content.Context; 7 | import android.util.Log; 8 | 9 | import java.text.NumberFormat; 10 | import java.text.ParseException; 11 | 12 | /** 13 | * Created by tonimoeckel on 15.07.14. 14 | */ 15 | public class FormEditCurrencyFieldCell extends FormEditNumberFieldCell { 16 | 17 | private static final String TAG = "FormEditCurrencyFieldCell"; 18 | 19 | public FormEditCurrencyFieldCell(Context context, 20 | RowDescriptor rowDescriptor) { 21 | super(context, rowDescriptor); 22 | } 23 | 24 | 25 | @Override 26 | protected void updateEditView() { 27 | 28 | @SuppressWarnings("unchecked") Value value = (Value) getRowDescriptor().getValue(); 29 | if (value != null && value.getValue() != null) { 30 | NumberFormat format = NumberFormat.getCurrencyInstance(); 31 | String valueString = format.format(value.getValue());//String.valueOf(value.getValue()); 32 | getEditView().setText(valueString); 33 | } 34 | 35 | } 36 | 37 | 38 | protected void onEditTextChanged(String string) { 39 | 40 | try { 41 | NumberFormat format = NumberFormat.getCurrencyInstance(); 42 | Number floatValue = (Number) format.parse(string); 43 | onValueChanged(new Value(floatValue)); 44 | } catch (NumberFormatException e) { 45 | Log.e(TAG, e.getMessage(), e); 46 | } catch (ParseException e) { 47 | Log.e(TAG, e.getMessage(), e); 48 | } catch (ClassCastException e) { 49 | Log.e(TAG, e.getMessage(), e); 50 | } 51 | 52 | 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/java/com/quemb/qmbform/view/FormEditEmailFieldCell.java: -------------------------------------------------------------------------------- 1 | package com.quemb.qmbform.view; 2 | 3 | import com.quemb.qmbform.descriptor.RowDescriptor; 4 | 5 | import android.content.Context; 6 | import android.text.InputType; 7 | import android.widget.EditText; 8 | 9 | /** 10 | * Created by tonimoeckel on 15.07.14. 11 | */ 12 | public class FormEditEmailFieldCell extends FormEditTextFieldCell { 13 | 14 | public FormEditEmailFieldCell(Context context, 15 | RowDescriptor rowDescriptor) { 16 | super(context, rowDescriptor); 17 | } 18 | 19 | 20 | @Override 21 | protected void init() { 22 | super.init(); 23 | 24 | EditText editView = getEditView(); 25 | editView.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS); 26 | } 27 | 28 | 29 | } 30 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/java/com/quemb/qmbform/view/FormEditEmailInlineFieldCell.java: -------------------------------------------------------------------------------- 1 | package com.quemb.qmbform.view; 2 | 3 | 4 | import com.quemb.qmbform.R; 5 | import com.quemb.qmbform.descriptor.RowDescriptor; 6 | 7 | import android.content.Context; 8 | 9 | /** 10 | * Created by pmaccamp on 8/28/2015. 11 | */ 12 | public class FormEditEmailInlineFieldCell extends FormEditEmailFieldCell { 13 | 14 | public FormEditEmailInlineFieldCell(Context context, 15 | RowDescriptor rowDescriptor) { 16 | super(context, rowDescriptor); 17 | } 18 | 19 | @Override 20 | protected int getResource() { 21 | return R.layout.edit_text_inline_field_cell; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/java/com/quemb/qmbform/view/FormEditHTMLTextViewFieldCell.java: -------------------------------------------------------------------------------- 1 | package com.quemb.qmbform.view; 2 | 3 | import com.quemb.qmbform.descriptor.RowDescriptor; 4 | import com.quemb.qmbform.descriptor.Value; 5 | 6 | import android.content.Context; 7 | import android.text.Html; 8 | 9 | /** 10 | * Created by tonimoeckel on 15.07.14. 11 | */ 12 | public class FormEditHTMLTextViewFieldCell extends FormEditTextViewFieldCell { 13 | 14 | public FormEditHTMLTextViewFieldCell(Context context, 15 | RowDescriptor rowDescriptor) { 16 | super(context, rowDescriptor); 17 | } 18 | 19 | protected void updateEditView() { 20 | 21 | @SuppressWarnings("unchecked") Value value = (Value) getRowDescriptor().getValue(); 22 | if (value != null && value.getValue() != null) { 23 | String valueString = value.getValue(); 24 | if (valueString != null) { 25 | valueString = Html.fromHtml(valueString).toString(); 26 | } 27 | getEditView().setText(valueString); 28 | } 29 | 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/java/com/quemb/qmbform/view/FormEditIntegerFieldCell.java: -------------------------------------------------------------------------------- 1 | package com.quemb.qmbform.view; 2 | 3 | import com.quemb.qmbform.descriptor.RowDescriptor; 4 | import com.quemb.qmbform.descriptor.Value; 5 | 6 | import android.content.Context; 7 | import android.text.InputType; 8 | import android.util.Log; 9 | import android.widget.EditText; 10 | 11 | /** 12 | * Created by tonimoeckel on 15.07.14. 13 | */ 14 | public class FormEditIntegerFieldCell extends FormEditTextFieldCell { 15 | 16 | private static final String TAG = "FormEditIntegerCell"; 17 | 18 | private EditText mEditView; 19 | 20 | public FormEditIntegerFieldCell(Context context, 21 | RowDescriptor rowDescriptor) { 22 | super(context, rowDescriptor); 23 | } 24 | 25 | 26 | @Override 27 | protected void init() { 28 | super.init(); 29 | 30 | mEditView = getEditView(); 31 | mEditView.setInputType(InputType.TYPE_CLASS_NUMBER); 32 | } 33 | 34 | 35 | @Override 36 | protected void updateEditView() { 37 | 38 | @SuppressWarnings("unchecked") Value value = (Value) getRowDescriptor().getValue(); 39 | if (value != null) { 40 | String valueString = String.valueOf(value.getValue()); 41 | getEditView().setText(valueString); 42 | } 43 | 44 | } 45 | 46 | 47 | protected void onEditTextChanged(String string) { 48 | 49 | try { 50 | Integer value = Integer.parseInt(string); 51 | onValueChanged(new Value(value)); 52 | } catch (NumberFormatException e) { 53 | Log.e(TAG, e.getMessage(), e); 54 | } 55 | 56 | } 57 | 58 | public EditText getEditText() { 59 | return mEditView; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/java/com/quemb/qmbform/view/FormEditIntegerInlineFieldCell.java: -------------------------------------------------------------------------------- 1 | package com.quemb.qmbform.view; 2 | 3 | import com.quemb.qmbform.R; 4 | import com.quemb.qmbform.descriptor.RowDescriptor; 5 | 6 | import android.content.Context; 7 | 8 | /** 9 | * Created by pmaccamp on 9/4/2015. 10 | */ 11 | public class FormEditIntegerInlineFieldCell extends FormEditIntegerFieldCell { 12 | public FormEditIntegerInlineFieldCell(Context context, RowDescriptor rowDescriptor) { 13 | super(context, rowDescriptor); 14 | } 15 | 16 | @Override 17 | protected int getResource() { 18 | return R.layout.edit_text_view_inline_field_cell; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/java/com/quemb/qmbform/view/FormEditNumberFieldCell.java: -------------------------------------------------------------------------------- 1 | package com.quemb.qmbform.view; 2 | 3 | import com.quemb.qmbform.descriptor.RowDescriptor; 4 | import com.quemb.qmbform.descriptor.Value; 5 | 6 | import android.content.Context; 7 | import android.text.InputType; 8 | import android.util.Log; 9 | import android.widget.EditText; 10 | 11 | /** 12 | * Created by tonimoeckel on 15.07.14. 13 | */ 14 | public class FormEditNumberFieldCell extends FormEditTextFieldCell { 15 | 16 | private static final String TAG = "FormEditNumberFieldCell"; 17 | 18 | public FormEditNumberFieldCell(Context context, 19 | RowDescriptor rowDescriptor) { 20 | super(context, rowDescriptor); 21 | } 22 | 23 | 24 | @Override 25 | protected void init() { 26 | super.init(); 27 | 28 | EditText editView = getEditView(); 29 | editView.setRawInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); 30 | } 31 | 32 | 33 | @Override 34 | protected void updateEditView() { 35 | 36 | @SuppressWarnings("unchecked") Value value = (Value) getRowDescriptor().getValue(); 37 | if (value != null) { 38 | String valueString = String.valueOf(value.getValue()); 39 | getEditView().setText(valueString); 40 | } 41 | 42 | } 43 | 44 | 45 | protected void onEditTextChanged(String string) { 46 | 47 | try { 48 | Float floatValue = Float.parseFloat(string); 49 | onValueChanged(new Value(floatValue)); 50 | } catch (NumberFormatException e) { 51 | Log.e(TAG, e.getMessage(), e); 52 | } 53 | 54 | 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/java/com/quemb/qmbform/view/FormEditNumberInlineFieldCell.java: -------------------------------------------------------------------------------- 1 | package com.quemb.qmbform.view; 2 | 3 | import com.quemb.qmbform.R; 4 | import com.quemb.qmbform.descriptor.RowDescriptor; 5 | 6 | import android.content.Context; 7 | 8 | /** 9 | * Created by pmaccamp on 9/4/2015. 10 | */ 11 | public class FormEditNumberInlineFieldCell extends FormEditNumberFieldCell { 12 | public FormEditNumberInlineFieldCell(Context context, RowDescriptor rowDescriptor) { 13 | super(context, rowDescriptor); 14 | } 15 | 16 | @Override 17 | protected int getResource() { 18 | return R.layout.edit_text_view_inline_field_cell; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/java/com/quemb/qmbform/view/FormEditPasswordFieldCell.java: -------------------------------------------------------------------------------- 1 | package com.quemb.qmbform.view; 2 | 3 | import com.quemb.qmbform.descriptor.RowDescriptor; 4 | 5 | import android.content.Context; 6 | import android.text.InputType; 7 | import android.text.method.PasswordTransformationMethod; 8 | import android.widget.EditText; 9 | 10 | /** 11 | * Created by tonimoeckel on 15.07.14. 12 | */ 13 | public class FormEditPasswordFieldCell extends FormEditTextFieldCell { 14 | 15 | public FormEditPasswordFieldCell(Context context, 16 | RowDescriptor rowDescriptor) { 17 | super(context, rowDescriptor); 18 | } 19 | 20 | 21 | @Override 22 | protected void init() { 23 | super.init(); 24 | 25 | EditText editView = getEditView(); 26 | editView.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD); 27 | editView.setTransformationMethod(PasswordTransformationMethod.getInstance()); 28 | } 29 | 30 | 31 | } 32 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/java/com/quemb/qmbform/view/FormEditPasswordInlineFieldCell.java: -------------------------------------------------------------------------------- 1 | package com.quemb.qmbform.view; 2 | 3 | 4 | import com.quemb.qmbform.R; 5 | import com.quemb.qmbform.descriptor.RowDescriptor; 6 | 7 | import android.content.Context; 8 | 9 | /** 10 | * Created by pmaccamp on 8/28/2015. 11 | */ 12 | public class FormEditPasswordInlineFieldCell extends FormEditPasswordFieldCell { 13 | 14 | public FormEditPasswordInlineFieldCell(Context context, 15 | RowDescriptor rowDescriptor) { 16 | super(context, rowDescriptor); 17 | } 18 | 19 | @Override 20 | protected int getResource() { 21 | return R.layout.edit_text_view_inline_field_cell; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/java/com/quemb/qmbform/view/FormEditPhoneFieldCell.java: -------------------------------------------------------------------------------- 1 | package com.quemb.qmbform.view; 2 | 3 | import com.quemb.qmbform.descriptor.RowDescriptor; 4 | 5 | import android.content.Context; 6 | import android.text.InputType; 7 | import android.widget.EditText; 8 | 9 | /** 10 | * Created by tonimoeckel on 15.07.14. 11 | */ 12 | public class FormEditPhoneFieldCell extends FormEditTextFieldCell { 13 | 14 | public FormEditPhoneFieldCell(Context context, 15 | RowDescriptor rowDescriptor) { 16 | super(context, rowDescriptor); 17 | } 18 | 19 | 20 | @Override 21 | protected void init() { 22 | super.init(); 23 | 24 | EditText editView = getEditView(); 25 | editView.setInputType(InputType.TYPE_CLASS_PHONE); 26 | } 27 | 28 | 29 | } 30 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/java/com/quemb/qmbform/view/FormEditTextFieldCell.java: -------------------------------------------------------------------------------- 1 | package com.quemb.qmbform.view; 2 | 3 | import com.quemb.qmbform.R; 4 | import com.quemb.qmbform.descriptor.CellDescriptor; 5 | import com.quemb.qmbform.descriptor.RowDescriptor; 6 | import com.quemb.qmbform.descriptor.Value; 7 | 8 | import android.content.Context; 9 | import android.os.Handler; 10 | import android.text.Editable; 11 | import android.text.InputType; 12 | import android.text.TextWatcher; 13 | import android.widget.EditText; 14 | 15 | /** 16 | * Created by tonimoeckel on 15.07.14. 17 | */ 18 | public class FormEditTextFieldCell extends FormTitleFieldCell { 19 | 20 | private EditText mEditView; 21 | 22 | public FormEditTextFieldCell(Context context, 23 | RowDescriptor rowDescriptor) { 24 | super(context, rowDescriptor); 25 | } 26 | 27 | private Handler handler = new Handler(); 28 | private int lastFocussedPosition = -1; 29 | 30 | @Override 31 | protected void init() { 32 | 33 | super.init(); 34 | mEditView = (EditText) findViewById(R.id.editText); 35 | mEditView.setRawInputType(InputType.TYPE_CLASS_TEXT); 36 | 37 | setStyleId(mEditView, CellDescriptor.APPEARANCE_TEXT_VALUE, CellDescriptor.COLOR_VALUE); 38 | } 39 | 40 | @Override 41 | protected void afterInit() { 42 | super.afterInit(); 43 | 44 | mEditView.addTextChangedListener(new TextWatcher() { 45 | 46 | public void afterTextChanged(Editable s) { 47 | 48 | FormEditTextFieldCell.this.onEditTextChanged(s.toString()); 49 | } 50 | 51 | public void beforeTextChanged(CharSequence s, int start, int count, int after) { 52 | 53 | } 54 | 55 | public void onTextChanged(CharSequence s, int start, int before, int count) { 56 | } 57 | }); 58 | 59 | } 60 | 61 | protected void onEditTextChanged(String string) { 62 | onValueChanged(new Value(string)); 63 | } 64 | 65 | @Override 66 | protected int getResource() { 67 | return R.layout.edit_text_field_cell; 68 | } 69 | 70 | @Override 71 | protected void update() { 72 | 73 | super.update(); 74 | 75 | updateEditView(); 76 | 77 | if (getRowDescriptor().getDisabled()) 78 | { 79 | mEditView.setEnabled(false); 80 | setTextColor(mEditView, CellDescriptor.COLOR_VALUE_DISABLED); 81 | } 82 | else 83 | mEditView.setEnabled(true); 84 | 85 | } 86 | 87 | protected void updateEditView() { 88 | 89 | String hint = getRowDescriptor().getHint(getContext()); 90 | if (hint != null) { 91 | mEditView.setHint(hint); 92 | } 93 | 94 | @SuppressWarnings("unchecked") Value value = (Value) getRowDescriptor().getValue(); 95 | if (value != null && value.getValue() != null) { 96 | String valueString = value.getValue(); 97 | mEditView.setText(valueString); 98 | } 99 | 100 | } 101 | 102 | public EditText getEditView() { 103 | return mEditView; 104 | } 105 | 106 | } 107 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/java/com/quemb/qmbform/view/FormEditTextInlineFieldCell.java: -------------------------------------------------------------------------------- 1 | package com.quemb.qmbform.view; 2 | 3 | import com.quemb.qmbform.R; 4 | import com.quemb.qmbform.descriptor.RowDescriptor; 5 | 6 | import android.content.Context; 7 | 8 | /** 9 | * Created by pmaccamp on 8/28/2015. 10 | */ 11 | public class FormEditTextInlineFieldCell extends FormEditTextFieldCell { 12 | public FormEditTextInlineFieldCell(Context context, RowDescriptor rowDescriptor) { 13 | super(context, rowDescriptor); 14 | } 15 | 16 | @Override 17 | protected int getResource() { 18 | return R.layout.edit_text_inline_field_cell; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/java/com/quemb/qmbform/view/FormEditTextViewFieldCell.java: -------------------------------------------------------------------------------- 1 | package com.quemb.qmbform.view; 2 | 3 | import com.quemb.qmbform.R; 4 | import com.quemb.qmbform.descriptor.RowDescriptor; 5 | 6 | import android.content.Context; 7 | 8 | /** 9 | * Created by tonimoeckel on 15.07.14. 10 | */ 11 | public class FormEditTextViewFieldCell extends FormEditTextFieldCell { 12 | 13 | 14 | public FormEditTextViewFieldCell(Context context, 15 | RowDescriptor rowDescriptor) { 16 | super(context, rowDescriptor); 17 | } 18 | 19 | 20 | @Override 21 | protected int getResource() { 22 | return R.layout.edit_text_view_field_cell; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/java/com/quemb/qmbform/view/FormEditTextViewInlineFieldCell.java: -------------------------------------------------------------------------------- 1 | package com.quemb.qmbform.view; 2 | 3 | 4 | import com.quemb.qmbform.R; 5 | import com.quemb.qmbform.descriptor.RowDescriptor; 6 | 7 | import android.content.Context; 8 | 9 | /** 10 | * Created by pmaccamp on 8/28/2015. 11 | */ 12 | public class FormEditTextViewInlineFieldCell extends FormEditTextFieldCell { 13 | 14 | 15 | public FormEditTextViewInlineFieldCell(Context context, 16 | RowDescriptor rowDescriptor) { 17 | super(context, rowDescriptor); 18 | } 19 | 20 | 21 | @Override 22 | protected int getResource() { 23 | return R.layout.edit_text_view_inline_field_cell; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/java/com/quemb/qmbform/view/FormEditURLFieldCell.java: -------------------------------------------------------------------------------- 1 | package com.quemb.qmbform.view; 2 | 3 | import com.quemb.qmbform.descriptor.RowDescriptor; 4 | 5 | import android.content.Context; 6 | import android.text.InputType; 7 | import android.widget.EditText; 8 | 9 | /** 10 | * Created by tonimoeckel on 15.07.14. 11 | */ 12 | public class FormEditURLFieldCell extends FormEditTextFieldCell { 13 | 14 | public FormEditURLFieldCell(Context context, 15 | RowDescriptor rowDescriptor) { 16 | super(context, rowDescriptor); 17 | } 18 | 19 | 20 | @Override 21 | protected void init() { 22 | super.init(); 23 | 24 | EditText editView = getEditView(); 25 | editView.setInputType(InputType.TYPE_TEXT_VARIATION_URI); 26 | } 27 | 28 | 29 | } 30 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/java/com/quemb/qmbform/view/FormExternalButtonFieldCell.java: -------------------------------------------------------------------------------- 1 | package com.quemb.qmbform.view; 2 | 3 | import com.quemb.qmbform.descriptor.RowDescriptor; 4 | import com.quemb.qmbform.descriptor.Value; 5 | 6 | import android.content.Context; 7 | import android.content.Intent; 8 | import android.net.Uri; 9 | 10 | /** 11 | * Created by tonimoeckel on 18.09.14. 12 | */ 13 | public class FormExternalButtonFieldCell extends FormButtonFieldCell { 14 | 15 | 16 | public FormExternalButtonFieldCell(Context context, 17 | RowDescriptor rowDescriptor) { 18 | super(context, rowDescriptor); 19 | } 20 | 21 | @Override 22 | public void onCellSelected() { 23 | super.onCellSelected(); 24 | 25 | @SuppressWarnings("unchecked") Value value = getRowDescriptor().getValue(); 26 | if (value != null && value.getValue() != null) { 27 | Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(value.getValue())); 28 | getContext().startActivity(i); 29 | } 30 | 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/java/com/quemb/qmbform/view/FormIntegerSliderFieldCell.java: -------------------------------------------------------------------------------- 1 | package com.quemb.qmbform.view; 2 | 3 | import com.quemb.qmbform.R; 4 | import com.quemb.qmbform.descriptor.RowDescriptor; 5 | import com.quemb.qmbform.descriptor.Value; 6 | 7 | import android.content.Context; 8 | import android.widget.SeekBar; 9 | 10 | import java.util.HashMap; 11 | 12 | /** 13 | * Created by tonimoeckel on 25.08.14. 14 | */ 15 | public class FormIntegerSliderFieldCell extends FormDetailTextInlineFieldCell { 16 | 17 | private SeekBar mSeekBar; 18 | public final static String CellConfigMaxKey = "CellConfigMaxKey"; 19 | 20 | public FormIntegerSliderFieldCell(Context context, RowDescriptor rowDescriptor) { 21 | super(context, rowDescriptor); 22 | } 23 | 24 | @Override 25 | protected void init() { 26 | 27 | super.init(); 28 | mSeekBar = (SeekBar) findViewById(R.id.seekBar); 29 | mSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { 30 | 31 | @Override 32 | public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { 33 | 34 | getDetailTextView().setText(Integer.toString(progress)); 35 | onValueChanged(new Value(progress)); 36 | 37 | } 38 | 39 | @Override 40 | public void onStartTrackingTouch(SeekBar seekBar) { 41 | 42 | } 43 | 44 | @Override 45 | public void onStopTrackingTouch(SeekBar seekBar) { 46 | 47 | } 48 | }); 49 | 50 | } 51 | 52 | @Override 53 | protected int getResource() { 54 | return R.layout.integer_slider_field_cell; 55 | } 56 | 57 | @Override 58 | protected void update() { 59 | 60 | super.update(); 61 | 62 | @SuppressWarnings("unchecked") Value value = (Value) getRowDescriptor().getValue(); 63 | 64 | HashMap config = getRowDescriptor().getCellConfig(); 65 | Integer max = config != null && config.containsKey(CellConfigMaxKey) ? (Integer) config.get(CellConfigMaxKey) : 100; 66 | 67 | mSeekBar.setMax(max); 68 | mSeekBar.setProgress(value.getValue()); 69 | mSeekBar.setEnabled(!getRowDescriptor().getDisabled()); 70 | 71 | } 72 | 73 | public SeekBar getSeekBar() { 74 | return mSeekBar; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/java/com/quemb/qmbform/view/FormMultipleDialogFieldCell.java: -------------------------------------------------------------------------------- 1 | package com.quemb.qmbform.view; 2 | 3 | import android.app.AlertDialog; 4 | import android.content.Context; 5 | import android.content.DialogInterface; 6 | import android.util.Log; 7 | import android.widget.ArrayAdapter; 8 | 9 | import com.quemb.qmbform.R; 10 | import com.quemb.qmbform.descriptor.DataSourceListener; 11 | import com.quemb.qmbform.descriptor.OnFormRowValueChangedListener; 12 | import com.quemb.qmbform.descriptor.RowDescriptor; 13 | import com.quemb.qmbform.descriptor.Value; 14 | import com.quemb.qmbform.exceptions.NoDataSourceException; 15 | 16 | import java.util.ArrayList; 17 | import java.util.Arrays; 18 | import java.util.List; 19 | 20 | /** 21 | * Created by Nico Ziegler on 05.01.15. 22 | */ 23 | public class FormMultipleDialogFieldCell extends FormDetailTextVerticalFieldCell { 24 | 25 | public FormMultipleDialogFieldCell(Context context, RowDescriptor rowDescriptor) { 26 | super(context, rowDescriptor); 27 | } 28 | 29 | 30 | @Override 31 | public void onCellSelected() { 32 | super.onCellSelected(); 33 | 34 | if (getRowDescriptor().getDataSource() == null) { 35 | throw new NoDataSourceException(); 36 | } else { 37 | getRowDescriptor().getDataSource().loadData(new DataSourceListener() { 38 | @Override 39 | public void onDataSourceLoaded(List list) { 40 | 41 | final ArrayList selectedItems = new ArrayList((ArrayList) getRowDescriptor().getValue().getValue()); 42 | 43 | if (list.size() > 0) { 44 | final ArrayAdapter adapter = new ArrayAdapter(getContext(), android.R.layout.simple_selectable_list_item, list); 45 | final CharSequence[] charSequence = (CharSequence[]) list.toArray(new CharSequence[list.size()]); 46 | final boolean[] checkedItems = new boolean[list.size()]; 47 | 48 | for (int i = 0; i < list.size(); i++) { 49 | checkedItems[i] = selectedItems.contains(list.get(i)); 50 | } 51 | 52 | AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); 53 | builder.setTitle(getRowDescriptor().getTitle()); 54 | builder.setMultiChoiceItems(charSequence, checkedItems, new DialogInterface.OnMultiChoiceClickListener() { 55 | @Override 56 | public void onClick(DialogInterface dialog, int which, boolean isChecked) { 57 | if (isChecked) { 58 | selectedItems.add(adapter.getItem(which).toString()); 59 | } else { 60 | selectedItems.remove(adapter.getItem(which).toString()); 61 | } 62 | } 63 | }); 64 | builder.setPositiveButton(R.string.btn_select, new DialogInterface.OnClickListener() { 65 | @Override 66 | public void onClick(DialogInterface dialog, int which) { 67 | onValueChanged(new Value(selectedItems)); 68 | update(); 69 | dialog.dismiss(); 70 | } 71 | }); 72 | 73 | AlertDialog dialog = builder.create(); 74 | dialog.show(); 75 | } else { 76 | AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); 77 | builder.setTitle(R.string.title_no_entries); 78 | builder.setMessage(R.string.msg_no_entries); 79 | AlertDialog dialog = builder.create(); 80 | dialog.show(); 81 | } 82 | } 83 | }); 84 | } 85 | 86 | } 87 | 88 | @Override 89 | protected void update() { 90 | 91 | super.update(); 92 | 93 | if (getRowDescriptor().getHint(getContext()) != null) { 94 | getDetailTextView().setHint(getRowDescriptor().getHint(getContext())); 95 | } 96 | 97 | Value value = getRowDescriptor().getValue(); 98 | if (value != null && value.getValue() != null) { 99 | if (value.getValue() instanceof String) { 100 | getDetailTextView().setText((String) value.getValue()); 101 | } else if (value.getValue() instanceof ArrayList) { 102 | ArrayList arrayList = (ArrayList) value.getValue(); 103 | String stringValue = ""; 104 | for (int i = 0; i < arrayList.size(); i++) { 105 | if (i > 0) { 106 | stringValue = stringValue.concat(", "); 107 | } 108 | stringValue = stringValue.concat((String) arrayList.get(i)); 109 | } 110 | getDetailTextView().setText(stringValue); 111 | } else { 112 | getDetailTextView().setText(String.valueOf(value.getValue())); 113 | 114 | } 115 | } 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/java/com/quemb/qmbform/view/FormPickerDialogFieldCell.java: -------------------------------------------------------------------------------- 1 | package com.quemb.qmbform.view; 2 | 3 | import com.quemb.qmbform.R; 4 | import com.quemb.qmbform.descriptor.DataSourceListener; 5 | import com.quemb.qmbform.descriptor.RowDescriptor; 6 | import com.quemb.qmbform.descriptor.Value; 7 | import com.quemb.qmbform.exceptions.NoDataSourceException; 8 | 9 | import android.app.AlertDialog; 10 | import android.content.Context; 11 | import android.content.DialogInterface; 12 | import android.widget.ArrayAdapter; 13 | 14 | import java.util.ArrayList; 15 | import java.util.List; 16 | 17 | /** 18 | * Created by tonimoeckel on 15.07.14. 19 | */ 20 | public class FormPickerDialogFieldCell extends FormDetailTextInlineFieldCell { 21 | 22 | 23 | public FormPickerDialogFieldCell(Context context, 24 | RowDescriptor rowDescriptor) { 25 | super(context, rowDescriptor); 26 | } 27 | 28 | @Override 29 | protected void update() { 30 | 31 | super.update(); 32 | setEnabled(!getRowDescriptor().getDisabled()); 33 | 34 | } 35 | 36 | @Override 37 | public void onCellSelected() { 38 | super.onCellSelected(); 39 | if (getRowDescriptor().getDataSource() == null) { 40 | throw new NoDataSourceException(); 41 | } else { 42 | getRowDescriptor().getDataSource().loadData(new DataSourceListener() { 43 | 44 | @Override 45 | public void onDataSourceLoaded(List list) { 46 | 47 | if (list.size() > 0) { 48 | final ArrayAdapter adapter = new ArrayAdapter(getContext(), android.R.layout.simple_selectable_list_item, list); 49 | AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); 50 | 51 | builder.setSingleChoiceItems(adapter, -1, new DialogInterface.OnClickListener() { 52 | @Override 53 | public void onClick(DialogInterface dialog, int which) { 54 | 55 | onValueChanged(new Value(adapter.getItem(which))); 56 | update(); 57 | dialog.dismiss(); 58 | } 59 | }) 60 | .setTitle(getRowDescriptor().getTitle()); 61 | 62 | AlertDialog dialog = builder.create(); 63 | dialog.show(); 64 | } else { 65 | AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); 66 | builder.setTitle(R.string.title_no_entries); 67 | builder.setMessage(R.string.msg_no_entries); 68 | AlertDialog dialog = builder.create(); 69 | dialog.show(); 70 | } 71 | 72 | 73 | } 74 | }); 75 | } 76 | 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/java/com/quemb/qmbform/view/FormPickerDialogVerticalFieldCell.java: -------------------------------------------------------------------------------- 1 | package com.quemb.qmbform.view; 2 | 3 | import com.quemb.qmbform.R; 4 | import com.quemb.qmbform.descriptor.RowDescriptor; 5 | 6 | import android.content.Context; 7 | 8 | /** 9 | * Created by tonimoeckel on 15.07.14. 10 | */ 11 | public class FormPickerDialogVerticalFieldCell extends FormPickerDialogFieldCell { 12 | 13 | 14 | public FormPickerDialogVerticalFieldCell(Context context, 15 | RowDescriptor rowDescriptor) { 16 | super(context, rowDescriptor); 17 | } 18 | 19 | @Override 20 | protected int getResource() { 21 | return R.layout.detail_text_field_cell; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/java/com/quemb/qmbform/view/FormSpinnerFieldCell.java: -------------------------------------------------------------------------------- 1 | package com.quemb.qmbform.view; 2 | 3 | import com.quemb.qmbform.R; 4 | import com.quemb.qmbform.adapter.FormOptionsObjectAdapter; 5 | import com.quemb.qmbform.descriptor.FormOptionsObject; 6 | import com.quemb.qmbform.descriptor.RowDescriptor; 7 | import com.quemb.qmbform.descriptor.Value; 8 | 9 | import android.app.AlertDialog; 10 | import android.content.Context; 11 | import android.view.View; 12 | import android.widget.AdapterView; 13 | import android.widget.Spinner; 14 | 15 | import java.util.ArrayList; 16 | import java.util.List; 17 | 18 | /** 19 | * Created by tonimoeckel on 15.07.14. 20 | */ 21 | public class FormSpinnerFieldCell extends FormTitleFieldCell { 22 | private Spinner mSpinner; 23 | private ArrayList mValues; 24 | 25 | public FormSpinnerFieldCell(Context context, 26 | RowDescriptor rowDescriptor) { 27 | super(context, rowDescriptor); 28 | } 29 | 30 | @Override 31 | protected void init() { 32 | super.init(); 33 | mSpinner = (Spinner) findViewById(R.id.spinner); 34 | } 35 | 36 | @Override 37 | protected int getResource() { 38 | return R.layout.spinner_field_cell; 39 | } 40 | 41 | @Override 42 | protected void update() { 43 | super.update(); 44 | 45 | List selectorOptions = getRowDescriptor().getSelectorOptions(); 46 | 47 | if (selectorOptions.size() > 0) { 48 | FormOptionsObjectAdapter adapter = new FormOptionsObjectAdapter(getContext(), 49 | android.R.layout.simple_spinner_item, 50 | android.R.layout.simple_spinner_dropdown_item, 51 | selectorOptions); 52 | mSpinner.setAdapter(adapter); 53 | Object value = getRowDescriptor().getValueData(); 54 | if (value != null) { 55 | mSpinner.setSelection(FormOptionsObject.indexOfFormOptionsObjectFromArrayWithValue(value, selectorOptions)); 56 | } else { 57 | mSpinner.setSelection(-1); 58 | } 59 | } else { 60 | AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); 61 | builder.setTitle(R.string.title_no_entries); 62 | builder.setMessage(R.string.msg_no_entries); 63 | AlertDialog dialog = builder.create(); 64 | dialog.show(); 65 | } 66 | mSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { 67 | @Override 68 | public void onItemSelected(AdapterView parent, View view, int position, 69 | long id) { 70 | FormOptionsObject selectedOption = (FormOptionsObject) mSpinner.getAdapter().getItem(position); 71 | onValueChanged(new Value(selectedOption.getValue())); 72 | } 73 | 74 | @Override 75 | public void onNothingSelected(AdapterView parent) { 76 | 77 | } 78 | }); 79 | } 80 | 81 | @Override 82 | public void onCellSelected() { 83 | super.onCellSelected(); 84 | 85 | 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/java/com/quemb/qmbform/view/FormSpinnerInlineFieldCell.java: -------------------------------------------------------------------------------- 1 | package com.quemb.qmbform.view; 2 | 3 | import com.quemb.qmbform.R; 4 | import com.quemb.qmbform.descriptor.RowDescriptor; 5 | 6 | import android.content.Context; 7 | 8 | /** 9 | * Created by pmaccamp on 9/4/2015. 10 | */ 11 | public class FormSpinnerInlineFieldCell extends FormSpinnerFieldCell { 12 | public FormSpinnerInlineFieldCell(Context context, RowDescriptor rowDescriptor) { 13 | super(context, rowDescriptor); 14 | } 15 | 16 | @Override 17 | protected int getResource() { 18 | return R.layout.spinner_inline_field_cell; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/java/com/quemb/qmbform/view/FormTextPickerDialogFieldCell.java: -------------------------------------------------------------------------------- 1 | package com.quemb.qmbform.view; 2 | 3 | import com.quemb.qmbform.R; 4 | import com.quemb.qmbform.descriptor.DataSourceListener; 5 | import com.quemb.qmbform.descriptor.RowDescriptor; 6 | import com.quemb.qmbform.descriptor.Value; 7 | import com.quemb.qmbform.exceptions.NoDataSourceException; 8 | 9 | import android.app.AlertDialog; 10 | import android.content.Context; 11 | import android.content.DialogInterface; 12 | import android.view.View; 13 | import android.widget.ArrayAdapter; 14 | import android.widget.ImageButton; 15 | 16 | import java.util.ArrayList; 17 | import java.util.List; 18 | 19 | /** 20 | * Created by tonimoeckel on 15.07.14. 21 | */ 22 | public class FormTextPickerDialogFieldCell extends FormEditTextFieldCell { 23 | 24 | private ImageButton mImageButton; 25 | 26 | public FormTextPickerDialogFieldCell(Context context, 27 | RowDescriptor rowDescriptor) { 28 | super(context, rowDescriptor); 29 | } 30 | 31 | @Override 32 | protected void init() { 33 | 34 | super.init(); 35 | mImageButton = (ImageButton) findViewById(R.id.imageButton); 36 | addListenerOnButton(); 37 | } 38 | 39 | @Override 40 | protected int getResource() { 41 | return R.layout.text_picker_field_cell; 42 | } 43 | 44 | public void addListenerOnButton() { 45 | mImageButton.setOnClickListener(new OnClickListener() { 46 | 47 | @Override 48 | public void onClick(View v) { 49 | onCellSelected(); 50 | } 51 | }); 52 | 53 | } 54 | 55 | @Override 56 | public void onCellSelected() { 57 | super.onCellSelected(); 58 | if (getRowDescriptor().getDataSource() == null) { 59 | throw new NoDataSourceException(); 60 | } else { 61 | getRowDescriptor().getDataSource().loadData(new DataSourceListener() { 62 | @Override 63 | public void onDataSourceLoaded(List list) { 64 | 65 | if (list.size() > 0) { 66 | final ArrayAdapter adapter = new ArrayAdapter(getContext(), android.R.layout.simple_selectable_list_item, list); 67 | AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); 68 | 69 | builder.setSingleChoiceItems(adapter, -1, new DialogInterface.OnClickListener() { 70 | @Override 71 | public void onClick(DialogInterface dialog, int which) { 72 | 73 | onValueChanged(new Value(adapter.getItem(which))); 74 | update(); 75 | dialog.dismiss(); 76 | } 77 | }) 78 | .setTitle(getRowDescriptor().getTitle()); 79 | 80 | AlertDialog dialog = builder.create(); 81 | dialog.show(); 82 | } else { 83 | AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); 84 | builder.setTitle(R.string.title_no_entries); 85 | builder.setMessage(R.string.msg_no_entries); 86 | AlertDialog dialog = builder.create(); 87 | dialog.show(); 88 | } 89 | 90 | 91 | } 92 | }); 93 | } 94 | 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/java/com/quemb/qmbform/view/FormTimeDialogFieldCell.java: -------------------------------------------------------------------------------- 1 | package com.quemb.qmbform.view; 2 | 3 | import com.quemb.qmbform.descriptor.RowDescriptor; 4 | 5 | import android.app.TimePickerDialog; 6 | import android.content.Context; 7 | import android.widget.TimePicker; 8 | 9 | import java.util.Calendar; 10 | 11 | /** 12 | * Created by tonimoeckel on 15.07.14. 13 | */ 14 | public class FormTimeDialogFieldCell extends FormTimeFieldCell implements 15 | TimePickerDialog.OnTimeSetListener { 16 | 17 | private Calendar mCalendar; 18 | 19 | public FormTimeDialogFieldCell(Context context, 20 | RowDescriptor rowDescriptor) { 21 | super(context, rowDescriptor); 22 | } 23 | 24 | @Override 25 | protected void initDatePicker(Calendar calendar) { 26 | 27 | mCalendar = calendar; 28 | } 29 | 30 | @Override 31 | public void onCellSelected() { 32 | super.onCellSelected(); 33 | 34 | TimePickerDialog dialog = new TimePickerDialog(getContext(), this, getCalendar().get(Calendar.HOUR_OF_DAY), mCalendar.get(Calendar.MINUTE), true); 35 | dialog.show(); 36 | 37 | } 38 | 39 | 40 | @Override 41 | public void onTimeSet(TimePicker view, int hourOfDay, int minute) { 42 | 43 | Calendar calendar = getCalendar(); 44 | calendar.set(Calendar.HOUR_OF_DAY, hourOfDay); 45 | calendar.set(Calendar.MINUTE, minute); 46 | 47 | onDateChanged(calendar.getTime()); 48 | 49 | } 50 | 51 | public Calendar getCalendar() { 52 | return mCalendar; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/java/com/quemb/qmbform/view/FormTimeFieldCell.java: -------------------------------------------------------------------------------- 1 | package com.quemb.qmbform.view; 2 | 3 | import com.quemb.qmbform.descriptor.CellDescriptor; 4 | import com.quemb.qmbform.descriptor.RowDescriptor; 5 | 6 | import android.content.Context; 7 | import android.widget.TextView; 8 | 9 | import java.text.DateFormat; 10 | import java.util.Date; 11 | 12 | /** 13 | * Created by tonimoeckel on 15.07.14. 14 | */ 15 | public class FormTimeFieldCell extends FormDateFieldCell { 16 | 17 | public FormTimeFieldCell(Context context, 18 | RowDescriptor rowDescriptor) { 19 | super(context, rowDescriptor); 20 | } 21 | 22 | 23 | @Override 24 | protected void updateDateLabel(Date date, boolean disabled) { 25 | 26 | DateFormat dateFormat = android.text.format.DateFormat.getTimeFormat(getContext()); 27 | String s = dateFormat.format(date); 28 | 29 | TextView editView = getDetailTextView(); 30 | editView.setText(s); 31 | 32 | if (disabled) 33 | { 34 | editView.setEnabled(false); 35 | setTextColor(editView, CellDescriptor.COLOR_VALUE_DISABLED); 36 | } 37 | 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/java/com/quemb/qmbform/view/FormTimeInlineFieldCell.java: -------------------------------------------------------------------------------- 1 | package com.quemb.qmbform.view; 2 | 3 | import com.quemb.qmbform.R; 4 | import com.quemb.qmbform.descriptor.RowDescriptor; 5 | 6 | import android.content.Context; 7 | import android.os.Build; 8 | import android.text.format.DateFormat; 9 | import android.widget.TimePicker; 10 | 11 | import java.util.Calendar; 12 | import java.util.Date; 13 | import java.util.concurrent.TimeUnit; 14 | 15 | /** 16 | * Created by tonimoeckel on 15.07.14. 17 | */ 18 | public class FormTimeInlineFieldCell extends FormTimeFieldCell implements 19 | TimePicker.OnTimeChangedListener { 20 | 21 | private TimePicker mTimePicker; 22 | 23 | public FormTimeInlineFieldCell(Context context, 24 | RowDescriptor rowDescriptor) { 25 | super(context, rowDescriptor); 26 | } 27 | 28 | 29 | @Override 30 | protected void init() { 31 | 32 | super.init(); 33 | mTimePicker = (TimePicker) findViewById(R.id.timePicker); 34 | 35 | 36 | } 37 | 38 | @Override 39 | protected int getResource() { 40 | return R.layout.time_inline_field_cell; 41 | } 42 | 43 | @SuppressWarnings("deprecation") 44 | @Override 45 | protected void initDatePicker(Calendar calendar) { 46 | 47 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) 48 | { 49 | mTimePicker.setHour(calendar.get(Calendar.HOUR_OF_DAY)); 50 | mTimePicker.setMinute(calendar.get(Calendar.MINUTE)); 51 | } 52 | else 53 | { 54 | mTimePicker.setCurrentHour(calendar.get(Calendar.HOUR_OF_DAY)); 55 | mTimePicker.setCurrentMinute(calendar.get(Calendar.MINUTE)); 56 | } 57 | mTimePicker.setOnTimeChangedListener(this); 58 | 59 | if (DateFormat.is24HourFormat(getContext())) 60 | mTimePicker.setIs24HourView(true); 61 | 62 | } 63 | 64 | @Override 65 | public void onCellSelected() { 66 | super.onCellSelected(); 67 | 68 | mTimePicker.setVisibility(mTimePicker.getVisibility() == VISIBLE ? GONE : VISIBLE); 69 | 70 | } 71 | 72 | public TimePicker getTimePicker() { 73 | return mTimePicker; 74 | } 75 | 76 | @Override 77 | public void onTimeChanged(TimePicker view, int hourOfDay, int minute) { 78 | 79 | Date date = new Date(); 80 | date.setTime(TimeUnit.HOURS.toMillis(hourOfDay) + TimeUnit.MINUTES.toMillis(minute)); 81 | 82 | onDateChanged(date); 83 | 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/java/com/quemb/qmbform/view/FormTitleFieldCell.java: -------------------------------------------------------------------------------- 1 | package com.quemb.qmbform.view; 2 | 3 | import com.quemb.qmbform.R; 4 | import com.quemb.qmbform.descriptor.CellDescriptor; 5 | import com.quemb.qmbform.descriptor.RowDescriptor; 6 | 7 | import android.content.Context; 8 | import android.widget.TextView; 9 | 10 | /** 11 | * Created by tonimoeckel on 15.07.14. 12 | */ 13 | public class FormTitleFieldCell extends FormBaseCell { 14 | private TextView mTextView; 15 | 16 | public FormTitleFieldCell(Context context, 17 | RowDescriptor rowDescriptor) { 18 | super(context, rowDescriptor); 19 | } 20 | 21 | @Override 22 | protected void init() { 23 | super.init(); 24 | mTextView = (TextView) findViewById(R.id.textView); 25 | 26 | setStyleId(mTextView, CellDescriptor.APPEARANCE_TEXT_LABEL, CellDescriptor.COLOR_LABEL); 27 | } 28 | 29 | @Override 30 | protected int getResource() { 31 | return R.layout.text_field_cell; 32 | } 33 | 34 | @Override 35 | protected void update() { 36 | String title = getFormItemDescriptor().getTitle(); 37 | mTextView.setText(title); 38 | mTextView.setVisibility(title == null ? GONE : VISIBLE); 39 | 40 | 41 | if (getRowDescriptor().getDisabled()) { 42 | getRowDescriptor().setOnFormRowClickListener(null); 43 | 44 | setTextColor(mTextView, CellDescriptor.COLOR_LABEL_DISABLED); 45 | } 46 | } 47 | 48 | public TextView getTextView() { 49 | return mTextView; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/java/com/quemb/qmbform/view/SectionCell.java: -------------------------------------------------------------------------------- 1 | package com.quemb.qmbform.view; 2 | 3 | import com.quemb.qmbform.R; 4 | import com.quemb.qmbform.descriptor.CellDescriptor; 5 | import com.quemb.qmbform.descriptor.SectionDescriptor; 6 | 7 | import android.content.Context; 8 | import android.widget.TextView; 9 | 10 | /** 11 | * Created by tonimoeckel on 15.07.14. 12 | */ 13 | public class SectionCell extends Cell { 14 | 15 | //private SectionDescriptor mSectionDescriptor; 16 | 17 | private TextView mTextView; 18 | 19 | public SectionCell(Context context, 20 | SectionDescriptor sectionDescriptor) { 21 | super(context, sectionDescriptor); 22 | } 23 | 24 | 25 | @Override 26 | protected void init() { 27 | 28 | super.init(); 29 | 30 | setClickable(false); 31 | setEnabled(false); 32 | 33 | mTextView = (TextView) findViewById(R.id.textView); 34 | 35 | setStyleId(mTextView, CellDescriptor.APPEARANCE_SECTION, CellDescriptor.COLOR_LABEL); 36 | mTextView.setTextColor(getThemeValue(R.attr.colorAccent)); 37 | 38 | } 39 | 40 | @Override 41 | protected int getResource() { 42 | return R.layout.section_cell; 43 | } 44 | 45 | @Override 46 | protected void update() { 47 | 48 | String title = getFormItemDescriptor().getTitle(); 49 | mTextView.setText(title); 50 | 51 | } 52 | 53 | @Override 54 | public boolean shouldAddDivider() { 55 | return false; 56 | } 57 | 58 | public SectionDescriptor getSectionDescriptor() { 59 | return (SectionDescriptor) getFormItemDescriptor(); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/java/com/quemb/qmbform/view/SeperatorSectionCell.java: -------------------------------------------------------------------------------- 1 | package com.quemb.qmbform.view; 2 | 3 | import com.quemb.qmbform.R; 4 | import com.quemb.qmbform.descriptor.RowDescriptor; 5 | 6 | import android.content.Context; 7 | import android.widget.LinearLayout; 8 | 9 | /** 10 | * Created by tonimoeckel on 18.02.15. 11 | */ 12 | public class SeperatorSectionCell extends FormBaseCell { 13 | 14 | 15 | public SeperatorSectionCell(Context context, 16 | RowDescriptor rowDescriptor) { 17 | super(context, rowDescriptor); 18 | } 19 | 20 | public void init() { 21 | 22 | super.init(); 23 | 24 | setOrientation(LinearLayout.VERTICAL); 25 | setClickable(false); 26 | setEnabled(false); 27 | 28 | } 29 | 30 | @Override 31 | public boolean shouldAddDivider() { 32 | return false; 33 | } 34 | 35 | @Override 36 | protected int getResource() { 37 | return R.layout.section_seperator_cell; 38 | } 39 | 40 | @Override 41 | protected void update() { 42 | 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/res/drawable-hdpi/ic_action_about.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quemb/QMBForm/95ddd131669531e61d75a7515b29f374fb557272/lib/QMBForm/src/main/res/drawable-hdpi/ic_action_about.png -------------------------------------------------------------------------------- /lib/QMBForm/src/main/res/drawable-hdpi/ic_action_new.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quemb/QMBForm/95ddd131669531e61d75a7515b29f374fb557272/lib/QMBForm/src/main/res/drawable-hdpi/ic_action_new.png -------------------------------------------------------------------------------- /lib/QMBForm/src/main/res/drawable-hdpi/ic_action_remove.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quemb/QMBForm/95ddd131669531e61d75a7515b29f374fb557272/lib/QMBForm/src/main/res/drawable-hdpi/ic_action_remove.png -------------------------------------------------------------------------------- /lib/QMBForm/src/main/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quemb/QMBForm/95ddd131669531e61d75a7515b29f374fb557272/lib/QMBForm/src/main/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /lib/QMBForm/src/main/res/drawable-mdpi/ic_action_about.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quemb/QMBForm/95ddd131669531e61d75a7515b29f374fb557272/lib/QMBForm/src/main/res/drawable-mdpi/ic_action_about.png -------------------------------------------------------------------------------- /lib/QMBForm/src/main/res/drawable-mdpi/ic_action_new.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quemb/QMBForm/95ddd131669531e61d75a7515b29f374fb557272/lib/QMBForm/src/main/res/drawable-mdpi/ic_action_new.png -------------------------------------------------------------------------------- /lib/QMBForm/src/main/res/drawable-mdpi/ic_action_remove.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quemb/QMBForm/95ddd131669531e61d75a7515b29f374fb557272/lib/QMBForm/src/main/res/drawable-mdpi/ic_action_remove.png -------------------------------------------------------------------------------- /lib/QMBForm/src/main/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quemb/QMBForm/95ddd131669531e61d75a7515b29f374fb557272/lib/QMBForm/src/main/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /lib/QMBForm/src/main/res/drawable-xhdpi/ic_action_about.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quemb/QMBForm/95ddd131669531e61d75a7515b29f374fb557272/lib/QMBForm/src/main/res/drawable-xhdpi/ic_action_about.png -------------------------------------------------------------------------------- /lib/QMBForm/src/main/res/drawable-xhdpi/ic_action_new.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quemb/QMBForm/95ddd131669531e61d75a7515b29f374fb557272/lib/QMBForm/src/main/res/drawable-xhdpi/ic_action_new.png -------------------------------------------------------------------------------- /lib/QMBForm/src/main/res/drawable-xhdpi/ic_action_remove.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quemb/QMBForm/95ddd131669531e61d75a7515b29f374fb557272/lib/QMBForm/src/main/res/drawable-xhdpi/ic_action_remove.png -------------------------------------------------------------------------------- /lib/QMBForm/src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quemb/QMBForm/95ddd131669531e61d75a7515b29f374fb557272/lib/QMBForm/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /lib/QMBForm/src/main/res/drawable-xxhdpi/ic_action_about.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quemb/QMBForm/95ddd131669531e61d75a7515b29f374fb557272/lib/QMBForm/src/main/res/drawable-xxhdpi/ic_action_about.png -------------------------------------------------------------------------------- /lib/QMBForm/src/main/res/drawable-xxhdpi/ic_action_new.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quemb/QMBForm/95ddd131669531e61d75a7515b29f374fb557272/lib/QMBForm/src/main/res/drawable-xxhdpi/ic_action_new.png -------------------------------------------------------------------------------- /lib/QMBForm/src/main/res/drawable-xxhdpi/ic_action_remove.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quemb/QMBForm/95ddd131669531e61d75a7515b29f374fb557272/lib/QMBForm/src/main/res/drawable-xxhdpi/ic_action_remove.png -------------------------------------------------------------------------------- /lib/QMBForm/src/main/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quemb/QMBForm/95ddd131669531e61d75a7515b29f374fb557272/lib/QMBForm/src/main/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /lib/QMBForm/src/main/res/drawable/section_seperator_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/res/layout/boolean_field_cell.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/res/layout/button_field_cell.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 11 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/res/layout/button_inline_field_cell.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 11 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/res/layout/check_field_cell.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 10 | 15 | 16 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/res/layout/date_field_cell.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 10 | 13 | 14 | 19 | 20 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/res/layout/date_inline_field_cell.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 11 | 14 | 15 | 20 | 21 | 25 | 26 | 27 | 28 | 29 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/res/layout/detail_html_text_vertical_field_cell.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 10 | 15 | 16 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/res/layout/detail_text_field_cell.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 10 | 15 | 16 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/res/layout/detail_text_inline_field_cell.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 10 | 15 | 16 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/res/layout/detail_text_vertical_field_cell.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 10 | 15 | 16 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/res/layout/edit_text_field_cell.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 10 | 14 | 15 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/res/layout/edit_text_inline_field_cell.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 10 | 16 | 17 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/res/layout/edit_text_view_field_cell.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 10 | 14 | 15 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/res/layout/edit_text_view_inline_field_cell.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 10 | 16 | 17 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/res/layout/integer_slider_field_cell.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 10 | 13 | 14 | 19 | 20 | 24 | 25 | 26 | 27 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/res/layout/section_cell.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 10 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/res/layout/section_seperator_cell.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/res/layout/spinner_field_cell.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 10 | android:layout_height="wrap_content" 11 | 12 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/res/layout/spinner_inline_field_cell.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 10 | 16 | 17 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/res/layout/text_field_cell.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 10 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/res/layout/text_picker_field_cell.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 10 | 14 | 15 | 21 | 22 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/res/layout/time_inline_field_cell.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 11 | 14 | 15 | 20 | 21 | 25 | 26 | 27 | 28 | 29 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/res/values-de/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | QMBForm 3 | Keine Einträge 4 | Zur Zeit liegen keine Einträge vor 5 | Keine korrekte E-Mail Adresse 6 | ist erforderlich 7 | Bitte überprüfen Sie Ihre Eingaben 8 | ist ein erforderliches Feld 9 | Auswählen 10 | Abbrechen 11 | Fertig 12 | Wähle eine Höhe 13 | Fuß 14 | Inches 15 | cm 16 | 17 | muss größer als 0 sein 18 | 19 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/res/values/attr.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFFFFFFF 4 | #000000 5 | 6 | #FFFFFF 7 | #777777 8 | #00000000 9 | #ffa13b3a 10 | #ff55a14d 11 | 12 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 5 | -------------------------------------------------------------------------------- /lib/QMBForm/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | QMBForm 3 | No entries 4 | No entries are made 5 | is not a valid email 6 | is required 7 | Please check your entries 8 | is a required field 9 | Select 10 | Cancel 11 | Done 12 | Select your height 13 | feet 14 | inches 15 | cm 16 | 17 | must be greater than zero 18 | 19 | -------------------------------------------------------------------------------- /lib/QMBForm/src/test/java/com/quemb/qmbform/AnnotationFormTest.java: -------------------------------------------------------------------------------- 1 | package com.quemb.qmbform; 2 | 3 | import com.quemb.qmbform.annotation.FormDescriptorAnnotationFactory; 4 | import com.quemb.qmbform.annotation.FormElement; 5 | import com.quemb.qmbform.annotation.FormElementDelegate; 6 | import com.quemb.qmbform.annotation.FormOptionsObjectElement; 7 | import com.quemb.qmbform.descriptor.FormDescriptor; 8 | import com.quemb.qmbform.descriptor.RowDescriptor; 9 | 10 | import org.junit.After; 11 | import org.junit.Before; 12 | import org.junit.Test; 13 | import org.junit.runner.RunWith; 14 | import org.robolectric.Robolectric; 15 | import org.robolectric.RobolectricTestRunner; 16 | import org.robolectric.annotation.Config; 17 | 18 | import android.app.Activity; 19 | import android.widget.ListView; 20 | 21 | import java.lang.reflect.Field; 22 | import java.util.Map; 23 | 24 | import static junit.framework.Assert.assertTrue; 25 | import static org.hamcrest.MatcherAssert.assertThat; 26 | import static org.hamcrest.core.Is.is; 27 | import static org.hamcrest.core.IsNull.notNullValue; 28 | import static org.hamcrest.core.IsNull.nullValue; 29 | 30 | /** 31 | * Created by pmaccamp on 9/14/2015. 32 | */ 33 | @Config(constants = BuildConfig.class) 34 | @RunWith(RobolectricTestRunner.class) 35 | public class AnnotationFormTest { 36 | private Activity activity; 37 | private TestUserClass testUserClass; 38 | 39 | public class TestUserClass implements FormElementDelegate { 40 | @FormElement( 41 | rowDescriptorType = RowDescriptor.FormRowDescriptorTypeInteger, 42 | required = true, 43 | section = android.R.string.unknownName 44 | ) 45 | public int age; 46 | 47 | @FormElement( 48 | rowDescriptorType = RowDescriptor.FormRowDescriptorTypeText, 49 | required = true, 50 | section = android.R.string.unknownName 51 | ) 52 | public String name; 53 | 54 | @FormElement( 55 | rowDescriptorType = RowDescriptor.FormRowDescriptorTypeText, 56 | section = android.R.string.untitled 57 | ) 58 | public String option; 59 | 60 | 61 | public TestUserClass(int age, String name, int bodyfat) { 62 | this.age = age; 63 | this.name = name; 64 | } 65 | 66 | @Override 67 | public boolean shouldAddRowDescriptorForField(RowDescriptor rowDescriptor, Field field) { 68 | 69 | if (rowDescriptor.getTag().equals("option")){ 70 | return this.option != null; 71 | } 72 | 73 | return true; 74 | } 75 | } 76 | 77 | @Before 78 | public void setUp() { 79 | activity = Robolectric.buildActivity(Activity.class).create().get(); 80 | testUserClass = new TestUserClass(25, "John", 10); 81 | } 82 | 83 | @Test 84 | public void hasCorrectFormValues() { 85 | FormDescriptorAnnotationFactory factory = new FormDescriptorAnnotationFactory(activity); 86 | FormDescriptor formDescriptor = factory.createFormDescriptorFromAnnotatedClass(testUserClass); 87 | 88 | final FormManager formManager = new FormManager(); 89 | ListView listView = new ListView(activity); 90 | formManager.setup(formDescriptor, listView, activity); 91 | 92 | Map formValues = formDescriptor.getFormValues(); 93 | 94 | assertThat((int) formValues.get("age"), is(25)); 95 | assertThat((String) formValues.get("name"), is("John")); 96 | } 97 | 98 | @Test 99 | public void shouldNotIncludeSection() { 100 | 101 | FormDescriptorAnnotationFactory factory = new FormDescriptorAnnotationFactory(activity); 102 | FormDescriptor formDescriptor = factory.createFormDescriptorFromAnnotatedClass(testUserClass); 103 | 104 | assertThat(formDescriptor.countOfSections(), is(1)); 105 | assertThat(formDescriptor.findRowDescriptor("option"), nullValue()); 106 | 107 | } 108 | 109 | @Test 110 | public void shouldIncludeSection() { 111 | 112 | FormDescriptorAnnotationFactory factory = new FormDescriptorAnnotationFactory(activity); 113 | testUserClass.option = "mock"; 114 | FormDescriptor formDescriptor = factory.createFormDescriptorFromAnnotatedClass(testUserClass); 115 | 116 | assertThat(formDescriptor.countOfSections(), is(2)); 117 | assertThat(formDescriptor.findRowDescriptor("option"), notNullValue()); 118 | 119 | } 120 | 121 | @After 122 | public void tearDown() { 123 | 124 | } 125 | 126 | } 127 | -------------------------------------------------------------------------------- /lib/QMBForm/src/test/java/com/quemb/qmbform/FormBooleanFieldCellTest.java: -------------------------------------------------------------------------------- 1 | package com.quemb.qmbform; 2 | 3 | import com.quemb.qmbform.descriptor.RowDescriptor; 4 | import com.quemb.qmbform.view.FormBooleanFieldCell; 5 | 6 | import org.junit.After; 7 | import org.junit.Before; 8 | import org.junit.Test; 9 | import org.junit.runner.RunWith; 10 | import org.robolectric.Robolectric; 11 | import org.robolectric.RobolectricTestRunner; 12 | import org.robolectric.annotation.Config; 13 | 14 | import android.app.Activity; 15 | 16 | import static org.hamcrest.MatcherAssert.assertThat; 17 | import static org.hamcrest.core.Is.is; 18 | 19 | /** 20 | * Created by tonimoeckel on 02.09.14. 21 | */ 22 | @Config(constants = BuildConfig.class) 23 | @RunWith(RobolectricTestRunner.class) 24 | public class FormBooleanFieldCellTest { 25 | 26 | 27 | private Activity activity; 28 | 29 | @Before 30 | public void setUp() { 31 | activity = Robolectric.buildActivity(Activity.class).create().get(); 32 | } 33 | 34 | @Test 35 | public void shouldBeDisabled(){ 36 | 37 | RowDescriptor rowDescriptor = RowDescriptor.newInstance("disabled", RowDescriptor.FormRowDescriptorTypeBooleanSwitch); 38 | rowDescriptor.setDisabled(true); 39 | 40 | FormBooleanFieldCell testCell = new FormBooleanFieldCell(activity, rowDescriptor); 41 | 42 | assertThat(testCell.getSwitch().isEnabled(), is(false)); 43 | 44 | } 45 | 46 | @After 47 | public void tearDown() { 48 | 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /lib/QMBForm/src/test/java/com/quemb/qmbform/FormButtonFieldCellTest.java: -------------------------------------------------------------------------------- 1 | package com.quemb.qmbform; 2 | 3 | import com.quemb.qmbform.descriptor.RowDescriptor; 4 | import com.quemb.qmbform.descriptor.Value; 5 | 6 | import org.junit.After; 7 | import org.junit.Before; 8 | import org.junit.Test; 9 | import org.junit.runner.RunWith; 10 | import org.robolectric.Robolectric; 11 | import org.robolectric.RobolectricTestRunner; 12 | import org.robolectric.annotation.Config; 13 | 14 | import android.app.Activity; 15 | 16 | import static org.hamcrest.MatcherAssert.assertThat; 17 | import static org.hamcrest.core.IsNull.nullValue; 18 | 19 | /** 20 | * Created by tonimoeckel on 02.09.14. 21 | */ 22 | @Config(constants = BuildConfig.class) 23 | @RunWith(RobolectricTestRunner.class) 24 | public class FormButtonFieldCellTest { 25 | private Activity activity; 26 | 27 | @Before 28 | public void setUp() { 29 | activity = Robolectric.buildActivity(Activity.class).create().get(); 30 | } 31 | 32 | @Test 33 | public void shouldBeDisabled(){ 34 | 35 | RowDescriptor rowDescriptor = RowDescriptor.newInstance("pickerDisabled",RowDescriptor.FormRowDescriptorTypeSelectorPickerDialog, "Picker Disabled", new Value("Value")); 36 | rowDescriptor.setDisabled(false); 37 | 38 | assertThat( rowDescriptor.getOnFormRowClickListener(), nullValue()); 39 | 40 | } 41 | 42 | @After 43 | public void tearDown() { 44 | 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /lib/QMBForm/src/test/java/com/quemb/qmbform/FormCheckFieldCellTest.java: -------------------------------------------------------------------------------- 1 | package com.quemb.qmbform; 2 | 3 | import com.quemb.qmbform.descriptor.RowDescriptor; 4 | import com.quemb.qmbform.view.FormCheckFieldCell; 5 | 6 | import org.junit.After; 7 | import org.junit.Before; 8 | import org.junit.Test; 9 | import org.junit.runner.RunWith; 10 | import org.robolectric.Robolectric; 11 | import org.robolectric.RobolectricTestRunner; 12 | import org.robolectric.annotation.Config; 13 | 14 | import android.app.Activity; 15 | 16 | import static org.hamcrest.MatcherAssert.assertThat; 17 | import static org.hamcrest.core.Is.is; 18 | 19 | /** 20 | * Created by tonimoeckel on 02.09.14. 21 | */ 22 | @Config(constants = BuildConfig.class) 23 | @RunWith(RobolectricTestRunner.class) 24 | public class FormCheckFieldCellTest { 25 | 26 | 27 | private Activity activity; 28 | 29 | @Before 30 | public void setUp() { 31 | activity = Robolectric.buildActivity(Activity.class).create().get(); 32 | } 33 | 34 | @Test 35 | public void shouldBeDisabled(){ 36 | 37 | RowDescriptor rowDescriptor = RowDescriptor.newInstance("disabled", RowDescriptor.FormRowDescriptorTypeBooleanCheck); 38 | rowDescriptor.setDisabled(true); 39 | 40 | FormCheckFieldCell testCell = new FormCheckFieldCell(activity, rowDescriptor); 41 | 42 | assertThat(testCell.getCheckBox().isEnabled(), is(false)); 43 | 44 | } 45 | 46 | @After 47 | public void tearDown() { 48 | 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /lib/QMBForm/src/test/java/com/quemb/qmbform/FormDateFieldCellTest.java: -------------------------------------------------------------------------------- 1 | package com.quemb.qmbform; 2 | 3 | import com.quemb.qmbform.descriptor.RowDescriptor; 4 | import com.quemb.qmbform.descriptor.Value; 5 | import com.quemb.qmbform.view.FormTimeDialogFieldCell; 6 | 7 | import org.junit.After; 8 | import org.junit.Before; 9 | import org.junit.Test; 10 | import org.junit.runner.RunWith; 11 | import org.robolectric.Robolectric; 12 | import org.robolectric.RobolectricTestRunner; 13 | import org.robolectric.annotation.Config; 14 | 15 | import android.app.Activity; 16 | 17 | import java.util.Date; 18 | 19 | import static org.hamcrest.MatcherAssert.assertThat; 20 | import static org.hamcrest.core.Is.is; 21 | 22 | /** 23 | * Created by tonimoeckel on 02.09.14. 24 | */ 25 | @Config(constants = BuildConfig.class) 26 | @RunWith(RobolectricTestRunner.class) 27 | public class FormDateFieldCellTest { 28 | 29 | 30 | private Activity activity; 31 | 32 | @Before 33 | public void setUp() { 34 | activity = Robolectric.buildActivity(Activity.class).create().get(); 35 | } 36 | 37 | @Test 38 | public void shouldBeDisabled(){ 39 | RowDescriptor rowDescriptor = RowDescriptor.newInstance("timeDialog",RowDescriptor.FormRowDescriptorTypeTime, "Time Dialog", new Value(new Date())); 40 | rowDescriptor.setDisabled(true); 41 | 42 | FormTimeDialogFieldCell testCell = new FormTimeDialogFieldCell(activity, rowDescriptor); 43 | 44 | assertThat(testCell.getTextView().isEnabled(), is(false)); 45 | 46 | } 47 | 48 | @After 49 | public void tearDown() { 50 | 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /lib/QMBForm/src/test/java/com/quemb/qmbform/FormEditFieldCellTest.java: -------------------------------------------------------------------------------- 1 | package com.quemb.qmbform; 2 | 3 | import com.quemb.qmbform.descriptor.RowDescriptor; 4 | import com.quemb.qmbform.view.FormEditIntegerFieldCell; 5 | 6 | import org.junit.After; 7 | import org.junit.Before; 8 | import org.junit.Test; 9 | import org.junit.runner.RunWith; 10 | import org.robolectric.Robolectric; 11 | import org.robolectric.RobolectricTestRunner; 12 | import org.robolectric.annotation.Config; 13 | 14 | import android.app.Activity; 15 | 16 | import static org.hamcrest.MatcherAssert.assertThat; 17 | import static org.hamcrest.core.Is.is; 18 | 19 | /** 20 | * Created by tonimoeckel on 02.09.14. 21 | */ 22 | @Config(constants = BuildConfig.class) 23 | @RunWith(RobolectricTestRunner.class) 24 | public class FormEditFieldCellTest { 25 | 26 | 27 | private Activity activity; 28 | 29 | @Before 30 | public void setUp() { 31 | activity = Robolectric.buildActivity(Activity.class).create().get(); 32 | } 33 | 34 | @Test 35 | public void shouldBeDisabled(){ 36 | 37 | RowDescriptor rowDescriptor = RowDescriptor.newInstance("disabled", RowDescriptor.FormRowDescriptorTypeInteger); 38 | rowDescriptor.setDisabled(true); 39 | 40 | FormEditIntegerFieldCell testCell = new FormEditIntegerFieldCell(activity, rowDescriptor); 41 | 42 | assertThat(testCell.getEditText().isEnabled(), is(false)); 43 | 44 | } 45 | 46 | @After 47 | public void tearDown() { 48 | 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /lib/QMBForm/src/test/java/com/quemb/qmbform/FormIntegerSliderCellTest.java: -------------------------------------------------------------------------------- 1 | package com.quemb.qmbform; 2 | 3 | import com.quemb.qmbform.descriptor.RowDescriptor; 4 | import com.quemb.qmbform.descriptor.Value; 5 | import com.quemb.qmbform.view.FormIntegerSliderFieldCell; 6 | 7 | import org.junit.After; 8 | import org.junit.Before; 9 | import org.junit.Test; 10 | import org.junit.runner.RunWith; 11 | import org.robolectric.Robolectric; 12 | import org.robolectric.RobolectricTestRunner; 13 | import org.robolectric.annotation.Config; 14 | 15 | import android.app.Activity; 16 | 17 | import static org.hamcrest.MatcherAssert.assertThat; 18 | import static org.hamcrest.core.Is.is; 19 | 20 | /** 21 | * Created by tonimoeckel on 02.09.14. 22 | */ 23 | @Config(constants = BuildConfig.class) 24 | @RunWith(RobolectricTestRunner.class) 25 | public class FormIntegerSliderCellTest { 26 | 27 | 28 | private Activity activity; 29 | 30 | @Before 31 | public void setUp() { 32 | activity = Robolectric.buildActivity(Activity.class).create().get(); 33 | } 34 | 35 | @Test 36 | public void shouldBeDisabled(){ 37 | 38 | RowDescriptor rowDescriptor = RowDescriptor.newInstance("integerSlider",RowDescriptor.FormRowDescriptorTypeIntegerSlider, "Integer Slider", new Value(50)); 39 | rowDescriptor.setDisabled(true); 40 | 41 | FormIntegerSliderFieldCell testCell = new FormIntegerSliderFieldCell(activity, rowDescriptor); 42 | 43 | assertThat(testCell.getSeekBar().isEnabled(), is(false)); 44 | 45 | } 46 | 47 | @After 48 | public void tearDown() { 49 | 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /lib/QMBForm/src/test/java/com/quemb/qmbform/FormManagerTest.java: -------------------------------------------------------------------------------- 1 | package com.quemb.qmbform; 2 | 3 | import com.quemb.qmbform.descriptor.FormDescriptor; 4 | 5 | import org.junit.After; 6 | import org.junit.Before; 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | import org.robolectric.Robolectric; 10 | import org.robolectric.RobolectricTestRunner; 11 | import org.robolectric.annotation.Config; 12 | 13 | import android.app.Activity; 14 | import android.widget.ListView; 15 | 16 | import static org.hamcrest.MatcherAssert.assertThat; 17 | import static org.hamcrest.core.Is.is; 18 | import static org.hamcrest.core.IsNull.notNullValue; 19 | 20 | /** 21 | * Created by tonimoeckel on 12.08.14. 22 | */ 23 | @Config(constants = BuildConfig.class) 24 | @RunWith(RobolectricTestRunner.class) 25 | public class FormManagerTest { 26 | 27 | private FormManager formManager; 28 | private Activity activity; 29 | 30 | @Before 31 | public void setUp() { 32 | formManager = new FormManager(); 33 | activity = Robolectric.buildActivity(Activity.class).create().get(); 34 | } 35 | 36 | @Test 37 | public void shouldSetupListView(){ 38 | 39 | ListView listView = new ListView(activity); 40 | FormDescriptor formDescriptor = new FormDescriptor(); 41 | formManager.setup(formDescriptor, listView, activity); 42 | 43 | assertThat(listView.getAdapter(), is(notNullValue())); 44 | 45 | } 46 | 47 | @After 48 | public void tearDown() { 49 | 50 | } 51 | 52 | } -------------------------------------------------------------------------------- /lib/QMBForm/src/test/java/com/quemb/qmbform/FormPickerFieldCellTest.java: -------------------------------------------------------------------------------- 1 | package com.quemb.qmbform; 2 | 3 | import com.quemb.qmbform.descriptor.RowDescriptor; 4 | import com.quemb.qmbform.view.FormPickerDialogFieldCell; 5 | 6 | import org.junit.After; 7 | import org.junit.Before; 8 | import org.junit.Test; 9 | import org.junit.runner.RunWith; 10 | import org.robolectric.Robolectric; 11 | import org.robolectric.RobolectricTestRunner; 12 | import org.robolectric.annotation.Config; 13 | 14 | import android.app.Activity; 15 | 16 | import static org.hamcrest.MatcherAssert.assertThat; 17 | import static org.hamcrest.core.Is.is; 18 | 19 | /** 20 | * Created by tonimoeckel on 02.09.14. 21 | */ 22 | @Config(constants = BuildConfig.class) 23 | @RunWith(RobolectricTestRunner.class) 24 | public class FormPickerFieldCellTest { 25 | 26 | 27 | private Activity activity; 28 | 29 | @Before 30 | public void setUp() { 31 | activity = Robolectric.buildActivity(Activity.class).create().get(); 32 | } 33 | 34 | @Test 35 | public void shouldBeDisabled(){ 36 | 37 | RowDescriptor rowDescriptor = RowDescriptor.newInstance("picker",RowDescriptor.FormRowDescriptorTypeButton, "Tap Me"); 38 | rowDescriptor.setDisabled(true); 39 | 40 | FormPickerDialogFieldCell testCell = new FormPickerDialogFieldCell(activity, rowDescriptor); 41 | 42 | assertThat( testCell.getTextView().isClickable(), is(false)); 43 | 44 | } 45 | 46 | @After 47 | public void tearDown() { 48 | 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /lib/QMBForm/src/test/java/com/quemb/qmbform/ValidationTest.java: -------------------------------------------------------------------------------- 1 | package com.quemb.qmbform; 2 | 3 | import com.quemb.qmbform.annotation.FormValidator; 4 | import com.quemb.qmbform.annotation.validators.EmailValidator; 5 | import com.quemb.qmbform.descriptor.RowDescriptor; 6 | import com.quemb.qmbform.descriptor.RowValidationError; 7 | import com.quemb.qmbform.descriptor.Value; 8 | 9 | import org.junit.After; 10 | import org.junit.Before; 11 | import org.junit.Test; 12 | 13 | import static org.hamcrest.MatcherAssert.assertThat; 14 | import static org.hamcrest.core.Is.is; 15 | 16 | /** 17 | * Created by pmaccamp on 9/14/2015. 18 | */ 19 | 20 | // @Config(constants = BuildConfig.class) 21 | // @RunWith(RobolectricTestRunner.class) 22 | public class ValidationTest { 23 | @Before 24 | public void setUp() { 25 | 26 | } 27 | 28 | @Test 29 | public void isValidRow() { 30 | RowDescriptor rowDescriptor = RowDescriptor.newInstance("valid", 31 | RowDescriptor.FormRowDescriptorTypeEmail, 32 | "Email Test", 33 | new Value("test@yahoo.com")); 34 | 35 | rowDescriptor.addValidator(new EmailValidator()); 36 | 37 | //Add true dummy validator to test multiple validation 38 | rowDescriptor.addValidator(new FormValidator() { 39 | @Override 40 | public RowValidationError validate(RowDescriptor descriptor) { 41 | return descriptor.getValueData().equals("test@yahoo.com") ? 42 | null : new RowValidationError(descriptor, R.string.test_error); 43 | } 44 | }); 45 | 46 | assertThat(rowDescriptor.isValid(), is(true)); 47 | } 48 | 49 | @Test 50 | public void isInvalidRow() { 51 | RowDescriptor rowDescriptor = RowDescriptor.newInstance("valid", 52 | RowDescriptor.FormRowDescriptorTypeEmail, 53 | "Email Test", 54 | new Value("notavalidemail")); 55 | 56 | //Add true dummy validator to test multiple validation 57 | rowDescriptor.addValidator(new FormValidator() { 58 | @Override 59 | public RowValidationError validate(RowDescriptor descriptor) { 60 | return descriptor.getValueData().equals("notavalidemail") ? 61 | null : new RowValidationError(descriptor, R.string.test_error); 62 | } 63 | }); 64 | 65 | rowDescriptor.addValidator(new EmailValidator()); 66 | 67 | assertThat(rowDescriptor.isValid(), is(false)); 68 | } 69 | 70 | @After 71 | public void tearDown() { 72 | 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /lib/QMBForm/src/test/java/com/quemb/qmbform/ValueTest.java: -------------------------------------------------------------------------------- 1 | package com.quemb.qmbform; 2 | 3 | import com.quemb.qmbform.descriptor.OnValueChangeListener; 4 | import com.quemb.qmbform.descriptor.Value; 5 | 6 | import org.junit.After; 7 | import org.junit.Before; 8 | import org.junit.Test; 9 | import org.junit.runner.RunWith; 10 | import org.robolectric.RobolectricTestRunner; 11 | import org.robolectric.annotation.Config; 12 | 13 | import static org.hamcrest.MatcherAssert.assertThat; 14 | import static org.hamcrest.core.Is.is; 15 | 16 | /** 17 | * Created by tonimoeckel on 28.08.14. 18 | */ 19 | @Config(constants = BuildConfig.class) 20 | @RunWith(RobolectricTestRunner.class) 21 | public class ValueTest { 22 | 23 | private Value value; 24 | private Integer resultInt = 0; 25 | 26 | @Before 27 | public void setUp() { 28 | value = new Value(50); 29 | } 30 | 31 | @Test 32 | public void shouldCallListener() { 33 | 34 | OnValueChangeListener listener = new OnValueChangeListener() { 35 | @Override 36 | public void onChange(Integer value) { 37 | resultInt = value; 38 | } 39 | }; 40 | value.setOnValueChangeListener(listener); 41 | value.setValue(100); 42 | 43 | assertThat(resultInt, is(100)); 44 | 45 | } 46 | 47 | @After 48 | public void tearDown() { 49 | 50 | } 51 | 52 | } -------------------------------------------------------------------------------- /lib/QMBForm/src/test/java/com/quemb/qmbform/view/FormBaseCellTest.java: -------------------------------------------------------------------------------- 1 | package com.quemb.qmbform.view; 2 | 3 | import com.quemb.qmbform.BuildConfig; 4 | import com.quemb.qmbform.descriptor.RowDescriptor; 5 | import com.quemb.qmbform.descriptor.SectionDescriptor; 6 | 7 | import org.junit.Before; 8 | import org.junit.Test; 9 | import org.junit.runner.RunWith; 10 | import org.robolectric.Robolectric; 11 | import org.robolectric.RobolectricTestRunner; 12 | import org.robolectric.annotation.Config; 13 | 14 | import android.app.Activity; 15 | import android.inputmethodservice.Keyboard; 16 | 17 | import static org.junit.Assert.*; 18 | 19 | /** 20 | * Created by Toni on 25.10.15. 21 | */ 22 | @Config(constants = BuildConfig.class) 23 | @RunWith(RobolectricTestRunner.class) 24 | public class FormBaseCellTest { 25 | 26 | FormBaseCell cell; 27 | 28 | @Before 29 | public void setUp() throws Exception { 30 | 31 | Activity activity = Robolectric.buildActivity(Activity.class).create().get(); 32 | SectionDescriptor sectionDescriptor = SectionDescriptor.newInstance("test"); 33 | RowDescriptor rowDescriptor = RowDescriptor.newInstance("sample"); 34 | sectionDescriptor.addRow(rowDescriptor); 35 | cell = new FormBaseCell(activity,rowDescriptor) { 36 | @Override 37 | protected int getResource() { 38 | return 0; 39 | } 40 | 41 | @Override 42 | protected void update() { 43 | 44 | } 45 | }; 46 | 47 | } 48 | 49 | @Test 50 | public void testShouldCreateMultiValueWrapper() { 51 | 52 | 53 | assertNotNull(cell.createMultiValueWrapper()); 54 | 55 | 56 | } 57 | } -------------------------------------------------------------------------------- /lib/QMBForm/src/test/resources/com/quemb/qmbform/robolectric.properties: -------------------------------------------------------------------------------- 1 | sdk=18 2 | manifest=lib/QMBForm/src/main/AndroidManifest.xml 3 | constants=com.quemb.qmbform.BuildConfig -------------------------------------------------------------------------------- /resources/sample_cast.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quemb/QMBForm/95ddd131669531e61d75a7515b29f374fb557272/resources/sample_cast.gif -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':lib:QMBForm' 2 | --------------------------------------------------------------------------------