...
 
Commits (8)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
// mavenCentral()
jcenter()
google()
}
......
......@@ -63,12 +63,12 @@ if (secretsFile.exists()) {
}
android {
compileSdkVersion(26)
compileSdkVersion(27)
buildToolsVersion('26.0.2')
defaultConfig {
applicationId('id.ac.stis.capi')
minSdkVersion(16)
targetSdkVersion(26)
targetSdkVersion(27)
versionName getVersionName()
testInstrumentationRunner('android.support.test.runner.AndroidJUnitRunner')
multiDexEnabled true
......@@ -140,9 +140,9 @@ allprojects {
dependencies {
compile fileTree(include: '*.jar', dir: 'libs')
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:design:26.1.0'
compile 'com.android.support:cardview-v7:26.1.0'
compile 'com.android.support:appcompat-v7:27.1.0'
compile 'com.android.support:design:27.1.0'
compile 'com.android.support:cardview-v7:27.1.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.google.android.gms:play-services-analytics:10.0.1'
compile 'com.google.android.gms:play-services-auth:10.0.1'
......@@ -178,8 +178,8 @@ dependencies {
exclude group: 'org.apache.httpcomponents'
}
compile 'com.jakewharton.timber:timber:4.5.1'
compile 'com.android.support:customtabs:26.1.0'
compile 'com.android.support:support-v13:26.1.0'
compile 'com.android.support:customtabs:27.1.0'
compile 'com.android.support:support-v13:27.1.0'
compile 'com.google.zxing:core:3.2.0'
compile 'com.journeyapps:zxing-android-embedded:3.5.0'
compile 'net.danlew:android.joda:2.9.9'
......@@ -209,9 +209,12 @@ dependencies {
androidTestCompile 'com.squareup.okhttp3:mockwebserver:3.6.0'
// tempat custom dependencies capi-stis, supaya gampang updatenya
// sudah ada ui-android, peta wb, revalidasi (soon)
compile('com.mikepenz:materialdrawer:6.0.7@aar') {
transitive = true
}
// compile('com.mikepenz:materialdrawer:6.0.7@aar') {
// transitive = true
// }
compile 'com.mikepenz:materialdrawer:6.0.7'
compile('com.mapbox.mapboxsdk:mapbox-android-sdk:5.0.2@aar') {
transitive = true
}
......@@ -219,8 +222,8 @@ dependencies {
// compile project(':vsen_p')
compile 'org.apache.commons:commons-lang3:3.6'
compile 'com.getbase:floatingactionbutton:1.10.1'
compile 'com.android.support:support-v4:26.1.0'
compile 'com.android.support:recyclerview-v7:26.1.0'
compile 'com.android.support:support-v4:27.1.0'
compile 'com.android.support:recyclerview-v7:27.1.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.volley:volley:1.0.0'
compile 'com.mapbox.mapboxsdk:mapbox-android-services:2.1.2'
......
......@@ -87,6 +87,8 @@ public class CapiFormFragment extends Fragment implements FormListDownloaderList
private static final String FORM_VERSION_KEY = "formversion";
private static final String HAS_BEEN_DOWNLOADED = "hasbeendownloaded";
private static final String FORM_TYPE_KEY = "formtype";
private static final boolean EXIT = true;
private static final boolean DO_NOT_EXIT = false;
......@@ -226,11 +228,14 @@ public class CapiFormFragment extends Fragment implements FormListDownloaderList
String formName = c.getString(c.getColumnIndex(FormsProviderAPI.FormsColumns.DISPLAY_NAME));
String formVersion = c.getString(c.getColumnIndex(FormsProviderAPI.FormsColumns.JR_FORM_ID));
String formId = c.getString(c.getColumnIndex(FormsProviderAPI.FormsColumns.JR_FORM_ID));
String formType = c.getString(c.getColumnIndex(FormsProviderAPI.FormsColumns.FORM_TYPE));
item.put(FORMNAME, formName);
item.put(FORM_ID_KEY, formId);
item.put(FORM_VERSION_KEY, formVersion);
item.put(HAS_BEEN_DOWNLOADED, "true");
item.put(FORM_TYPE_KEY, formType);
downloadedFormsBefore.add(item);
} while (c.moveToNext());
......@@ -418,10 +423,21 @@ public class CapiFormFragment extends Fragment implements FormListDownloaderList
ArrayList<HashMap<String, String>> downloadedFilteredFormList = new ArrayList<>();
ArrayList<HashMap<String, String>> unDownloadedFilteredFormList = new ArrayList<>();
FormsDao formsDao = new FormsDao();
for (int idx = 0; idx < mFilteredFormList.size(); idx++) {
HashMap<String, String> item = mFilteredFormList.get(idx);
Cursor c = formsDao.getFormsCursor(FormsProviderAPI.FormsColumns.JR_FORM_ID + "=?",
new String[]{item.get(FORM_ID_KEY)});
c.moveToFirst();
if (item.get(HAS_BEEN_DOWNLOADED) != null && item.get(HAS_BEEN_DOWNLOADED).equals("true")) {
if (isFormInActiveSurvey(item)) downloadedFilteredFormList.add(item);
if (isFormInActiveSurvey(item)) {
item.put(FORM_TYPE_KEY, c.getString(c.getColumnIndex(FormsProviderAPI.FormsColumns.FORM_TYPE)));
downloadedFilteredFormList.add(item);
}
} else {
if (isLocalFormSuperseded(item.get(FORM_ID_KEY), item.get(FORM_VERSION_KEY))) {
//need to downloaded
......@@ -430,9 +446,13 @@ public class CapiFormFragment extends Fragment implements FormListDownloaderList
} else {
//has been downloaded
item.put(HAS_BEEN_DOWNLOADED, "true");
item.put(FORM_TYPE_KEY, c.getString(c.getColumnIndex(FormsProviderAPI.FormsColumns.FORM_TYPE)));
if (isFormInActiveSurvey(item)) downloadedFilteredFormList.add(item);
}
}
c.close();
}
downloadedFilteredFormList.addAll(unDownloadedFilteredFormList);
......@@ -492,6 +512,11 @@ public class CapiFormFragment extends Fragment implements FormListDownloaderList
item.put(FORM_ID_KEY, details.formID);
item.put(FORM_VERSION_KEY, details.formVersion);
// FormsDao formsDao = new FormsDao();
// Cursor c = formsDao.getFormsCursor(FormsProviderAPI.FormsColumns.JR_FORM_ID + "=?",
// new String[]{details.formID});
// item.put(FORM_TYPE_KEY, c.getString(c.getColumnIndex(FormsProviderAPI.FormsColumns.FORM_TYPE)));
if (!mFormListContain(details.formName)) {
// Insert the new form in alphabetical order.
if (mFormList.size() == 0) {
......@@ -597,85 +622,6 @@ public class CapiFormFragment extends Fragment implements FormListDownloaderList
Set<FormDetails> keys = result.keySet();
//RAHADI: Comments to resolve dependencies
// StringBuilder b = new StringBuilder();
// for (FormDetails k : keys) {
// b.append(k.formName + " (" + ((k.formVersion != null) ? (this.getString(R.string.version) + ": " + k.formVersion + " ") : "") + "ID: " + k.formID + ") - " + result.get(k));
// b.append("\n\n");
//
// //RAHADI
// if (result.get(k).equalsIgnoreCase(Collect.getInstance().getString(R.string.success))) {
// Cursor c = Collect.getInstance().getContentResolver().query(FormsProviderAPI.FormsColumns.CONTENT_URI, new String[]{FormsProviderAPI.FormsColumns.FORM_FILE_PATH}, FormsProviderAPI.FormsColumns.JR_FORM_ID + "=?", new String[]{k.formID}, null);
// if (c != null && c.moveToFirst() && c.getCount() == 1) {
// String formPath = c.getString(c.getColumnIndex(FormsProviderAPI.FormsColumns.FORM_FILE_PATH));
// c.close();
// File file = new File(formPath);
// if (file.exists()) {
// try {
// FileInputStream fis = new FileInputStream(file);
// KXmlParser parser = new KXmlParser();
// parser.setInput(new InputStreamReader(fis));
// Document doc = new Document();
// doc.parse(parser);
//
// Element root = doc.getRootElement();
// HashMap<String, String> namespaceSet = new HashMap<>();
// for (int i = 0; i < root.getAttributeCount(); i++) {
// if (root.getAttributeName(i).contains("xmlns")) {
// namespaceSet.put(root.getAttributeName(i), root.getAttributeValue(i));
// }
// }
// Element head = root.getElement(root.getNamespace(), "h:head");
// Element model = getChildElement(head, "model");
// Element instance = getChildElement(model, "instance");
//
// int i;
// int idx = instance.getChildCount();
// for (i = 0; i < idx; i++) {
// if (instance.isText(i)) {
// continue;
// }
//
// if (instance.getType(i) == Element.ELEMENT) {
// break;
// }
// }
//
// if (i < idx) {
// Element e = instance.getElement(i);
//
// File out = new File(Collect.EMPTY_INSTANCES_PATH + File.separator + k.formName + ".xml");
// int j = 2;
// while (out.exists()) {
// out = new File(Collect.EMPTY_INSTANCES_PATH + File.separator + k.formName + "_" + j + ".xml");
// j++;
// }
// FileOutputStream fos = new FileOutputStream(out);
// KXmlSerializer serializer = new KXmlSerializer();
// serializer.setOutput(new OutputStreamWriter(fos));
// Set<String> nsKeys = namespaceSet.keySet();
// for (String key : nsKeys) {
// e.setAttribute(root.getNamespace(), key, namespaceSet.get(key));
// }
// e.write(serializer);
// serializer.flush();
// serializer.endDocument();
// fos.close();
//
// ContentValues v = new ContentValues();
// v.put(FormsProviderAPI.FormsColumns.EMPTY_INSTANCE_FILE_PATH, out.getAbsolutePath());
// Collect.getInstance().getContentResolver().update(FormsProviderAPI.FormsColumns.CONTENT_URI, v, FormsProviderAPI.FormsColumns.JR_FORM_ID + "=?", new String[]{k.formID});
// }
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// new GetGenerateTask(k.formID).execute(null);
// }
//
// }
// }
List<FormDetails> toDependenciesResolve = new ArrayList<>();
for (FormDetails k : keys) {
if (result.get(k).equalsIgnoreCase(Collect.getInstance().getString(R.string.success))) {
......
......@@ -321,7 +321,7 @@ public class FormHierarchyFragment extends Fragment implements AdapterView.OnIte
}
// Add this group name to the drop down list for this repeating group.
HierarchyElement h = formList.get(formList.size() - 1);
h.addChild(new HierarchyElement("rensponse "
h.addChild(new HierarchyElement("response "
+ (fc.getMultiplicity() + 1), null, null, Color.WHITE, CHILD, fc
.getIndex(),1));
break;
......
package id.ac.stis.capi.lessthink.activities;
import android.content.ContentUris;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.Toast;
import java.util.LinkedHashMap;
import java.io.File;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import id.ac.stis.capi.R;
import id.ac.stis.capi.collectiva.preferences.Constants;
import id.ac.stis.capi.lessthink.fragments.FormEntryDialogFragment;
import id.ac.stis.capi.lessthink.listeners.OnTableAddButtonClickListener;
import id.ac.stis.capi.lessthink.models.FormLabels;
import id.ac.stis.capi.lessthink.models.InstanceValues;
import id.ac.stis.capi.lessthink.utils.XmlUtils;
import id.ac.stis.capi.lessthink.views.TableFooterView;
import id.ac.stis.capi.lessthink.views.TableHeaderView;
import id.ac.stis.capi.lessthink.views.TableRowView;
import id.ac.stis.capi.odk.dao.FormsDao;
import id.ac.stis.capi.odk.dao.InstancesDao;
import id.ac.stis.capi.odk.dto.Form;
import id.ac.stis.capi.odk.dto.Instance;
import id.ac.stis.capi.odk.provider.FormsProviderAPI;
import id.ac.stis.capi.odk.provider.InstanceProviderAPI;
import id.ac.stis.capi.odk.utilities.ApplicationConstants;
import timber.log.Timber;
public class ListingInstanceActivity extends AppCompatActivity {
private static final String FORM_ID_KEY = "formid";
private static final String FORMNAME = "formname";
private TableHeaderView tableHeaderView;
private TableRowView tableRowView;
private TableFooterView tableFooterView;
private String formId, formName;
// private FormEntryDialogFragment entryDialogFragment;
private FormEntryDialogFragment entryDialogFragment;
@Override
protected void onCreate(Bundle savedInstanceState) {
......@@ -35,26 +56,33 @@ public class ListingInstanceActivity extends AppCompatActivity {
tableRowView = findViewById(R.id.row_view);
tableFooterView = findViewById(R.id.footer_view);
Map<String, String> headerList = new LinkedHashMap<>();
headerList.put("no_sls", "No. SLS");
headerList.put("no_bs", "No. BS");
headerList.put("no_bf", "No. BF");
headerList.put("no_nks", "No. NKS");
headerList.put("nama_krt", "Nama KRT");
FormLabels formLabels = new FormLabels("formId", headerList);
formId = getIntent().getStringExtra(FORM_ID_KEY);
formName = getIntent().getStringExtra(FORMNAME);
FormsDao formsDao = new FormsDao();
List<Form> forms = formsDao.getFormsFromCursor(formsDao.getFormsCursorForFormId(formId));
File file = new File(forms.get(0).getFormFilePath());
List<String> xPaths = XmlUtils.getInstanceXPathList(file);
FormLabels labels = XmlUtils.getFormLabels(formId, file, xPaths);
tableHeaderView.setColumns(formLabels);
tableHeaderView.setColumns(labels);
List<InstanceValues> instanceValues = new LinkedList<>();
for (int i = 0; i < 31; i++) {
Map<String, String> rowData = new LinkedHashMap<>();
rowData.put("no_sls", (i < 9 ? "00" : "0") + (i + 1));
rowData.put("no_bs", (i < 9 ? "00" : "0") + (i + 1));
rowData.put("no_bf", (i < 9 ? "00" : "0") + (i + 1));
rowData.put("no_nks", (i < 9 ? "00" : "0") + (i + 1));
rowData.put("nama_krt", "Nama KRT " + i);
instanceValues.add(new InstanceValues("instanceId" + i, "formId", rowData));
String selection = InstanceProviderAPI.InstanceColumns.LATEST + " =? AND " +
InstanceProviderAPI.InstanceColumns.JR_FORM_ID + " =?";
String[] selectionArgs = new String[]{InstanceProviderAPI.LATEST_VERSION, formId};
InstancesDao instancesDao = new InstancesDao();
// TODO: 30/06/2018 Sorting order
Cursor data = instancesDao.getInstancesCursor(null, selection, selectionArgs, null);
List<Instance> instanceList = instancesDao.getInstancesFromCursor(data);
for (Instance instance : instanceList) {
File f = new File(instance.getInstanceFilePath());
InstanceValues values = XmlUtils.getInstanceValues(instance.getInstanceUuid(), f, labels);
instanceValues.add(values);
}
tableRowView.setRows(instanceValues);
......@@ -62,8 +90,63 @@ public class ListingInstanceActivity extends AppCompatActivity {
tableRowView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(ListingInstanceActivity.this, "Click : " + view.getTag(), Toast.LENGTH_LONG).show();
// Toast.makeText(ListingInstanceActivity.this, "Click : " + view.getTag(), Toast.LENGTH_LONG).show();
String instanceUuid = view.getTag().toString();
// entryDialogFragment = FormEntryDialogFragment.newInstance(instanceUuid,
// FormEntryDialogFragment.MODE_EDIT, false);
entryDialogFragment = FormEntryDialogFragment.newInstance(instanceUuid,
FormEntryDialogFragment.MODE_EDIT, false);
entryDialogFragment.show(getSupportFragmentManager(), instanceUuid);
//
// Intent i =new Intent(ListingInstanceActivity.this, ListingFormEntryActivity.class);
// i.putExtra("instanceUuid", view.getTag().toString());
// startActivity(i);
}
});
tableFooterView.setOnTableAddButtonClickListener(new OnTableAddButtonClickListener() {
@Override
public void onAddButtonClick(View v) {
fillBlankForm();
}
});
}
@Override
public void onActivityResult(int requestCode, int resultCode, final Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
Timber.d("Activity Result : %s %s", requestCode, resultCode);
entryDialogFragment.onActivityResult(requestCode, resultCode, intent);
}
//todo: update yow
private void fillBlankForm() {
Cursor formslist = new FormsDao().getFormsCursor();
//getting id
long itemIdPosition = -1;
if (formslist.moveToFirst()) {
do {
if (formslist.getString(formslist.getColumnIndex(FormsProviderAPI.FormsColumns.JR_FORM_ID)).equals(formId)) {
itemIdPosition = formslist.getLong(formslist.getColumnIndex(FormsProviderAPI.FormsColumns._ID));
}
} while (formslist.moveToNext());
}
if (itemIdPosition > -1) {
// get uri to form
Uri formUri = ContentUris.withAppendedId(FormsProviderAPI.FormsColumns.CONTENT_URI, itemIdPosition);
// caller wants to view/edit a form, so launch formentryactivity
Intent intent = new Intent(Intent.ACTION_EDIT, formUri);
intent.putExtra("fillblankform", true);
intent.putExtra(Constants.CURRENT_FORMNAME, getIntent().getStringExtra(FORMNAME));
intent.putExtra(ApplicationConstants.BundleKeys.FORM_MODE, ApplicationConstants.FormModes.EDIT_SAVED);
startActivity(intent);
} else {
//xxxseharusnya tidak terjadi, tidak mungkin itemIdposition < 1
Toast.makeText(this, "Form not exist", Toast.LENGTH_SHORT).show();
}
}
}
package id.ac.stis.capi.lessthink.adapters;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import java.util.List;
import id.ac.stis.capi.lessthink.models.BaseHierarchy;
import timber.log.Timber;
/**
* Author : Rahadi Jalu
* Email : 14.8325@stis.ac.id
* Company: Politeknik Statistika STIS
*/
public class HierarchyAdapter extends RecyclerView.Adapter<HierarchyAdapter.ViewHolder> {
private List<BaseHierarchy> hierarchies;
public HierarchyAdapter(List<BaseHierarchy> hierarchies) {
this.hierarchies = hierarchies;
}
public void setHierarchies(List<BaseHierarchy> hierarchies) {
this.hierarchies = hierarchies;
}
public BaseHierarchy getItem(int position) {
return hierarchies.get(position);
}
@Override
public int getItemViewType(int position) {
return position;
}
@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
Timber.d("Creating with type %s", viewType);
// BaseHierarchy hierarchy = hierarchies.get(viewType);
// if (hierarchy instanceof PromptHierarchy) {
// ((PromptHierarchy) hierarchy).setOnChangeListener(onChangeListener);
// return new PromptViewHolder(hierarchy.getView());
// } else if (hierarchy instanceof CaptionHierarchy) {
// return new CaptionViewHolder(hierarchy.getView());
// } else {
// // Should not be happening
// return new ViewHolder(hierarchy.getView());
// }
return new ViewHolder(new LinearLayout(parent.getContext()));
}
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
// if (holder instanceof PromptViewHolder) {
// PromptHierarchy hierarchy = (PromptHierarchy) hierarchies.get(position);
// }
holder.bind(hierarchies.get(position));
}
@Override
public int getItemCount() {
return hierarchies.size();
}
class ViewHolder extends RecyclerView.ViewHolder {
public ViewHolder(View itemView) {
super(itemView);
}
void bind(BaseHierarchy hierarchy) {
ViewGroup parent = (ViewGroup) itemView;
if (parent != null) {
parent.removeAllViews();
parent.addView(hierarchy.getView());
}
}
}
}
package id.ac.stis.capi.lessthink.interfaces;
/**
* Author : Rahadi Jalu
* Email : 14.8325@stis.ac.id
* Company: Politeknik Statistika STIS
*/
public interface UpdatingErrorInterface {
/**
* Shows error message to the view.
* Specifically made for updating mode.
*
* @param message error message to be shown. maybe constraintMsg or requiredMsg.
* */
void setError(String message);
/**
* Clears error message of the view.
* Specifically made for updating mode.
* */
void clearError();
}
\ No newline at end of file
package id.ac.stis.capi.lessthink.listeners;
import android.view.View;
import org.javarosa.core.model.FormIndex;
import id.ac.stis.capi.odk.widgets.QuestionWidget;
/**
* Author : Rahadi Jalu
* Email : 14.8325@stis.ac.id
* Company: Politeknik Statistika STIS
*/
public interface OnAnswerChangedListener {
void onChange(QuestionWidget questionWidget, FormIndex formIndex);
}
package id.ac.stis.capi.lessthink.listeners;
import android.view.View;
import org.javarosa.core.model.FormIndex;
/**
* Author : Rahadi Jalu
* Email : 14.8325@stis.ac.id
* Company: Politeknik Statistika STIS
*/
public interface OnButtonHierarchyClickListener {
void onButtonClick(View v, FormIndex formIndex, int type);
}
package id.ac.stis.capi.lessthink.listeners;
/**
* Author : Rahadi Jalu
* Email : 14.8325@stis.ac.id
* Company: Politeknik Statistika STIS
*/
public interface OnEditRutaSavedListener {
void onEditRutaSaved();
}
package id.ac.stis.capi.lessthink.listeners;
import android.view.View;
/**
* Author : Rahadi Jalu
* Email : 14.8325@stis.ac.id
* Company: Politeknik Statistika STIS
*/
public interface OnTableAddButtonClickListener {
void onAddButtonClick(View v);
}
package id.ac.stis.capi.lessthink.models;
import android.view.View;
/**
* Author : Rahadi Jalu
* Email : 14.8325@stis.ac.id
* Company: Politeknik Statistika STIS
*/
public abstract class BaseHierarchy {
private int level;
private int prevLevel;
public BaseHierarchy(int level, int prevLevel) {
this.level = level;
this.prevLevel = prevLevel;
}
public abstract View getView();
public abstract int getType();
public abstract int getPrevType();
public int getLevel() {
return level;
}
public int getPrevLevel() {
return prevLevel;
}
}
package id.ac.stis.capi.lessthink.models;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.support.v4.content.ContextCompat;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import org.javarosa.core.model.FormIndex;
import id.ac.stis.capi.R;
import id.ac.stis.capi.lessthink.listeners.OnButtonHierarchyClickListener;
import id.ac.stis.capi.odk.application.Collect;
/**
* Author : Rahadi Jalu
* Email : 14.8325@stis.ac.id
* Company: Politeknik Statistika STIS
*/
public class ButtonHierarchy extends BaseHierarchy {
public static int TYPE_NEW_REPEAT = 31;
public static int TYPE_MULTIPLICITY = 32;
private Context context;
private View buttonView;
private TextView textView;
private int type, prevType;
private FormIndex formIndex;
private OnButtonHierarchyClickListener onButtonHierarchyClickListener;
public ButtonHierarchy(Context context, FormIndex formIndex, int type, int prevType, int level, int prevLevel) {
super(level, prevLevel);
this.type = type;
this.prevType = prevType;
this.formIndex = formIndex;
this.context = context;
this.textView = new TextView(context);
textView.setGravity(Gravity.CENTER);
if (getType() == TYPE_NEW_REPEAT) {
textView.setText(context.getResources().getString(R.string.add_another));
textView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_add, 0, 0, 0);
int[] attrs = new int[]{R.attr.selectableItemBackground /* index 0 */};
TypedArray ta = context.obtainStyledAttributes(attrs);
Drawable drawable = ta.getDrawable(0 /* index */);
ta.recycle();
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, Collect.getQuestionFontsize() - 1);
textView.setPadding(15, 45, 15, 45);
textView.setTextColor(ContextCompat.getColor(context, R.color.white));
textView.setBackground(drawable);
} else if (getType() == TYPE_MULTIPLICITY) {
textView.setText(String.valueOf(formIndex.getElementMultiplicity() + 1));
textView.setTextColor(ContextCompat.getColor(context, R.color.primary_dark));
textView.setBackground(ContextCompat.getDrawable(context, R.drawable.wb_circle_btn));
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, Collect.getQuestionFontsize() - 3);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
75, 75);
params.topMargin = 26;
params.bottomMargin = 15;
textView.setLayoutParams(params);
}
textView.setTypeface(textView.getTypeface(), Typeface.BOLD);
textView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (onButtonHierarchyClickListener != null) {
onButtonHierarchyClickListener.onButtonClick(v, ButtonHierarchy.this.formIndex,
getType());
}
}
});
createWidgetView();
}
public void setOnButtonHierarchyClickListener(OnButtonHierarchyClickListener onButtonHierarchyClickListener) {
this.onButtonHierarchyClickListener = onButtonHierarchyClickListener;
}
private void createWidgetView() {
RelativeLayout container = new RelativeLayout(context);
container.setBackgroundColor(ContextCompat.getColor(context, R.color.primary));
LinearLayout widgetContainer = new LinearLayout(context);
widgetContainer.setOrientation(LinearLayout.VERTICAL);
widgetContainer.setGravity(Gravity.CENTER);
widgetContainer.setBackgroundColor(ContextCompat.getColor(context, R.color.primary_dark));
widgetContainer.addView(textView);
RelativeLayout.LayoutParams widgetContainerParams = new RelativeLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
widgetContainerParams.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
widgetContainerParams.rightMargin = 14 * getLevel();
widgetContainerParams.leftMargin = 14 * getLevel();
widgetContainer.setLayoutParams(widgetContainerParams);
container.addView(widgetContainer);
if (getLevel() != getPrevLevel()) {
View shadowView;
View protector;
RelativeLayout.LayoutParams protectorParams;
View shadow;
RelativeLayout.LayoutParams shadowParams;
if (getLevel() > getPrevLevel()) {
shadowView = LayoutInflater.from(context).inflate(R.layout.view_shadow_protector, null);
shadow = shadowView.findViewById(R.id.shadow);
shadowParams = (RelativeLayout.LayoutParams) shadow.getLayoutParams();
shadowParams.rightMargin = 14 * getPrevLevel();
shadowParams.leftMargin = 14 * getPrevLevel();
protector = shadowView.findViewById(R.id.protector);
protectorParams = (RelativeLayout.LayoutParams) protector.getLayoutParams();
protectorParams.rightMargin = 14 * getLevel();
protectorParams.leftMargin = 14 * getLevel();
} else {
shadowView = LayoutInflater.from(context).inflate(R.layout.view_shadow_inverted_protector, null);
shadow = shadowView.findViewById(R.id.shadow);
shadowParams = (RelativeLayout.LayoutParams) shadow.getLayoutParams();
shadowParams.rightMargin = 14 * getLevel();
shadowParams.leftMargin = 14 * getLevel();
protector = shadowView.findViewById(R.id.protector);
protectorParams = (RelativeLayout.LayoutParams) protector.getLayoutParams();
protectorParams.rightMargin = 14 * getPrevLevel();
protectorParams.leftMargin = 14 * getPrevLevel();
}
shadowView.setBackgroundColor(ContextCompat.getColor(context, R.color.primary));
protector.setLayoutParams(protectorParams);
shadow.setLayoutParams(shadowParams);
container.addView(shadowView);
}
this.buttonView = container;
}
public View getText() {
return textView;
}
@Override
public View getView() {
return buttonView;
}
@Override
public int getType() {
return type;
}
@Override
public int getPrevType() {
return prevType;
}
}
package id.ac.stis.capi.lessthink.models;
import android.content.Context;
import android.graphics.Typeface;
import android.support.v4.content.ContextCompat;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import org.javarosa.form.api.FormEntryCaption;
import id.ac.stis.capi.R;
import id.ac.stis.capi.odk.application.Collect;
/**
* Author : Rahadi Jalu
* Email : 14.8325@stis.ac.id
* Company: Politeknik Statistika STIS
*/
public class CaptionHierarchy extends BaseHierarchy {
public static int TYPE_GROUP = 10;
public static int TYPE_REPEAT = 11;
private Context context;
private View captionView;
private TextView textView;
private int type, prevType;
private FormEntryCaption caption;
public CaptionHierarchy(Context context, FormEntryCaption caption, int type, int prevType, int level, int prevLevel) {
super(level, prevLevel);
this.type = type;
this.prevType = prevType;
this.caption = caption;
this.context = context;
this.textView = new TextView(context);
textView.setGravity(Gravity.CENTER);
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, Collect.getQuestionFontsize() - 1);
textView.setText(caption.getLongText());
textView.setTextColor(ContextCompat.getColor(context, R.color.white));
textView.setPadding(15, 20, 15, 20);
textView.setTypeface(textView.getTypeface(), Typeface.BOLD);
createWidgetView();
}
public FormEntryCaption getCaption() {
return caption;
}
public View getTextView() {
return textView;
}
private void createWidgetView() {
RelativeLayout container = new RelativeLayout(context);
container.setBackgroundColor(ContextCompat.getColor(context, R.color.primary));
LinearLayout widgetContainer = new LinearLayout(context);
widgetContainer.setOrientation(LinearLayout.VERTICAL);
widgetContainer.setGravity(Gravity.CENTER);
widgetContainer.setBackgroundColor(ContextCompat.getColor(context, R.color.primary_dark));
widgetContainer.addView(textView);
RelativeLayout.LayoutParams widgetContainerParams = new RelativeLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
widgetContainerParams.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
widgetContainerParams.rightMargin = 14 * getLevel();
widgetContainerParams.leftMargin = 14 * getLevel();
widgetContainer.setLayoutParams(widgetContainerParams);
container.addView(widgetContainer);
if (getLevel() != getPrevLevel()) {
View shadowView;
View protector;
RelativeLayout.LayoutParams protectorParams;
View shadow;
RelativeLayout.LayoutParams shadowParams;
if (getLevel() > getPrevLevel()) {
shadowView = LayoutInflater.from(context).inflate(R.layout.view_shadow_protector, null);
shadow = shadowView.findViewById(R.id.shadow);
shadowParams = (RelativeLayout.LayoutParams) shadow.getLayoutParams();
shadowParams.rightMargin = 14 * getPrevLevel();
shadowParams.leftMargin = 14 * getPrevLevel();
protector = shadowView.findViewById(R.id.protector);
protectorParams = (RelativeLayout.LayoutParams) protector.getLayoutParams();
protectorParams.rightMargin = 14 * getLevel();
protectorParams.leftMargin = 14 * getLevel();
} else {
shadowView = LayoutInflater.from(context).inflate(R.layout.view_shadow_inverted_protector, null);
shadow = shadowView.findViewById(R.id.shadow);
shadowParams = (RelativeLayout.LayoutParams) shadow.getLayoutParams();
shadowParams.rightMargin = 14 * getLevel();
shadowParams.leftMargin = 14 * getLevel();
protector = shadowView.findViewById(R.id.protector);
protectorParams = (RelativeLayout.LayoutParams) protector.getLayoutParams();
protectorParams.rightMargin = 14 * getPrevLevel();
protectorParams.leftMargin = 14 * getPrevLevel();
}
shadowView.setBackgroundColor(ContextCompat.getColor(context, R.color.primary));
protector.setLayoutParams(protectorParams);
shadow.setLayoutParams(shadowParams);
container.addView(shadowView);
}
this.captionView = container;
// View v = LayoutInflater.from(context).inflate(R.layout.item_updating_hierarchy, null);
// View mainContent = v.findViewById(R.id.main_content);
//
// ViewGroup parent = (ViewGroup) mainContent.getParent();
// int index = parent.indexOfChild(mainContent);
//
// parent.removeView(mainContent);
// parent.addView(textView, index);
//
// ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) parent.getLayoutParams();
// params.setMargins(6 * getLevel(), 0, 6 * getLevel(), 0);
// parent.setLayoutParams(params);
//
// this.captionView = v;
}
public View getText() {
return textView;
}
@Override
public View getView() {
return captionView;
}
@Override
public int getType() {
return type;
}
@Override
public int getPrevType() {
return prevType;
}
}
......@@ -45,4 +45,5 @@ public class InstanceValues implements Serializable {
public String getInstanceValue(String xPath) {
return instanceValue.get(xPath);
}
}
package id.ac.stis.capi.lessthink.models;
import android.content.Context;
import android.support.v4.content.ContextCompat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import org.javarosa.core.model.data.IAnswerData;
import org.javarosa.form.api.FormEntryPrompt;
import java.io.InvalidObjectException;
import id.ac.stis.capi.R;
import id.ac.stis.capi.lessthink.utils.ViewUtils;
import id.ac.stis.capi.lessthink.views.HierarchyErrorView;
import id.ac.stis.capi.odk.widgets.QuestionWidget;
import id.ac.stis.capi.odk.widgets.WidgetFactory;
import timber.log.Timber;
/**
* Author : Rahadi Jalu
* Email : 14.8325@stis.ac.id
* Company: Politeknik Statistika STIS
*/
public class PromptHierarchy extends BaseHierarchy {
public static int TYPE_QUESTION = 21;
private Context context;
private View widgetView;
private LinearLayout widgetContainer;
private int type, prevType;
private QuestionWidget widget;
private FormEntryPrompt prompt;
private HierarchyErrorView errorView;
public PromptHierarchy(Context context, FormEntryPrompt prompt, int type, int prevType, int level, int prevLevel) {
super(level, prevLevel);
this.type = type;
this.prevType = prevType;
this.context = context;
this.prompt = prompt;
this.widget = WidgetFactory.createWidgetFromPrompt(prompt, context, false);
LinearLayout.LayoutParams widgetParams = new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
widgetParams.setMargins(12, 12, 12, 12);
widget.setLayoutParams(widgetParams);
this.errorView = new HierarchyErrorView(context);
createWidgetView();
}
public FormEntryPrompt getPrompt() {
return prompt;
}
public QuestionWidget getWidget() {
return widget;
}
private void createWidgetView() {
RelativeLayout container = new RelativeLayout(context);
container.setBackgroundColor(ContextCompat.getColor(context, R.color.primary));
this.widgetContainer = new LinearLayout(context);
widgetContainer.setOrientation(LinearLayout.VERTICAL);
widgetContainer.setBackgroundColor(ContextCompat.getColor(context, R.color.white));
widgetContainer.addView(widget);
LinearLayout.LayoutParams errorParams = new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
// errorParams.leftMargin = 20;
// errorParams.bottomMargin = 14;
// errorParams.rightMargin = 20;
// errorParams.topMargin = 14;
errorView.setLayoutParams(errorParams);
widgetContainer.addView(errorView);
RelativeLayout.LayoutParams widgetContainerParams = new RelativeLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
widgetContainerParams.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
widgetContainerParams.rightMargin = 14 * getLevel();
widgetContainerParams.leftMargin = 14 * getLevel();
widgetContainer.setLayoutParams(widgetContainerParams);
container.addView(widgetContainer);
if (getLevel() != getPrevLevel()) {
View shadowView;
View protector;
RelativeLayout.LayoutParams protectorParams;
View shadow;
RelativeLayout.LayoutParams shadowParams;
if (getLevel() > getPrevLevel()) {
shadowView = LayoutInflater.from(context).inflate(R.layout.view_shadow_protector, null);
shadow = shadowView.findViewById(R.id.shadow);
shadowParams = (RelativeLayout.LayoutParams) shadow.getLayoutParams();
shadowParams.rightMargin = 14 * getPrevLevel();
shadowParams.leftMargin = 14 * getPrevLevel();
protector = shadowView.findViewById(R.id.protector);
protectorParams = (RelativeLayout.LayoutParams) protector.getLayoutParams();
protectorParams.rightMargin = 14 * getLevel();
protectorParams.leftMargin = 14 * getLevel();
} else {
shadowView = LayoutInflater.from(context).inflate(R.layout.view_shadow_inverted_protector, null);
shadow = shadowView.findViewById(R.id.shadow);
shadowParams = (RelativeLayout.LayoutParams) shadow.getLayoutParams();
shadowParams.rightMargin = 14 * getLevel();
shadowParams.leftMargin = 14 * getLevel();
protector = shadowView.findViewById(R.id.protector);
protectorParams = (RelativeLayout.LayoutParams) protector.getLayoutParams();
protectorParams.rightMargin = 14 * getPrevLevel();
protectorParams.leftMargin = 14 * getPrevLevel();
}
shadowView.setBackgroundColor(ContextCompat.getColor(context, R.color.primary));
protector.setLayoutParams(protectorParams);
shadow.setLayoutParams(shadowParams);
container.addView(shadowView);
}
this.widgetView = container;
}
public void setError(String message) {
Timber.d("Set Error: %s %s", message, prompt.getIndex().getReference().toString());
if (message == null) {
widgetContainer.setBackgroundColor(ContextCompat.getColor(context, R.color.white));
errorView.setVisibility(View.GONE);
} else {
widgetContainer.setBackgroundColor(ContextCompat.getColor(context, R.color.smooth_red));
errorView.setVisibility(View.VISIBLE);
}
errorView.setError(message);
}
@Override
public View getView() {
return widgetView;
}
public IAnswerData getAnswer() {
return widget.getAnswer();
}
@Override
public int getType() {
return type;
}
@Override
public int getPrevType() {
return prevType;
}
}
package id.ac.stis.capi.lessthink.views;
import android.content.Context;
import android.graphics.Typeface;
import android.support.v4.content.ContextCompat;
import android.util.TypedValue;
import android.view.Gravity;
import android.widget.LinearLayout;
import android.widget.TextView;
import id.ac.stis.capi.R;
import id.ac.stis.capi.odk.application.Collect;
/**
* Author : Rahadi Jalu
* Email : 14.8325@stis.ac.id
* Company: Politeknik Statistika STIS
*/
public class HierarchyErrorView extends LinearLayout {
private TextView messageView;
public HierarchyErrorView(Context context) {
super(context);
setVisibility(GONE);
setOrientation(HORIZONTAL);
setGravity(Gravity.CENTER_VERTICAL);
setPadding(25, 25, 25, 25);
// setBackground(ContextCompat.getDrawable(context, R.drawable.bg_border_t));
setBackgroundColor(ContextCompat.getColor(context, R.color.smooth_red));
this.messageView = new TextView(context);
messageView.setGravity(Gravity.CENTER_VERTICAL);
messageView.setTextColor(ContextCompat.getColor(context, R.color.md_red_A700));
messageView.setTypeface(messageView.getTypeface(), Typeface.BOLD);
// messageView.setPaintFlags(messageView.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
messageView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_error_fill, 0, 0, 0);
messageView.setCompoundDrawablePadding(25);
messageView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, Collect.getQuestionFontsize() - 5);
addView(messageView);
}
public void setError(String message) {
if (message == null) {
setVisibility(GONE);
} else {
messageView.setText(message);
setVisibility(VISIBLE);
}
}
}
......@@ -15,6 +15,7 @@ import android.widget.TextView;
import android.widget.Toast;
import id.ac.stis.capi.R;
import id.ac.stis.capi.lessthink.listeners.OnTableAddButtonClickListener;
import id.ac.stis.capi.lessthink.listeners.OnFooterNavigationListener;
/**
......@@ -29,6 +30,7 @@ public class TableFooterView extends RelativeLayout implements View.OnClickListe
private LinearLayout pageIndicator, navigationWrapper;
private int textSize, componentColor, footerColor, currentPage, pageCount;
private OnFooterNavigationListener onFooterNavigationListener;
private OnTableAddButtonClickListener onTableAddButtonClickListener;
public TableFooterView(Context context, AttributeSet attrs) {
super(context, attrs);
......@@ -174,6 +176,10 @@ public class TableFooterView extends RelativeLayout implements View.OnClickListe
this.onFooterNavigationListener = onFooterNavigationListener;
}
public void setOnTableAddButtonClickListener(OnTableAddButtonClickListener onTableAddButtonClickListener) {
this.onTableAddButtonClickListener = onTableAddButtonClickListener;
}
public int getTextSize() {
return textSize;
}
......@@ -208,7 +214,11 @@ public class TableFooterView extends RelativeLayout implements View.OnClickListe
public void onClick(View view) {
switch (view.getId()) {
case R.id.footer_view_add_button:
Toast.makeText(getContext(), "ADD", Toast.LENGTH_LONG).show();
if (onTableAddButtonClickListener != null) {
onTableAddButtonClickListener.onAddButtonClick(view);
} else {
Toast.makeText(getContext(), "Add Button is Not Implemented Yet", Toast.LENGTH_LONG).show();
}
break;
case R.id.footer_view_prev_button:
// Toast.makeText(getContext(), "PREV", Toast.LENGTH_LONG).show();
......
......@@ -197,7 +197,12 @@ public class TableRowView extends HorizontalScrollView implements OnHandlerMoved
int availableHeight = container.getHeight();
int currIdx = this.rowCount * page - this.rowCount;
int maxIdx = this.rowCount != 0 && this.rowCount * page < rows.size() ? this.rowCount * page : rows.size();
int maxIdx;
if(this.rowCount != 0 && this.rowCount * page < rows.size()) {
maxIdx = this.rowCount * page;
} else {
maxIdx = rows.size();
}
Timber.d("Max Idx : %s", maxIdx);
......@@ -277,10 +282,12 @@ public class TableRowView extends HorizontalScrollView implements OnHandlerMoved
// Timber.d("Row Height : %s, Available Height : %s", rowHeight, availableHeight);
}
this.rowCount = container.getHeight() / rowHeight;
this.currentPage = page;
if(rows.size() > 0) {
this.rowCount = container.getHeight() / rowHeight;
this.currentPage = page;
calculatePageCount();
calculatePageCount();
}
animate().alpha(1.0f).setDuration(animationDuration);
}
......
......@@ -94,8 +94,8 @@ import id.ac.stis.capi.odk.listeners.AdvanceToNextListener;
import id.ac.stis.capi.odk.listeners.FormLoaderListener;
import id.ac.stis.capi.odk.listeners.FormSavedListener;
import id.ac.stis.capi.odk.listeners.SavePointListener;
import id.ac.stis.capi.odk.logic.FailedConstraint;
import id.ac.stis.capi.odk.logic.FormController;
import id.ac.stis.capi.odk.logic.FormController.FailedConstraint;
import id.ac.stis.capi.odk.preferences.AdminKeys;
import id.ac.stis.capi.odk.preferences.AdminPreferencesActivity;
import id.ac.stis.capi.odk.preferences.AdminSharedPreferences;
......@@ -892,11 +892,11 @@ public class FormEntryActivity extends SlidingActivity implements AnimationListe
|| evaluateConstraints == EVALUATE_CONSTRAINTS_BUT_CAN_SKIP) {
isNeedToEvaluated = true;
}
FailedConstraint constraint = formController.saveAllScreenAnswers(answers,
ArrayList<FailedConstraint> constraint = formController.saveAllScreenAnswers(answers,
isNeedToEvaluated);
if (constraint != null && (evaluateConstraints == EVALUATE_CONSTRAINTS
|| evaluateConstraints == EVALUATE_CONSTRAINTS_BUT_CAN_SKIP)) {
createConstraintToast(constraint.index, constraint.status);
createConstraintToast(constraint);
checkErrorHandler();
return false;
}
......@@ -1994,51 +1994,58 @@ public class FormEntryActivity extends SlidingActivity implements AnimationListe
/**
* Creates and displays a dialog displaying the violated constraint.
*/
private void createConstraintToast(FormIndex index, int saveStatus) {
private void createConstraintToast(ArrayList<FailedConstraint> failedConstraints) {
FormController formController = Collect.getInstance()
.getFormController();
String constraintText;
switch (saveStatus) {
case FormEntryController.ANSWER_CONSTRAINT_VIOLATED:
Collect.getInstance()
.getActivityLogger()
.logInstanceAction(this,
"createConstraintToast.ANSWER_CONSTRAINT_VIOLATED",
"show", index);
constraintText = formController
.getQuestionPromptConstraintText(index);
if (constraintText == null) {
constraintText = formController.getQuestionPrompt(index)
.getSpecialFormQuestionText("constraintMsg");
if (constraintText == null) {
constraintText = getString(R.string.invalid_answer_error);
}
}
break;
case FormEntryController.ANSWER_REQUIRED_BUT_EMPTY:
Collect.getInstance()
.getActivityLogger()
.logInstanceAction(this,
"createConstraintToast.ANSWER_REQUIRED_BUT_EMPTY",
"show", index);
constraintText = formController
.getQuestionPromptRequiredText(index);
if (constraintText == null) {
constraintText = formController.getQuestionPrompt(index)
.getSpecialFormQuestionText("requiredMsg");
if (constraintText == null) {
constraintText = getString(R.string.required_answer_error);
}
String constraintText = "";
if (failedConstraints.size() > 1) {
constraintText = "Can't go to the next question, You have " + failedConstraints.size() + " errors input";
} else {
for (int i = 0; i < failedConstraints.size(); i++) {
FailedConstraint failedConstraint = failedConstraints.get(i);
switch (failedConstraint.status) {
case FormEntryController.ANSWER_CONSTRAINT_VIOLATED:
Collect.getInstance()
.getActivityLogger()
.logInstanceAction(this,
"createConstraintToast.ANSWER_CONSTRAINT_VIOLATED",
"show", failedConstraint.index);
String constraintTextLocal = formController
.getQuestionPromptConstraintText(failedConstraint.index);
if (constraintTextLocal == null || constraintTextLocal.trim().length() == 0) {
constraintTextLocal = formController.getQuestionPrompt(failedConstraint.index)
.getSpecialFormQuestionText("constraintMsg");
if (constraintTextLocal == null || constraintTextLocal.trim().length() == 0) {
constraintTextLocal = getString(R.string.invalid_answer_error);
}
}
constraintText = constraintTextLocal;
// constraintText = constraintText+constraintTextLocal;
break;
case FormEntryController.ANSWER_REQUIRED_BUT_EMPTY:
Collect.getInstance()
.getActivityLogger()
.logInstanceAction(this,
"createConstraintToast.ANSWER_REQUIRED_BUT_EMPTY",
"show", failedConstraint.index);
String constraintTextLocalB = formController
.getQuestionPromptRequiredText(failedConstraint.index);
if (constraintTextLocalB == null || constraintTextLocalB.trim().length() == 0) {
constraintTextLocalB = formController.getQuestionPrompt(failedConstraint.index)
.getSpecialFormQuestionText("requiredMsg");
if (constraintTextLocalB == null || constraintTextLocalB.trim().length() == 0) {
constraintTextLocalB = getString(R.string.required_answer_error);
}
}
constraintText = constraintTextLocalB;
// constraintText=constraintText+constraintTextLocalB;
break;
}
break;
default:
return;
}
}
showCustomToast(constraintText, Toast.LENGTH_SHORT);
}
// Hopefully someday we can use managed dialogs when the bugs are fixed
/*
* Ideally, we'd like to use Android to manage dialogs with onCreateDialog()
......@@ -2202,7 +2209,7 @@ public class FormEntryActivity extends SlidingActivity implements AnimationListe
// .logInstanceAction(this, "onOptionsItemSelected",
// "MENU_HIERARCHY_VIEW");
// if (formController.currentPromptIsQuestion()) {
// saveAnswersForCurrentScreen(DO_NOT_EVALUATE_CONSTRAINTS);
// saveAnswers(DO_NOT_EVALUATE_CONSTRAINTS);
// }
// Intent i = new Intent(this, FormHierarchyActivity.class);
// i.putExtra(ApplicationConstants.BundleKeys.FORM_MODE, ApplicationConstants.FormModes.EDIT_SAVED);
......@@ -2668,7 +2675,8 @@ public class FormEntryActivity extends SlidingActivity implements AnimationListe
if (formController.indexIsAsChildInRepeat() || event == FormEntryController.EVENT_REPEAT) {
if (showAsTable(formController))
//show table view!
odkv = new ODKView(this, formController.getAllQuestionsPromts(), groups, advancingPage, true);
odkv = new ODKView(this, formController.getAllQuestionsPromptsWithinRepeat(),
groups, advancingPage, true);
else
odkv = new ODKView(this, prompts, groups, advancingPage, false);
} else {
......
......@@ -20,13 +20,13 @@ import android.content.ContentValues;
import android.database.Cursor;
import android.net.Uri;
import java.util.ArrayList;
import java.util.List;
import id.ac.stis.capi.odk.application.Collect;
import id.ac.stis.capi.odk.dto.Form;
import id.ac.stis.capi.odk.provider.FormsProviderAPI;
import java.util.ArrayList;
import java.util.List;
/**
* This class is used to encapsulate all access to the {@link id.ac.stis.capi.odk.provider.FormsProvider#DATABASE_NAME}
* For more information about this pattern go to https://en.wikipedia.org/wiki/Data_access_object
......@@ -128,6 +128,10 @@ public class FormsDao {
int formMediaPathColumnIndex = cursor.getColumnIndex(FormsProviderAPI.FormsColumns.FORM_MEDIA_PATH);
int languageColumnIndex = cursor.getColumnIndex(FormsProviderAPI.FormsColumns.LANGUAGE);
//RAHADI
int emptyInstanceFilePath = cursor.getColumnIndex(FormsProviderAPI.FormsColumns.EMPTY_INSTANCE_FILE_PATH);
int formType = cursor.getColumnIndex(FormsProviderAPI.FormsColumns.FORM_TYPE);
Form form = new Form.Builder()
.displayName(cursor.getString(displayNameColumnIndex))
.description(cursor.getString(descriptionColumnIndex))
......@@ -142,6 +146,8 @@ public class FormsDao {